mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-25 16:58:06 +08:00
opt code
This commit is contained in:
parent
048ccaec34
commit
fdaa2538d8
@ -5,7 +5,7 @@ if !exists("g:ctx_sid") | let ctx_sid = "" | end
|
||||
fun! ShySend(arg)
|
||||
if has_key(a:arg, "sub") && a:arg["sub"] != ""
|
||||
let temp = tempname()
|
||||
call writefile([a:arg["sub"]], temp)
|
||||
call writefile(split(a:arg["sub"], "\n"), temp, "b")
|
||||
let a:arg["sub"] = "@" . temp
|
||||
endif
|
||||
|
||||
@ -66,16 +66,6 @@ fun! ShyCheck(target)
|
||||
call ShySync("regs")
|
||||
call ShySync("marks")
|
||||
call ShySync("tags")
|
||||
elseif a:target == "exec"
|
||||
let cmd = getcmdline()
|
||||
if cmd != ""
|
||||
call ShySync("exec")
|
||||
if getcmdline() == "w"
|
||||
call ShySync("regs")
|
||||
call ShySync("marks")
|
||||
call ShySync("tags")
|
||||
endif
|
||||
endif
|
||||
elseif a:target == "fixs"
|
||||
let l = len(getqflist())
|
||||
if l > 0
|
||||
@ -93,64 +83,26 @@ endfun
|
||||
fun! ShyGrep(word)
|
||||
if !exists("g:grep_dir") | let g:grep_dir = "./" | endif
|
||||
let g:grep_dir = input("dir: ", g:grep_dir, "file")
|
||||
execute "grep -rn --exclude tags --exclude '\..*' --exclude '*.tags' " . a:word . " " . g:grep_dir
|
||||
execute "grep -rn --exclude tags --exclude '*.tags' " . a:word . " " . g:grep_dir
|
||||
endfun
|
||||
fun! ShyTag(word)
|
||||
execute "tag " . a:word
|
||||
endfun
|
||||
|
||||
fun! ShyHelp()
|
||||
echo ShySend({"cmd": "help"})
|
||||
endfun
|
||||
|
||||
call ShyLogin()
|
||||
" " call ShySync("bufs")
|
||||
" call ShySync("regs")
|
||||
" call ShySync("marks")
|
||||
" call ShySync("tags")
|
||||
" " call ShySync("fixs")
|
||||
"
|
||||
" autocmd VimLeave * call ShyLogout()
|
||||
" autocmd BufReadPost * call ShySync("bufs")
|
||||
" hello
|
||||
autocmd VimLeave * call ShyLogout()
|
||||
autocmd BufReadPost * call ShySync("bufs")
|
||||
autocmd BufReadPost * call ShySync("read")
|
||||
autocmd BufWritePre * call ShySync("write")
|
||||
autocmd CmdlineLeave * call ShyCheck("exec")
|
||||
" autocmd QuickFixCmdPost * call ShyCheck("fixs")
|
||||
autocmd CmdlineLeave * call ShySync("exec")
|
||||
autocmd QuickFixCmdPost * call ShyCheck("fixs")
|
||||
autocmd InsertLeave * call ShySync("insert")
|
||||
"
|
||||
" command! ShyHelp echo ShyPost({"cmd": "help"})
|
||||
"
|
||||
" nnoremap <C-g><C-g> :call ShyGrep(expand("<cword>"))<CR>
|
||||
" " nnoremap <C-g><C-t> :call ShyTag(expand("<cword>"))<CR>
|
||||
" nnoremap <C-g><C-t> :call ShyTask()<CR>
|
||||
" nnoremap <C-g><C-r> :call ShyCheck("cache")<CR>
|
||||
" nnoremap <C-g><C-f> :call ShyFavor("note")<CR>
|
||||
" nnoremap <C-g>f :call ShyFavor("")<CR>
|
||||
" nnoremap <C-g>F :call ShyFavors()<CR>
|
||||
"
|
||||
" autocmd BufUnload * call Shy("close", expand("<afile>")) | call ShySync("bufs")
|
||||
" autocmd CmdlineLeave *
|
||||
" autocmd CompleteDone * call Shy("sync", "regs")
|
||||
" autocmd InsertEnter * call Shy("sync", "regs")
|
||||
" autocmd CmdlineEnter * call Shy("sync", "regs")
|
||||
" autocmd BufWinEnter * call Shy("enter", expand("<afile>"))
|
||||
" autocmd WinEnter * call Shy("enter", expand("<afile>"))
|
||||
" autocmd WinLeave * call Shy("leave", expand("<afile>"))
|
||||
" autocmd CursorMoved * call Shy("line", getcurpos()[1])
|
||||
" autocmd InsertCharPre * call Shy("char", v:char)
|
||||
"
|
||||
" let g:colorscheme=1
|
||||
" let g:colorlist = [ "ron", "torte", "darkblue", "peachpuff" ]
|
||||
" function! ColorNext()
|
||||
" if g:colorscheme >= len(g:colorlist)
|
||||
" let g:colorscheme = 0
|
||||
" endif
|
||||
" let g:scheme = g:colorlist[g:colorscheme]
|
||||
" exec "colorscheme " . g:scheme
|
||||
" let g:colorscheme = g:colorscheme+1
|
||||
" endfunction
|
||||
" call ColorNext()
|
||||
" command! NN call ColorNext()<CR>
|
||||
" command! SS mksession! etc/session.vim
|
||||
nnoremap <C-G><C-G> :call ShyGrep(expand("<cword>"))<CR>
|
||||
nnoremap <C-G><C-R> :call ShyCheck("cache")<CR>
|
||||
nnoremap <C-G><C-F> :call ShyFavor()<CR>
|
||||
nnoremap <C-G>f :call ShyFavors()<CR>
|
||||
nnoremap <C-G><C-T> :call ShyTask()<CR>
|
||||
|
||||
|
@ -50,6 +50,12 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
"git": {Name: "git", Help: "记录", Value: map[string]interface{}{
|
||||
"alias": map[string]interface{}{"s": "status", "b": "branch"},
|
||||
}},
|
||||
"cache": {Name: "cache", Help: "缓存默认的全局配置", Value: map[string]interface{}{
|
||||
"store": "var/tmp/hi.csv",
|
||||
"limit": 6,
|
||||
"least": 3,
|
||||
}},
|
||||
|
||||
"zsh": {Name: "zsh", Help: "命令行", Value: map[string]interface{}{
|
||||
"history": map[string]interface{}{"meta": map[string]interface{}{
|
||||
"fields": "time sid cmd pwd",
|
||||
@ -94,26 +100,21 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
}},
|
||||
|
||||
"bufs": map[string]interface{}{"meta": map[string]interface{}{
|
||||
"fields": "sid buf tag file line",
|
||||
"fields": "buf tag file line",
|
||||
}},
|
||||
"regs": map[string]interface{}{"meta": map[string]interface{}{
|
||||
"fields": "sid reg word",
|
||||
"fields": "reg word",
|
||||
}},
|
||||
"marks": map[string]interface{}{"meta": map[string]interface{}{
|
||||
"fields": "sid mark line col file",
|
||||
"fields": "mark line col file",
|
||||
}},
|
||||
"tags": map[string]interface{}{"meta": map[string]interface{}{
|
||||
"fields": "sid tag line file",
|
||||
"fields": "tag line file",
|
||||
}},
|
||||
"fixs": map[string]interface{}{"meta": map[string]interface{}{
|
||||
"fields": "sid fix file line word",
|
||||
"fields": "fix file line word",
|
||||
}},
|
||||
}},
|
||||
"cache": {Name: "cache", Help: "缓存默认的全局配置", Value: map[string]interface{}{
|
||||
"store": "var/tmp/hi.csv",
|
||||
"limit": 6,
|
||||
"least": 3,
|
||||
}},
|
||||
|
||||
"login": {Name: "login", Value: map[string]interface{}{"check": false, "local": true, "expire": "720h", "meta": map[string]interface{}{
|
||||
"fields": "time sid type status ship.dream ship.stage pwd pid pane hostname username",
|
||||
@ -387,7 +388,7 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
}
|
||||
return
|
||||
}},
|
||||
"state": {Name: "state post|list", Help: "状态", Hand: func(m *ctx.Message, c *ctx.Context, cmd string, arg ...string) (e error) {
|
||||
"state": {Name: "state post|list agent type", Help: "状态", Hand: func(m *ctx.Message, c *ctx.Context, cmd string, arg ...string) (e error) {
|
||||
switch arg[0] {
|
||||
case "post":
|
||||
data := map[string]interface{}{}
|
||||
@ -406,6 +407,7 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
return
|
||||
}
|
||||
if value["sid"] = key; len(arg) < 6 || arg[4] == "" || strings.HasPrefix(kit.Format(value[arg[4]]), arg[5]) {
|
||||
m.Push("sid", key)
|
||||
m.Push(fields, value)
|
||||
}
|
||||
})
|
||||
@ -951,7 +953,6 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
m.Echo(p)
|
||||
}
|
||||
return
|
||||
|
||||
}
|
||||
return
|
||||
}},
|
||||
@ -990,65 +991,50 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
case "read", "write":
|
||||
m.Cmd("trend", "post", "vim.opens", "sid", m.Option("sid"),
|
||||
"action", m.Option("cmd"), "file", m.Option("arg"), "pwd", m.Option("pwd"))
|
||||
|
||||
case "exec":
|
||||
m.Cmd("trend", "post", "vim.cmds", "sid", m.Option("sid"),
|
||||
"cmd", m.Option("sub"), "file", m.Option("buf"), "pwd", m.Option("pwd"))
|
||||
case "insert":
|
||||
m.Cmd("trend", "post", "vim.txts", "sid", m.Option("sid"),
|
||||
"word", m.Option("sub"), "line", m.Option("row"), "col", m.Option("col"), "file", m.Option("buf"), "pwd", m.Option("pwd"))
|
||||
|
||||
case "tasklet":
|
||||
m.Cmd("ssh._route", m.Option("dream"), "web.team.task", "create", "task", "3", "add", "action", m.Time(), m.Time("10m"), m.Option("arg"), m.Option("sub"))
|
||||
m.Cmd("ssh._route", m.Option("dream"), "web.team.task", "create", "task",
|
||||
"3", "add", "action", m.Time(), m.Time("10m"), m.Option("arg"), m.Option("sub"))
|
||||
|
||||
case "sync":
|
||||
m.Conf(cmd, []string{m.Option("arg"), "hash", m.Option("sid")}, "")
|
||||
m.Confv(cmd, []string{m.Option("arg"), "hash", m.Option("sid")}, []interface{}{})
|
||||
switch m.Option("arg") {
|
||||
case "bufs":
|
||||
m.Split(strings.TrimSpace(m.Option("sub")), " ", "5", "id tag name some line").Table(func(index int, value map[string]string) {
|
||||
m.Confv(cmd, []string{m.Option("arg"), "hash", m.Option("sid"), "-2"}, map[string]interface{}{
|
||||
"buf": value["id"],
|
||||
"tag": value["tag"],
|
||||
"file": strings.TrimSuffix(strings.TrimPrefix(value["name"], "\""), "\""),
|
||||
"line": value["line"],
|
||||
})
|
||||
m.Split(m.Option("sub"), " ", "5", "id tag name some line").Table(func(index int, value map[string]string) {
|
||||
m.Cmd("state", "post", cmd, m.Option("arg"),
|
||||
"buf", value["id"], "tag", value["tag"], "line", value["line"],
|
||||
"file", strings.TrimSuffix(strings.TrimPrefix(value["name"], "\""), "\""))
|
||||
})
|
||||
case "regs":
|
||||
m.Split(strings.TrimPrefix(m.Option("sub"), "\n--- Registers ---\n"), " ", "2", "name word").Table(func(index int, value map[string]string) {
|
||||
m.Confv(cmd, []string{m.Option("arg"), "hash", m.Option("sid"), "-2"}, map[string]interface{}{
|
||||
"word": strings.Replace(strings.Replace(value["word"], "^I", "\t", -1), "^J", "\n", -1),
|
||||
"reg": strings.TrimPrefix(value["name"], "\""),
|
||||
})
|
||||
m.Split(strings.TrimPrefix(m.Option("sub"), "--- Registers ---\n"), " ", "2", "name word").Table(func(index int, value map[string]string) {
|
||||
m.Cmd("state", "post", cmd, m.Option("arg"),
|
||||
"reg", strings.TrimPrefix(value["name"], "\""),
|
||||
"word", strings.Replace(strings.Replace(value["word"], "^I", "\t", -1), "^J", "\n", -1))
|
||||
})
|
||||
case "marks":
|
||||
m.Split(strings.TrimPrefix(m.Option("sub"), "\n"), " ", "4").Table(func(index int, value map[string]string) {
|
||||
m.Confv(cmd, []string{m.Option("arg"), "hash", m.Option("sid"), "-2"}, map[string]interface{}{
|
||||
"mark": value["mark"],
|
||||
"line": value["line"],
|
||||
"col": value["col"],
|
||||
"file": value["file/text"],
|
||||
})
|
||||
m.Split(m.Option("sub"), " ", "4").Table(func(index int, value map[string]string) {
|
||||
m.Cmd("state", "post", cmd, m.Option("arg"),
|
||||
"mark", value["mark"], "line", value["line"], "col", value["col"],
|
||||
"file", value["file/text"])
|
||||
})
|
||||
case "tags":
|
||||
m.Split(strings.TrimPrefix(m.Option("sub"), "\n"), " ", "6").Table(func(index int, value map[string]string) {
|
||||
m.Confv(cmd, []string{m.Option("arg"), "hash", m.Option("sid"), "-2"}, map[string]interface{}{
|
||||
"tag": value["tag"],
|
||||
"line": value["line"],
|
||||
"file": value["in file/text"],
|
||||
})
|
||||
m.Split(strings.TrimSuffix(m.Option("sub"), ">"), " ", "6").Table(func(index int, value map[string]string) {
|
||||
m.Cmd("state", "post", cmd, m.Option("arg"),
|
||||
"tag", value["tag"], "line", value["line"], "file", value["in file/text"])
|
||||
})
|
||||
case "fixs":
|
||||
if strings.HasPrefix(m.Option("sub"), "\nError") {
|
||||
break
|
||||
}
|
||||
m.Split(strings.TrimPrefix(m.Option("sub"), "\n"), " ", "3", "id file word").Table(func(index int, value map[string]string) {
|
||||
m.Split(m.Option("sub"), " ", "3", "id file word").Table(func(index int, value map[string]string) {
|
||||
vs := strings.Split(kit.Format(value["file"]), ":")
|
||||
m.Confv(cmd, []string{m.Option("arg"), "hash", m.Option("sid"), "-2"}, map[string]interface{}{
|
||||
"fix": value["id"],
|
||||
"file": vs[0],
|
||||
"line": vs[1],
|
||||
"word": value["word"],
|
||||
})
|
||||
m.Cmd("state", "post", cmd, m.Option("arg"),
|
||||
"fix", value["id"], "file", vs[0], "line", vs[1], "word", value["word"])
|
||||
})
|
||||
}
|
||||
m.Set("append").Set("result")
|
||||
|
@ -53,43 +53,38 @@ kit txts "插入记录" private "web.code.trend" list "vim.txts" \
|
||||
button "查看" action auto \
|
||||
button "返回" cb Last
|
||||
|
||||
kit bufs "文件缓存" private "web.code.state" vim bufs \
|
||||
kit bufs "文件缓存" private "web.code.state" list vim bufs \
|
||||
text "" name sid imports plugin_vim_sid action auto \
|
||||
text "tag" name key view tiny \
|
||||
text "" name value \
|
||||
text "sids tag file line" name fields \
|
||||
text "tag" name match view tiny \
|
||||
text "" name value view tiny \
|
||||
exports vim_file file "" vim_line line \
|
||||
button "查看" action auto
|
||||
|
||||
kit regs "粘贴缓存" private "web.code.state" vim regs \
|
||||
kit regs "粘贴缓存" private "web.code.state" list vim regs \
|
||||
text "" name sid imports plugin_vim_sid action auto \
|
||||
text "reg" name key view tiny \
|
||||
text "" name value \
|
||||
text "sids reg word" name fields \
|
||||
text "reg" name match view tiny \
|
||||
text "" name value view tiny \
|
||||
exports vim_word word \
|
||||
button "查看" action auto
|
||||
|
||||
kit marks "文件标记" private "web.code.state" vim marks \
|
||||
kit marks "文件标记" private "web.code.state" list vim marks \
|
||||
text "" name sid imports plugin_vim_sid action auto \
|
||||
text "mark" name key view tiny \
|
||||
text "" name value \
|
||||
text "sids mark line file" name fields \
|
||||
exports vim_file file "" vim_line line "" \
|
||||
text "mark" name match view tiny \
|
||||
text "" name value view tiny \
|
||||
exports vim_file file "" vim_line line "" vim_col col "" \
|
||||
button "查看" action auto
|
||||
|
||||
kit tags "语法标记" private "web.code.state" vim tags \
|
||||
kit tags "语法标记" private "web.code.state" list vim tags \
|
||||
text "" name sid imports plugin_vim_sid action auto \
|
||||
text "tag" name key view tiny \
|
||||
text "" name value \
|
||||
text "sids tag line file" name fields \
|
||||
text "tag" name match view tiny \
|
||||
text "" name value view tiny \
|
||||
exports vim_file file "" vim_line line "" vim_word tag "" \
|
||||
button "查看" action auto
|
||||
|
||||
kit fixs "项目索引" private "web.code.state" vim fixs \
|
||||
kit fixs "项目索引" private "web.code.state" list vim fixs \
|
||||
text "" name sid imports plugin_vim_sid action auto \
|
||||
text "files" name key view tiny \
|
||||
text "" name value \
|
||||
text "sids word line file" name fields \
|
||||
text "files" name value view tiny \
|
||||
text "" name value view tiny \
|
||||
exports vim_file file "" vim_line line "" vim_word word "" \
|
||||
button "查看" action auto
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user