Fixed vim and zsh
This commit is contained in:
@ -0,0 +1,74 @@
|
||||
" ___vital___
|
||||
" NOTE: lines between '" ___vital___' is generated by :Vitalize.
|
||||
" Do not mofidify the code nor insert new lines before '" ___vital___'
|
||||
if v:version > 703 || v:version == 703 && has('patch1170')
|
||||
function! vital#_easymotion#Palette#Capture#import() abort
|
||||
return map({'extend': '', 'command': ''}, 'function("s:" . v:key)')
|
||||
endfunction
|
||||
else
|
||||
function! s:_SID() abort
|
||||
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
|
||||
endfunction
|
||||
execute join(['function! vital#_easymotion#Palette#Capture#import() abort', printf("return map({'extend': '', 'command': ''}, \"function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
|
||||
delfunction s:_SID
|
||||
endif
|
||||
" ___vital___
|
||||
scriptencoding utf-8
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
|
||||
let s:verbosefiles = []
|
||||
|
||||
function! s:_verbosefile_push(file)
|
||||
call add(s:verbosefiles, &verbosefile)
|
||||
let &verbosefile = a:file
|
||||
return a:file
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:_verbosefile_pop()
|
||||
let filename = &verbosefile
|
||||
let &verbosefile = get(s:verbosefiles, -1)
|
||||
call remove(s:verbosefiles, -1)
|
||||
return filename
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:_reset()
|
||||
let s:verbosefiles = []
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:extend(dict, src)
|
||||
for [key, value] in items(a:src)
|
||||
let a:dict[key] = value
|
||||
unlet value
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:command(cmd, ...)
|
||||
" Workaround : Vim 7.3.xxx in Travis and Ubuntu
|
||||
" https://github.com/osyo-manga/vital-palette/issues/5
|
||||
" call extend(l:, get(a:, 1, {}))
|
||||
if a:0 > 0
|
||||
call s:extend(l:, a:1)
|
||||
endif
|
||||
|
||||
call s:_verbosefile_push(tempname())
|
||||
try
|
||||
redir =>result
|
||||
silent execute a:cmd
|
||||
finally
|
||||
redir END
|
||||
endtry
|
||||
call s:_verbosefile_pop()
|
||||
" let result = substitute(result, "<SRN>", "\<SNR>", "g")
|
||||
" let result = substitute(result, "<SID>", "\<SID>", "g")
|
||||
return result
|
||||
endfunction
|
||||
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
@ -0,0 +1,133 @@
|
||||
" ___vital___
|
||||
" NOTE: lines between '" ___vital___' is generated by :Vitalize.
|
||||
" Do not mofidify the code nor insert new lines before '" ___vital___'
|
||||
if v:version > 703 || v:version == 703 && has('patch1170')
|
||||
function! vital#_easymotion#Palette#Highlight#import() abort
|
||||
return map({'capture': '', '_vital_depends': '', 'parse': '', 'group_list': '', 'set': '', 'parse_to_name': '', 'links_to': '', 'get': '', '_vital_loaded': ''}, 'function("s:" . v:key)')
|
||||
endfunction
|
||||
else
|
||||
function! s:_SID() abort
|
||||
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
|
||||
endfunction
|
||||
execute join(['function! vital#_easymotion#Palette#Highlight#import() abort', printf("return map({'capture': '', '_vital_depends': '', 'parse': '', 'group_list': '', 'set': '', 'parse_to_name': '', 'links_to': '', 'get': '', '_vital_loaded': ''}, \"function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
|
||||
delfunction s:_SID
|
||||
endif
|
||||
" ___vital___
|
||||
scriptencoding utf-8
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
|
||||
function! s:_vital_loaded(V)
|
||||
let s:V = a:V
|
||||
let s:Message = s:V.import("Vim.Message")
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:_vital_depends()
|
||||
return [
|
||||
\ "Vim.Message",
|
||||
\ ]
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:_execute(cmd)
|
||||
execute a:cmd
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:capture(name)
|
||||
if hlexists(a:name) == 0
|
||||
return ""
|
||||
endif
|
||||
return s:Message.capture("highlight " . a:name)
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:links_to(highlight)
|
||||
return matchstr(a:highlight, '^\S\+\s\+xxx links to \zs.*\ze$')
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:parse_to_name(highlight)
|
||||
return matchstr(a:highlight, '^\zs\w\+\ze')
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:parse(highlight)
|
||||
let highlight = a:highlight
|
||||
|
||||
if highlight !~# '^\w\+\s\+xxx\s'
|
||||
return {}
|
||||
endif
|
||||
|
||||
let name = s:parse_to_name(a:highlight)
|
||||
let result = { "_name" : name }
|
||||
|
||||
if highlight =~# '^\w\+\s\+xxx cleared'
|
||||
let result.cleared = 1
|
||||
return result
|
||||
endif
|
||||
|
||||
let link = s:links_to(highlight)
|
||||
if link != ""
|
||||
let result.link = link
|
||||
return result
|
||||
endif
|
||||
|
||||
let attrs = [
|
||||
\ "term",
|
||||
\ "cterm",
|
||||
\ "ctermfg",
|
||||
\ "ctermbg",
|
||||
\ "gui",
|
||||
\ "font",
|
||||
\ "guifg",
|
||||
\ "guibg",
|
||||
\ "guisp",
|
||||
\ ]
|
||||
for attr in attrs
|
||||
let item = matchstr(highlight, '\s' . attr . '=\zs#\?\w\+\ze')
|
||||
if item != ""
|
||||
let result[attr] = item
|
||||
endif
|
||||
endfor
|
||||
return result
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:get(name, ...)
|
||||
if !hlexists(a:name)
|
||||
return {}
|
||||
endif
|
||||
let result = s:parse(substitute(s:capture(a:name), "\n", "", "g"))
|
||||
if has_key(result, "link") && get(a:, 1, 0)
|
||||
return s:get(result.link, get(a:, 1, 0))
|
||||
else
|
||||
return result
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:set(name, config)
|
||||
if type(a:config) == type("")
|
||||
return s:set(a:config, s:get(a:config))
|
||||
endif
|
||||
if has_key(a:config, "cleared")
|
||||
return s:_execute("highlight clear " . a:name)
|
||||
endif
|
||||
if has_key(a:config, "link")
|
||||
return s:_execute("highlight link " . a:name . " " . a:config.link)
|
||||
endif
|
||||
return s:_execute("highlight " . a:name . " " . join(map(items(filter(a:config, "v:key !=# '_name'")), "v:val[0] . '=' . v:val[1]"), " "))
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:group_list()
|
||||
let highlights = split(s:Message.capture("highlight"), "\n")
|
||||
return filter(map(highlights, "s:parse_to_name(v:val)"), "v:val != ''")
|
||||
endfunction
|
||||
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
@ -0,0 +1,121 @@
|
||||
" ___vital___
|
||||
" NOTE: lines between '" ___vital___' is generated by :Vitalize.
|
||||
" Do not mofidify the code nor insert new lines before '" ___vital___'
|
||||
if v:version > 703 || v:version == 703 && has('patch1170')
|
||||
function! vital#_easymotion#Palette#Keymapping#import() abort
|
||||
return map({'capture': '', '_vital_depends': '', 'escape_special_key': '', 'rhs_key_list': '', 'parse_lhs_list': '', 'lhs_key_list': '', 'capture_list': '', 'parse_lhs': '', '_vital_loaded': ''}, 'function("s:" . v:key)')
|
||||
endfunction
|
||||
else
|
||||
function! s:_SID() abort
|
||||
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
|
||||
endfunction
|
||||
execute join(['function! vital#_easymotion#Palette#Keymapping#import() abort', printf("return map({'capture': '', '_vital_depends': '', 'escape_special_key': '', 'rhs_key_list': '', 'parse_lhs_list': '', 'lhs_key_list': '', 'capture_list': '', 'parse_lhs': '', '_vital_loaded': ''}, \"function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
|
||||
delfunction s:_SID
|
||||
endif
|
||||
" ___vital___
|
||||
scriptencoding utf-8
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
|
||||
let s:modep = "[nvoicsxl]"
|
||||
|
||||
|
||||
function! s:_vital_loaded(V)
|
||||
let s:V = a:V
|
||||
let s:Capture = s:V.import("Palette.Capture")
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:_vital_depends()
|
||||
return [
|
||||
\ "Palette.Capture",
|
||||
\ ]
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:_capture(mode)
|
||||
let cmd = "map"
|
||||
if a:mode ==# "!"
|
||||
let cmd = cmd . "!"
|
||||
elseif a:mode =~# "[nvoicsxl]"
|
||||
let cmd = a:mode . cmd
|
||||
endif
|
||||
return s:Capture.command(cmd)
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:capture(...)
|
||||
let mode = get(a:, 1, "")
|
||||
let modes = split(mode, '\zs')
|
||||
return join(map(modes, "s:_capture(v:val)"), "\n")
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:_keymapping(str)
|
||||
return a:str =~ '^[!nvoicsxl]\s'
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:capture_list(...)
|
||||
let mode = get(a:, 1, "")
|
||||
return filter(split(s:capture(mode), "\n"), "s:_keymapping(v:val)")
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:escape_special_key(key)
|
||||
" Workaround : <C-?> https://github.com/osyo-manga/vital-palette/issues/5
|
||||
if a:key ==# "<^?>"
|
||||
return "\<C-?>"
|
||||
endif
|
||||
execute 'let result = "' . substitute(escape(a:key, '\"'), '\(<.\{-}>\)', '\\\1', 'g') . '"'
|
||||
return result
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:parse_lhs(text, ...)
|
||||
let mode = get(a:, 1, '[!nvoicsxl]')
|
||||
" NOTE: :map! Surpport : https://github.com/osyo-manga/vital-palette/issues/4
|
||||
if get(a:, 1, "") =~# '[!ci]'
|
||||
let mode = '[!ci]'
|
||||
endif
|
||||
return matchstr(a:text, mode . '\{1,3\}\s*\zs\S\{-}\ze\s\+')
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:parse_lhs_list(...)
|
||||
let mode = get(a:, 1, "")
|
||||
return map(s:capture_list(mode), "s:parse_lhs(v:val, mode)")
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:lhs_key_list(...)
|
||||
let mode = get(a:, 1, "")
|
||||
return map(s:parse_lhs_list(mode), "s:escape_special_key(v:val)")
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:_maparg(name, mode, abbr, dict)
|
||||
" Workaround : <C-?> https://github.com/osyo-manga/vital-palette/issues/5
|
||||
if a:name ==# "<^?>"
|
||||
return maparg("\<C-?>", a:mode, a:abbr, a:dict)
|
||||
endif
|
||||
return maparg(a:name, a:mode, a:abbr, a:dict)
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:rhs_key_list(...)
|
||||
let mode = get(a:, 1, "")
|
||||
let abbr = get(a:, 2, 0)
|
||||
let dict = get(a:, 3, 0)
|
||||
|
||||
let result = []
|
||||
for m in split(mode, '\zs')
|
||||
let result += map(s:parse_lhs_list(m), "s:_maparg(v:val, m, abbr, dict)")
|
||||
endfor
|
||||
return filter(result, "empty(v:val) == 0")
|
||||
endfunction
|
||||
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
Reference in New Issue
Block a user