Cosmetic: retab to expandtab all and add modeline

This commit is contained in:
haya14busa 2014-01-17 17:39:26 +09:00
parent c4e1a44787
commit 5bed6b3f9e
8 changed files with 1250 additions and 1244 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
"=============================================================================
" FILE: autoload/EasyMotion/cmigemo.vim
" AUTHOR: haya14busa
" Last Change: 14 Jan 2014.
" Last Change: 17 Jan 2014.
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
@ -107,4 +107,4 @@ endfunction "}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" }}}
" vim: fdm=marker:et:ts=4:sw=4:sts=4

View File

@ -30,13 +30,13 @@ set cpo&vim
" }}}
function! s:InputPrompt(message, input) "{{{
redraw
echohl Question | echon a:message | echohl None
echon a:input
redraw
echohl Question | echon a:message | echohl None
echon a:input
endfunction "}}}
function! s:Cancell() " {{{
redraw
echo 'EasyMotion: Cancelled'
echo 'EasyMotion: Cancelled'
return ''
endfunction " }}}
@ -58,80 +58,80 @@ function! s:getPromptMessage(num_strokes)
endfunction
function! EasyMotion#command_line#GetInput(num_strokes, ...) "{{{
let previous_input = a:0 == 1 ? a:1 : ''
let input = ''
let prompt = s:getPromptMessage(a:num_strokes)
let previous_input = a:0 == 1 ? a:1 : ''
let input = ''
let prompt = s:getPromptMessage(a:num_strokes)
while EasyMotion#helper#strchars(input) < a:num_strokes ||
\ a:num_strokes == -1
if g:EasyMotion_show_prompt
call s:InputPrompt(prompt, input)
endif
let c = getchar()
let s:char = type(c) == type(0) ? nr2char(c) : c
if EasyMotion#command_line#is_input("\<Esc>")
" Cancel if Escape key pressed
while EasyMotion#helper#strchars(input) < a:num_strokes ||
\ a:num_strokes == -1
if g:EasyMotion_show_prompt
call s:InputPrompt(prompt, input)
endif
let c = getchar()
let s:char = type(c) == type(0) ? nr2char(c) : c
if EasyMotion#command_line#is_input("\<Esc>")
" Cancel if Escape key pressed
call s:Cancell() | return ''
elseif EasyMotion#command_line#is_input("\<C-c>")
elseif EasyMotion#command_line#is_input("\<C-c>")
" Cancel
call s:Cancell() | return ''
elseif EasyMotion#command_line#is_input("\<C-h>")
elseif EasyMotion#command_line#is_input("\<C-h>")
" Delete one character
if len(input) == 0 | call s:Cancell() | return '' | endif
let input = substitute(input, '.$', '', '')
elseif EasyMotion#command_line#is_input("\<C-d>")
if len(input) == 0 | call s:Cancell() | return '' | endif
let input = substitute(input, '.$', '', '')
elseif EasyMotion#command_line#is_input("\<C-d>")
" Delete one character
if len(input) == 0 | call s:Cancell() | return '' | endif
let input = substitute(input, '.$', '', '')
elseif EasyMotion#command_line#is_input("\<C-u>")
if len(input) == 0 | call s:Cancell() | return '' | endif
let input = substitute(input, '.$', '', '')
elseif EasyMotion#command_line#is_input("\<C-u>")
" Delete all
if len(input) == 0 | call s:Cancell() | return '' | endif
let input = ''
elseif EasyMotion#command_line#is_input("\<C-w>")
if len(input) == 0 | call s:Cancell() | return '' | endif
let input = ''
elseif EasyMotion#command_line#is_input("\<C-w>")
" Delete word
let input = matchstr(input, '^\zs.\{-}\ze\(\(\w*\)\|\(.\)\)$')
elseif EasyMotion#command_line#is_input("\<C-p>")
let input = previous_input
elseif EasyMotion#command_line#is_input("\<C-n>")
let input = ''
elseif EasyMotion#command_line#is_input("\<CR>")
if len(input) == 0
return previous_input
endif
" Return input charcters
return input
elseif EasyMotion#command_line#is_input("\<C-j>")
" Return input charcters
let input = matchstr(input, '^\zs.\{-}\ze\(\(\w*\)\|\(.\)\)$')
elseif EasyMotion#command_line#is_input("\<C-p>")
let input = previous_input
elseif EasyMotion#command_line#is_input("\<C-n>")
let input = ''
elseif EasyMotion#command_line#is_input("\<CR>")
if len(input) == 0
return previous_input
endif
" Return input charcters
return input
elseif char2nr(s:char) == 128 || char2nr(s:char) < 27
elseif EasyMotion#command_line#is_input("\<C-j>")
" Return input charcters
return input
elseif char2nr(s:char) == 128 || char2nr(s:char) < 27
" Do nothing for special key
continue
else
let input .= s:char
endif
endwhile
return input
continue
else
let input .= s:char
endif
endwhile
return input
endfunction "}}}
function! EasyMotion#command_line#char() "{{{
return s:char
return s:char
endfunction "}}}
function! EasyMotion#command_line#is_input(key) "{{{
return EasyMotion#command_line#keymap(EasyMotion#command_line#char()) == a:key
return EasyMotion#command_line#keymap(EasyMotion#command_line#char()) == a:key
endfunction "}}}
function! EasyMotion#command_line#keymap(key) "{{{
return get(extend(deepcopy(s:default_key_mapping), g:EasyMotion_command_line_key_mappings), a:key, a:key)
return get(extend(deepcopy(s:default_key_mapping), g:EasyMotion_command_line_key_mappings), a:key, a:key)
endfunction "}}}
" Default_key_mapping: {{{
let s:default_key_mapping = {
\ "\<Right>" : "\<C-f>",
\ "\<Left>" : "\<C-b>",
\ "\<Up>" : "\<C-p>",
\ "\<Down>" : "\<C-n>",
\ "\<BS>" : "\<C-h>",
\ "\<Del>" : "\<C-d>",
\ "\<Home>" : "\<C-a>",
\ "\<End>" : "\<C-e>",
\ "\<Right>" : "\<C-f>",
\ "\<Left>" : "\<C-b>",
\ "\<Up>" : "\<C-p>",
\ "\<Down>" : "\<C-n>",
\ "\<BS>" : "\<C-h>",
\ "\<Del>" : "\<C-d>",
\ "\<Home>" : "\<C-a>",
\ "\<End>" : "\<C-e>",
\}
"}}}
"
@ -139,3 +139,4 @@ let s:default_key_mapping = {
let &cpo = s:save_cpo
unlet s:save_cpo
" }}}
" vim: fdm=marker:et:ts=4:sw=4:sts=4

View File

@ -1,7 +1,7 @@
"=============================================================================
" FILE: autoload/EasyMotion/helper.vim
" AUTHOR: haya14busa
" Last Change: 14 Jan 2014.
" Last Change: 17 Jan 2014.
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
@ -30,55 +30,55 @@ set cpo&vim
" }}}
function! EasyMotion#helper#mode(flag) "{{{
return mode(a:flag) == "\<C-v>" ? "C-v" : mode(a:flag)
return mode(a:flag) == "\<C-v>" ? "C-v" : mode(a:flag)
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
" [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
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
" Same line
if a:coords1[1] < a:coords2[1]
return 1
elseif a:coords1[1] > a:coords2[1]
return -1
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
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
function! EasyMotion#helper#strchars(str)
return strchars(a:str)
endfunction
else
function! EasyMotion#helper#strchars(str)
return strlen(substitute(str, ".", "x", "g"))
endfunction
function! EasyMotion#helper#strchars(str)
return strlen(substitute(str, ".", "x", "g"))
endfunction
endif "}}}
function! EasyMotion#helper#include_multibyte_char(str) "{{{
return strlen(a:str) != EasyMotion#helper#strchars(a:str)
@ -89,3 +89,4 @@ endfunction "}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" }}}
" vim: fdm=marker:et:ts=4:sw=4:sts=4

View File

@ -4,76 +4,76 @@ set cpo&vim
" }}}
function! EasyMotion#init#InitHL(group, colors) " {{{
let group_default = a:group . 'Default'
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])
if !exists('g:CSApprox_loaded')
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])
else
let ctermhl = ''
endif
" Prepare highlighting variables
let guihl = printf('guibg=%s guifg=%s gui=%s', a:colors.gui[0], a:colors.gui[1], a:colors.gui[2])
if !exists('g:CSApprox_loaded')
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])
else
let ctermhl = ''
endif
" Create default highlighting group
execute printf('hi default %s %s %s', group_default, guihl, ctermhl)
" 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
" 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
" 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)
" No colors are defined for this group, link to defaults
execute printf('hi default link %s %s', a:group, group_default)
endfunction " }}}
function! EasyMotion#init#InitMappings(motions, do_mapping) "{{{
for [motion, fn] in items(a:motions)
" Mapping {{{
if exists('g:EasyMotion_mapping_' . motion)
" Backward compatible mapping [deprecated]
silent exec 'map <silent> ' .
\ eval('g:EasyMotion_mapping_' . motion) . ' <Plug>(easymotion-' . motion . ')'
elseif a:do_mapping
\ && !hasmapto('<Plug>(easymotion-' . motion . ')')
\ && empty(maparg('<Plug>(easymotion-prefix)' . motion, 'nov'))
for [motion, fn] in items(a:motions)
" Mapping {{{
if exists('g:EasyMotion_mapping_' . motion)
" Backward compatible mapping [deprecated]
silent exec 'map <silent> ' .
\ eval('g:EasyMotion_mapping_' . motion) . ' <Plug>(easymotion-' . motion . ')'
elseif a:do_mapping
\ && !hasmapto('<Plug>(easymotion-' . motion . ')')
\ && empty(maparg('<Plug>(easymotion-prefix)' . motion, 'nov'))
" Do mapping
silent exec 'map <silent> ' .
\'<Plug>(easymotion-prefix)' . motion . ' <Plug>(easymotion-' . motion . ')'
endif "}}}
" Do mapping
silent exec 'map <silent> ' .
\'<Plug>(easymotion-prefix)' . motion . ' <Plug>(easymotion-' . motion . ')'
endif "}}}
endfor
endfor
endfunction "}}}
function! EasyMotion#init#InitSpecialMappings(motions, do_mapping) "{{{
for [motion, fn] in items(a:motions)
" Do mapping {{{
if a:do_mapping
\ && !hasmapto('<Plug>(easymotion-special-' . motion . ')')
\ && empty(maparg('<Plug>(easymotion-prefix)' . motion, 'ov'))
\ && empty(maparg('d<Plug>(easymotion-prefix)'. motion, 'n'))
\ && empty(maparg('y<Plug>(easymotion-prefix)'. motion, 'n'))
silent exec 'omap <silent> ' .
\ '<Plug>(easymotion-prefix)' . motion . ' <Plug>(easymotion-special-' . motion . ')'
silent exec 'xmap <silent> ' .
\ '<Plug>(easymotion-prefix)' . motion . ' <Plug>(easymotion-special-' . motion . ')'
silent exec 'nmap <silent> ' .
\ 'd<Plug>(easymotion-prefix)' . motion . ' <Plug>(easymotion-special-' . motion . 'd)'
silent exec 'nmap <silent> ' .
\ 'y<Plug>(easymotion-prefix)' . motion . ' <Plug>(easymotion-special-' . motion . 'y)'
endif "}}}
endfor
for [motion, fn] in items(a:motions)
" Do mapping {{{
if a:do_mapping
\ && !hasmapto('<Plug>(easymotion-special-' . motion . ')')
\ && empty(maparg('<Plug>(easymotion-prefix)' . motion, 'ov'))
\ && empty(maparg('d<Plug>(easymotion-prefix)'. motion, 'n'))
\ && empty(maparg('y<Plug>(easymotion-prefix)'. motion, 'n'))
silent exec 'omap <silent> ' .
\ '<Plug>(easymotion-prefix)' . motion . ' <Plug>(easymotion-special-' . motion . ')'
silent exec 'xmap <silent> ' .
\ '<Plug>(easymotion-prefix)' . motion . ' <Plug>(easymotion-special-' . motion . ')'
silent exec 'nmap <silent> ' .
\ 'd<Plug>(easymotion-prefix)' . motion . ' <Plug>(easymotion-special-' . motion . 'd)'
silent exec 'nmap <silent> ' .
\ 'y<Plug>(easymotion-prefix)' . motion . ' <Plug>(easymotion-special-' . motion . 'y)'
endif "}}}
endfor
endfunction "}}}
" Restore 'cpoptions' {{{
let &cpo = s:save_cpo
unlet s:save_cpo
" }}}
" vim: fdm=marker:noet:ts=4:sw=4:sts=4
" vim: fdm=marker:et:ts=4:sw=4:sts=4

View File

@ -21,3 +21,4 @@ let EasyMotion#sticky_table#jp = {
let &cpo = s:save_cpo
unlet s:save_cpo
" }}}
" vim: fdm=marker:et:ts=4:sw=4:sts=4

View File

@ -12,6 +12,7 @@ endif
let g:EasyMotion_loaded = 1
" }}}
" == Saving 'cpoptions' {{{
let s:save_cpo = &cpo
set cpo&vim

View File

@ -1087,3 +1087,6 @@ describe 'EasyMotion is jump motion'
"}}}
end
"}}}
" vim: fdm=marker:et:ts=4:sw=4:sts=4