1
0
forked from x/ContextOS
This commit is contained in:
shaoying 2018-10-30 08:24:36 +08:00
parent 8e21f50944
commit 2a654f675f
4 changed files with 73 additions and 50 deletions

View File

@ -37,6 +37,13 @@ nnoremap <C-G> :Ag <C-R>=expand("<cword>")<CR><CR>
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
nnoremap <C-N> :FZF -q <C-R>=expand("<cword>")<CR><CR> nnoremap <C-N> :FZF -q <C-R>=expand("<cword>")<CR><CR>
Plug 'benmills/vimux'
let mapleader=";"
nnoremap <Leader>; :VimuxPromptCommand<CR>
" nnoremap <Leader>j :VimuxZoomRunner<CR>
" nnoremap <Leader>l :VimuxRunLastCommand<CR>
" nnoremap <Leader>vx :VimuxInterruptRunner<CR>
Plug 'fatih/vim-go' Plug 'fatih/vim-go'
Plug 'chr4/nginx.vim' Plug 'chr4/nginx.vim'
Plug 'othree/html5.vim' Plug 'othree/html5.vim'
@ -51,15 +58,22 @@ let g:syntastic_quiet_messages = { "regex": [
\ "Missing class docstring", \ "Missing class docstring",
\ "Missing method docstring", \ "Missing method docstring",
\ "Missing function docstring", \ "Missing function docstring",
\ "Wrong continued indentation", \ "Invalid class name",
\ "Line Too Long", \ "Invalid method name",
\ "Invalid function name",
\ "Invalid constant name",
\ "Invalid variable name", \ "Invalid variable name",
\ "Method could be a function",
\ "Too many instance attributes", \ "Too many instance attributes",
\ "Wrong continued indentation",
\ "Too many lines in module",
\ "Too many arguments",
\ "Too many local variables",
\ "Too many branches",
\ "Too many statements",
\ "Line Too Long",
\ "defined outside __init__", \ "defined outside __init__",
\ "Catching too general exception Exception", \ "Catching too general exception Exception",
\ "Exactly one space required before assignment",
\ "Too many lines in module",
\ "Invalid constant name",
\ ] } \ ] }
Plug 'Valloric/YouCompleteMe' Plug 'Valloric/YouCompleteMe'
@ -68,13 +82,6 @@ let g:ycm_confirm_extra_conf=0
nnoremap gd :YcmCompleter GoToDeclaration<CR> nnoremap gd :YcmCompleter GoToDeclaration<CR>
nnoremap gD :YcmCompleter GoToReferences<CR> nnoremap gD :YcmCompleter GoToReferences<CR>
Plug 'benmills/vimux'
let mapleader=";"
nnoremap <Leader>; :VimuxPromptCommand<CR>
" nnoremap <Leader>j :VimuxZoomRunner<CR>
" nnoremap <Leader>l :VimuxRunLastCommand<CR>
" nnoremap <Leader>vx :VimuxInterruptRunner<CR>
Plug 'vim-scripts/matrix.vim--Yang' Plug 'vim-scripts/matrix.vim--Yang'
call plug#end() call plug#end()
"}}} "}}}
@ -116,7 +123,7 @@ set mouse=a
" colorscheme default " colorscheme default
set t_Co=256 set t_Co=256
"}}} "}}}
"映射快捷键"{{{ "快捷键映射"{{{
nnoremap <C-H> <C-W>h nnoremap <C-H> <C-W>h
nnoremap <C-J> <C-W>j nnoremap <C-J> <C-W>j
nnoremap <C-K> <C-W>k nnoremap <C-K> <C-W>k

View File

@ -10,38 +10,36 @@ syn match shOperator "\~[-_a-zA-Z0-9]\+\>"
syn match shShellVariables "\$[-_a-zA-Z0-9]\+\>" syn match shShellVariables "\$[-_a-zA-Z0-9]\+\>"
syn match shShellVariables "@[-_a-zA-Z0-9]\+\>" syn match shShellVariables "@[-_a-zA-Z0-9]\+\>"
syn keyword shStatement break cd chdir continue eval exec exit kill newgrp pwd read readonly return shift test trap ulimit umask wait syn keyword shStatement break cd chdir continue eval exec exit kill newgrp pwd read readonly shift trap ulimit umask wait
syn keyword shStatement source return function
syn keyword shStatement if else elif end for syn keyword shStatement if else elif end for
syn keyword shStatement let var
" ctx command " ctx command
syn match shStatement "\(^\|\t\|$(\)cache" syn match shStatement "\(^\|\t\| \|$(\)cache"
syn match shStatement "\(^\|\t\|$(\)config" syn match shStatement "\(^\|\t\| \|$(\)config"
syn match shStatement "\(^\|\t\|$(\)detail"
syn match shStatement "\(^\|\t\|$(\)option"
syn match shStatement "\(^\|\t\|$(\)append"
syn match shStatement "\(^\|\t\|$(\)result"
" ctx command " ctx command
syn match shCommand "\(^\|\t\|$(\)message" syn match shCommand "\(^\|\t\| \|$(\)command"
syn match shCommand "\(^\|\t\|$(\)session" " cli command
syn match shCommand "\(^\|\t\|$(\)context" syn match shStatement "\(^\|\t\| \|$(\)let"
syn match shCommand "\(^\|\t\|$(\)server" syn match shStatement "\(^\|\t\| \|$(\)var"
syn match shCommand "\(^\|\t\|$(\)command" syn match shStatement "\(^\|\t\| \|$(\)return"
syn match shCommand "\(^\|\t\|$(\)right" syn match shStatement "\(^\|\t\| \|$(\)source"
syn match shCommand "\(^\|\t\| \|$(\)alias"
" tcp command " aaa command
syn match shCommand "\(^\|\t\|$(\)listen" syn match shCommand "\(^\|\t\| \|$(\)login"
syn match shCommand "\(^\|\t\| \|$(\)right"
" web command " web command
syn match shCommand "\(^\|\t\|$(\)serve" syn match shCommand "\(^\|\t\| \|$(\)serve"
syn match shCommand "\(^\|\t\|$(\)route" syn match shCommand "\(^\|\t\| \|$(\)route"
syn match shCommand "\(^\|\t\| \|$(\)client"
syn match shCommand "\(^\|\t\| \|$(\)cookie"
syn match shCommand "\(^\|\t\| \|$(\)template"
" mdb command
syn match shCommand "\(^\|\t\| \|$(\)open"
syn match shCommand "\(^\|\t\|$(\)open"
syn match shCommand "\(^\|\t\|$(\)cookie"
syn match shCommand "\(^\|\t\|$(\)login"
hi def link shComment Comment hi def link shComment Comment
hi def link shString String hi def link shString String

View File

@ -208,10 +208,9 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
} }
if detail[0] != "context" { if detail[0] != "context" {
target := cli.target target := m.Cap("ps_target")
defer func() { defer func() {
cli.target = target m.Cap("ps_target", target)
m.Cap("ps_target", cli.target.Name)
}() }()
} }
@ -242,16 +241,15 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
} }
if msg.Cmd(detail); msg.Hand { if msg.Cmd(detail); msg.Hand {
cli.target = msg.Target() m.Cap("ps_target", msg.Cap("module"))
m.Cap("ps_target", cli.target.Name)
} else { } else {
msg.Copy(m, "target").Detail(-1, "system") msg.Copy(m, "target").Detail(-1, "system")
msg.Cmd() msg.Cmd()
} }
m.Target().Message().Set("result").Set("append").Copy(msg, "result").Copy(msg, "append") m.Target().Message().Set("result").Set("append").Copy(msg, "result").Copy(msg, "append")
m.Copy(msg, "result").Copy(msg, "append") m.Copy(msg, "result").Copy(msg, "append")
m.Capi("last_msg", 0, msg.Code()) // m.Capi("last_msg", 0, msg.Code())
m.Capi("ps_count", 1) // m.Capi("ps_count", 1)
} }
}}, }},
"str": &ctx.Command{Name: "str word", Help: "解析字符串", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) { "str": &ctx.Command{Name: "str word", Help: "解析字符串", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
@ -556,7 +554,11 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
} }
if len(arg) < 2 || arg[1] != "async" { if len(arg) < 2 || arg[1] != "async" {
m.Wait() if arg[0] == "stdio" && len(arg) > 1 {
fmt.Printf(m.Spawn().Cmd("source", arg[1]).Result(0))
} else {
m.Wait()
}
if arg[0] == "stdio" { if arg[0] == "stdio" {
if m.Sess("nfs").Cmd("exist", m.Confx("exit.shy", arg, 2)).Results(0) { if m.Sess("nfs").Cmd("exist", m.Confx("exit.shy", arg, 2)).Results(0) {
m.Spawn().Add("option", "scan_end", "false").Cmd("source", m.Conf("exit.shy")) m.Spawn().Add("option", "scan_end", "false").Cmd("source", m.Conf("exit.shy"))

View File

@ -297,6 +297,15 @@ func (c *Context) Spawn(m *Message, name string, help string) *Context {
c.Register(s, nil) c.Register(s, nil)
} }
item := []string{name}
for s := c; s != nil; s = s.context {
item = append(item, s.Name)
}
for i := 0; i < len(item)/2; i++ {
item[i], item[len(item)-i-1] = item[len(item)-i-1], item[i]
}
s.Caches["module"] = &Cache{Name: "module", Value: strings.Join(item, "."), Help: "模块域名"}
s.message = m
return s return s
} }
func (c *Context) Begin(m *Message, arg ...string) *Context { func (c *Context) Begin(m *Message, arg ...string) *Context {
@ -853,7 +862,7 @@ func (m *Message) Add(meta string, key string, value ...interface{}) *Message {
func (m *Message) Set(meta string, arg ...string) *Message { func (m *Message) Set(meta string, arg ...string) *Message {
switch meta { switch meta {
case "detail", "result": case "detail", "result":
if m.Meta != nil { if m != nil && m.Meta != nil {
delete(m.Meta, meta) delete(m.Meta, meta)
} }
case "option", "append": case "option", "append":
@ -1365,6 +1374,9 @@ func (m *Message) Start(name string, help string, arg ...string) bool {
return m.Set("detail", arg...).target.Spawn(m, name, help).Begin(m).Start(m) return m.Set("detail", arg...).target.Spawn(m, name, help).Begin(m).Start(m)
} }
func (m *Message) Cmd(args ...interface{}) *Message { func (m *Message) Cmd(args ...interface{}) *Message {
if m == nil {
return m
}
if len(args) > 0 { if len(args) > 0 {
m.Set("detail", Trans(args...)...) m.Set("detail", Trans(args...)...)
} }
@ -1401,6 +1413,7 @@ func (m *Message) Cmd(args ...interface{}) *Message {
arg = args arg = args
} }
m.Hand = true
x.Hand(m, s, key, arg...) x.Hand(m, s, key, arg...)
if m.Hand = true; len(rest) > 0 { if m.Hand = true; len(rest) > 0 {
@ -3715,12 +3728,16 @@ func Start(args ...string) {
Pulse.Sess("log", "log") Pulse.Sess("log", "log")
if len(args) > 0 { if len(args) > 0 {
Pulse.Sess("cli", false).Conf("init.shy", args[0]) if Pulse.Sess("nfs").Cmd("exist", args[0]).Results(0) {
args = args[1:] Pulse.Sess("cli", false).Conf("init.shy", args[0])
args = args[1:]
}
} }
if len(args) > 0 { if len(args) > 0 {
Pulse.Sess("log", false).Conf("bench.log", args[0]) if Pulse.Sess("nfs").Cmd("exist", args[0]).Results(0) {
args = args[1:] Pulse.Sess("log", false).Conf("bench.log", args[0])
args = args[1:]
}
} }
Pulse.Options("log", true) Pulse.Options("log", true)
@ -3728,6 +3745,5 @@ func Start(args ...string) {
log.target.Start(log) log.target.Start(log)
Pulse.Options("terminal_color", true) Pulse.Options("terminal_color", true)
Pulse.Sess("cli", false).Cmd("source", "stdio") Pulse.Sess("cli", false).Cmd("source", "stdio")
} }