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' }
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 'chr4/nginx.vim'
Plug 'othree/html5.vim'
@ -51,15 +58,22 @@ let g:syntastic_quiet_messages = { "regex": [
\ "Missing class docstring",
\ "Missing method docstring",
\ "Missing function docstring",
\ "Wrong continued indentation",
\ "Line Too Long",
\ "Invalid class name",
\ "Invalid method name",
\ "Invalid function name",
\ "Invalid constant name",
\ "Invalid variable name",
\ "Method could be a function",
\ "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__",
\ "Catching too general exception Exception",
\ "Exactly one space required before assignment",
\ "Too many lines in module",
\ "Invalid constant name",
\ ] }
Plug 'Valloric/YouCompleteMe'
@ -68,13 +82,6 @@ let g:ycm_confirm_extra_conf=0
nnoremap gd :YcmCompleter GoToDeclaration<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'
call plug#end()
"}}}
@ -116,7 +123,7 @@ set mouse=a
" colorscheme default
set t_Co=256
"}}}
"映射快捷键"{{{
"快捷键映射"{{{
nnoremap <C-H> <C-W>h
nnoremap <C-J> <C-W>j
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 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 let var
" ctx command
syn match shStatement "\(^\|\t\|$(\)cache"
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"
syn match shStatement "\(^\|\t\| \|$(\)cache"
syn match shStatement "\(^\|\t\| \|$(\)config"
" ctx command
syn match shCommand "\(^\|\t\|$(\)message"
syn match shCommand "\(^\|\t\|$(\)session"
syn match shCommand "\(^\|\t\|$(\)context"
syn match shCommand "\(^\|\t\|$(\)server"
syn match shCommand "\(^\|\t\|$(\)command"
syn match shCommand "\(^\|\t\|$(\)right"
syn match shCommand "\(^\|\t\| \|$(\)command"
" cli command
syn match shStatement "\(^\|\t\| \|$(\)let"
syn match shStatement "\(^\|\t\| \|$(\)var"
syn match shStatement "\(^\|\t\| \|$(\)return"
syn match shStatement "\(^\|\t\| \|$(\)source"
syn match shCommand "\(^\|\t\| \|$(\)alias"
" tcp command
syn match shCommand "\(^\|\t\|$(\)listen"
" aaa command
syn match shCommand "\(^\|\t\| \|$(\)login"
syn match shCommand "\(^\|\t\| \|$(\)right"
" web command
syn match shCommand "\(^\|\t\|$(\)serve"
syn match shCommand "\(^\|\t\|$(\)route"
syn match shCommand "\(^\|\t\| \|$(\)serve"
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 shString String

View File

@ -208,10 +208,9 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
}
if detail[0] != "context" {
target := cli.target
target := m.Cap("ps_target")
defer func() {
cli.target = target
m.Cap("ps_target", cli.target.Name)
m.Cap("ps_target", target)
}()
}
@ -242,16 +241,15 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
}
if msg.Cmd(detail); msg.Hand {
cli.target = msg.Target()
m.Cap("ps_target", cli.target.Name)
m.Cap("ps_target", msg.Cap("module"))
} else {
msg.Copy(m, "target").Detail(-1, "system")
msg.Cmd()
}
m.Target().Message().Set("result").Set("append").Copy(msg, "result").Copy(msg, "append")
m.Copy(msg, "result").Copy(msg, "append")
m.Capi("last_msg", 0, msg.Code())
m.Capi("ps_count", 1)
// m.Capi("last_msg", 0, msg.Code())
// m.Capi("ps_count", 1)
}
}},
"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" {
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 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"))

View File

@ -297,6 +297,15 @@ func (c *Context) Spawn(m *Message, name string, help string) *Context {
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
}
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 {
switch meta {
case "detail", "result":
if m.Meta != nil {
if m != nil && m.Meta != nil {
delete(m.Meta, meta)
}
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)
}
func (m *Message) Cmd(args ...interface{}) *Message {
if m == nil {
return m
}
if len(args) > 0 {
m.Set("detail", Trans(args...)...)
}
@ -1401,6 +1413,7 @@ func (m *Message) Cmd(args ...interface{}) *Message {
arg = args
}
m.Hand = true
x.Hand(m, s, key, arg...)
if m.Hand = true; len(rest) > 0 {
@ -3715,12 +3728,16 @@ func Start(args ...string) {
Pulse.Sess("log", "log")
if len(args) > 0 {
Pulse.Sess("cli", false).Conf("init.shy", args[0])
args = args[1:]
if Pulse.Sess("nfs").Cmd("exist", args[0]).Results(0) {
Pulse.Sess("cli", false).Conf("init.shy", args[0])
args = args[1:]
}
}
if len(args) > 0 {
Pulse.Sess("log", false).Conf("bench.log", args[0])
args = args[1:]
if Pulse.Sess("nfs").Cmd("exist", args[0]).Results(0) {
Pulse.Sess("log", false).Conf("bench.log", args[0])
args = args[1:]
}
}
Pulse.Options("log", true)
@ -3728,6 +3745,5 @@ func Start(args ...string) {
log.target.Start(log)
Pulse.Options("terminal_color", true)
Pulse.Sess("cli", false).Cmd("source", "stdio")
}