1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-26 01:04:06 +08:00

opt vim.favor

This commit is contained in:
shaoying 2019-11-13 10:31:55 +08:00
parent bddad6839c
commit 490af7bf6d
4 changed files with 40 additions and 19 deletions

View File

@ -1,7 +1,9 @@
let ctx_url = (len($ctx_dev) > 1? $ctx_dev: "http://127.0.0.1:9095") . "/code/vim"
let ctx_head = "Content-Type: application/json"
if !exists("g:ctx_sid")
let ctx_sid = ""
end
fun! ShyPost(arg)
let a:arg["buf"] = bufname("%")
@ -39,6 +41,14 @@ fun! ShyCheck(target)
endif
elseif a:target == "favor"
cexpr ShyPost({"cmd": "favor"})
elseif a:target == "favors"
let msg = json_decode(ShyPost({"cmd": "favors"}))
let i = 0
for i in range(len(msg["tab"]))
tabnew
lexpr msg["fix"][i]
lopen
endfor
elseif a:target == "cache"
call ShySync("bufs")
call ShySync("regs")
@ -74,11 +84,15 @@ fun! Shy(action, target)
endif
endfun
let favor_tab = ""
let favor_note = ""
fun! ShyFavor(note)
if a:note == ""
call ShyPost({"cmd": "favor", "arg": getline("."), "line": getpos(".")[1], "col": getpos(".")[2]})
else
call ShyPost({"cmd": "favor", "note": input("note: "), "arg": getline("."), "line": getpos(".")[1], "col": getpos(".")[2]})
let g:favor_tab = input("tab: ", g:favor_tab)
let g:favor_note = input("note: ", g:favor_note)
call ShyPost({"cmd": "favor", "tab": g:favor_tab, "note": g:favor_note, "arg": getline("."), "line": getpos(".")[1], "col": getpos(".")[2]})
endif
endfun
@ -104,7 +118,8 @@ call ShySync("tags")
" call ShySync("fixs")
"
nnoremap <C-R><C-R> :call ShyCheck("cache")<CR>
nnoremap <C-R><C-F> :call ShyCheck("favor")<CR>
" nnoremap <C-R><C-F> :call ShyCheck("favor")<CR>
nnoremap <C-R><C-F> :call ShyCheck("favors")<CR>
nnoremap <C-R>F :call ShyFavor("note")<CR>
nnoremap <C-R>f :call ShyFavor("")<CR>

View File

@ -410,7 +410,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
switch arg[0] {
case "show":
if arg[1] == "" {
if len(arg) > 1 && arg[1] == "" {
arg = arg[:1]
}
switch len(arg) {

View File

@ -831,12 +831,30 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
m.Conf(cmd, []string{"editor", "hash", m.Option("sid"), "time"}, m.Time())
m.Conf(cmd, []string{"editor", "hash", m.Option("sid"), "status"}, "logout")
case "favors":
m.Option("river", m.Conf(cmd, []string{"editor", "hash", m.Option("sid"), "river"}))
table := m.Conf(cmd, []string{"editor", "hash", m.Option("sid"), "table"})
m.Log("info", "favor: %v table: %v", m.Option("river"), table)
data := map[string][]string{}
m.Cmd("ssh.data", "show", table).Table(func(index int, value map[string]string) {
data[value["tab"]] = append(data[value["tab"]],
fmt.Sprintf("%v:%v:0:(%v): %v\n", value["file"], value["line"], value["note"], value["word"]))
})
for k, v := range data {
m.Push("tab", k)
m.Push("fix", strings.Join(v, "\n"))
}
return
case "favor":
m.Option("river", m.Conf(cmd, []string{"editor", "hash", m.Option("sid"), "river"}))
table := m.Conf(cmd, []string{"editor", "hash", m.Option("sid"), "table"})
m.Log("info", "favor: %v table: %v", m.Option("river"), table)
if m.Options("line") {
m.Cmd("ssh.data", "insert", table,
"tab", m.Option("tab"),
"note", m.Option("note"), "word", m.Option("arg"),
"file", m.Option("buf"), "line", m.Option("line"), "col", m.Option("col"),
)

View File

@ -1,27 +1,15 @@
fun tips "便签" private \
select "" name "action" values "show" values "insert" values "update" \
text "tip" name table imports plugin_vim_table action auto \
text "" name index imports plugin_view_tip_id view tiny \
text "" name file imports plugin_vim_file view long \
text "" name line imports plugin_vim_line view tiny \
text "" name word imports plugin_vim_word view long \
textarea "" name note \
text "" name index imports plugin_tip_id view tiny action auto \
feature detail "修改" "复制" "下载" \
exports vim_table table "" tip_id id "" vim_file file "" vim_line line "" vim_word word "" \
button "记录" action auto
if $1 == "show"
copy skip ssh.data _ _
end
if $1 == "insert"
copy skip ssh.data insert $2 file $4 line $5 word $6 note $7
end
if $1 == "update"
copy skip ssh.data update $2 $3 file $4 line $5 word $6 note $7
end
if $2 == "modify"
copy skip ssh.data update $table $1 $3 $4
else
copy ssh.data show
end
end