diff --git a/etc/auto.vim b/etc/auto.vim index 6ae0fbf4..17c3e0dd 100644 --- a/etc/auto.vim +++ b/etc/auto.vim @@ -127,7 +127,7 @@ endfun fun! ShyComplete(firststart, base) if a:firststart | let line = getline('.') | let start = col('.') - 1 " 命令位置 - if match(trim(line), "ice ") == 0 | return match(line, "ice ") | endif + if match(line, '\s*ice ') == 0 | return match(line, "ice ") | endif " 符号位置 if line[start-1] !~ '\a' | return start - 1 | end " 单词位置 @@ -155,7 +155,7 @@ fun! ShyCome(buf, row, action, extra) let a:extra["count"] = 0 endif " 刷新命令 - for line in reverse(split(trim(ShySend({"cmd": "trans", "arg": getbufline(a:buf, a:row)[0]})), "\n")) + for line in reverse(split(ShySend({"cmd": "trans", "arg": getbufline(a:buf, a:row)[0]}), "\n")) call appendbufline(a:buf, a:row, line) let a:extra["count"] += 1 endfor @@ -169,12 +169,19 @@ fun! ShyUpdate(timer) call ShyCome(what["buf"], what["row"], what["action"], what) endfun fun! ShyComes(action) + " 低配命令 + if !exists("appendbufline") + for line in reverse(split(ShySend({"cmd": "trans", "arg": getline(".")}), "\n")) + call append(".", line) + endfor + return + endif if !exists("b:timer") | let b:timer = -1 | endif " 清除定时 if b:timer > 0 | call timer_stop(b:timer) | let b:timer = -2 | return | endif " 添加定时 let b:timer = timer_start(1000, funcref('ShyUpdate'), {"repeat": -1}) - let g:ShyComeList[b:timer] = {"buf": bufname(), "row": line("."), "pre": getline("."), "action": a:action, "count": 0} + let g:ShyComeList[b:timer] = {"buf": bufname("."), "row": line("."), "pre": getline("."), "action": a:action, "count": 0} call ShyLog("new timer", b:timer) endfun diff --git a/etc/exit.shy b/etc/exit.shy deleted file mode 100644 index e69de29b..00000000 diff --git a/etc/init.shy b/etc/init.shy deleted file mode 100644 index e69de29b..00000000 diff --git a/go.mod b/go.mod index 580e7b0e..579b3261 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,14 @@ module miss go 1.13 -require github.com/shylinux/icebergs v0.1.9 +require ( + github.com/shylinux/contexts v0.0.0-00010101000000-000000000000 // indirect + github.com/shylinux/icebergs v0.1.9 + github.com/shylinux/toolkits v0.1.0 +) replace ( + github.com/shylinux/contexts => ./ github.com/shylinux/icebergs => ../icebergs github.com/shylinux/toolkits => ../toolkits ) diff --git a/go.sum b/go.sum index 5876c073..4d149605 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,7 @@ github.com/gomarkdown/markdown v0.0.0-20200112043221-ec51d717629d h1:Qw3Ku+gg4x3 github.com/gomarkdown/markdown v0.0.0-20200112043221-ec51d717629d/go.mod h1:aii0r/K0ZnHv7G0KF7xy1v0A7s2Ljrb5byB7MO5p6TU= github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/shylinux/contexts v0.0.0-20200121121314-2b28848b15ea h1:xmFZmpT3RMt4JnmxSwJ9M552SaiCC8DufYVadssbuS8= github.com/shylinux/icebergs v0.1.12 h1:pUWWp4p5rF1JT7lcbaBlCJOWzwjPYDzmWcO9+nrNsfs= github.com/shylinux/icebergs v0.1.12/go.mod h1:/gccR5uyFaaml8CBSD4BfHmIPOK6QlaFp3sK4eOiv4s= github.com/shylinux/toolkits v0.1.0 h1:7ghnVEjuwLf7zBsyeR37ahm2gaOKIyjSw9F9Pp9oTBU= diff --git a/src/main.go b/src/main.go index 6a6452db..767d0d5f 100644 --- a/src/main.go +++ b/src/main.go @@ -12,6 +12,8 @@ import ( _ "github.com/shylinux/icebergs/misc/mp" _ "github.com/shylinux/icebergs/misc/pi" _ "github.com/shylinux/icebergs/misc/wx" + + _ "github.com/shylinux/contexts/src/support/wuhan" ) func main() { diff --git a/src/support/wuhan/wuhan.go b/src/support/wuhan/wuhan.go new file mode 100644 index 00000000..76f1844b --- /dev/null +++ b/src/support/wuhan/wuhan.go @@ -0,0 +1,24 @@ +package wuhan + +import ( + "github.com/shylinux/icebergs" + "github.com/shylinux/icebergs/base/cli" + "github.com/shylinux/toolkits" +) + +var Index = &ice.Context{Name: "wuhan", Help: "武汉加油", + Caches: map[string]*ice.Cache{}, + Configs: map[string]*ice.Config{ + "wuhan": {Name: "wuhan", Help: "武汉", Value: kit.Data(kit.MDB_SHORT, "name")}, + }, + Commands: map[string]*ice.Command{ + ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}}, + ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}}, + + "wuhan": {Name: "wuhan", Help: "武汉", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + m.Echo("hello world") + }}, + }, +} + +func init() { cli.Index.Register(Index, nil) } diff --git a/src/support/wuhan/wuhan.md b/src/support/wuhan/wuhan.md new file mode 100644 index 00000000..9e587817 --- /dev/null +++ b/src/support/wuhan/wuhan.md @@ -0,0 +1 @@ +# {{title "wuhan"}}