Fixed vim and zsh

This commit is contained in:
2018-04-05 13:06:54 +02:00
parent f9db886bd3
commit 0331f6518a
2009 changed files with 256303 additions and 0 deletions

View File

@ -0,0 +1,117 @@
"=============================================================================
" FILE: autoload/EasyMotion/cmigemo.vim
" AUTHOR: haya14busa
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
" "Software"), to deal in the Software without restriction, including
" without limitation the rights to use, copy, modify, merge, publish,
" distribute, sublicense, and/or sell copies of the Software, and to
" permit persons to whom the Software is furnished to do so, subject to
" the following conditions:
"
" The above copyright notice and this permission notice shall be included
" in all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================
scriptencoding utf-8
" Saving 'cpoptions' {{{
let s:save_cpo = &cpo
set cpo&vim
" }}}
function! s:has_vimproc() "{{{
if !exists('s:exists_vimproc')
try
silent call vimproc#version()
let s:exists_vimproc = 1
catch
let s:exists_vimproc = 0
endtry
endif
return s:exists_vimproc
endfunction "}}}
function! EasyMotion#cmigemo#system(...) "{{{
return call(s:has_vimproc() ? 'vimproc#system' : 'system', a:000)
endfunction "}}}
function! s:SearchDict2(name) "{{{
let path = $VIM . ',' . &runtimepath
let dict = globpath(path, "dict/".a:name)
if dict == ''
let dict = globpath(path, a:name)
endif
if dict == ''
for path in [
\ '/usr/local/share/migemo/',
\ '/usr/local/share/cmigemo/',
\ '/usr/local/share/',
\ '/usr/share/cmigemo/',
\ '/usr/share/',
\ ]
let path = path . a:name
if filereadable(path)
let dict = path
break
endif
endfor
endif
let dict = matchstr(dict, "^[^\<NL>]*")
return dict
endfunction "}}}
function! s:SearchDict() "{{{
for path in [
\ 'migemo/'.&encoding.'/migemo-dict',
\ &encoding.'/migemo-dict',
\ 'migemo-dict',
\ ]
let dict = s:SearchDict2(path)
if dict != ''
return dict
endif
endfor
echoerr 'a dictionary for migemo is not found'
echoerr 'your encoding is '.&encoding
endfunction "}}}
function! EasyMotion#cmigemo#getMigemoPattern(input) "{{{
if !exists('s:migemodict')
let s:migemodict = s:SearchDict()
endif
if has('migemo')
" Use migemo().
if &migemodict !=# ''
return migemo(a:input)
endif
let &migemodict = s:migemodict
try
return migemo(a:input)
finally
let &migemodict = ''
endtry
elseif executable('cmigemo')
" Use cmigemo.
return EasyMotion#cmigemo#system('cmigemo -v -w "'.a:input.'" -d "'.s:migemodict.'"')
else
" Not supported
return a:input
endif
endfunction "}}}
" Restore 'cpoptions' {{{
let &cpo = s:save_cpo
unlet s:save_cpo
" }}}
" vim: fdm=marker:et:ts=4:sw=4:sts=4

View File

@ -0,0 +1,283 @@
"=============================================================================
" FILE: autoload/EasyMotion/command_line.vim
" AUTHOR: haya14busa
" Reference: https://github.com/osyo-manga/vim-over
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
" "Software"), to deal in the Software without restriction, including
" without limitation the rights to use, copy, modify, merge, publish,
" distribute, sublicense, and/or sell copies of the Software, and to
" permit persons to whom the Software is furnished to do so, subject to
" the following conditions:
"
" The above copyright notice and this permission notice shall be included
" in all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================
scriptencoding utf-8
" Saving 'cpoptions' {{{
let s:save_cpo = &cpo
set cpo&vim
" }}}
" CommandLine:
let s:V = vital#easymotion#new()
let s:cmdline = s:V.import('Over.Commandline.Base')
let s:modules = s:V.import("Over.Commandline.Modules")
let s:search = s:cmdline.make()
let s:search.highlights.prompt = 'Question'
" Add Module: {{{
call s:search.connect('Exit')
call s:search.connect('Cancel')
call s:search.connect('Redraw')
call s:search.connect('DrawCommandline')
call s:search.connect('Delete')
call s:search.connect('CursorMove')
call s:search.connect('Paste')
call s:search.connect('BufferComplete')
call s:search.connect('InsertRegister')
call s:search.connect('ExceptionExit')
call s:search.connect(s:modules.get('ExceptionMessage').make('EasyMotion: ', 'echom'))
call s:search.connect(s:modules.get('History').make('/'))
call s:search.connect(s:modules.get('NoInsert').make_special_chars())
call s:search.connect(s:modules.get('KeyMapping').make_emacs())
call s:search.connect(s:modules.get('Doautocmd').make('EMCommandLine'))
let s:module = {
\ "name" : "EasyMotion",
\}
function! s:module.on_char_pre(cmdline)
if a:cmdline.is_input("<Over>(em-scroll-f)")
call s:scroll(0)
call a:cmdline.setchar('')
elseif a:cmdline.is_input("<Over>(em-scroll-b)")
call s:scroll(1)
call a:cmdline.setchar('')
elseif a:cmdline.is_input("<Over>(em-jumpback)")
keepjumps call setpos('.', s:save_orig_pos)
let s:orig_pos = s:save_orig_pos
let s:orig_line_start = getpos('w0')
let s:orig_line_end = getpos('w$')
let s:direction = s:save_direction
call a:cmdline.setchar('')
elseif a:cmdline.is_input("<Over>(em-openallfold)")
" TODO: better solution
normal! zR
call a:cmdline.setchar('')
endif
endfunction
call s:search.connect(s:module)
"}}}
" CommandLine Keymap: {{{
" .keymapping() won't be remapped by user defined KeyMappings.
function! s:search.keymapping() "{{{
return {
\ "\<CR>" : {
\ "key" : "<Over>(exit)",
\ "noremap" : 1,
\ "lock" : 1,
\ },
\ }
endfunction "}}}
call s:search.cnoremap("\<C-l>", '<Over>(buffer-complete)')
call s:search.cnoremap("\<Tab>", '<Over>(em-scroll-f)')
call s:search.cnoremap("\<S-Tab>", '<Over>(em-scroll-b)')
call s:search.cnoremap("\<C-o>", '<Over>(em-jumpback)')
call s:search.cnoremap("\<C-z>", '<Over>(em-openallfold)')
" Fins Motion CommandLine Mapping Command: {{{
function! EasyMotion#command_line#cmap(args)
let lhs = s:as_keymapping(a:args[0])
let rhs = s:as_keymapping(a:args[1])
call s:search.cmap(lhs, rhs)
endfunction
function! EasyMotion#command_line#cnoremap(args)
let lhs = s:as_keymapping(a:args[0])
let rhs = s:as_keymapping(a:args[1])
call s:search.cnoremap(lhs, rhs)
endfunction
function! EasyMotion#command_line#cunmap(lhs)
let lhs = s:as_keymapping(a:lhs)
call s:search.cunmap(lhs)
endfunction
function! s:as_keymapping(key)
execute 'let result = "' . substitute(a:key, '\(<.\{-}>\)', '\\\1', 'g') . '"'
return result
endfunction
"}}}
"}}}
" Event: {{{
function! s:search.on_enter(cmdline) "{{{
if s:num_strokes == -1
call EasyMotion#highlight#delete_highlight()
call EasyMotion#helper#VarReset('&scrolloff', 0)
if g:EasyMotion_do_shade
call EasyMotion#highlight#add_highlight('\_.*',
\ g:EasyMotion_hl_group_shade)
endif
endif
if g:EasyMotion_cursor_highlight
call EasyMotion#highlight#add_highlight('\%#',
\ g:EasyMotion_hl_inc_cursor)
endif
endfunction "}}}
function! s:search.on_leave(cmdline) "{{{
if s:num_strokes == -1
call EasyMotion#highlight#delete_highlight(g:EasyMotion_hl_inc_search)
if g:EasyMotion_do_shade
call EasyMotion#highlight#delete_highlight(g:EasyMotion_hl_group_shade)
endif
endif
if g:EasyMotion_cursor_highlight
call EasyMotion#highlight#delete_highlight(g:EasyMotion_hl_inc_cursor)
endif
endfunction "}}}
function! s:search.on_char(cmdline) "{{{
if s:num_strokes == -1
let re = s:search.getline()
if EasyMotion#helper#should_case_sensitive(re, 1)
let case_flag = '\c'
else
let case_flag = '\C'
endif
let re .= case_flag
if g:EasyMotion_inc_highlight
call s:inc_highlight(re)
endif
if g:EasyMotion_off_screen_search
call s:off_screen_search(re)
endif
elseif s:search.line.length() >= s:num_strokes
call s:search.exit()
endif
endfunction "}}}
"}}}
" Main:
function! EasyMotion#command_line#GetInput(num_strokes, prev, direction) "{{{
let s:num_strokes = a:num_strokes
let s:prompt_base = s:getPromptMessage(a:num_strokes)
call s:search.set_prompt(s:prompt_base)
" Screen: cursor position, first and last line
let s:orig_pos = getpos('.')
let s:orig_line_start = getpos('w0')
let s:orig_line_end = getpos('w$')
let s:save_orig_pos = deepcopy(s:orig_pos)
" Direction:
let s:direction = a:direction == 1 ? 'b' : ''
let s:save_direction = deepcopy(s:direction)
let input = s:search.get()
if input == '' && ! s:search.exit_code()
return a:prev
elseif s:search.exit_code() == 1 || s:search.exit_code() == -1
call s:Cancell()
return ''
else
return input
endif
endfunction "}}}
" Helper:
function! s:Cancell() " {{{
call EasyMotion#highlight#delete_highlight()
call EasyMotion#helper#VarReset('&scrolloff')
keepjumps call setpos('.', s:save_orig_pos)
if g:EasyMotion_verbose
echo 'EasyMotion: Cancelled'
endif
return ''
endfunction " }}}
function! s:getPromptMessage(num_strokes) "{{{
if a:num_strokes == 1
let prompt = substitute(
\ substitute(g:EasyMotion_prompt,'{n}', a:num_strokes, 'g'),
\ '(s)', '', 'g')
elseif a:num_strokes == -1
let prompt = substitute(
\ substitute(g:EasyMotion_prompt, '{n}\s\{0,1}', '', 'g'),
\ '(s)', 's', 'g')
else
let prompt = substitute(
\ substitute(g:EasyMotion_prompt,'{n}', a:num_strokes, 'g'),
\ '(s)', 's', 'g')
endif
return prompt
endfunction "}}}
function! s:off_screen_search(re) "{{{
" First: search within visible screen range
call s:adjust_screen()
" Error occur when '\zs' without '!'
silent! let pos = searchpos(a:re, s:direction . 'n', s:orig_line_end[1])
if pos != [0, 0]
" Restore cursor posision
keepjumps call setpos('.', s:orig_pos)
else
" Second: if there were no much, search off screen
silent! let pos = searchpos(a:re, s:direction)
if pos != [0, 0]
" Match
keepjumps call setpos('.', pos)
" Move cursor
if s:save_direction != 'b'
normal! zzH0
else
normal! zzL0
endif
else
" No much
call s:adjust_screen()
keepjumps call setpos('.', s:orig_pos)
endif
endif
" redraw
endfunction "}}}
function! s:adjust_screen() "{{{
if s:save_direction != 'b'
" Forward
keepjumps call setpos('.', s:orig_line_start)
normal! zt
else
" Backward
keepjumps call setpos('.', s:orig_line_end)
normal! zb
endif
endfunction "}}}
function! s:scroll(direction) "{{{
" direction: 0 -> forward, 1 -> backward
exec a:direction == 0 ? "normal! \<C-f>" : "normal! \<C-b>"
let s:orig_pos = getpos('.')
let s:orig_line_start = getpos('w0')
let s:orig_line_end = getpos('w$')
let s:direction = a:direction == 0 ? '' : 'b'
endfunction "}}}
function! s:inc_highlight(re) "{{{
call EasyMotion#highlight#delete_highlight(g:EasyMotion_hl_inc_search)
if s:search.line.length() > 0
" Error occur when '\zs' without '!'
silent! call EasyMotion#highlight#add_highlight(a:re, g:EasyMotion_hl_inc_search)
endif
endfunction "}}}
" Restore 'cpoptions' {{{
let &cpo = s:save_cpo
unlet s:save_cpo
" }}}
" vim: fdm=marker:et:ts=4:sw=4:sts=4

View File

@ -0,0 +1,185 @@
"=============================================================================
" FILE: autoload/EasyMotion/helper.vim
" AUTHOR: haya14busa
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
" "Software"), to deal in the Software without restriction, including
" without limitation the rights to use, copy, modify, merge, publish,
" distribute, sublicense, and/or sell copies of the Software, and to
" permit persons to whom the Software is furnished to do so, subject to
" the following conditions:
"
" The above copyright notice and this permission notice shall be included
" in all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================
scriptencoding utf-8
" Saving 'cpoptions' {{{
let s:save_cpo = &cpo
set cpo&vim
" }}}
function! EasyMotion#helper#mode(flag) "{{{
return mode(a:flag) == "\<C-v>" ? "C-v" : mode(a:flag)
endfunction "}}}
function! EasyMotion#helper#get_char_by_coord(coord) "{{{
" @param coord: [lnum, col] or [bufnum, lnum, col, off]
if len(a:coord) == 4
let [line_num, col_num] = [a:coord[1], a:coord[2]]
else
let [line_num, col_num] = a:coord
endif
let target_col_regexp = '\%' . (col_num) . 'c.'
return matchstr(getline(line_num), target_col_regexp)
endfunction "}}}
function! EasyMotion#helper#is_greater_coords(coords1, coords2) "{{{
" [line_num, col_num] < [line_num, col_num]
"
" coords1 < coords2 : return 1
" coords1 > coords2 : return -1
" coords1 == coords2 : return 0
if a:coords1 == a:coords2 | return 0 | endif
if a:coords1[0] < a:coords2[0]
return 1
elseif a:coords1[0] > a:coords2[0]
return -1
endif
" Same line
if a:coords1[1] < a:coords2[1]
return 1
elseif a:coords1[1] > a:coords2[1]
return -1
endif
endfunction "}}}
function! EasyMotion#helper#is_folded(line) "{{{
" Return false if g:EasyMotion_skipfoldedline == 1
" and line is start of folded lines
let _foldclosed = foldclosed(a:line)
return _foldclosed != -1 &&
\ (g:EasyMotion_skipfoldedline == 1 || a:line != _foldclosed)
endfunction "}}}
function! EasyMotion#helper#should_case_sensitive(input, is_search) "{{{
if !a:is_search
if g:EasyMotion_smartcase == 0
return 0
else
" return 1 if input didn't match uppercase letter
return match(a:input, '\u') == -1
endif
endif
if (g:EasyMotion_smartcase == 1 && match(a:input, '\u') == -1) ||
\ (&ignorecase && &smartcase && match(a:input, '\u') == -1) ||
\ (&ignorecase && !&smartcase)
return 1
endif
return 0
endfunction "}}}
function! EasyMotion#helper#silent_feedkeys(expr, name, ...) "{{{
" Ref:
" https://github.com/osyo-manga/vim-over/blob/d51b028c29661d4a5f5b79438ad6d69266753711/autoload/over.vim#L6
let mode = get(a:, 1, "m")
let name = "easymotion-" . a:name
let map = printf("<Plug>(%s)", name)
if mode == "n"
let command = "nnoremap"
else
let command = "nmap"
endif
execute command "<silent>" map printf("%s:nunmap %s<CR>", a:expr, map)
if mode(1) !=# 'ce'
" FIXME: mode(1) !=# 'ce' exists only for the test
" :h feedkeys() doesn't work while runnning a test script
" https://github.com/kana/vim-vspec/issues/27
call feedkeys(printf("\<Plug>(%s)", name))
endif
endfunction "}}}
function! EasyMotion#helper#VarReset(var, ...) "{{{
if ! exists('s:var_reset')
let s:var_reset = {}
endif
if a:0 == 0 && has_key(s:var_reset, a:var)
" Reset var to original value
" setbufvar( or bufname): '' or '%' can be used for the current buffer
call setbufvar('%', a:var, s:var_reset[a:var])
elseif a:0 == 1
" Save original value and set new var value
let new_value = a:0 == 1 ? a:1 : ''
" Store original value
let s:var_reset[a:var] = getbufvar("", a:var)
" Set new var value
call setbufvar('%', a:var, new_value)
endif
endfunction "}}}
" Migemo {{{
function! EasyMotion#helper#load_migemo_dict() "{{{
let enc = &l:encoding
if enc ==# 'utf-8'
return EasyMotion#migemo#utf8#load_dict()
elseif enc ==# 'cp932'
return EasyMotion#migemo#cp932#load_dict()
elseif enc ==# 'euc-jp'
return EasyMotion#migemo#eucjp#load_dict()
else
let g:EasyMotion_use_migemo = 0
throw "Error: ".enc." is not supported. Migemo is made disabled."
endif
endfunction "}}}
" EasyMotion#helper#strchars() {{{
if exists('*strchars')
function! EasyMotion#helper#strchars(str)
return strchars(a:str)
endfunction
else
function! EasyMotion#helper#strchars(str)
return strlen(substitute(a:str, ".", "x", "g"))
endfunction
endif "}}}
function! EasyMotion#helper#include_multibyte_char(str) "{{{
return strlen(a:str) != EasyMotion#helper#strchars(a:str)
endfunction "}}}
function! EasyMotion#helper#vcol(expr) abort
let col_num = col(a:expr)
let line = getline(a:expr)
let before_line = col_num > 2 ? line[: col_num - 2]
\ : col_num is# 2 ? line[0]
\ : ''
let vcol_num = 1
for c in split(before_line, '\zs')
let vcol_num += c is# "\t" ? s:_virtual_tab2spacelen(vcol_num) : len(c)
endfor
return vcol_num
endfunction
function! s:_virtual_tab2spacelen(col_num) abort
return &tabstop - ((a:col_num - 1) % &tabstop)
endfunction
"}}}
" Restore 'cpoptions' {{{
let &cpo = s:save_cpo
unlet s:save_cpo
" }}}
" vim: fdm=marker:et:ts=4:sw=4:sts=4

View File

@ -0,0 +1,251 @@
"=============================================================================
" FILE: highlight.vim
" AUTHOR: haya14busa
" Reference: https://github.com/t9md/vim-smalls
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
" "Software"), to deal in the Software without restriction, including
" without limitation the rights to use, copy, modify, merge, publish,
" distribute, sublicense, and/or sell copies of the Software, and to
" permit persons to whom the Software is furnished to do so, subject to
" the following conditions:
"
" The above copyright notice and this permission notice shall be included
" in all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
"=============================================================================
scriptencoding utf-8
" Saving 'cpoptions' {{{
let s:save_cpo = &cpo
set cpo&vim
" }}}
function! EasyMotion#highlight#load()
"load
endfunction
" -- Default highlighting ---------------- {{{
let g:EasyMotion_hl_group_target = get(g:,
\ 'EasyMotion_hl_group_target', 'EasyMotionTarget')
let g:EasyMotion_hl2_first_group_target = get(g:,
\ 'EasyMotion_hl2_first_group_target', 'EasyMotionTarget2First')
let g:EasyMotion_hl2_second_group_target = get(g:,
\ 'EasyMotion_hl2_second_group_target', 'EasyMotionTarget2Second')
let g:EasyMotion_hl_group_shade = get(g:,
\ 'EasyMotion_hl_group_shade', 'EasyMotionShade')
let g:EasyMotion_hl_inc_search = get(g:,
\ 'EasyMotion_hl_inc_search', 'EasyMotionIncSearch')
let g:EasyMotion_hl_inc_cursor = get(g:,
\ 'EasyMotion_hl_inc_cursor', 'EasyMotionIncCursor')
let g:EasyMotion_hl_move = get(g:,
\ 'EasyMotion_hl_move', 'EasyMotionMoveHL')
let s:target_hl_defaults = {
\ 'gui' : ['NONE', '#ff0000' , 'bold']
\ , 'cterm256': ['NONE', '196' , 'bold']
\ , 'cterm' : ['NONE', 'red' , 'bold']
\ }
let s:target_hl2_first_defaults = {
\ 'gui' : ['NONE', '#ffb400' , 'bold']
\ , 'cterm256': ['NONE', '11' , 'bold']
\ , 'cterm' : ['NONE', 'yellow' , 'bold']
\ }
let s:target_hl2_second_defaults = {
\ 'gui' : ['NONE', '#b98300' , 'bold']
\ , 'cterm256': ['NONE', '3' , 'bold']
\ , 'cterm' : ['NONE', 'yellow' , 'bold']
\ }
let s:shade_hl_defaults = {
\ 'gui' : ['NONE', '#777777' , 'NONE']
\ , 'cterm256': ['NONE', '242' , 'NONE']
\ , 'cterm' : ['NONE', 'grey' , 'NONE']
\ }
let s:shade_hl_line_defaults = {
\ 'gui' : ['red' , '#FFFFFF' , 'NONE']
\ , 'cterm256': ['red' , '242' , 'NONE']
\ , 'cterm' : ['red' , 'grey' , 'NONE']
\ }
let s:target_hl_inc = {
\ 'gui' : ['NONE', '#7fbf00' , 'bold']
\ , 'cterm256': ['NONE', '40' , 'bold']
\ , 'cterm' : ['NONE', 'green' , 'bold']
\ }
let s:target_hl_inc_cursor = {
\ 'gui' : ['#ACDBDA', '#121813' , 'bold']
\ , 'cterm256': ['cyan' , '232' , 'bold']
\ , 'cterm' : ['cyan' , 'black' , 'bold']
\ }
let s:target_hl_move = {
\ 'gui' : ['#7fbf00', '#121813' , 'bold']
\ , 'cterm256': ['green' , '15' , 'bold']
\ , 'cterm' : ['green' , 'white' , 'bold']
\ }
" }}}
function! EasyMotion#highlight#InitHL(group, colors) " {{{
let group_default = a:group . 'Default'
" Prepare highlighting variables
let guihl = printf('guibg=%s guifg=%s gui=%s', a:colors.gui[0], a:colors.gui[1], a:colors.gui[2])
let ctermhl = &t_Co == 256
\ ? printf('ctermbg=%s ctermfg=%s cterm=%s', a:colors.cterm256[0], a:colors.cterm256[1], a:colors.cterm256[2])
\ : printf('ctermbg=%s ctermfg=%s cterm=%s', a:colors.cterm[0], a:colors.cterm[1], a:colors.cterm[2])
" Create default highlighting group
execute printf('hi default %s %s %s', group_default, guihl, ctermhl)
" Check if the hl group exists
if hlexists(a:group)
redir => hlstatus | exec 'silent hi ' . a:group | redir END
" Return if the group isn't cleared
if hlstatus !~ 'cleared'
return
endif
endif
" No colors are defined for this group, link to defaults
execute printf('hi default link %s %s', a:group, group_default)
endfunction " }}}
function! EasyMotion#highlight#init() "{{{
call EasyMotion#highlight#InitHL(g:EasyMotion_hl_group_target, s:target_hl_defaults)
call EasyMotion#highlight#InitHL(g:EasyMotion_hl2_first_group_target, s:target_hl2_first_defaults)
call EasyMotion#highlight#InitHL(g:EasyMotion_hl2_second_group_target, s:target_hl2_second_defaults)
call EasyMotion#highlight#InitHL(g:EasyMotion_hl_group_shade, s:shade_hl_defaults)
call EasyMotion#highlight#InitHL(g:EasyMotion_hl_inc_search, s:target_hl_inc)
call EasyMotion#highlight#InitHL(g:EasyMotion_hl_inc_cursor, s:target_hl_inc_cursor)
call EasyMotion#highlight#InitHL(g:EasyMotion_hl_move, s:target_hl_move)
if exists(':CSApprox') == 2 && g:EasyMotion_force_csapprox
"TODO: better solution or remove completly
CSApprox!
endif
endfunction "}}}
" Reset highlighting after loading a new color scheme {{{
augroup EasyMotionInitHL
autocmd!
autocmd ColorScheme * call EasyMotion#highlight#init()
augroup end
" }}}
call EasyMotion#highlight#init()
" Init: {{{
let s:h = {}
let s:h.ids = {}
let s:priorities = {
\ g:EasyMotion_hl_group_target : 100,
\ g:EasyMotion_hl2_first_group_target : 100,
\ g:EasyMotion_hl2_second_group_target : 100,
\ g:EasyMotion_hl_group_shade : 0,
\ g:EasyMotion_hl_inc_search : 1,
\ g:EasyMotion_hl_inc_cursor : 2,
\ g:EasyMotion_hl_move : 0,
\ }
for s:group in keys(s:priorities)
let s:h.ids[s:group] = []
endfor
unlet s:group
"}}}
function! EasyMotion#highlight#delete_highlight(...) "{{{
let groups = !empty(a:000) ? a:000 : keys(s:priorities)
for group in groups
for id in s:h.ids[group]
silent! call matchdelete(id)
endfor
let s:h.ids[group] = []
endfor
endfunction "}}}
function! EasyMotion#highlight#add_highlight(re, group) "{{{
call add(s:h.ids[a:group], matchadd(a:group, a:re, s:priorities[a:group]))
endfunction "}}}
function! EasyMotion#highlight#add_pos_highlight(line_num, col_num, group) "{{{
call add(s:h.ids[a:group], matchaddpos(a:group, [[a:line_num, a:col_num]], s:priorities[a:group]))
endfunction "}}}
function! EasyMotion#highlight#attach_autocmd() "{{{
" Reference: https://github.com/justinmk/vim-sneak
augroup plugin-easymotion
autocmd!
autocmd InsertEnter,WinLeave,BufLeave <buffer>
\ silent! call EasyMotion#highlight#delete_highlight()
\ | autocmd! plugin-easymotion * <buffer>
autocmd CursorMoved <buffer>
\ autocmd plugin-easymotion CursorMoved <buffer>
\ silent! call EasyMotion#highlight#delete_highlight()
\ | autocmd! plugin-easymotion * <buffer>
augroup END
endfunction "}}}
function! EasyMotion#highlight#add_color_group(new_groups) "{{{
let s:priorities = extend(deepcopy(s:priorities), a:new_groups)
for group in keys(a:new_groups)
let s:h.ids[group] = []
endfor
endfunction "}}}
function! EasyMotion#highlight#capture(hlname) "{{{
" Based On: https://github.com/t9md/vim-ezbar
" https://github.com/osyo-manga/vital-over
let hlname = a:hlname
if !hlexists(hlname)
return
endif
while 1
let save_verbose = &verbose
let &verbose = 0
try
redir => HL_SAVE
execute 'silent! highlight ' . hlname
redir END
finally
let &verbose = save_verbose
endtry
if !empty(matchstr(HL_SAVE, 'xxx cleared$'))
return ''
endif
" follow highlight link
let ml = matchlist(HL_SAVE, 'links to \zs.*')
if !empty(ml)
let hlname = ml[0]
continue
endif
break
endwhile
let HL_SAVE = substitute(matchstr(HL_SAVE, 'xxx \zs.*'),
\ '[ \t\n]\+', ' ', 'g')
return [hlname, HL_SAVE]
endfunction "}}}
function! EasyMotion#highlight#turn_off(hl) "{{{
if type(a:hl) != type([])
return
endif
execute 'highlight ' . a:hl[0] . ' NONE'
endfunction "}}}
function! EasyMotion#highlight#turn_on(hl) "{{{
if type(a:hl) != type([])
return
endif
execute 'highlight ' . a:hl[0] . ' ' . a:hl[1]
endfunction "}}}
" Restore 'cpoptions' {{{
let &cpo = s:save_cpo
unlet s:save_cpo
" }}}
" __END__ {{{
" vim: expandtab softtabstop=4 shiftwidth=4
" vim: foldmethod=marker
" }}}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,27 @@
let s:V = vital#easymotion#new()
let s:HitAHintMotion = s:V.import('HitAHint.Motion')
call EasyMotion#init()
function! EasyMotion#overwin#move(pattern) abort
return s:HitAHintMotion.move(a:pattern, {
\ 'keys': g:EasyMotion_keys,
\ 'use_upper': g:EasyMotion_use_upper,
\ 'highlight': {
\ 'shade': g:EasyMotion_hl_group_shade,
\ 'target': g:EasyMotion_hl_group_target,
\ },
\ 'jump_first_target_keys':
\ (g:EasyMotion_enter_jump_first ? ["\<CR>"] : []) +
\ (g:EasyMotion_space_jump_first ? ["\<Space>"] : []),
\ 'do_shade': g:EasyMotion_do_shade,
\ })
endfunction
function! EasyMotion#overwin#line() abort
return EasyMotion#overwin#move('^')
endfunction
function! EasyMotion#overwin#w() abort
return EasyMotion#overwin#move('\(\<.\|^$\)')
endfunction

View File

@ -0,0 +1,24 @@
" Saving 'cpoptions' {{{
let s:save_cpo = &cpo
set cpo&vim
" }}}
"
let EasyMotion#sticky_table#us = {
\',' : '<', '.' : '>', '/' : '?',
\'1' : '!', '2' : '@', '3' : '#', '4' : '$', '5' : '%',
\'6' : '^', '7' : '&', '8' : '*', '9' : '(', '0' : ')', '-' : '_', '=' : '+',
\';' : ':', '[' : '{', ']' : '}', '`' : '~', "'" : "\"", '\' : '|',
\}
let EasyMotion#sticky_table#jp = {
\',' : '<', '.' : '>', '/' : '?',
\'1' : '!', '2' : '"', '3' : '#', '4' : '$', '5' : '%',
\'6' : '&', '7' : "'", '8' : '(', '9' : ')', '0' : '_', '-' : '=', '^' : '~',
\';' : '+', ':' : '*', '[' : '{', ']' : '}', '@' : '`', '\' : '|',
\}
" Restore 'cpoptions' {{{
let &cpo = s:save_cpo
unlet s:save_cpo
" }}}
" vim: fdm=marker:et:ts=4:sw=4:sts=4