From ae04d14640132ce9bfe826caed26cc7cdb3213d3 Mon Sep 17 00:00:00 2001 From: shaoying Date: Tue, 12 Nov 2019 09:50:01 +0800 Subject: [PATCH] add vim.Favor --- etc/conf/auto.vim | 11 +++++++++++ src/contexts/ssh/ssh.go | 3 +++ src/examples/code/code.go | 11 ++++++++++- src/plugin/vim/index.shy | 8 ++++---- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/etc/conf/auto.vim b/etc/conf/auto.vim index 500140d4..8a590e2b 100644 --- a/etc/conf/auto.vim +++ b/etc/conf/auto.vim @@ -74,6 +74,14 @@ fun! Shy(action, target) endif endfun +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]}) + endif +endfun + fun! ShyLogout() call Shy("logout", "") let g:ctx_sid = "" @@ -94,8 +102,11 @@ call ShySync("regs") call ShySync("marks") call ShySync("tags") " call ShySync("fixs") +" nnoremap :call ShyCheck("cache") nnoremap :call ShyCheck("favor") +nnoremap F :call ShyFavor("note") +nnoremap f :call ShyFavor("") " autocmd BufUnload * call Shy("close", expand("")) | call ShySync("bufs") " autocmd CmdlineLeave * diff --git a/src/contexts/ssh/ssh.go b/src/contexts/ssh/ssh.go index 08f368bc..b3a73545 100644 --- a/src/contexts/ssh/ssh.go +++ b/src/contexts/ssh/ssh.go @@ -410,6 +410,9 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心", switch arg[0] { case "show": + if arg[1] == "" { + arg = arg[:1] + } switch len(arg) { case 1: // 数据库 m.Confm("flow", []string{m.Option("river"), "data"}, func(key string, value map[string]interface{}) { diff --git a/src/examples/code/code.go b/src/examples/code/code.go index a21fd804..d6ee1919 100644 --- a/src/examples/code/code.go +++ b/src/examples/code/code.go @@ -830,7 +830,16 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", case "favor": m.Option("river", m.Conf(cmd, []string{"editor", "hash", m.Option("sid"), "river"})) - m.Cmd("ssh.data", "show", m.Conf(cmd, []string{"editor", "hash", m.Option("sid"), "table"})).Table(func(index int, value map[string]string) { + table := m.Conf(cmd, []string{"editor", "hash", m.Option("sid"), "table"}) + + if m.Options("line") { + m.Cmd("ssh.data", "insert", table, + "note", m.Option("note"), "word", m.Option("arg"), + "file", m.Option("buf"), "line", m.Option("line"), "col", m.Option("col"), + ) + return + } + m.Cmd("ssh.data", "show", table).Table(func(index int, value map[string]string) { m.Echo("%v:%v:0:(%v): %v\n", value["file"], value["line"], value["note"], value["word"]) }).Set("append") return diff --git a/src/plugin/vim/index.shy b/src/plugin/vim/index.shy index c2863b58..7951fbe8 100644 --- a/src/plugin/vim/index.shy +++ b/src/plugin/vim/index.shy @@ -1,14 +1,14 @@ fun tips "便签" private \ select "" name "action" values "show" values "insert" values "update" \ - text "tip" name table \ + 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 \ feature detail "修改" "复制" "下载" \ - exports tip_id id "" vim_file file "" vim_line line "" vim_word word "" \ + exports vim_table table "" tip_id id "" vim_file file "" vim_line line "" vim_word word "" \ button "记录" action auto if $1 == "show" @@ -26,8 +26,8 @@ fun tips "便签" private \ end kit editor "编辑器" private "web.code.vim" editor \ - text "" name sid imports plugin_vim_sid \ - text "" name favor \ + text "" name sid imports plugin_vim_sid action auto \ + text "" name table imports plugin_vim_table \ text "times sids status pid pane" name fields \ exports vim_sid sid \ button "查看" action auto