├── .gitignore ├── README.md ├── autoload ├── over.vim ├── over │ ├── command_line.vim │ └── command_line │ │ ├── command_history.vim │ │ ├── complete.vim │ │ ├── global.vim │ │ ├── insert_register.vim │ │ ├── search.vim │ │ └── substitute.vim └── vital │ ├── _over.vim │ ├── _over │ ├── Coaster │ │ ├── Buffer.vim │ │ ├── Buffer │ │ │ └── Object.vim │ │ ├── Highlight.vim │ │ ├── Search.vim │ │ └── Window.vim │ ├── Data │ │ ├── Dict.vim │ │ └── List.vim │ ├── Gift.vim │ ├── Gift │ │ ├── Tabpage.vim │ │ └── Window.vim │ ├── Over.vim │ ├── Over │ │ ├── Commandline.vim │ │ ├── Commandline │ │ │ ├── Base.vim │ │ │ ├── Maker.vim │ │ │ ├── Modules.vim │ │ │ └── Modules │ │ │ │ ├── All.vim │ │ │ │ ├── AsyncUpdate.vim │ │ │ │ ├── BufferComplete.vim │ │ │ │ ├── Cancel.vim │ │ │ │ ├── CursorMove.vim │ │ │ │ ├── Delete.vim │ │ │ │ ├── Digraphs.vim │ │ │ │ ├── Doautocmd.vim │ │ │ │ ├── DrawCommandline.vim │ │ │ │ ├── ExceptionExit.vim │ │ │ │ ├── ExceptionMessage.vim │ │ │ │ ├── Execute.vim │ │ │ │ ├── ExecuteFailedMessage.vim │ │ │ │ ├── Exit.vim │ │ │ │ ├── HighlightBufferCursor.vim │ │ │ │ ├── HistAdd.vim │ │ │ │ ├── History.vim │ │ │ │ ├── IgnoreRegexpBackwardWord.vim │ │ │ │ ├── Incsearch.vim │ │ │ │ ├── InsertRegister.vim │ │ │ │ ├── KeyMapping.vim │ │ │ │ ├── LiteralInsert.vim │ │ │ │ ├── NoInsert.vim │ │ │ │ ├── Paste.vim │ │ │ │ ├── Redraw.vim │ │ │ │ └── Scroll.vim │ │ ├── Exception.vim │ │ ├── Input.vim │ │ ├── Keymapping.vim │ │ ├── Signals.vim │ │ └── String.vim │ ├── Palette │ │ ├── Capture.vim │ │ ├── Highlight.vim │ │ └── Keymapping.vim │ ├── Prelude.vim │ ├── Unlocker │ │ ├── Holder.vim │ │ ├── Holder │ │ │ ├── Any.vim │ │ │ ├── Buffer │ │ │ │ ├── Text.vim │ │ │ │ └── Undofile.vim │ │ │ ├── File.vim │ │ │ ├── Multi.vim │ │ │ ├── Option.vim │ │ │ ├── Position.vim │ │ │ ├── Register.vim │ │ │ ├── Value.vim │ │ │ ├── Variable.vim │ │ │ └── Winview.vim │ │ ├── Rocker.vim │ │ └── Rocker │ │ │ ├── HolderBase.vim │ │ │ ├── Multi.vim │ │ │ └── Undotree.vim │ └── Vim │ │ ├── Buffer.vim │ │ ├── Guard.vim │ │ ├── Message.vim │ │ └── Type.vim │ ├── over.vim │ └── over.vital ├── doc ├── over.jax └── over.txt ├── plugin └── over.vim └── test └── autoload ├── over.vim └── over └── command_line ├── complete.vim └── substitute.vim /.gitignore: -------------------------------------------------------------------------------- 1 | doc/tags* 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # over.vim 3.0 2 | 3 | ## Screencapture 4 | ### Preview in the command line window 5 | 6 | ![test](https://f.cloud.github.com/assets/214488/1461854/922bd38c-44d1-11e3-9ca4-eb3902be19f7.gif) 7 | 8 | 9 | ### Preview in the over command line 10 | 11 | ![test](https://f.cloud.github.com/assets/214488/1490845/da05d670-479d-11e3-93d6-e8b9214df405.gif) 12 | 13 | 14 | ### Buffer word complete in the over command line 15 | 16 | ![test](https://f.cloud.github.com/assets/214488/1584401/89e13068-520b-11e3-8acb-de8a58538dbb.gif) 17 | 18 | 19 | ## License 20 | 21 | [NYSL](http://www.kmonos.net/nysl/) 22 | 23 | [NYSL English](http://www.kmonos.net/nysl/index.en.html) 24 | 25 | ## Change log 26 | 27 | * 3.0 (2015/04/01) 28 | * Add digraph 29 | * Add `` 30 | * Import cmap/cnoremap setting 31 | * `` by regexp 32 | * Multi lhs by keymapping 33 | * Support `` keymapping 34 | * Refactoring 35 | 36 | * 2.0 37 | * Refactoring 38 | * Change cursor highlight 39 | * Add highlighting `:/` and `:%g/` 40 | * No input specital keys(e.g. ``, ``) 41 | 42 | ## Special Thanks 43 | 44 | * [@haya14busa](https://github.com/haya14busa) 45 | 46 | 47 | -------------------------------------------------------------------------------- /autoload/over.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | let g:over#debug_vital_over = get(g:, "over#debug_vital_over", 0) 7 | 8 | 9 | function! over#load() 10 | call over#command_line#load() 11 | endfunction 12 | 13 | 14 | function! over#vital() 15 | if exists("s:V") 16 | return s:V 17 | endif 18 | if g:over#debug_vital_over 19 | let s:V = vital#of("vital") 20 | else 21 | let s:V = vital#over#new() 22 | endif 23 | return s:V 24 | endfunction 25 | 26 | function! over#revital() 27 | call s:V.unload() 28 | unlet! s:V 29 | call over#vital() 30 | endfunction 31 | 32 | 33 | function! s:silent_feedkeys(expr, name, ...) 34 | let mode = get(a:, 1, "m") 35 | let name = "over-" . a:name 36 | let map = printf("(%s)", name) 37 | if mode == "n" 38 | let command = "nnoremap" 39 | else 40 | let command = "nmap" 41 | endif 42 | execute command "" map printf("%s:nunmap %s", a:expr, map) 43 | call feedkeys(printf("\(%s)", name)) 44 | endfunction 45 | 46 | 47 | " http://d.hatena.ne.jp/thinca/20131104/1383498883 48 | " {range}s/{pattern}/{string}/{flags} 49 | function! s:parse_substitute(word) 50 | let very_magic = '\v' 51 | let range = '(.{-})' 52 | let command = 's%[ubstitute]' 53 | let first_slash = '([\x00-\xff]&[^\\"|[:alnum:][:blank:]])' 54 | let pattern = '(%(\\.|.){-})' 55 | let second_slash = '\2' 56 | let string = '(%(\\.|.){-})' 57 | let flags = '%(\2([&cegiInp#lr]*))?' 58 | let parse_pattern 59 | \ = very_magic 60 | \ . '^:*' 61 | \ . range 62 | \ . command 63 | \ . first_slash 64 | \ . pattern 65 | \ . '%(' 66 | \ . second_slash 67 | \ . string 68 | \ . flags 69 | \ . ')?$' 70 | let result = matchlist(a:word, parse_pattern)[1:5] 71 | if type(result) == type(0) || empty(result) 72 | return [] 73 | endif 74 | unlet result[1] 75 | return result 76 | endfunction 77 | 78 | 79 | 80 | 81 | " base code 82 | " https://github.com/thinca/vim-ambicmd/blob/78fa88c5647071e73a3d21e5f575ed408f68aaaf/autoload/ambicmd.vim#L26 83 | function! over#parse_range(string) 84 | let search_pattern = '\v/[^/]*\\@:set hlsearch | set incsearch\", 'n') 101 | endif 102 | let @/ = text 103 | endfunction 104 | 105 | 106 | function! s:set_options() 107 | if s:search_highlighted 108 | let s:search_highlighted = 0 109 | return 110 | endif 111 | 112 | let s:old_incsearch = &incsearch 113 | let s:old_hlsearch = &hlsearch 114 | let s:old_search_pattern = @/ 115 | endfunction 116 | 117 | 118 | 119 | nnoremap (over-restore-search-pattern) 120 | \ (mode() =~ '[iR]' ? "\" : "") . ":let @/ = " . string(s:old_search_pattern) . "\" 121 | 122 | nnoremap (over-restore-nohlsearch) 123 | \ (mode() =~ '[iR]' ? "\" : "") . ":nohlsearch\" 124 | 125 | function! s:restore_options() 126 | if s:search_highlighted || s:set_flag == 0 127 | return 128 | endif 129 | 130 | let s:set_flag = 0 131 | let &incsearch = s:old_incsearch 132 | let &hlsearch = s:old_hlsearch 133 | if g:over_enable_auto_nohlsearch 134 | call s:silent_feedkeys(":nohlsearch\", "nohlsearch", 'n') 135 | call feedkeys("\(over-restore-nohlsearch)") 136 | endif 137 | execute "normal \(over-restore-search-pattern)" 138 | " call s:silent_feedkeys(":let @/ = " . string(s:old_search_pattern) . "\", "restore-search-pattern", 'n') 139 | endfunction 140 | 141 | 142 | function! over#setup() 143 | let s:set_flag = 0 144 | let s:search_highlighted = 0 145 | augroup over-cmdwindow 146 | autocmd! 147 | autocmd InsertCharPre * call s:search_highlight(getline(".") . v:char) 148 | autocmd InsertEnter * call s:set_options() 149 | autocmd InsertLeave * call s:restore_options() 150 | augroup END 151 | endfunction 152 | 153 | 154 | function! over#unsetup() 155 | augroup over-cmdwindow 156 | autocmd! 157 | augroup END 158 | endfunction 159 | 160 | 161 | function! over#command_line(prompt, input, ...) 162 | let context = get(a:, 1, {}) 163 | return over#command_line#start(a:prompt, a:input, context) 164 | endfunction 165 | 166 | 167 | function! over#parse_substitute(word) 168 | return s:parse_substitute(a:word) 169 | endfunction 170 | 171 | 172 | let &cpo = s:save_cpo 173 | unlet s:save_cpo 174 | -------------------------------------------------------------------------------- /autoload/over/command_line.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | let g:over#command_line#enable_import_commandline_map = get(g:, "over#command_line#enable_import_commandline_map", 1) 7 | let g:over#command_line#substitute#replace_pattern_visually = get(g:, "over#command_line#substitute#replace_pattern_visually", 0) 8 | 9 | function! over#command_line#load() 10 | " dummy 11 | endfunction 12 | 13 | let s:V = over#vital() 14 | let s:Highlight = s:V.import("Coaster.Highlight") 15 | let s:Modules = s:V.import("Over.Commandline.Modules") 16 | 17 | 18 | unlet! s:_cmdline 19 | function! s:cmdline() 20 | if exists("s:_cmdline") 21 | return s:_cmdline 22 | endif 23 | let s:_cmdline = over#vital().import("Over.Commandline") 24 | return s:_cmdline 25 | endfunction 26 | 27 | 28 | let s:main = s:cmdline().make_standard("") 29 | call s:main.connect(s:cmdline().get_module("Doautocmd").make("OverCmdLine")) 30 | call s:main.connect(s:cmdline().get_module("KeyMapping").make_emacs()) 31 | call s:main.connect("BufferComplete") 32 | call s:main.connect("ExceptionMessage") 33 | " call s:main.connect("Paste") 34 | 35 | 36 | 37 | let g:over#command_line#paste_escape_chars = get(g:, "over#command_line#paste_escape_chars", '') 38 | 39 | 40 | let s:default_filters = { 41 | \ "\n" : '\\n', 42 | \ "\r" : '\\r', 43 | \} 44 | 45 | let g:over#command_line#paste_filters = get(g:, "over#command_line#paste_filters", s:default_filters) 46 | 47 | 48 | let s:module = { 49 | \ "name" : "Paste" 50 | \} 51 | 52 | function! s:module.on_char_pre(cmdline) 53 | if a:cmdline.is_input("(paste)") 54 | let register = v:register == "" ? '"' : v:register 55 | let text = escape(getreg(register), g:over#command_line#paste_escape_chars) 56 | for [pat, rep] in items(g:over#command_line#paste_filters) 57 | let text = substitute(text, pat, rep, "g") 58 | endfor 59 | call a:cmdline.insert(text) 60 | call a:cmdline.setchar('') 61 | endif 62 | endfunction 63 | call s:main.connect(s:module) 64 | unlet s:module 65 | 66 | 67 | " call s:main.cnoremap("\", "(buffer-complete)") 68 | 69 | let s:base_keymapping = { 70 | \ "\" : { 71 | \ "key" : "(buffer-complete)", 72 | \ "lock" : 1, 73 | \ "noremap" : 1, 74 | \ }, 75 | \ "\" : { 76 | \ "key" : "(paste)", 77 | \ "lock" : 1, 78 | \ "noremap" : 1, 79 | \ } 80 | \} 81 | 82 | function! s:main.keymapping() 83 | return extend( 84 | \ deepcopy(s:base_keymapping), 85 | \ g:over_command_line_key_mappings, 86 | \ ) 87 | endfunction 88 | 89 | 90 | 91 | let s:module = { 92 | \ "name" : "Scroll" 93 | \} 94 | function! s:module.on_char_pre(cmdline) 95 | if a:cmdline.is_input("\(over-cmdline-scroll-y)") 96 | execute "normal! \" 97 | call a:cmdline.setchar('') 98 | elseif a:cmdline.is_input("\(over-cmdline-scroll-u)") 99 | execute "normal! \" 100 | call a:cmdline.setchar('') 101 | elseif a:cmdline.is_input("\(over-cmdline-scroll-f)") 102 | execute "normal! \" 103 | call a:cmdline.setchar('') 104 | elseif a:cmdline.is_input("\(over-cmdline-scroll-e)") 105 | execute "normal! \" 106 | call a:cmdline.setchar('') 107 | elseif a:cmdline.is_input("\(over-cmdline-scroll-d)") 108 | execute "normal! \" 109 | call a:cmdline.setchar('') 110 | elseif a:cmdline.is_input("\(over-cmdline-scroll-b)") 111 | execute "normal! \" 112 | call a:cmdline.setchar('') 113 | endif 114 | endfunction 115 | call s:main.connect(s:module) 116 | 117 | 118 | let g:over#command_line#enable_Digraphs = get(g:, "over#command_line#enable_Digraphs", 1) 119 | 120 | function! over#command_line#start(prompt, input, ...) 121 | let context = get(a:, 1, {}) 122 | 123 | if g:over#command_line#enable_Digraphs 124 | \ && empty(over#command_line#get().get_module("Digraphs")) 125 | call over#command_line#get().connect("Digraphs") 126 | else 127 | call over#command_line#get().disconnect("Digraphs") 128 | endif 129 | 130 | if g:over#command_line#enable_import_commandline_map == 0 131 | call s:main.disconnect("KeyMapping_vim_cmdline_mapping") 132 | else 133 | call s:main.connect(s:Modules.get("KeyMapping").make_vim_cmdline_mapping()) 134 | endif 135 | 136 | if get(context, "line1", 1) != get(context, "line2", 1) 137 | call s:main.connect(s:hl_visualmode) 138 | else 139 | call s:main.disconnect("HighlightVisualMode") 140 | endif 141 | 142 | if exists("*strchars") && has("conceal") 143 | call s:main.set_prompt(a:prompt) 144 | let exit_code = s:main.start(a:input) 145 | if exit_code == 1 146 | doautocmd User OverCmdLineCancel 147 | endif 148 | else 149 | echohl ErrorMsg 150 | echo "Vim 7.3 or above and +conceal." 151 | echo "Need strchars()." 152 | echohl NONE 153 | endif 154 | endfunction 155 | 156 | 157 | function! over#command_line#getline() 158 | return s:main.getline() 159 | endfunction 160 | 161 | function! over#command_line#setline(line) 162 | return s:main.set(a:line) 163 | endfunction 164 | 165 | function! over#command_line#char() 166 | return s:main.char() 167 | endfunction 168 | 169 | function! over#command_line#setchar(char) 170 | call s:main.setchar(a:char) 171 | endfunction 172 | 173 | function! over#command_line#getpos() 174 | return s:main.getpos() 175 | endfunction 176 | 177 | function! over#command_line#setpos(pos) 178 | return s:main.setpos(a:pos) 179 | endfunction 180 | 181 | 182 | function! over#command_line#wait_keyinput_on(key) 183 | return s:main.tap_keyinput(a:key) 184 | endfunction 185 | 186 | function! over#command_line#wait_keyinput_off(key) 187 | return s:main.untap_keyinput(a:key) 188 | endfunction 189 | 190 | function! over#command_line#get_wait_keyinput() 191 | return s:main.get_tap_key() 192 | endfunction 193 | 194 | 195 | function! over#command_line#is_input(...) 196 | return call(s:main.is_input, a:000, s:main) 197 | endfunction 198 | 199 | 200 | function! over#command_line#insert(...) 201 | return call(s:main.insert, a:000, s:main) 202 | endfunction 203 | 204 | function! over#command_line#forward() 205 | return s:main.forward() 206 | endfunction 207 | 208 | function! over#command_line#backward() 209 | return s:main.backward() 210 | endfunction 211 | 212 | 213 | call over#command_line#substitute#load() 214 | call over#command_line#search#load() 215 | call over#command_line#global#load() 216 | 217 | 218 | function! over#command_line#do(input) 219 | call s:main.start(a:input) 220 | return s:main.getline() 221 | endfunction 222 | 223 | 224 | function! over#command_line#get() 225 | return s:main 226 | endfunction 227 | 228 | 229 | 230 | let s:hl_visualmode = { 231 | \ "name" : "HighlightVisualMode" 232 | \} 233 | 234 | function! s:hl_visualmode.on_enter(...) 235 | if &selection == "exclusive" 236 | let pat = '\%''<\|\%>''<.*\%<''>' 237 | else 238 | let pat = '\%''<\|\%>''<.*\%<''>\|\%''>' 239 | endif 240 | 241 | call s:Highlight.highlight("visualmode", "Visual", pat, 0) 242 | endfunction 243 | 244 | 245 | function! s:hl_visualmode.on_leave(...) 246 | call s:Highlight.clear("visualmode") 247 | endfunction 248 | 249 | 250 | 251 | let &cpo = s:save_cpo 252 | unlet s:save_cpo 253 | -------------------------------------------------------------------------------- /autoload/over/command_line/command_history.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | function! over#command_line#command_history#load() 6 | " load 7 | endfunction 8 | 9 | 10 | function! s:command_histories() 11 | return map(range(1, &history), 'histget(":", v:val * -1)') 12 | endfunction 13 | 14 | 15 | let s:cmdhist = [] 16 | let s:count = 0 17 | 18 | function! s:main() 19 | if !over#command_line#is_input("\") && !over#command_line#is_input("\") 20 | let s:cmdhist = [] 21 | let s:count = 0 22 | return 23 | else 24 | if s:count == 0 && empty(s:cmdhist) 25 | let cmdline = '^' . over#command_line#getline() 26 | let s:cmdhist = filter(s:command_histories(), 'v:val =~ cmdline') 27 | endif 28 | endif 29 | call over#command_line#setchar("") 30 | if over#command_line#is_input("\") 31 | let s:count = max([s:count - 1, 0]) 32 | endif 33 | if over#command_line#is_input("\") 34 | let s:count = min([s:count + 1, len(s:cmdhist)]) 35 | endif 36 | call over#command_line#setline(get(s:cmdhist, s:count, over#command_line#getline())) 37 | endfunction 38 | 39 | augroup over-cmdline-command_history 40 | autocmd! 41 | autocmd User OverCmdLineCharPre call s:main() 42 | augroup END 43 | 44 | let &cpo = s:save_cpo 45 | unlet s:save_cpo 46 | -------------------------------------------------------------------------------- /autoload/over/command_line/complete.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | function! over#command_line#complete#load() 6 | " load 7 | endfunction 8 | 9 | 10 | function! s:uniq(list) 11 | let dict = {} 12 | for _ in a:list 13 | let dict[_] = 0 14 | endfor 15 | return keys(dict) 16 | endfunction 17 | 18 | 19 | function! s:buffer_complete() 20 | return sort(s:uniq(filter(split(join(getline(1, '$')), '\W'), '!empty(v:val)')), 1) 21 | endfunction 22 | 23 | 24 | function! s:parse_line(line) 25 | let keyword = matchstr(a:line, '\zs\w\+\ze$') 26 | let pos = strchars(a:line) - strchars(keyword) 27 | return [pos, keyword] 28 | endfunction 29 | 30 | 31 | function! s:make_context(...) 32 | let base = get(a:, 1, {}) 33 | return extend(base, { 34 | \ "backward" : over#command_line#backward() 35 | \ "forward" : over#command_line#forward() 36 | \ }) 37 | endfunction 38 | 39 | 40 | function! s:get_complete_words() 41 | return s:buffer_complete() 42 | endfunction 43 | 44 | 45 | function! s:as_statusline(list, count) 46 | if empty(a:list) 47 | return 48 | endif 49 | let hl_none = "%#StatusLine#" 50 | let hl_select = "%#StatusLineNC#" 51 | let tail = " > " 52 | let result = a:list[0] 53 | let pos = 0 54 | for i in range(1, len(a:list)-1) 55 | if strdisplaywidth(result . " " . a:list[i]) > &columns - len(tail) 56 | if a:count < i 57 | break 58 | else 59 | let pos = -i 60 | endif 61 | let result = a:list[i] 62 | else 63 | let result .= (" " . a:list[i]) 64 | endif 65 | if a:count == i 66 | let pos = pos + i 67 | endif 68 | endfor 69 | return join(map(split(result, " "), 'v:key == pos ? hl_select . v:val . hl_none : v:val')) 70 | endfunction 71 | 72 | 73 | function! s:start() 74 | let s:old_statusline = &statusline 75 | 76 | let backward = over#command_line#backward() 77 | let [pos, keyword] = s:parse_line(backward) 78 | 79 | if !exists("s:complete") 80 | let s:complete = s:get_complete_words() 81 | endif 82 | let s:complete_list = filter(copy(s:complete), 'v:val =~ ''^''.keyword') 83 | if empty(s:complete_list) 84 | return -1 85 | endif 86 | 87 | if pos == 0 88 | let backward = "" 89 | else 90 | let backward = join(split(backward, '\zs')[ : pos-1 ], "") 91 | endif 92 | let s:line = backward . over#command_line#forward() 93 | let s:pos = pos 94 | call over#command_line#setline(s:line) 95 | 96 | let s:count = 0 97 | endfunction 98 | 99 | 100 | function! s:finish() 101 | if exists("s:old_statusline") 102 | let &statusline = s:old_statusline 103 | unlet s:old_statusline 104 | endif 105 | endfunction 106 | 107 | 108 | 109 | function! s:main() 110 | if over#command_line#is_input("\") 111 | if s:start() == -1 112 | call s:finish() 113 | call over#command_line#setchar('') 114 | return 115 | endif 116 | call over#command_line#setchar('') 117 | call over#command_line#wait_keyinput_on("Completion") 118 | elseif over#command_line#is_input("\", "Completion") 119 | \ || over#command_line#is_input("\", "Completion") 120 | call over#command_line#setchar('') 121 | let s:count += 1 122 | if s:count >= len(s:complete_list) 123 | let s:count = 0 124 | endif 125 | elseif over#command_line#is_input("\", "Completion") 126 | call over#command_line#setchar('') 127 | let s:count -= 1 128 | if s:count < 0 129 | let s:count = len(s:complete_list) - 1 130 | endif 131 | else 132 | call over#command_line#wait_keyinput_off("Completion") 133 | call s:finish() 134 | return 135 | endif 136 | call over#command_line#setline(s:line) 137 | call over#command_line#insert(s:complete_list[s:count], s:pos) 138 | if len(s:complete_list) > 1 139 | let &statusline = s:as_statusline(s:complete_list, s:count) 140 | endif 141 | endfunction 142 | 143 | 144 | augroup over-cmdwindow-complete 145 | autocmd! 146 | autocmd User OverCmdLineCharPre call s:main() 147 | autocmd User OverCmdLineLeave unlet! s:complete 148 | augroup END 149 | 150 | 151 | let &cpo = s:save_cpo 152 | unlet s:save_cpo 153 | -------------------------------------------------------------------------------- /autoload/over/command_line/global.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | " 0 = match just the pattern 6 | " 1 = match whole line 7 | let g:over#command_line#global#highlight_line = get(g:, "over#command_line#global#highlight_line", 0) 8 | 9 | " 0 = do nothing 10 | " 1 = highlight all lines not matching pattern 11 | let g:over#command_bang#global#highlight_bang = get(g:, "over#command_bang#global#highlight_bang", 1) 12 | 13 | function! over#command_line#global#load() 14 | " load 15 | endfunction 16 | 17 | 18 | function! s:search_hl_off() 19 | if exists("s:search_id") && s:search_id != -1 20 | call matchdelete(s:search_id) 21 | unlet s:search_id 22 | endif 23 | endfunction 24 | 25 | 26 | function! s:search_hl_on(pattern, bang) 27 | let pattern = g:over#command_line#global#highlight_line ? 28 | \ '.*' . a:pattern . '.*' : a:pattern 29 | let pattern = a:bang && g:over#command_bang#global#highlight_bang ? 30 | \ '^\%(\%(' . pattern . '\)\@!.\)*$' : pattern 31 | silent! let s:search_id = matchadd("IncSearch", a:pattern) 32 | endfunction 33 | 34 | 35 | function! s:main() 36 | call s:search_hl_off() 37 | let line = over#command_line#backward() 38 | if line =~ '\v^\%g!?\/.' 39 | let bang = line =~ 'g!\/' 40 | let pattern = matchstr(line, '\v\%g!?\/\zs%(\\\/|[^/])+') 41 | call s:search_hl_on((&ignorecase ? '\c' : '') . pattern, bang) 42 | endif 43 | endfunction 44 | 45 | 46 | augroup over-cmdline-global 47 | autocmd! 48 | autocmd User OverCmdLineChar call s:main() 49 | autocmd User OverCmdLineLeave call s:search_hl_off() 50 | autocmd User OverCmdLineEnter let s:old_pos = getpos(".") 51 | autocmd User OverCmdLineExecutePre call setpos(".", s:old_pos) 52 | augroup END 53 | 54 | let &cpo = s:save_cpo 55 | unlet s:save_cpo 56 | 57 | -------------------------------------------------------------------------------- /autoload/over/command_line/insert_register.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | function! over#command_line#insert_register#load() 6 | " load 7 | endfunction 8 | 9 | 10 | function! s:to_string(expr) 11 | return type(a:expr) == type("") ? a:expr : string(a:expr) 12 | endfunction 13 | 14 | 15 | function! s:input() 16 | call over#command_line#hl_cursor_on() 17 | try 18 | call over#command_line#redraw() 19 | let input = input("=", "", "expression") 20 | if !empty(input) 21 | let input = s:to_string(eval(input)) 22 | endif 23 | catch 24 | return "" 25 | finally 26 | call over#command_line#hl_cursor_off() 27 | endtry 28 | return input 29 | endfunction 30 | 31 | 32 | function! s:main() 33 | if over#command_line#is_input("\") 34 | call over#command_line#setchar('"') 35 | call over#command_line#wait_keyinput_on("InsertRegister") 36 | let s:old_line = over#command_line#getline() 37 | let s:old_pos = over#command_line#getpos() 38 | return 39 | elseif over#command_line#get_wait_keyinput() == "InsertRegister" 40 | call over#command_line#setline(s:old_line) 41 | call over#command_line#setpos(s:old_pos) 42 | let key = over#command_line#keymap(over#command_line#char()) 43 | if key =~ '^[0-9a-zA-z.%#:/"\-*]$' 44 | execute "let regist = @" . key 45 | call over#command_line#setchar(regist) 46 | elseif key == '=' 47 | call over#command_line#setchar(s:input()) 48 | elseif key == "\" 49 | call over#command_line#setchar(s:cword) 50 | elseif key == "\" 51 | call over#command_line#setchar(s:cWORD) 52 | elseif key == "\" 53 | call over#command_line#setchar(s:cfile) 54 | elseif key == "\" 55 | call over#command_line#setchar('"') 56 | endif 57 | endif 58 | endfunction 59 | 60 | 61 | function! s:on_OverCmdLineChar() 62 | if over#command_line#is_input("\", "InsertRegister") 63 | call over#command_line#setpos(over#command_line#getpos()-1) 64 | else 65 | call over#command_line#wait_keyinput_off("InsertRegister") 66 | endif 67 | endfunction 68 | 69 | 70 | function! s:save_op() 71 | let s:cword = expand("") 72 | let s:cWORD = expand("cWORD") 73 | let s:cfile = expand("") 74 | endfunction 75 | 76 | augroup over-cmdline-insert_register 77 | autocmd! 78 | autocmd User OverCmdLineEnter call s:save_op() 79 | autocmd User OverCmdLineCharPre call s:main() 80 | autocmd User OverCmdLineChar call s:on_OverCmdLineChar() 81 | augroup END 82 | 83 | let &cpo = s:save_cpo 84 | unlet s:save_cpo 85 | -------------------------------------------------------------------------------- /autoload/over/command_line/search.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | let g:over#command_line#search#enable_incsearch = get(g:, "over#command_line#search#enable_incsearch", 1) 6 | let g:over#command_line#search#enable_move_cursor = get(g:, "over#command_line#search#enable_move_cursor", 0) 7 | 8 | 9 | function! over#command_line#search#load() 10 | " load 11 | endfunction 12 | 13 | 14 | function! s:search_hl_off() 15 | if exists("s:search_id") && s:search_id != -1 16 | call matchdelete(s:search_id) 17 | unlet s:search_id 18 | endif 19 | endfunction 20 | 21 | 22 | function! s:search_hl_on(pattern) 23 | call s:search_hl_off() 24 | silent! let s:search_id = matchadd("IncSearch", a:pattern) 25 | endfunction 26 | 27 | 28 | function! s:main() 29 | call s:search_hl_off() 30 | let line = over#command_line#backward() 31 | if line =~ '^/.\+' 32 | \ || line =~ '^?.\+' 33 | let pattern = matchstr(line, '^\(/\|?\)\zs.\+') 34 | if g:over#command_line#search#enable_incsearch 35 | call s:search_hl_on((&ignorecase ? '\c' : "") . pattern) 36 | endif 37 | if g:over#command_line#search#enable_move_cursor 38 | if line =~ '^/.\+' 39 | silent! call search(pattern, "c") 40 | else 41 | silent! call search(pattern, "cb") 42 | endif 43 | endif 44 | endif 45 | endfunction 46 | 47 | 48 | augroup over-cmdline-search 49 | autocmd! 50 | autocmd User OverCmdLineChar call s:main() 51 | autocmd User OverCmdLineLeave call s:search_hl_off() 52 | autocmd User OverCmdLineEnter let s:old_pos = getpos(".") 53 | autocmd User OverCmdLineExecutePre call setpos(".", s:old_pos) 54 | augroup END 55 | 56 | 57 | 58 | let &cpo = s:save_cpo 59 | unlet s:save_cpo 60 | 61 | -------------------------------------------------------------------------------- /autoload/over/command_line/substitute.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | function! over#command_line#substitute#load() 6 | " load 7 | endfunction 8 | 9 | 10 | let s:V = over#vital() 11 | let s:Rocker = s:V.import("Unlocker.Rocker") 12 | let s:Undo = s:V.import("Unlocker.Rocker.Undotree") 13 | 14 | 15 | let s:hl_mark_begin = '' 16 | let s:hl_mark_center = '' 17 | let s:hl_mark_end = '' 18 | 19 | 20 | let g:over#command_line#substitute#highlight_pattern = get(g:, "over#command_line#substitute#highlight_pattern", "Search") 21 | 22 | if hlexists("Error") 23 | let g:over#command_line#substitute#highlight_string = get(g:, "over#command_line#substitute#highlight_string", "Error") 24 | else 25 | let g:over#command_line#substitute#highlight_string = get(g:, "over#command_line#substitute#highlight_string", "ErrorMsg") 26 | endif 27 | 28 | 29 | function! s:init() 30 | if &modifiable == 0 31 | return 32 | endif 33 | let s:undo_flag = 0 34 | 35 | let hl_f = "syntax match %s '%s' conceal containedin=.*" 36 | execute printf(hl_f, "OverCmdLineSubstituteHiddenBegin", s:hl_mark_begin) 37 | execute printf(hl_f, "OverCmdLineSubstituteHiddenCenter", s:hl_mark_center) 38 | execute printf(hl_f, "OverCmdLineSubstituteHiddenEnd", s:hl_mark_end) 39 | " syntax match OverCmdLineSubstituteHiddenBegin '`os`' conceal containedin=ALL 40 | " syntax match OverCmdLineSubstituteHiddenMiddle '`om`' conceal containedin=ALL 41 | " syntax match OverCmdLineSubstituteHiddenEnd '`oe`' conceal containedin=ALL 42 | 43 | " let s:undo_file = tempname() 44 | " execute "wundo" s:undo_file 45 | 46 | " let s:old_pos = getpos(".") 47 | 48 | let s:locker = s:Rocker.lock( 49 | \ "&scrolloff", 50 | \ "&l:conceallevel", 51 | \ "&l:concealcursor", 52 | \ "&l:modified", 53 | \ "&l:undolevels", 54 | \ ) 55 | let &scrolloff = 0 56 | let s:old_modified = &l:modified 57 | 58 | let s:undo_locker = s:Undo.make().lock() 59 | 60 | " Workaround https://github.com/osyo-manga/vim-over/issues/43 61 | " substitute use undo 62 | setlocal undolevels=0 63 | 64 | let s:finished = 0 65 | " let s:buffer_text = getline(1, "$") 66 | endfunction 67 | 68 | 69 | function! s:finish() 70 | if &modifiable == 0 || s:finished 71 | return 72 | endif 73 | call s:reset_match() 74 | let s:finished = 1 75 | " call setpos(".", s:old_pos) 76 | call s:locker.unlock() 77 | 78 | " highlight link OverCmdLineSubstitute NONE 79 | " highlight link OverCmdLineSubstitutePattern NONE 80 | " highlight link OverCmdLineSubstituteString NONE 81 | endfunction 82 | 83 | 84 | function! s:undojoin() 85 | if exists("s:undo_locker") 86 | call s:undo() 87 | " call setline(1, s:buffer_text) 88 | call s:undo_locker.unlock() 89 | " if filereadable(s:undo_file) 90 | " silent execute "rundo" s:undo_file 91 | " endif 92 | unlet s:undo_locker 93 | " unlet s:undo_file 94 | endif 95 | endfunction 96 | 97 | 98 | function! s:silent_undo() 99 | let pos = getpos(".") 100 | redir => _ 101 | silent undo 102 | redir END 103 | call setpos(".", pos) 104 | endfunction 105 | 106 | 107 | function! s:undo() 108 | if s:undo_flag 109 | call s:silent_undo() 110 | let s:undo_flag = 0 111 | endif 112 | endfunction 113 | 114 | 115 | function! s:matchadd(group, pat) 116 | if hlID(a:group) 117 | try 118 | let id = matchadd(a:group, a:pat, 1) 119 | catch 120 | return 121 | endtry 122 | call add(s:matchlist, id) 123 | endif 124 | endfunction 125 | 126 | 127 | let s:matchlist = [] 128 | function! s:reset_match() 129 | for id in s:matchlist 130 | if id != -1 131 | silent! call matchdelete(id) 132 | endif 133 | endfor 134 | let s:matchlist = [] 135 | endfunction 136 | 137 | 138 | function! s:silent_substitute(range, pattern, string, flags) 139 | try 140 | let flags = substitute(a:flags, 'c', '', "g") 141 | let old_pos = getpos(".") 142 | let old_search = @/ 143 | let check = b:changedtick 144 | silent execute printf('%ss/%s/%s/%s', a:range, a:pattern, a:string, flags) 145 | call histdel("search", -1) 146 | let &l:modified = s:old_modified 147 | catch /\v^Vim%(\(\a+\))=:(E121)|(E117)|(E110)|(E112)|(E113)|(E731)|(E475)|(E15)/ 148 | if check != b:changedtick 149 | call s:silent_undo() 150 | endif 151 | return 0 152 | catch 153 | finally 154 | call setpos(".", old_pos) 155 | let @/ = old_search 156 | endtry 157 | return check != b:changedtick 158 | endfunction 159 | 160 | 161 | function! s:substitute_preview(line) 162 | if &modifiable == 0 163 | return 164 | endif 165 | 166 | if over#command_line#is_input("\") 167 | return 168 | endif 169 | 170 | call s:undo() 171 | 172 | call s:reset_match() 173 | 174 | let result = over#parse_substitute(a:line) 175 | if empty(result) 176 | return 177 | endif 178 | nohlsearch 179 | 180 | let [range, pattern, string, flags] = result 181 | if empty(pattern) 182 | let pattern = @/ 183 | endif 184 | 185 | if empty(string) 186 | call s:matchadd(g:over#command_line#substitute#highlight_pattern, (&ignorecase ? '\c' : '') . pattern) 187 | return 188 | endif 189 | 190 | let range = (range ==# "%") ? printf("%d,%d", line("w0"), line("w$")) : range 191 | if string =~ '^\\=.\+' 192 | 193 | " \="`os`" . submatch(0) . "`om`" . (submatch(0)) . "`oe`" 194 | let hl_submatch = printf('\\="%s" . submatch(0) . "%s" . (', s:hl_mark_begin, s:hl_mark_center) 195 | let string = substitute(string, '^\\=\ze.\+', hl_submatch, "") . ') . "' . s:hl_mark_end . '"' 196 | else 197 | if g:over#command_line#substitute#replace_pattern_visually 198 | let string = s:hl_mark_begin . s:hl_mark_center . string . s:hl_mark_end 199 | else 200 | let string = s:hl_mark_begin . '\0' . s:hl_mark_center . string . s:hl_mark_end 201 | endif 202 | endif 203 | let s:undo_flag = s:silent_substitute(range, pattern, string, flags) 204 | 205 | let &l:concealcursor = "nvic" 206 | let &l:conceallevel = 3 207 | 208 | let pattern = s:hl_mark_begin . '\zs\_.\{-}\ze' . s:hl_mark_center 209 | let string = s:hl_mark_center . '\zs\_.\{-}\ze' . s:hl_mark_end 210 | call s:matchadd(g:over#command_line#substitute#highlight_pattern, pattern) 211 | call s:matchadd(g:over#command_line#substitute#highlight_string, string) 212 | endfunction 213 | 214 | 215 | function! s:on_charpre() 216 | if over#command_line#is_input("\(over-cmdline-substitute-jump-string)") 217 | let result = over#parse_substitute(over#command_line#getline()) 218 | if empty(result) 219 | return 220 | endif 221 | let [range, pattern, string, flags] = result 222 | call over#command_line#setpos(strchars(range . pattern) + 3) 223 | call over#command_line#setchar("") 224 | endif 225 | if over#command_line#is_input("\(over-cmdline-substitute-jump-pattern)") 226 | let result = over#parse_substitute(over#command_line#getline()) 227 | if empty(result) 228 | return 229 | endif 230 | let [range, pattern, string, flags] = result 231 | call over#command_line#setpos(strchars(range ) + 2) 232 | call over#command_line#setchar("") 233 | endif 234 | endfunction 235 | 236 | 237 | augroup over-cmdline-substitute 238 | autocmd! 239 | autocmd User OverCmdLineEnter call s:init() 240 | autocmd User OverCmdLineExecutePre call s:undojoin() 241 | autocmd User OverCmdLineExecutePre call s:finish() 242 | autocmd User OverCmdLineLeave call s:finish() 243 | autocmd User OverCmdLineException call s:finish() 244 | autocmd User OverCmdLineException call s:undojoin() 245 | autocmd User OverCmdLineCancel call s:undojoin() 246 | autocmd User OverCmdLineChar call s:substitute_preview(over#command_line#getline()) 247 | autocmd user OverCmdLineCharPre call s:on_charpre() 248 | augroup END 249 | 250 | 251 | 252 | let &cpo = s:save_cpo 253 | unlet s:save_cpo 254 | -------------------------------------------------------------------------------- /autoload/vital/_over.vim: -------------------------------------------------------------------------------- 1 | let s:_plugin_name = expand(':t:r') 2 | 3 | function! vital#{s:_plugin_name}#new() abort 4 | return vital#{s:_plugin_name[1:]}#new() 5 | endfunction 6 | 7 | function! vital#{s:_plugin_name}#function(funcname) abort 8 | silent! return function(a:funcname) 9 | endfunction 10 | -------------------------------------------------------------------------------- /autoload/vital/_over/Coaster/Buffer/Object.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Coaster#Buffer#Object#import() abort', printf("return map({'setbufline_if_python': '', 'setbufline_if_python3': '', 'setbufline_if_ruby': '', 'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | let s:obj = { 16 | \ "__variable" : {} 17 | \} 18 | 19 | 20 | function! s:obj.number() 21 | return self.__variable.bufnr 22 | endfunction 23 | 24 | 25 | function! s:obj.invoke(func, ...) 26 | let args = get(a:, 1, []) 27 | return call(a:func, [self.number()] + args) 28 | endfunction 29 | 30 | 31 | function! s:obj.name() 32 | return self.invoke("bufname") 33 | endfunction 34 | 35 | 36 | function! s:obj.get_variable(...) 37 | return self.invoke("getbufvar", a:000) 38 | endfunction 39 | 40 | 41 | function! s:obj.set_variable(...) 42 | return self.invoke("setbufvar", a:000) 43 | endfunction 44 | 45 | 46 | function! s:obj.get_option(name) 47 | return self.get_variable("&" . a:name) 48 | endfunction 49 | 50 | 51 | function! s:obj.set_option(name, var) 52 | return self.set_variable("&" . a:name, a:var) 53 | endfunction 54 | 55 | 56 | function! s:obj.winnr() 57 | return self.invoke("bufwinnr") 58 | endfunction 59 | 60 | 61 | function! s:obj.is_exists() 62 | return bufexists(self.number()) 63 | endfunction 64 | 65 | 66 | function! s:obj.is_listed() 67 | return self.invoke("buflisted") 68 | endfunction 69 | 70 | 71 | function! s:obj.is_loaded() 72 | return self.invoke("bufloaded") 73 | endfunction 74 | 75 | 76 | function! s:obj.is_current() 77 | return self.number() == bufnr("%") 78 | endfunction 79 | 80 | 81 | function! s:obj.is_modifiable() 82 | return self.get_option("modifiable") 83 | endfunction 84 | 85 | 86 | function! s:obj.is_opened_in_current_tabpage() 87 | return self.winnr() != -1 88 | endfunction 89 | 90 | 91 | function! s:obj.tap() 92 | if !self.is_exists() || self.is_tapped() 93 | return 94 | endif 95 | let self.__variable.tap_bufnr = bufnr("%") 96 | split 97 | execute "b" self.number() 98 | return self.number() 99 | endfunction 100 | 101 | 102 | function! s:obj.untap() 103 | if !self.is_tapped() 104 | return 105 | endif 106 | quit 107 | silent! execute "buffer" self.__variable.tap_bufnr 108 | unlet self.__variable.tap_bufnr 109 | return self.number() 110 | endfunction 111 | 112 | 113 | function! s:obj.tap_modifiable(...) 114 | let force = get(a:, 1, 1) 115 | if !(self.is_modifiable() || force) 116 | return 117 | endif 118 | let result = self.tap() 119 | if result 120 | let self.__variable.modifiable = &modifiable 121 | set modifiable 122 | endif 123 | return result 124 | endfunction 125 | 126 | 127 | function! s:obj.untap_modifiable() 128 | if has_key(self.__variable, "modifiable") 129 | let &modifiable = self.__variable.modifiable 130 | unlet self.__variable.modifiable 131 | call self.untap() 132 | endif 133 | endfunction 134 | 135 | 136 | function! s:obj.is_tapped() 137 | return has_key(self.__variable, "tap_bufnr") 138 | endfunction 139 | 140 | 141 | function! s:obj.execute(cmd) 142 | if self.is_current() 143 | execute a:cmd 144 | return 145 | endif 146 | if self.tap() 147 | try 148 | execute a:cmd 149 | finally 150 | call self.untap() 151 | endtry 152 | endif 153 | 154 | " let view = winsaveview() 155 | " try 156 | " noautocmd silent! execute "bufdo if bufnr('%') == " a:expr . ' | ' . string(a:cmd) . ' | endif' 157 | " finally 158 | " noautocmd silent! execute "buffer" bufnr 159 | " call winrestview(view) 160 | " endtry 161 | endfunction 162 | 163 | 164 | function! s:setbufline_if_python(expr, lnum, text) 165 | if len(getbufline(a:expr, 1, "$")) < a:lnum - 1 166 | return 167 | endif 168 | let list = type(a:text) == type([]) ? a:text : [a:text] 169 | python import vim 170 | py vim.buffers[int(vim.eval('a:expr'))][int(vim.eval("a:lnum")) - 1 : int(vim.eval("a:lnum")) - 1 + len(vim.eval("list"))] = vim.eval("list") 171 | endfunction 172 | 173 | 174 | function! s:setbufline_if_python3(expr, lnum, text) 175 | if len(getbufline(a:expr, 1, "$")) < a:lnum - 1 176 | return 177 | endif 178 | let list = type(a:text) == type([]) ? a:text : [a:text] 179 | python3 import vim 180 | py3 vim.buffers[int(vim.eval('a:expr'))][int(vim.eval("a:lnum")) - 1 : int(vim.eval("a:lnum")) - 1 + len(vim.eval("list"))] = vim.eval("list") 181 | endfunction 182 | 183 | 184 | function! s:setbufline_if_ruby(expr, lnum, text) 185 | if len(getbufline(a:expr, 1, "$")) < a:lnum - 1 186 | return 187 | endif 188 | let save_op = getbufvar(a:expr, "&buflisted") 189 | call setbufvar(a:expr, "&buflisted", 1) 190 | try 191 | let list = type(a:text) == type([]) ? a:text : [a:text] 192 | let bufnr = index(filter(range(1, bufnr("$")), "buflisted(v:val)"), bufnr(a:expr)) 193 | ruby << EOR 194 | bufnr = Vim::evaluate("bufnr") 195 | text = Vim::evaluate("list") 196 | lnum = Vim::evaluate("a:lnum") 197 | b = Vim::Buffer[bufnr] 198 | text.each_with_index {|it, i| 199 | if b.count < lnum + i 200 | b.append lnum + i - 1, it.to_s 201 | else 202 | b[lnum + i] = it.to_s 203 | end 204 | } 205 | EOR 206 | finally 207 | let save_op = setbufvar(a:expr, "&buflisted", save_op) 208 | endtry 209 | endfunction 210 | 211 | 212 | function! s:obj.setline(lnum, text, ...) 213 | " if has("ruby") 214 | " return s:setbufline_if_ruby(self.number(), a:lnum, a:text) 215 | " endif 216 | let force = get(a:, 1, 0) 217 | if self.tap_modifiable(force) 218 | try 219 | if exists("*setbufline") 220 | return setbufline(self.number(), a:lnum, a:text) 221 | endif 222 | 223 | if has("python") 224 | return s:setbufline_if_python(self.number(), a:lnum, a:text) 225 | endif 226 | 227 | if has("python3") 228 | return s:setbufline_if_python3(self.number(), a:lnum, a:text) 229 | endif 230 | 231 | call setline(a:lnum, a:text) 232 | finally 233 | call self.untap_modifiable() 234 | endtry 235 | endif 236 | " return self.execute("call setline(" . a:lnum . "," . string(a:text) . ")") 237 | endfunction 238 | 239 | 240 | function! s:obj.append(lnum, text, ...) 241 | let force = get(a:, 1, 0) 242 | if self.tap_modifiable(force) 243 | try 244 | call append(a:lnum, a:text) 245 | finally 246 | call self.untap_modifiable() 247 | endtry 248 | endif 249 | endfunction 250 | 251 | 252 | function! s:obj.clear(...) 253 | let force = get(a:, 1, 0) 254 | if self.tap_modifiable(force) 255 | try 256 | silent % delete _ 257 | finally 258 | call self.untap_modifiable() 259 | endtry 260 | endif 261 | endfunction 262 | 263 | 264 | function! s:obj.getline(...) 265 | return self.invoke("getbufline", a:000) 266 | endfunction 267 | 268 | 269 | function! s:obj.line_length() 270 | return len(getbufline(self.number(), 1, "$")) 271 | endfunction 272 | 273 | 274 | function! s:obj.open(...) 275 | let open_cmd = get(a:, 1, "") 276 | execute open_cmd 277 | execute "buffer" self.number() 278 | endfunction 279 | 280 | 281 | function! s:obj.close() 282 | call self.execute("close") 283 | call self.delete() 284 | endfunction 285 | 286 | 287 | function! s:obj.delete(...) 288 | let force = get(a:, 1, 0) 289 | if self.is_exists() 290 | try 291 | execute "bdelete" . (force ? "! " : " ") . self.number() 292 | return 0 293 | catch 294 | return -1 295 | endtry 296 | endif 297 | endfunction 298 | 299 | 300 | function! s:obj.set_name(name) 301 | return self.execute(":file " . string(a:name)) 302 | endfunction 303 | 304 | 305 | function! s:make(expr) 306 | let obj = deepcopy(s:obj) 307 | let obj.__variable.bufnr = bufnr(a:expr) 308 | return obj 309 | endfunction 310 | 311 | 312 | 313 | let &cpo = s:save_cpo 314 | unlet s:save_cpo 315 | -------------------------------------------------------------------------------- /autoload/vital/_over/Coaster/Highlight.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Coaster#Highlight#import() abort', printf("return map({'highlight': '', 'clear': '', 'delete': '', 'add': '', 'as_windo': '', '_vital_depends': '', 'get_hl_id': '', 'to_list': '', 'clear_all': '', 'delete_all': '', 'to_list_by': '', 'update': '', 'enable': '', 'delete_by': '', 'hl_list': '', 'make': '', 'enable_list': '', 'update_all': '', 'disable': '', 'disable_all': '', 'is_enabled': '', 'enable_all': '', 'is_added': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:_vital_loaded(V) 16 | let s:V = a:V 17 | let s:Window = a:V.import("Coaster.Window") 18 | let s:Gift = a:V.import("Gift") 19 | call s:_init() 20 | endfunction 21 | 22 | 23 | function! s:_vital_depends() 24 | return [ 25 | \ "Coaster.Window", 26 | \ "Gift", 27 | \ ] 28 | endfunction 29 | 30 | 31 | 32 | let s:base = { 33 | \ "variables" : { 34 | \ "hl_list" : {}, 35 | \ "id_list" : {}, 36 | \ "id_count" : 0 37 | \ } 38 | \} 39 | 40 | 41 | function! s:base.add(name, group, pattern, ...) 42 | if a:name == "" 43 | let self.variables.id_count += 1 44 | return self.add(self.variables.id_count, a:group, a:pattern, get(a:, 1, 10)) 45 | endif 46 | call self.delete(a:name) 47 | let priority = get(a:, 1, 10) 48 | let self.variables.hl_list[a:name] = { 49 | \ "group" : a:group, 50 | \ "pattern" : a:pattern, 51 | \ "priority" : priority, 52 | \ "name" : a:name, 53 | \ } 54 | return self.variables.hl_list[a:name] 55 | endfunction 56 | 57 | 58 | function! s:base.is_added(name) 59 | return has_key(self.variables.hl_list, a:name) 60 | endfunction 61 | 62 | 63 | function! s:base.hl_list() 64 | return keys(self.variables.hl_list) 65 | endfunction 66 | 67 | 68 | function! s:base.to_list() 69 | return values(self.variables.hl_list) 70 | endfunction 71 | 72 | 73 | function! s:_is_equal(__expr, __hl) 74 | let name = a:__hl.name 75 | let group = a:__hl.group 76 | let pattern = a:__hl.pattern 77 | let priority = a:__hl.priority 78 | return eval(a:__expr) 79 | endfunction 80 | 81 | 82 | function! s:base.to_list_by(expr) 83 | return filter(values(self.variables.hl_list), "s:_is_equal(a:expr, v:val)") 84 | endfunction 85 | 86 | 87 | function! s:base.enable_list(...) 88 | let window = get(a:, 1, s:Gift.uniq_winnr()) 89 | return keys(get(self.variables.id_list, window, {})) 90 | endfunction 91 | 92 | 93 | function! s:base.delete(name) 94 | if !self.is_added(a:name) 95 | return -1 96 | endif 97 | unlet! self.variables.hl_list[a:name] 98 | endfunction 99 | 100 | 101 | function! s:base.delete_by(expr) 102 | return map(self.to_list_by(a:expr), "self.delete(v:val.name)") 103 | endfunction 104 | 105 | 106 | function! s:base.delete_all() 107 | for name in self.hl_list() 108 | call self.delete(name) 109 | endfor 110 | endfunction 111 | 112 | 113 | function! s:base.get_hl_id(name, ...) 114 | let window = get(a:, 1, s:Gift.uniq_winnr()) 115 | return get(get(self.variables.id_list, window, {}), a:name, "") 116 | endfunction 117 | 118 | 119 | function! s:base.is_enabled(name, ...) 120 | let window = get(a:, 1, s:Gift.uniq_winnr()) 121 | return self.get_hl_id(a:name, window) != "" 122 | endfunction 123 | 124 | 125 | function! s:base.enable(name) 126 | let hl = get(self.variables.hl_list, a:name, {}) 127 | if empty(hl) 128 | return -1 129 | endif 130 | if self.is_enabled(a:name) 131 | call self.disable(a:name) 132 | endif 133 | let winnr = s:Gift.uniq_winnr() 134 | if !has_key(self.variables.id_list, winnr) 135 | let self.variables.id_list[winnr] = {} 136 | endif 137 | let self.variables.id_list[winnr][a:name] = matchadd(hl.group, hl.pattern, hl.priority) 138 | endfunction 139 | 140 | 141 | function! s:base.enable_all() 142 | for name in self.hl_list() 143 | call self.enable(name) 144 | endfor 145 | endfunction 146 | 147 | 148 | function! s:base.disable(name) 149 | if !self.is_enabled(a:name) 150 | return -1 151 | endif 152 | let id = -1 153 | silent! let id = matchdelete(self.get_hl_id(a:name)) 154 | if id == -1 155 | return -1 156 | endif 157 | let winnr = get(a:, 1, s:Gift.uniq_winnr()) 158 | unlet! self.variables.id_list[winnr][a:name] 159 | endfunction 160 | 161 | 162 | function! s:base.disable_all() 163 | for name in self.enable_list() 164 | call self.disable(name) 165 | endfor 166 | endfunction 167 | 168 | 169 | function! s:base.update(name) 170 | call self.disable(a:name) 171 | call self.enable(a:name) 172 | endfunction 173 | 174 | 175 | function! s:base.update_all() 176 | call self.disable_all() 177 | call self.enable_all() 178 | endfunction 179 | 180 | 181 | function! s:base.highlight(name, group, pattern, ...) 182 | let priority = get(a:, 1, 10) 183 | let result = self.add(a:name, a:group, a:pattern, priority) 184 | call self.enable(result.name) 185 | return result 186 | endfunction 187 | 188 | 189 | function! s:base.clear(name) 190 | call self.disable(a:name) 191 | call self.delete(a:name) 192 | endfunction 193 | 194 | 195 | function! s:base.clear_all() 196 | call self.disable_all() 197 | call self.delete_all() 198 | endfunction 199 | 200 | 201 | function! s:base.as_windo() 202 | return self.windo 203 | endfunction 204 | 205 | 206 | function! s:make() 207 | let result = deepcopy(s:base) 208 | let result.windo = s:Window.as_windo(result) 209 | return result 210 | endfunction 211 | 212 | 213 | let s:global = deepcopy(s:base) 214 | let s:funcs = keys(filter(copy(s:global), "type(v:val) == type(function('tr'))")) 215 | 216 | for s:name in s:funcs 217 | execute 218 | \ "function! s:" . s:name . "(...) \n" 219 | \ "return call(s:global." . s:name . ", a:000, s:global) \n" 220 | \ "endfunction" 221 | endfor 222 | unlet s:name 223 | 224 | 225 | function! s:_init() 226 | let s:global.windo = s:Window.as_windo(s:global) 227 | endfunction 228 | 229 | " function! s:matchadd(...) 230 | " return { 231 | " \ "id" : call("matchadd", a:000), 232 | " \ "bufnr" : bufnr("%"), 233 | " \ } 234 | " endfunction 235 | " 236 | " 237 | " function! s:matchdelete(id) 238 | " if empty(a:id) 239 | " return -1 240 | " endif 241 | " return s:Buffer.execute(a:id.bufnr, "call matchdelete(" . a:id.id . ")") 242 | " endfunction 243 | 244 | 245 | let &cpo = s:save_cpo 246 | unlet s:save_cpo 247 | -------------------------------------------------------------------------------- /autoload/vital/_over/Coaster/Search.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Coaster#Search#import() abort', printf("return map({'region': '', '_vital_depends': '', 'pos_ignore_syntaxes': '', 'pattern_by_range': '', 'pattern_in_region': '', 'pattern_in_region_char': '', 'pattern_in_region_block': '', 'pattern_in_region_line': '', 'region_pair': '', 'pattern_in_range': '', 'count': '', 'text_by_pattern': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | 16 | function! s:_vital_loaded(V) 17 | let s:V = a:V 18 | let s:Buffer = s:V.import("Coaster.Buffer") 19 | endfunction 20 | 21 | 22 | function! s:_vital_depends() 23 | return [ 24 | \ ] 25 | endfunction 26 | 27 | 28 | function! s:region(pattern, ...) 29 | let flag_first = get(a:, 1, "") 30 | let flag_last = get(a:, 2, "") 31 | return [searchpos(a:pattern, flag_first), searchpos(a:pattern, flag_last)] 32 | endfunction 33 | 34 | 35 | function! s:region_pair(fist, last, ...) 36 | " todo 37 | endfunction 38 | 39 | 40 | function! s:pattern_in_region_char(first, last, pattern) 41 | if a:first == a:last 42 | return printf('\%%%dl\%%%dc', a:first[0], a:first[1]) 43 | elseif a:first[0] == a:last[0] 44 | return printf('\%%%dl\%%>%dc\%%(%s\M\)\%%<%dc', a:first[0], a:first[1]-1, a:pattern, a:last[1]+1) 45 | elseif a:last[0] - a:first[0] == 1 46 | return printf('\%%%dl\%%(%s\M\)\%%>%dc', a:first[0], a:pattern, a:first[1]-1) 47 | \ . "\\|" . printf('\%%%dl\%%(%s\M\)\%%<%dc', a:last[0], a:pattern, a:last[1]+1) 48 | else 49 | return printf('\%%%dl\%%(%s\M\)\%%>%dc', a:first[0], a:pattern, a:first[1]-1) 50 | \ . "\\|" . printf('\%%>%dl\%%(%s\M\)\%%<%dl', a:first[0], a:pattern, a:last[0]) 51 | \ . "\\|" . printf('\%%%dl\%%(%s\M\)\%%<%dc', a:last[0], a:pattern, a:last[1]+1) 52 | endif 53 | endfunction 54 | 55 | 56 | " function! s:pattern_in_region_char(first, last, pattern) 57 | " if a:first == a:last 58 | " return printf('\%%%dl\%%%dv', a:first[0], a:first[1]) 59 | " elseif a:first[0] == a:last[0] 60 | " return printf('\%%%dl\%%>%dv\%%(%s\M\)\%%<%dv', a:first[0], a:first[1]-1, a:pattern, a:last[1]+1) 61 | " elseif a:last[0] - a:first[0] == 1 62 | " return printf('\%%%dl\%%(%s\M\)\%%>%dv', a:first[0], a:pattern, a:first[1]-1) 63 | " \ . "\\|" . printf('\%%%dl\%%(%s\M\)\%%<%dv', a:last[0], a:pattern, a:last[1]+1) 64 | " else 65 | " return printf('\%%%dl\%%(%s\M\)\%%>%dv', a:first[0], a:pattern, a:first[1]-1) 66 | " \ . "\\|" . printf('\%%>%dl\%%(%s\M\)\%%<%dl', a:first[0], a:pattern, a:last[0]) 67 | " \ . "\\|" . printf('\%%%dl\%%(%s\M\)\%%<%dv', a:last[0], a:pattern, a:last[1]+1) 68 | " endif 69 | " endfunction 70 | 71 | 72 | 73 | 74 | function! s:pattern_in_region_line(first, last, pattern) 75 | return printf('\%%>%dl\%%(%s\M\)\%%<%dl', a:first[0]-1, a:pattern, a:last[0]+1) 76 | endfunction 77 | 78 | 79 | function! s:pattern_in_region_block(first, last, pattern) 80 | return join(map(range(a:first[0], a:last[0]), "s:pattern_in_region_char([v:val, a:first[1]], [v:val, a:last[1]], a:pattern)"), '\|') 81 | endfunction 82 | 83 | 84 | function! s:pattern_in_region(wise, first, last, ...) 85 | let pattern = get(a:, 1, "") 86 | if a:wise ==# "v" 87 | return s:pattern_in_region_char(a:first, a:last, pattern) 88 | elseif a:wise ==# "V" 89 | return s:pattern_in_region_line(a:first, a:last, pattern) 90 | elseif a:wise ==# "\" 91 | return s:pattern_in_region_block(a:first, a:last, pattern) 92 | endif 93 | endfunction 94 | 95 | function! s:pattern_in_range(...) 96 | return call("s:pattern_in_region", a:000) 97 | endfunction 98 | 99 | 100 | function! s:pattern_by_range(wise, first, last) 101 | return s:pattern_in_range(a:wise, a:first, a:last, '.\{-}') 102 | endfunction 103 | 104 | 105 | function! s:text_by_pattern(pattern, ...) 106 | let flag = get(a:, 1, "") 107 | let [first, last] = s:region(a:pattern, "c" . flag, "ce" . flag) 108 | if first == [0, 0] || last == [0, 0] 109 | endif 110 | let result = s:Buffer.get_text_from_region([0] + first + [0], [0] + last + [0], "v") 111 | return result 112 | endfunction 113 | 114 | 115 | function! s:_syntax_name(pos) 116 | return synIDattr(synIDtrans(synID(a:pos[0], a:pos[1], 1)), 'name') 117 | endfunction 118 | 119 | 120 | " log : http://lingr.com/room/vim/archives/2014/08/15#message-19938628 121 | function! s:pos_ignore_syntaxes(pattern, syntaxes, ...) 122 | let old_pos = getpos(".") 123 | let old_view = winsaveview() 124 | let flag = substitute(get(a:, 1, ""), 'n', "", "g") 125 | try 126 | while 1 127 | let pos = searchpos(a:pattern, flag . "W") 128 | if pos == [0, 0] || index(a:syntaxes, s:_syntax_name(pos)) == -1 129 | return pos 130 | endif 131 | endwhile 132 | finally 133 | if get(a:, 1, "") =~# "n" 134 | call setpos(".", old_pos) 135 | call winrestview(old_view) 136 | endif 137 | endtry 138 | endfunction 139 | 140 | 141 | function! s:count(pattern) 142 | return matchstr(s:M.capture('%s/' . a:pattern . '//n'), '\d\+\ze') 143 | endfunction 144 | 145 | 146 | let &cpo = s:save_cpo 147 | unlet s:save_cpo 148 | -------------------------------------------------------------------------------- /autoload/vital/_over/Coaster/Window.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Coaster#Window#import() abort', printf("return map({'as_windo': '', '_vital_depends': '', 'windo': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:_vital_loaded(V) 16 | let s:V = a:V 17 | let s:Buffer = a:V.import("Vim.Buffer") 18 | endfunction 19 | 20 | 21 | function! s:_vital_depends() 22 | return [ 23 | \ "Vim.Buffer", 24 | \ ] 25 | endfunction 26 | 27 | 28 | function! s:windo(func, args, ...) 29 | let dict = get(a:, 1, {}) 30 | if len(tabpagebuflist()) <= 1 || s:Buffer.is_cmdwin() 31 | return call(a:func, a:args, dict) 32 | endif 33 | let pre_winnr = winnr() 34 | 35 | noautocmd windo call call(a:func, a:args, dict) 36 | 37 | if pre_winnr == winnr() 38 | return 39 | endif 40 | noautocmd execute pre_winnr . "wincmd w" 41 | endfunction 42 | 43 | 44 | function! s:as_windo(base) 45 | let windo = {} 46 | let windo.obj = a:base 47 | for [key, Value] in items(a:base) 48 | if type(function("tr")) == type(Value) 49 | execute 50 | \ "function! windo.". key. "(...)\n" 51 | \ " return s:windo(self.obj." . key . ", a:000, self.obj)\n" 52 | \ "endfunction" 53 | endif 54 | unlet Value 55 | endfor 56 | return windo 57 | endfunction 58 | 59 | 60 | 61 | let &cpo = s:save_cpo 62 | unlet s:save_cpo 63 | -------------------------------------------------------------------------------- /autoload/vital/_over/Data/Dict.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Data#Dict#import() abort', printf("return map({'_vital_depends': '', 'clear': '', 'max_by': '', 'foldl': '', 'pick': '', 'from_list': '', 'swap': '', 'omit': '', 'min_by': '', 'foldr': '', 'make_index': '', 'make': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | " Utilities for dictionary. 11 | 12 | let s:save_cpo = &cpo 13 | set cpo&vim 14 | 15 | function! s:_vital_loaded(V) abort 16 | let s:t = a:V.import('Vim.Type').types 17 | endfunction 18 | 19 | function! s:_vital_depends() abort 20 | return ['Vim.Type'] 21 | endfunction 22 | 23 | 24 | function! s:_ensure_key(key) abort 25 | let t = type(a:key) 26 | if t != s:t.string && t != s:t.number 27 | throw 'vital: Data.Dict: Invalid key: ' . string(a:key) 28 | endif 29 | endfunction 30 | 31 | function! s:from_list(list) abort 32 | let dict = {} 33 | let i = 0 34 | let len = len(a:list) 35 | while i < len 36 | if type(a:list[i]) == s:t.list 37 | let key_value = a:list[i] 38 | if len(key_value) != 2 39 | throw 'vital: Data.Dict: Invalid key-value pair index at ' . i 40 | endif 41 | call s:_ensure_key(key_value[0]) 42 | let dict[key_value[0]] = key_value[1] 43 | let i += 1 44 | else 45 | if len <= i + 1 46 | throw 'vital: Data.Dict: Invalid key-value pair index at ' . i 47 | endif 48 | call s:_ensure_key(a:list[i]) 49 | let dict[a:list[i]] = a:list[i + 1] 50 | let i += 2 51 | endif 52 | endwhile 53 | return dict 54 | endfunction 55 | 56 | " Makes a dict from keys and values 57 | function! s:make(keys, values, ...) abort 58 | let dict = {} 59 | let fill = a:0 ? a:1 : 0 60 | for i in range(len(a:keys)) 61 | let key = type(a:keys[i]) == s:t.string ? a:keys[i] : string(a:keys[i]) 62 | if key ==# '' 63 | throw "vital: Data.Dict: Can't use an empty string for key." 64 | endif 65 | let dict[key] = get(a:values, i, fill) 66 | endfor 67 | return dict 68 | endfunction 69 | 70 | " Swaps keys and values 71 | function! s:swap(dict) abort 72 | return s:make(values(a:dict), keys(a:dict)) 73 | endfunction 74 | 75 | " Makes a index dict from a list 76 | function! s:make_index(list, ...) abort 77 | let value = a:0 ? a:1 : 1 78 | return s:make(a:list, [], value) 79 | endfunction 80 | 81 | function! s:pick(dict, keys) abort 82 | let new_dict = {} 83 | for key in a:keys 84 | if has_key(a:dict, key) 85 | let new_dict[key] = a:dict[key] 86 | endif 87 | endfor 88 | return new_dict 89 | endfunction 90 | 91 | function! s:omit(dict, keys) abort 92 | let new_dict = copy(a:dict) 93 | for key in a:keys 94 | if has_key(a:dict, key) 95 | call remove(new_dict, key) 96 | endif 97 | endfor 98 | return new_dict 99 | endfunction 100 | 101 | function! s:clear(dict) abort 102 | for key in keys(a:dict) 103 | call remove(a:dict, key) 104 | endfor 105 | return a:dict 106 | endfunction 107 | 108 | function! s:_max_by(dict, expr) abort 109 | let dict = s:swap(map(copy(a:dict), a:expr)) 110 | let key = dict[max(keys(dict))] 111 | return [key, a:dict[key]] 112 | endfunction 113 | 114 | function! s:max_by(dict, expr) abort 115 | if empty(a:dict) 116 | throw 'vital: Data.Dict: Empty dictionary' 117 | endif 118 | return s:_max_by(a:dict, a:expr) 119 | endfunction 120 | 121 | function! s:min_by(dict, expr) abort 122 | if empty(a:dict) 123 | throw 'vital: Data.Dict: Empty dictionary' 124 | endif 125 | return s:_max_by(a:dict, '-(' . a:expr . ')') 126 | endfunction 127 | 128 | function! s:_foldl(f, init, xs) abort 129 | let memo = a:init 130 | for [k, v] in a:xs 131 | let expr = substitute(a:f, 'v:key', string(k), 'g') 132 | let expr = substitute(expr, 'v:val', string(v), 'g') 133 | let expr = substitute(expr, 'v:memo', string(memo), 'g') 134 | unlet memo 135 | let memo = eval(expr) 136 | endfor 137 | return memo 138 | endfunction 139 | 140 | function! s:foldl(f, init, dict) abort 141 | return s:_foldl(a:f, a:init, items(a:dict)) 142 | endfunction 143 | 144 | function! s:foldr(f, init, dict) abort 145 | return s:_foldl(a:f, a:init, reverse(items(a:dict))) 146 | endfunction 147 | 148 | let &cpo = s:save_cpo 149 | unlet s:save_cpo 150 | 151 | " vim:set et ts=2 sts=2 sw=2 tw=0: 152 | -------------------------------------------------------------------------------- /autoload/vital/_over/Gift.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Gift#import() abort', printf("return map({'flatten': '', 'uniq_tabpagenr': '', 'tabpagewinnr_list': '', 'execute': '', 'getwinvar': '', 'winnr': '', 'jump_window': '', '_vital_depends': '', 'uniq_winnr': '', 'setwinvar': '', 'find': '', 'openable_bufnr_list': '', 'to_fullpath': '', 'bufnr': '', 'set_current_window': '', 'tabpagewinnr': '', 'close_window': '', 'close_window_by': '', 'uniq_winnr_list': '', '_vital_loaded': '', 'find_by': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:_vital_loaded(V) 16 | let s:V = a:V 17 | let s:Window = s:V.import("Gift.Window") 18 | let s:Tabpage = s:V.import("Gift.Tabpage") 19 | endfunction 20 | 21 | 22 | function! s:_vital_depends() 23 | return [ 24 | \ "Gift.Window", 25 | \ "Gift.Tabpage", 26 | \ ] 27 | endfunction 28 | 29 | 30 | function! s:to_fullpath(filename) 31 | let name = substitute(fnamemodify(a:filename, ":p"), '\', '/', "g") 32 | if filereadable(name) 33 | return name 34 | else 35 | return a:filename 36 | endif 37 | endfunction 38 | 39 | 40 | function! s:flatten(list) 41 | return eval(join(a:list, "+")) 42 | endfunction 43 | 44 | 45 | function! s:bufnr(expr) 46 | return type(a:expr) == type([]) 47 | \ ? s:bufnr(s:uniq_winnr(a:expr[1], a:expr[0])) 48 | \ : s:Window.bufnr(a:expr) 49 | endfunction 50 | 51 | 52 | function! s:openable_bufnr_list() 53 | return map(s:tabpagewinnr_list(), "s:bufnr([v:val[0], v:val[1]])") 54 | endfunction 55 | 56 | 57 | function! s:tabpagewinnr(...) 58 | return a:0 == 0 ? s:tabpagewinnr(s:uniq_winnr()) 59 | \ : s:Window.tabpagewinnr(a:1) 60 | endfunction 61 | 62 | 63 | function! s:tabpagewinnr_list() 64 | return s:Window.tabpagewinnr_list() 65 | " return s:flatten(map(range(1, tabpagenr("$")), "map(range(1, tabpagewinnr(v:val, '$')), '['.v:val.', v:val]')")) 66 | endfunction 67 | 68 | 69 | 70 | function! s:uniq_winnr(...) 71 | return call(s:Window.uniq_nr, a:000, s:Window) 72 | endfunction 73 | 74 | 75 | function! s:winnr(uniqnr) 76 | let [tabnr, winnr] = s:Window.tabpagewinnr(a:uniqnr) 77 | return winnr 78 | endfunction 79 | 80 | 81 | function! s:uniq_winnr_list(...) 82 | return map(s:tabpagewinnr_list(), "s:uniq_winnr(v:val[1], v:val[0])") 83 | endfunction 84 | 85 | 86 | 87 | function! s:find(expr) 88 | let gift_find_result = [] 89 | for [tabnr, winnr] in s:tabpagewinnr_list() 90 | let bufnr = s:bufnr([tabnr, winnr]) 91 | if eval(a:expr) 92 | call add(gift_find_result, [tabnr, winnr]) 93 | endif 94 | endfor 95 | return gift_find_result 96 | endfunction 97 | 98 | 99 | function! s:find_by(expr) 100 | if type(a:expr) == type(function("tr")) 101 | return filter(s:tabpagewinnr_list(), "a:expr(s:bufnr([v:val[0], v:val[1]]), v:val[0], v:val[1])") 102 | else 103 | return s:find(a:expr) 104 | endif 105 | endfunction 106 | 107 | 108 | function! s:jump_window(expr) 109 | return type(a:expr) == type([]) 110 | \ ? s:jump_window(s:uniq_winnr(a:expr[1], a:expr[0])) 111 | \ : s:Window.jump(a:expr) 112 | endfunction 113 | 114 | 115 | function! s:set_current_window(expr) 116 | return s:jump_window(a:expr) 117 | endfunction 118 | 119 | 120 | function! s:close_window(expr, ...) 121 | let close_cmd = get(a:, 1, "close") 122 | return type(a:expr) == type([]) 123 | \ ? s:close_window(s:uniq_winnr(a:expr[1], a:expr[0]), close_cmd) 124 | \ : s:Window.close(a:expr, close_cmd) 125 | endfunction 126 | 127 | 128 | function! s:close_window_by(expr, ...) 129 | let close_cmd = get(a:, 1, "close") 130 | return map(map(s:find(a:expr), "s:uniq_winnr(v:val[1], v:val[0])"), 's:close_window(v:val, close_cmd)') 131 | endfunction 132 | 133 | 134 | function! s:execute(expr, execute) 135 | return type(a:expr) == type([]) 136 | \ ? s:execute(s:uniq_winnr(a:expr[1], a:expr[0]), a:execute) 137 | \ : s:Window.execute(a:expr, a:execute) 138 | endfunction 139 | 140 | 141 | function! s:getwinvar(uniq_winnr, varname, ...) 142 | let def = get(a:, 1, "") 143 | return s:Window.getvar(a:uniq_winnr, a:varname, def) 144 | endfunction 145 | 146 | 147 | function! s:setwinvar(uniq_winnr, varname, val) 148 | return s:Window.setvar(a:uniq_winnr, a:varname, a:val) 149 | endfunction 150 | 151 | 152 | function! s:uniq_tabpagenr(...) 153 | return call(s:Tabpage.uniq_nr, a:000, s:Tabpage) 154 | endfunction 155 | 156 | 157 | 158 | let &cpo = s:save_cpo 159 | unlet s:save_cpo 160 | -------------------------------------------------------------------------------- /autoload/vital/_over/Gift/Tabpage.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Gift#Tabpage#import() abort', printf("return map({'uniq_nr': '', 'make_uniq_nr': '', 'numbering': '', 'set_prefix': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | let s:prefix = expand(":p:h:h:t") 16 | function! s:set_prefix(prefix) 17 | let s:prefix = a:prefix 18 | endfunction 19 | 20 | 21 | let s:uniq_counter = 0 22 | function! s:make_uniq_nr() 23 | let s:uniq_counter += 1 24 | return s:uniq_counter 25 | endfunction 26 | 27 | 28 | function! s:numbering(...) 29 | let tabnr = get(a:, 1, tabpagenr()) 30 | let uniq_nr = s:make_uniq_nr() 31 | call settabvar(tabnr, s:prefix . "_gift_uniq_tabpagenr", uniq_nr) 32 | return uniq_nr 33 | endfunction 34 | 35 | 36 | function! s:uniq_nr(...) 37 | let tabnr = get(a:, 1, tabpagenr()) 38 | let uniq_nr = get(gettabvar(tabnr, ""), s:prefix . "_gift_uniq_tabpagenr", -1) 39 | if uniq_nr == -1 40 | let uniq_nr = s:numbering(tabnr) 41 | endif 42 | return uniq_nr 43 | endfunction 44 | 45 | 46 | let &cpo = s:save_cpo 47 | unlet s:save_cpo 48 | -------------------------------------------------------------------------------- /autoload/vital/_over/Gift/Window.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Gift#Window#import() abort', printf("return map({'flatten': '', 'tabpagewinnr_list': '', 'execute': '', 'close': '', 'numbering': '', 'set_prefix': '', '_vital_depends': '', 'exists': '', 'jump': '', 'setvar': '', 'bufnr': '', 'uniq_nr': '', 'make_uniq_nr': '', 'tabpagewinnr': '', 'getvar': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:_vital_loaded(V) 16 | let s:V = a:V 17 | let s:Tabpage = s:V.import("Gift.Tabpage") 18 | endfunction 19 | 20 | 21 | function! s:_vital_depends() 22 | return [ 23 | \ "Gift.Tabpage", 24 | \ ] 25 | endfunction 26 | 27 | 28 | let s:prefix = expand(":p:h:h:t") 29 | function! s:set_prefix(prefix) 30 | let s:prefix = a:prefix 31 | endfunction 32 | 33 | function! s:flatten(list) 34 | return eval(join(a:list, "+")) 35 | endfunction 36 | 37 | 38 | function! s:tabpagewinnr_list() 39 | return s:flatten(map(range(1, tabpagenr("$")), "map(range(1, tabpagewinnr(v:val, '$')), '['.v:val.', v:val]')")) 40 | endfunction 41 | 42 | 43 | if !exists("s:uniq_counter") 44 | let s:uniq_counter = 0 45 | endif 46 | function! s:make_uniq_nr() 47 | let s:uniq_counter += 1 48 | return s:uniq_counter 49 | endfunction 50 | 51 | 52 | function! s:numbering(...) 53 | let winnr = get(a:, 1, winnr()) 54 | let tabnr = get(a:, 2, tabpagenr()) 55 | let uniq_nr = s:make_uniq_nr() 56 | call settabwinvar(tabnr, winnr, s:prefix . "_gift_uniq_winnr", uniq_nr) 57 | return uniq_nr 58 | endfunction 59 | 60 | 61 | function! s:uniq_nr(...) 62 | let winnr = get(a:, 1, winnr()) 63 | let tabnr = get(a:, 2, tabpagenr()) 64 | let uniq_nr = get(gettabwinvar(tabnr, winnr, ""), s:prefix . "_gift_uniq_winnr", -1) 65 | if uniq_nr == -1 66 | let uniq_nr = s:numbering(winnr, tabnr) 67 | endif 68 | return uniq_nr 69 | endfunction 70 | 71 | 72 | function! s:exists(nr) 73 | let [tabnr, winnr] = s:tabpagewinnr(a:nr) 74 | return tabnr != 0 && winnr != 0 75 | endfunction 76 | 77 | 78 | function! s:tabpagewinnr(nr) 79 | if a:nr == 0 80 | return s:tabpagewinnr(s:uniq_nr()) 81 | endif 82 | let tabwinnrs = s:tabpagewinnr_list() 83 | for [tabnr, winnr] in tabwinnrs 84 | if s:uniq_nr(winnr, tabnr) == a:nr 85 | return [tabnr, winnr] 86 | endif 87 | endfor 88 | return [0, 0] 89 | endfunction 90 | 91 | 92 | function! s:getvar(nr, varname, ...) 93 | let def = get(a:, 1, "") 94 | let [tabnr, winnr] = s:tabpagewinnr(a:nr) 95 | return get(gettabwinvar(tabnr, winnr, ""), a:varname, def) 96 | endfunction 97 | 98 | 99 | function! s:setvar(nr, varname, val) 100 | let [tabnr, winnr] = s:tabpagewinnr(a:nr) 101 | if tabnr == 0 || winnr == 0 102 | return 103 | endif 104 | return settabwinvar(tabnr, winnr, a:varname, a:val) 105 | endfunction 106 | 107 | 108 | function! s:bufnr(nr) 109 | let [tabnr, winnr] = s:tabpagewinnr(a:nr) 110 | return winnr >= 1 ? get(tabpagebuflist(tabnr), winnr-1, -1) : -1 111 | endfunction 112 | 113 | 114 | 115 | function! s:jump(nr) 116 | let [tabnr, winnr] = s:tabpagewinnr(a:nr) 117 | if tabnr == 0 || winnr == 0 118 | return -1 119 | endif 120 | 121 | execute "tabnext" tabnr 122 | execute winnr . "wincmd w" 123 | endfunction 124 | 125 | 126 | function! s:close(nr, close_cmd) 127 | call s:execute(a:nr, a:close_cmd) 128 | " let current = gift#uniq_winnr() 129 | " let result = s:jump(a:nr) 130 | " if result == -1 131 | " return -1 132 | " endif 133 | " execute a:close_cmd 134 | " return s:jump(current) 135 | endfunction 136 | 137 | 138 | function! s:execute(nr, expr) 139 | let current = s:uniq_nr() 140 | let result = s:jump(a:nr) 141 | if result == -1 142 | return -1 143 | endif 144 | execute a:expr 145 | return s:jump(current) 146 | endfunction 147 | 148 | 149 | 150 | 151 | 152 | let &cpo = s:save_cpo 153 | unlet s:save_cpo 154 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#import() abort', printf("return map({'error': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:error(text) 16 | echohl ErrorMsg 17 | echom "vital-over:" . a:text 18 | echohl None 19 | endfunction 20 | 21 | 22 | let &cpo = s:save_cpo 23 | unlet s:save_cpo 24 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#import() abort', printf("return map({'_vital_depends': '', 'make_standard_search_back': '', 'get_module': '', 'make_standard_search': '', 'make_standard': '', 'make_module': '', 'make_default': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:_vital_loaded(V) 16 | let s:V = a:V 17 | let s:Maker = s:V.import("Over.Commandline.Maker") 18 | let s:Modules = s:V.import("Over.Commandline.Modules") 19 | endfunction 20 | 21 | 22 | function! s:_vital_depends() 23 | return [ 24 | \ "Over.Commandline.Maker", 25 | \ "Over.Commandline.Modules", 26 | \ "Over.Commandline.Modules.All", 27 | \ ] 28 | endfunction 29 | 30 | 31 | function! s:make_module(...) 32 | return call(s:Modules.make, a:000, s:Modules) 33 | endfunction 34 | 35 | 36 | function! s:get_module(...) 37 | return call(s:Modules.get, a:000, s:Modules) 38 | endfunction 39 | 40 | 41 | function! s:make_default(...) 42 | return call(s:Maker.default, a:000, s:Maker) 43 | endfunction 44 | 45 | 46 | function! s:make_standard(...) 47 | return call(s:Maker.standard, a:000, s:Maker) 48 | endfunction 49 | 50 | 51 | function! s:make_standard_search(...) 52 | return call(s:Maker.standard_search, a:000, s:Maker) 53 | endfunction 54 | 55 | 56 | function! s:make_standard_search_back(...) 57 | return call(s:Maker.standard_search_back, a:000, s:Maker) 58 | endfunction 59 | 60 | let &cpo = s:save_cpo 61 | unlet s:save_cpo 62 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Maker.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Maker#import() abort', printf("return map({'plain': '', '_vital_depends': '', 'standard_search': '', 'standard': '', 'standard_search_back': '', 'default': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | let s:modules = [ 15 | \ "Scroll", 16 | \ "CursorMove", 17 | \ "Delete", 18 | \ "HistAdd", 19 | \ "History", 20 | \ "Cancel", 21 | \ "Execute", 22 | \ "NoInsert", 23 | \ "InsertRegister", 24 | \ "Redraw", 25 | \ "DrawCommandline", 26 | \ "ExceptionExit", 27 | \ "ExceptionMessage", 28 | \] 29 | 30 | 31 | function! s:_vital_loaded(V) 32 | let s:V = a:V 33 | let s:Cmdline = s:V.import("Over.Commandline.Base") 34 | let s:Modules = s:V.import("Over.Commandline.Modules") 35 | endfunction 36 | 37 | 38 | function! s:_vital_depends() 39 | return [ 40 | \ "Over.Commandline.Base", 41 | \ "Over.Commandline.Modules", 42 | \ ] + map(copy(s:modules), "'Over.Commandline.Modules.' . v:val") 43 | endfunction 44 | 45 | 46 | function! s:default(...) 47 | return call(s:Cmdline.make, a:000, s:Cmdline) 48 | endfunction 49 | 50 | 51 | function! s:plain() 52 | return s:Cmdline.plain() 53 | endfunction 54 | 55 | 56 | function! s:standard(...) 57 | let result = call(s:Cmdline.make, a:000, s:Cmdline) 58 | call result.connect("Execute") 59 | call result.connect("Cancel") 60 | call result.connect("Delete") 61 | call result.connect("CursorMove") 62 | call result.connect("HistAdd") 63 | call result.connect("History") 64 | call result.connect("InsertRegister") 65 | call result.connect(s:Modules.get("NoInsert").make_special_chars()) 66 | call result.connect("Redraw") 67 | call result.connect("DrawCommandline") 68 | call result.connect("ExceptionExit") 69 | call result.connect("ExceptionMessage") 70 | call result.connect(s:Modules.get("KeyMapping").make_vim_cmdline_mapping()) 71 | call result.connect("Digraphs") 72 | call result.connect("LiteralInsert") 73 | 74 | return result 75 | endfunction 76 | 77 | 78 | function! s:standard_search(...) 79 | let result = s:standard(get(a:, 1, "/")) 80 | call result.connect(s:Modules.get("Execute").make_search("/")) 81 | call result.connect(s:Modules.make("HistAdd", "/")) 82 | call result.connect(s:Modules.make("History", "/")) 83 | return result 84 | endfunction 85 | 86 | 87 | function! s:standard_search_back(...) 88 | let result = s:standard(get(a:, 1, "?")) 89 | call result.connect(s:Modules.get("Execute").make_search("?")) 90 | call result.connect(s:Modules.make("HistAdd", "/")) 91 | call result.connect(s:Modules.make("History", "/")) 92 | return result 93 | endfunction 94 | 95 | 96 | let &cpo = s:save_cpo 97 | unlet s:save_cpo 98 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#import() abort', printf("return map({'get': '', 'make': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:_vital_loaded(V) 16 | let s:V = a:V 17 | endfunction 18 | 19 | 20 | function! s:get(name) 21 | if exists("s:" . a:name) 22 | return s:{a:name} 23 | endif 24 | let s:{a:name} = s:V.import('Over.Commandline.Modules.' . a:name) 25 | return s:{a:name} 26 | endfunction 27 | 28 | 29 | function! s:make(name, ...) 30 | let module = s:get(a:name) 31 | return call(module.make, a:000, module) 32 | endfunction 33 | 34 | 35 | let &cpo = s:save_cpo 36 | unlet s:save_cpo 37 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/All.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#All#import() abort', printf("return map({'_vital_depends': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | let s:modules = map(split(globpath(expand(":p:h"), "/*.vim"), "\n"), "fnamemodify(v:val, ':t:r')") 16 | 17 | 18 | function! s:_vital_depends() 19 | return map(copy(s:modules), "'Over.Commandline.Modules.' . v:val") 20 | endfunction 21 | 22 | 23 | let &cpo = s:save_cpo 24 | unlet s:save_cpo 25 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/AsyncUpdate.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#AsyncUpdate#import() abort', printf("return map({'make': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | function! s:_vital_loaded(V) 15 | let s:V = a:V 16 | let s:Base = s:V.import("Over.Commandline.Base") 17 | endfunction 18 | 19 | 20 | let s:module = { 21 | \ "name" : "AsyncUpdate" 22 | \} 23 | 24 | function! s:module.on_enter(cmdline) 25 | function! a:cmdline.__update() 26 | call self.callevent("on_update") 27 | try 28 | if !getchar(1) 29 | return 30 | endif 31 | call self.__inputting() 32 | catch /^Vim:Interrupt$/ 33 | call self.__input("\") 34 | endtry 35 | 36 | call self.draw() 37 | endfunction 38 | endfunction 39 | 40 | 41 | function! s:make() 42 | return deepcopy(s:module) 43 | endfunction 44 | 45 | 46 | let &cpo = s:save_cpo 47 | unlet s:save_cpo 48 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/BufferComplete.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#BufferComplete#import() abort', printf("return map({'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:_uniq(list) 16 | let dict = {} 17 | for _ in a:list 18 | let dict[_] = 0 19 | endfor 20 | return keys(dict) 21 | endfunction 22 | 23 | 24 | let s:module = { 25 | \ "name" : "BufferComplete", 26 | \} 27 | 28 | 29 | function! s:_buffer_complete() 30 | return sort(s:_uniq(filter(split(join(getline(1, '$')), '\W'), '!empty(v:val)')), 1) 31 | endfunction 32 | 33 | 34 | function! s:_parse_line(line) 35 | let keyword = matchstr(a:line, '\zs\w\+\ze$') 36 | let pos = strchars(a:line) - strchars(keyword) 37 | return [pos, keyword] 38 | endfunction 39 | 40 | 41 | function! s:_as_statusline(list, count) 42 | if empty(a:list) 43 | return 44 | endif 45 | let hl_none = "%#StatusLine#" 46 | let hl_select = "%#StatusLineNC#" 47 | let tail = " > " 48 | let result = a:list[0] 49 | let pos = 0 50 | for i in range(1, len(a:list)-1) 51 | if strdisplaywidth(result . " " . a:list[i]) > &columns - len(tail) 52 | if a:count < i 53 | break 54 | else 55 | let pos = -i 56 | endif 57 | let result = a:list[i] 58 | else 59 | let result .= (" " . a:list[i]) 60 | endif 61 | if a:count == i 62 | let pos = pos + i 63 | endif 64 | endfor 65 | return join(map(split(result, " "), 'v:key == pos ? hl_select . v:val . hl_none : v:val')) 66 | endfunction 67 | 68 | 69 | function! s:module.get_complete_words() 70 | return s:_buffer_complete() 71 | endfunction 72 | 73 | 74 | function! s:module.complete(cmdline) 75 | call s:_finish() 76 | let s:old_statusline = &statusline 77 | 78 | let backward = a:cmdline.backward() 79 | let [pos, keyword] = s:_parse_line(backward) 80 | 81 | if !exists("s:complete") 82 | let s:complete = self.get_complete_words() 83 | endif 84 | let s:complete_list = filter(copy(s:complete), 'v:val =~ ''^''.keyword') 85 | if empty(s:complete_list) 86 | return -1 87 | endif 88 | 89 | if pos == 0 90 | let backward = "" 91 | else 92 | let backward = join(split(backward, '\zs')[ : pos-1 ], "") 93 | endif 94 | let s:line = backward . a:cmdline.forward() 95 | let s:pos = pos 96 | call a:cmdline.setline(s:line) 97 | 98 | let s:count = 0 99 | endfunction 100 | 101 | 102 | function! s:_finish() 103 | if exists("s:old_statusline") 104 | let &statusline = s:old_statusline 105 | unlet s:old_statusline 106 | redrawstatus 107 | endif 108 | endfunction 109 | 110 | 111 | function! s:module.on_char_pre(cmdline) 112 | if a:cmdline.is_input("(buffer-complete)") 113 | \ || a:cmdline.is_input("(buffer-complete-prev)") 114 | if self.complete(a:cmdline) == -1 115 | call s:_finish() 116 | call a:cmdline.setchar('') 117 | return 118 | endif 119 | if a:cmdline.is_input("(buffer-complete-prev)") 120 | let s:count = len(s:complete_list) - 1 121 | endif 122 | call a:cmdline.setchar('') 123 | call a:cmdline.tap_keyinput("Completion") 124 | " elseif a:cmdline.is_input("\", "Completion") 125 | elseif a:cmdline.is_input("(buffer-complete)", "Completion") 126 | \ || a:cmdline.is_input("\", "Completion") 127 | call a:cmdline.setchar('') 128 | let s:count += 1 129 | if s:count >= len(s:complete_list) 130 | let s:count = 0 131 | endif 132 | elseif a:cmdline.is_input("(buffer-complete-prev)", "Completion") 133 | \ || a:cmdline.is_input("\", "Completion") 134 | call a:cmdline.setchar('') 135 | let s:count -= 1 136 | if s:count < 0 137 | let s:count = len(s:complete_list) - 1 138 | endif 139 | else 140 | if a:cmdline.untap_keyinput("Completion") 141 | call a:cmdline.callevent("on_char_pre") 142 | endif 143 | call s:_finish() 144 | return 145 | endif 146 | call a:cmdline.setline(s:line) 147 | call a:cmdline.insert(s:complete_list[s:count], s:pos) 148 | if len(s:complete_list) > 1 149 | let &statusline = s:_as_statusline(s:complete_list, s:count) 150 | redrawstatus 151 | endif 152 | if len(s:complete_list) == 1 153 | call a:cmdline.untap_keyinput("Completion") 154 | endif 155 | endfunction 156 | 157 | 158 | function! s:module.on_draw_pre(...) 159 | " redrawstatus 160 | endfunction 161 | 162 | 163 | function! s:module.on_leave(cmdline) 164 | call s:_finish() 165 | unlet! s:complete 166 | endfunction 167 | 168 | function! s:make() 169 | return deepcopy(s:module) 170 | endfunction 171 | 172 | let &cpo = s:save_cpo 173 | unlet s:save_cpo 174 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/Cancel.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#Cancel#import() abort', printf("return map({'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | let s:module = { 15 | \ "name" : "Cancel" 16 | \} 17 | 18 | function! s:module.on_char_pre(cmdline) 19 | if a:cmdline.is_input("\") 20 | \ || a:cmdline.is_input("\") 21 | " call a:cmdline.cancel() 22 | call a:cmdline.exit(1) 23 | call a:cmdline.setchar("") 24 | endif 25 | endfunction 26 | 27 | 28 | function! s:make() 29 | return deepcopy(s:module) 30 | endfunction 31 | 32 | 33 | let &cpo = s:save_cpo 34 | unlet s:save_cpo 35 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/CursorMove.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#CursorMove#import() abort', printf("return map({'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | let s:module = { 16 | \ "name" : "CursorMove" 17 | \} 18 | function! s:module.on_char_pre(cmdline) 19 | if a:cmdline.is_input("\") 20 | call a:cmdline.line.next() 21 | call a:cmdline.setchar('') 22 | elseif a:cmdline.is_input("\") 23 | call a:cmdline.line.prev() 24 | call a:cmdline.setchar('') 25 | elseif a:cmdline.is_input("\") 26 | \ || a:cmdline.is_input("\") 27 | call a:cmdline.setline(0) 28 | call a:cmdline.setchar('') 29 | elseif a:cmdline.is_input("\") 30 | \ || a:cmdline.is_input("\") 31 | call a:cmdline.setline(a:cmdline.line.length()) 32 | call a:cmdline.setchar('') 33 | elseif a:cmdline.is_input("\") 34 | \ || a:cmdline.is_input("\") 35 | call a:cmdline.setline(strridx(a:cmdline.backward()[:-2], ' ') + 1) 36 | call a:cmdline.setchar('') 37 | elseif a:cmdline.is_input("\") 38 | \ || a:cmdline.is_input("\") 39 | let p = stridx(a:cmdline.forward()[1:], ' ') 40 | call a:cmdline.setline(p != -1 ? a:cmdline.line.pos() + p + 2 : a:cmdline.line.length()) 41 | call a:cmdline.setchar('') 42 | endif 43 | endfunction 44 | 45 | 46 | function! s:make() 47 | return deepcopy(s:module) 48 | endfunction 49 | 50 | 51 | let &cpo = s:save_cpo 52 | unlet s:save_cpo 53 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/Delete.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#Delete#import() abort', printf("return map({'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | let s:module = { 16 | \ "name" : "Delete", 17 | \} 18 | function! s:module.on_char_pre(cmdline) 19 | if a:cmdline.is_input("\") 20 | \ || a:cmdline.is_input("\") 21 | if a:cmdline.line.length() == 0 22 | return a:cmdline.exit(1) 23 | else 24 | call a:cmdline.line.remove_prev() 25 | call a:cmdline.setchar('') 26 | endif 27 | elseif a:cmdline.is_input("\") 28 | call a:cmdline.line.remove_pos() 29 | call a:cmdline.setchar('') 30 | elseif a:cmdline.is_input("\") 31 | let word = a:cmdline.backward_word() 32 | let backward = a:cmdline.backward()[ : -strlen(word)-1 ] 33 | call a:cmdline.setline(backward . a:cmdline.line.pos_char() . a:cmdline.forward()) 34 | call a:cmdline.setline(strchars(backward)) 35 | call a:cmdline.setchar('') 36 | elseif a:cmdline.is_input("\") 37 | call a:cmdline.setline(a:cmdline.line.pos_char() . a:cmdline.forward()) 38 | call a:cmdline.setline(0) 39 | call a:cmdline.setchar('') 40 | endif 41 | endfunction 42 | 43 | 44 | function! s:make() 45 | return deepcopy(s:module) 46 | endfunction 47 | 48 | 49 | let &cpo = s:save_cpo 50 | unlet s:save_cpo 51 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/Digraphs.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#Digraphs#import() abort', printf("return map({'capture': '', '_vital_depends': '', 'digraph': '', 'make': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | function! s:_vital_loaded(V) 15 | let s:Input = a:V.import("Over.Input") 16 | endfunction 17 | 18 | 19 | function! s:_vital_depends() 20 | return [ 21 | \ "Over.Input", 22 | \ ] 23 | endfunction 24 | 25 | 26 | let s:module = { 27 | \ "name" : "Digraphs", 28 | \ "digraphs" : {} 29 | \} 30 | 31 | function! s:capture(cmd) 32 | let verbose_save = &verbose 33 | let &verbose = 0 34 | try 35 | redir => result 36 | execute "silent!" a:cmd 37 | redir END 38 | finally 39 | let &verbose = verbose_save 40 | endtry 41 | return result 42 | endfunction 43 | 44 | function! s:digraph() abort 45 | let x = split(substitute(s:capture(':digraph'), "\n", ' ', 'g'), 46 | \ '[[:graph:]]\{2}\s.\{1,4}\s\+\d\+\s*\zs') 47 | let digraphs = map(x, "split(v:val, ' \\+')") 48 | let r = {} 49 | for d in digraphs 50 | let r[d[0]] = len(d) is 3 && d[2] =~# '\d\+' ? nr2char(str2nr(d[2],10)) 51 | \ : len(d) is 2 && d[1] =~# '32' ? nr2char(str2nr(d[1],10)) 52 | \ : '' 53 | endfor 54 | return r 55 | endfunction 56 | 57 | 58 | function! s:module.on_leave(cmdline) 59 | " Delete cache to handle additional digraphs definition 60 | let self.digraphs = {} 61 | endfunction 62 | 63 | function! s:module.on_char_pre(cmdline) 64 | if a:cmdline.is_input("\") 65 | if empty(self.digraphs) 66 | " Get digraphs when inputting instead of on_enter because it cause 67 | " flicker in some environments #107 68 | let self.digraphs = s:digraph() 69 | endif 70 | call a:cmdline.setchar('?') 71 | let self.prefix_key = a:cmdline.input_key() 72 | let self.old_line = a:cmdline.getline() 73 | let self.old_pos = a:cmdline.getpos() 74 | return 75 | elseif exists("self.prefix_key") 76 | \ && a:cmdline.get_tap_key() == self.prefix_key 77 | call a:cmdline.setline(self.old_line) 78 | call a:cmdline.setpos(self.old_pos) 79 | let x = a:cmdline.input_key() 80 | let y = s:Input.getchar() 81 | " For CTRL-K, there is one general digraph: CTRL-K {char} will 82 | " enter {char} with the highest bit set. You can use this to enter 83 | " meta-characters. 84 | let char = x ==# "\" ? 85 | \ nr2char(char2nr(y) + 128) : get(self.digraphs, x . y, y) 86 | call a:cmdline.setchar(char) 87 | endif 88 | endfunction 89 | 90 | function! s:module.on_char(cmdline) 91 | if a:cmdline.is_input("\") 92 | call a:cmdline.tap_keyinput(self.prefix_key) 93 | call a:cmdline.disable_keymapping() 94 | call a:cmdline.setpos(a:cmdline.getpos()-1) 95 | else 96 | if exists("self.prefix_key") 97 | call a:cmdline.untap_keyinput(self.prefix_key) 98 | call a:cmdline.enable_keymapping() 99 | unlet! self.prefix_key 100 | endif 101 | endif 102 | endfunction 103 | 104 | 105 | function! s:make() 106 | return deepcopy(s:module) 107 | endfunction 108 | 109 | let &cpo = s:save_cpo 110 | unlet s:save_cpo 111 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/Doautocmd.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#Doautocmd#import() abort', printf("return map({'_vital_depends': '', 'doautocmd_user': '', 'get_cmdline': '', 'make': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:_vital_loaded(V) 16 | let s:V = a:V 17 | let s:E = s:V.import("Over.Exception") 18 | endfunction 19 | 20 | 21 | function! s:_vital_depends() 22 | return [ 23 | \ "Over.Exception", 24 | \ ] 25 | endfunction 26 | 27 | 28 | let s:cache_command = {} 29 | function! s:doautocmd_user(prefix, command) 30 | let group = a:prefix . "-vital-over-commandline-doautocmd-dummy" 31 | if !has_key(s:cache_command, a:prefix) 32 | let s:cache_command[a:prefix] = {} 33 | endif 34 | 35 | if !has_key(s:cache_command[a:prefix], a:command) 36 | execute "autocmd " . group 37 | \ . " User " . a:command." silent! execute ''" 38 | 39 | if v:version > 703 || v:version == 703 && has("patch438") 40 | let s:cache_command[a:prefix][a:command] = "doautocmd User " . a:command 41 | else 42 | let s:cache_command[a:prefix][a:command] = "doautocmd User " . a:command 43 | endif 44 | endif 45 | 46 | execute s:cache_command[a:prefix][a:command] 47 | endfunction 48 | 49 | 50 | let s:hooks = [ 51 | \ "enter", 52 | \ "leave", 53 | \ "char", 54 | \ "char_pre", 55 | \ "draw", 56 | \ "draw_pre", 57 | \ "execute_pre", 58 | \ "execute_failed", 59 | \ "execute", 60 | \ "exception", 61 | \] 62 | 63 | let s:hooks_camel = [ 64 | \ "Enter", 65 | \ "Leave", 66 | \ "Char", 67 | \ "CharPre", 68 | \ "Draw", 69 | \ "DrawPre", 70 | \ "ExecutePre", 71 | \ "ExecuteFailed", 72 | \ "Execute", 73 | \ "Exception", 74 | \] 75 | 76 | 77 | let s:module = { 78 | \ "name" : "Doautocmd", 79 | \} 80 | 81 | 82 | for s:i in range(len(s:hooks)) 83 | execute join([ 84 | \ "function! s:module.on_" . s:hooks[s:i] . "(cmdline, ...)", 85 | \ " let s:cmdline = a:cmdline", 86 | \ " call s:doautocmd_user(self.prefix, self.prefix . " . string(s:hooks_camel[s:i]) . ")", 87 | \ "endfunction", 88 | \ ], "\n") 89 | endfor 90 | 91 | 92 | function! s:get_cmdline() 93 | if !exists("s:cmdline") 94 | execute s:E.throw_cmd("Undefined cmdline object.", "Over.Commandline.Modules.Doautocmd") 95 | endif 96 | return s:cmdline 97 | endfunction 98 | 99 | 100 | function! s:make(prefix) 101 | if has_key(s:cache_command, a:prefix) 102 | unlet! s:cache_command[a:prefix] 103 | endif 104 | execute "augroup " a:prefix . "-vital-over-commandline-doautocmd-dummy" 105 | autocmd! 106 | augroup END 107 | 108 | let module = deepcopy(s:module) 109 | let module.prefix = a:prefix 110 | return module 111 | endfunction 112 | 113 | 114 | let &cpo = s:save_cpo 115 | unlet s:save_cpo 116 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/DrawCommandline.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#DrawCommandline#import() abort', printf("return map({'suffix': '', 'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | let s:module = { 15 | \ "name" : "DrawCommandline" 16 | \} 17 | 18 | let s:cmdheight = {} 19 | 20 | function! s:cmdheight.save() 21 | if has_key(self, "value") 22 | return 23 | endif 24 | let self.value = &cmdheight 25 | endfunction 26 | 27 | function! s:cmdheight.restore() 28 | if has_key(self, "value") 29 | let &cmdheight = self.value 30 | unlet self.value 31 | endif 32 | endfunction 33 | 34 | 35 | function! s:cmdheight.get() 36 | return self.value 37 | endfunction 38 | 39 | 40 | function! s:suffix(left, suffix) 41 | let left_len = strdisplaywidth(a:left) 42 | let len = &columns - left_len % &columns 43 | let len = len + (&columns * (strdisplaywidth(a:suffix) > (len - 1))) - 1 44 | return repeat(" ", len - strdisplaywidth(a:suffix)) . a:suffix 45 | " return printf("%" . len . "S", a:suffix) 46 | endfunction 47 | 48 | 49 | let s:old_width = 0 50 | function! s:_redraw(cmdline) 51 | let left = a:cmdline.get_prompt() . a:cmdline.getline() . (empty(a:cmdline.line.pos_char()) ? " " : "") 52 | let width = len(left) + 1 53 | 54 | if a:cmdline.get_suffix() != "" 55 | let width += len(s:suffix(left, a:cmdline.get_suffix())) - 1 56 | endif 57 | 58 | if &columns >= width && &columns <= s:old_width && s:old_width >= width 59 | redraw 60 | normal! : 61 | elseif &columns <= width 62 | normal! : 63 | else 64 | redraw 65 | endif 66 | let s:old_width = width 67 | 68 | call s:cmdheight.save() 69 | let height = max([(width - 1) / (&columns) + 1, s:cmdheight.get()]) 70 | if height > &cmdheight || &cmdheight > height 71 | let &cmdheight = height 72 | redraw 73 | endif 74 | endfunction 75 | 76 | 77 | function! s:_as_echon(str) 78 | return "echon " . strtrans(string(a:str)) 79 | endfunction 80 | 81 | 82 | function! s:module.on_draw_pre(cmdline) 83 | if empty(a:cmdline.line.pos_char()) 84 | let cursor = "echohl " . a:cmdline.highlights.cursor . " | echon ' '" 85 | else 86 | let cursor = "echohl " . a:cmdline.highlights.cursor_on . " | " . s:_as_echon(a:cmdline.line.pos_char()) 87 | endif 88 | let suffix = "" 89 | if a:cmdline.get_suffix() != "" 90 | let suffix = s:_as_echon(s:suffix(a:cmdline.get_prompt() . a:cmdline.getline() . repeat(" ", empty(a:cmdline.line.pos_char())), a:cmdline.get_suffix())) 91 | endif 92 | let self.draw_command = join([ 93 | \ "echohl " . a:cmdline.highlights.prompt, 94 | \ s:_as_echon(a:cmdline.get_prompt()), 95 | \ "echohl NONE", 96 | \ s:_as_echon(a:cmdline.backward()), 97 | \ cursor, 98 | \ "echohl NONE", 99 | \ s:_as_echon(a:cmdline.forward()), 100 | \ suffix, 101 | \ ], " | ") 102 | 103 | call s:_redraw(a:cmdline) 104 | endfunction 105 | 106 | 107 | function! s:_echon(expr) 108 | echon strtrans(a:expr) 109 | endfunction 110 | 111 | 112 | function! s:module.on_draw(cmdline) 113 | execute self.draw_command 114 | " execute "echohl" a:cmdline.highlights.prompt 115 | " call s:echon(a:cmdline.get_prompt()) 116 | " echohl NONE 117 | " call s:echon(a:cmdline.backward()) 118 | " if empty(a:cmdline.line.pos_char()) 119 | " execute "echohl" a:cmdline.highlights.cursor 120 | " call s:echon(' ') 121 | " else 122 | " execute "echohl" a:cmdline.highlights.cursor_on 123 | " call s:echon(a:cmdline.line.pos_char()) 124 | " endif 125 | " echohl NONE 126 | " call s:echon(a:cmdline.forward()) 127 | " if a:cmdline.get_suffix() != "" 128 | " call s:echon(s:suffix(a:cmdline.get_prompt() . a:cmdline.getline() . repeat(" ", empty(a:cmdline.line.pos_char())), a:cmdline.get_suffix())) 129 | " endif 130 | endfunction 131 | 132 | 133 | function! s:module.on_execute_pre(...) 134 | call s:cmdheight.restore() 135 | endfunction 136 | 137 | 138 | function! s:module.on_leave(...) 139 | call s:cmdheight.restore() 140 | endfunction 141 | 142 | 143 | function! s:make() 144 | return deepcopy(s:module) 145 | endfunction 146 | 147 | 148 | let &cpo = s:save_cpo 149 | unlet s:save_cpo 150 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/ExceptionExit.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#ExceptionExit#import() abort', printf("return map({'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | let s:module = { 15 | \ "name" : "ExceptionExit", 16 | \} 17 | 18 | 19 | function! s:module.on_exception(cmdline) 20 | call a:cmdline.exit(-1) 21 | endfunction 22 | 23 | 24 | function! s:make(...) 25 | let result = deepcopy(s:module) 26 | let result.exit_code = get(a:, 1, 0) 27 | return result 28 | endfunction 29 | 30 | let &cpo = s:save_cpo 31 | unlet s:save_cpo 32 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/ExceptionMessage.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#ExceptionMessage#import() abort', printf("return map({'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | let s:vname = expand(":h:h:h:h:t") 16 | 17 | 18 | let s:module = { 19 | \ "name" : "ExceptionMessage", 20 | \} 21 | 22 | 23 | function! s:module.on_exception(cmdline) 24 | let self.exception = v:exception 25 | let self.throwpoint = v:throwpoint 26 | endfunction 27 | 28 | 29 | function! s:module.on_draw_pre(cmdline) 30 | if has_key(self, "exception") 31 | call self.message(a:cmdline) 32 | unlet self.exception 33 | endif 34 | endfunction 35 | 36 | function! s:module.message(...) 37 | echohl ErrorMsg 38 | execute self.command string(self.prefix . " : " . self.throwpoint . " " . self.exception) 39 | echohl None 40 | endfunction 41 | 42 | 43 | function! s:module.on_leave(cmdline) 44 | if has_key(self, "exception") 45 | call self.message(a:cmdline) 46 | unlet self.exception 47 | endif 48 | endfunction 49 | 50 | 51 | function! s:make(...) 52 | let result = deepcopy(s:module) 53 | let result.prefix = get(a:, 1, "vital-over(".s:vname.") Exception") 54 | let result.command = get(a:, 2, "echom") 55 | return result 56 | endfunction 57 | 58 | 59 | let &cpo = s:save_cpo 60 | unlet s:save_cpo 61 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/Execute.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#Execute#import() abort', printf("return map({'make_search': '', 'silent_feedkeys': '', 'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:silent_feedkeys(expr, name, ...) 16 | let mode = get(a:, 1, "m") 17 | let map = printf("(%s)", a:name) 18 | if mode == "n" 19 | let command = "nnoremap" 20 | else 21 | let command = "nmap" 22 | endif 23 | execute command "" map printf("%s:nunmap %s", a:expr, map) 24 | call feedkeys(printf("\(%s)", a:name)) 25 | endfunction 26 | 27 | 28 | function! s:_is_input_enter(cmdline) 29 | return a:cmdline.is_input("\") 30 | \ || a:cmdline.is_input("\") 31 | \ || a:cmdline.is_input("\") 32 | endfunction 33 | 34 | 35 | let s:module = { 36 | \ "name" : "Execute" 37 | \} 38 | 39 | function! s:module.on_char_pre(cmdline) 40 | if s:_is_input_enter(a:cmdline) 41 | call self.execute(a:cmdline) 42 | call a:cmdline.setchar("") 43 | call a:cmdline.exit(0) 44 | endif 45 | if a:cmdline.is_input("(execute-no-exit)") 46 | call self.execute(a:cmdline) 47 | call a:cmdline.setchar("") 48 | endif 49 | endfunction 50 | 51 | function! s:module.execute(cmdline) 52 | return a:cmdline.execute() 53 | endfunction 54 | 55 | 56 | function! s:make() 57 | return deepcopy(s:module) 58 | endfunction 59 | 60 | 61 | let s:search = deepcopy(s:module) 62 | let s:search.prefix = "/" 63 | 64 | 65 | function! s:search.execute(cmdline) 66 | call a:cmdline.callevent("on_execute_pre") 67 | let input = a:cmdline.getline() 68 | if input == "" 69 | return 70 | endif 71 | call s:silent_feedkeys(":call histdel('/', -1)\", "remove_hist", "n") 72 | let cmd = printf("call s:silent_feedkeys(\"%s%s\\", 'search', 'n')", self.prefix, input) 73 | try 74 | execute cmd 75 | catch 76 | echohl ErrorMsg 77 | echom matchstr(v:exception, 'Vim\((\w*)\)\?:\zs.*\ze') 78 | echohl None 79 | call a:cmdline.callevent("on_execute_failed") 80 | finally 81 | call a:cmdline.callevent("on_execute") 82 | endtry 83 | 84 | " let cmd = printf("call search('%s')", a:cmdline.getline()) 85 | " call a:cmdline.execute(cmd) 86 | " let @/ = a:cmdline.getline() 87 | " call s:silent_feedkeys(":let &hlsearch = &hlsearch\", "hlsearch", "n") 88 | endfunction 89 | 90 | 91 | 92 | function! s:make_search(...) 93 | let result = deepcopy(s:search) 94 | let result.prefix = get(a:, 1, "/") 95 | return result 96 | endfunction 97 | 98 | 99 | let &cpo = s:save_cpo 100 | unlet s:save_cpo 101 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/ExecuteFailedMessage.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#ExecuteFailedMessage#import() abort', printf("return map({}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | 16 | let &cpo = s:save_cpo 17 | unlet s:save_cpo 18 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/Exit.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#Exit#import() abort', printf("return map({'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | let s:module = { 15 | \ "name" : "Exit", 16 | \ "exit_code" : 0 17 | \} 18 | 19 | 20 | function! s:module.on_char_pre(cmdline) 21 | if a:cmdline.is_input("(exit)") 22 | call a:cmdline.setchar("") 23 | call a:cmdline.exit(self.exit_code) 24 | endif 25 | endfunction 26 | 27 | 28 | function! s:make() 29 | return deepcopy(s:module) 30 | endfunction 31 | 32 | 33 | let &cpo = s:save_cpo 34 | unlet s:save_cpo 35 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/HighlightBufferCursor.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#HighlightBufferCursor#import() abort', printf("return map({}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/HistAdd.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#HistAdd#import() abort', printf("return map({'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | let s:module = { 16 | \ "name" : "HistAdd", 17 | \ "mode" : "cmd" 18 | \} 19 | 20 | function! s:module.on_leave(cmdline) 21 | call histadd(self.mode, a:cmdline.getline()) 22 | endfunction 23 | 24 | 25 | function! s:make(...) 26 | let module = deepcopy(s:module) 27 | let module.mode = get(a:, 1, "cmd") 28 | return module 29 | endfunction 30 | 31 | let &cpo = s:save_cpo 32 | unlet s:save_cpo 33 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/History.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#History#import() abort', printf("return map({'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | let s:module = { 15 | \ "name" : "History", 16 | \ "mode" : "cmd", 17 | \} 18 | 19 | function! s:module.histories() 20 | return map(range(1, &history), 'histget(self.mode, v:val * -1)') 21 | endfunction 22 | 23 | function! s:_should_match_cmdline(cmdline) 24 | return a:cmdline.is_input("\") 25 | \ || a:cmdline.is_input("\") 26 | endfunction 27 | 28 | function! s:_reset() 29 | let s:cmdhist = [] 30 | let s:count = 0 31 | let s:is_match_mode = 0 " /: true, /: false 32 | endfunction 33 | 34 | function! s:module.on_enter(...) 35 | call s:_reset() 36 | endfunction 37 | 38 | function! s:module.on_char_pre(cmdline) 39 | if !a:cmdline.is_input("\") && !a:cmdline.is_input("\") 40 | \ && !a:cmdline.is_input("\") && !a:cmdline.is_input("\") 41 | call s:_reset() 42 | return 43 | else 44 | if s:count == 0 && empty(s:cmdhist) 45 | \ || s:is_match_mode != s:_should_match_cmdline(a:cmdline) 46 | let cmdline = '^' . a:cmdline.getline() 47 | let s:is_match_mode = s:_should_match_cmdline(a:cmdline) 48 | let s:cmdhist = [a:cmdline.getline()] + (s:is_match_mode ? 49 | \ filter(self.histories(), 'v:val =~ cmdline') : self.histories()) 50 | endif 51 | endif 52 | call a:cmdline.setchar("") 53 | if a:cmdline.is_input("\") || a:cmdline.is_input("\") 54 | let s:count = max([s:count - 1, 0]) 55 | endif 56 | if a:cmdline.is_input("\") || a:cmdline.is_input("\") 57 | let s:count = min([s:count + 1, len(s:cmdhist)]) 58 | endif 59 | call a:cmdline.setline(get(s:cmdhist, s:count, a:cmdline.getline())) 60 | endfunction 61 | 62 | function! s:make(...) 63 | let module = deepcopy(s:module) 64 | let module.mode = get(a:, 1, "cmd") 65 | return module 66 | endfunction 67 | 68 | let &cpo = s:save_cpo 69 | unlet s:save_cpo 70 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/IgnoreRegexpBackwardWord.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#IgnoreRegexpBackwardWord#import() abort', printf("return map({'backward_word': '', 'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | " Improved backward word detection which ignore regular expression 15 | let s:module = { 16 | \ "name" : "IgnoreRegexpBackwardWord" 17 | \} 18 | 19 | function! s:backward_word(str, ...) 20 | let pat = get(a:, 1, '\k\+\s*\|.') 21 | let flags = s:non_escaped_backslash . 22 | \ '\%(' . 'z[se]' . 23 | \ '\|' . '[iIkKfFpPsSdDxXoOwWhHaAlLuUetrbncCZmMvV]' . 24 | \ '\|' . '%[dxouUCVlcv]' . 25 | \ '\|' . "%'[a-zA-Z]" . 26 | \ '\|' . '%#=\d' . 27 | \ '\|' . 'z\=\d' . 28 | \ '\)' 29 | return matchstr(get(split(a:str, flags . '\s*\zs'), -1, ""), 30 | \ '\%(' . flags . '\s*\|' . pat . '\)$') 31 | endfunction 32 | 33 | 34 | let s:non_escaped_backslash = '\m\%(\%(^\|[^\\]\)\%(\\\\\)*\)\@<=\\' 35 | 36 | function! s:module.on_enter(cmdline) 37 | function! a:cmdline.backward_word(...) 38 | return call("s:backward_word", [self.backward()] + a:000) 39 | endfunction 40 | endfunction 41 | 42 | function! s:make() 43 | return deepcopy(s:module) 44 | endfunction 45 | 46 | 47 | let &cpo = s:save_cpo 48 | unlet s:save_cpo 49 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/Incsearch.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#Incsearch#import() abort', printf("return map({'escape_regex': '', 'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:escape_regex(pattern) 16 | return substitute(a:pattern, '^\^', '\\_^', "") 17 | endfunction 18 | 19 | 20 | 21 | let s:module = { 22 | \ "name" : "Incsearch", 23 | \ "highlights" : { 24 | \ "incsearch" : "IncSearch" 25 | \ }, 26 | \ "pattern" : "", 27 | \ "search_flag" : "", 28 | \ "mode" : "", 29 | \} 30 | 31 | 32 | function! s:module.search_hl_off() 33 | if exists("self.search_hl_id") 34 | call matchdelete(self.search_hl_id) 35 | unlet self.search_hl_id 36 | endif 37 | endfunction 38 | 39 | 40 | function! s:module.search_hl_on(pattern) 41 | call self.search_hl_off() 42 | let self.search_hl_id = matchadd(self.highlights.incsearch, a:pattern) 43 | endfunction 44 | 45 | 46 | function! s:module.on_enter(...) 47 | let self.old_pos = getpos(".") 48 | endfunction 49 | 50 | 51 | function! s:module.on_leave(...) 52 | call setpos(".", self.old_pos) 53 | call self.search_hl_off() 54 | endfunction 55 | 56 | 57 | function! s:module.on_char(cmdline) 58 | call self.search_hl_off() 59 | let line = a:cmdline.getline() 60 | let result = get(matchlist(line, self.pattern), 1, "") 61 | if result != "" 62 | let pos = searchpos(result, self.search_flag) 63 | if pos == [0, 0] 64 | return 65 | endif 66 | call self.search_hl_on('\%' . pos[0] . 'l' . (&ignorecase ? '\c' : "") . s:escape_regex(result)) 67 | redraw 68 | endif 69 | endfunction 70 | 71 | 72 | function! s:make(...) 73 | let module = deepcopy(s:module) 74 | let module.mode = get(a:, 1, "/") 75 | let module.pattern = get(a:, 2, '^\(.\+\)') 76 | let module.search_flag = get(a:, 3, 'c') 77 | return module 78 | endfunction 79 | 80 | 81 | 82 | let &cpo = s:save_cpo 83 | unlet s:save_cpo 84 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/InsertRegister.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#InsertRegister#import() abort', printf("return map({'_vital_depends': '', 'to_string': '', 'input': '', 'get_cmdline_cword': '', 'make': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:_vital_loaded(V) 16 | let s:V = a:V 17 | let s:String = s:V.import("Over.String") 18 | endfunction 19 | 20 | 21 | function! s:_vital_depends() 22 | return [ 23 | \ "Over.String", 24 | \ ] 25 | endfunction 26 | 27 | 28 | function! s:to_string(expr) 29 | return type(a:expr) == type("") ? a:expr : string(a:expr) 30 | endfunction 31 | 32 | 33 | function! s:input(cmdline) 34 | let CR_index = index(a:cmdline.input_key_stack(), "\") 35 | if CR_index != -1 36 | let input = a:cmdline.input_key_stack_string() 37 | let input = input[ : CR_index-1] 38 | call a:cmdline.set_input_key_stack(a:cmdline.input_key_stack()[CR_index+1 : ]) 39 | return eval(input) 40 | endif 41 | 42 | let input_text = "" 43 | if !empty(a:cmdline.input_key_stack()) 44 | let input_text = a:cmdline.input_key_stack_string() 45 | call a:cmdline.set_input_key_stack([]) 46 | endif 47 | 48 | call a:cmdline.hl_cursor_on() 49 | try 50 | redraw 51 | let input = input("=", input_text, "expression") 52 | if !empty(input) 53 | let input = s:to_string(eval(input)) 54 | endif 55 | catch 56 | return "" 57 | finally 58 | call a:cmdline.hl_cursor_off() 59 | endtry 60 | return input 61 | endfunction 62 | 63 | 64 | let s:module = { 65 | \ "name" : "InsertRegister" 66 | \} 67 | 68 | 69 | 70 | function! s:module.reset() 71 | let self.cword = expand("") 72 | let self.cWORD = expand("") 73 | let self.cfile = expand("") 74 | endfunction 75 | 76 | function! s:module.on_enter(...) 77 | call self.reset() 78 | " let self.prefix_key = "" 79 | endfunction 80 | 81 | 82 | function! s:get_cmdline_cword(backward, cword) 83 | " let backward = matchstr(a:backward, '.\{-}\zs\k\+$') 84 | let backward = a:backward 85 | if &incsearch == 0 || a:cword == "" || a:backward == "" || s:String.index(a:cword, backward) != 0 86 | return a:cword 87 | endif 88 | return a:cword[len(backward) : ] 89 | endfunction 90 | 91 | 92 | function! s:module.on_char_pre(cmdline) 93 | if a:cmdline.is_input("\") 94 | call a:cmdline.setchar('"') 95 | let self.prefix_key = a:cmdline.input_key() 96 | let self.old_line = a:cmdline.getline() 97 | let self.old_pos = a:cmdline.getpos() 98 | return 99 | elseif exists("self.prefix_key") 100 | \ && a:cmdline.get_tap_key() == self.prefix_key 101 | call a:cmdline.setline(self.old_line) 102 | call a:cmdline.setpos(self.old_pos) 103 | let char = a:cmdline.input_key() 104 | if char =~ '^[0-9a-zA-z.%#:/"\-*+]$' 105 | let register = tr(getreg(char), "\n", "\r") 106 | call a:cmdline.setchar(register) 107 | elseif char == "=" 108 | call a:cmdline.setchar(s:input(a:cmdline)) 109 | elseif char == "\" 110 | call a:cmdline.setchar(s:get_cmdline_cword(a:cmdline.backward_word(), self.cword)) 111 | elseif char == "\" 112 | call a:cmdline.setchar(self.cWORD) 113 | elseif char == "\" 114 | call a:cmdline.setchar(self.cfile) 115 | elseif char == "\" 116 | call a:cmdline.setchar('"') 117 | else 118 | call a:cmdline.setchar("") 119 | endif 120 | " elseif a:cmdline.is_input('=', self.prefix_key) 121 | " call a:cmdline.setchar(s:input(a:cmdline)) 122 | " elseif a:cmdline.is_input("\", self.prefix_key) 123 | " call a:cmdline.setchar(self.cword) 124 | " elseif a:cmdline.is_input("\", self.prefix_key) 125 | " call a:cmdline.setchar(self.cWORD) 126 | " elseif a:cmdline.is_input("\", self.prefix_key) 127 | " call a:cmdline.setchar(self.cfile) 128 | " elseif a:cmdline.is_input("\", self.prefix_key) 129 | " call a:cmdline.setchar('"') 130 | " else 131 | " call a:cmdline.setchar("") 132 | " endif 133 | endif 134 | endfunction 135 | 136 | 137 | function! s:module.on_char(cmdline) 138 | if a:cmdline.is_input("\") 139 | call a:cmdline.tap_keyinput(self.prefix_key) 140 | call a:cmdline.disable_keymapping() 141 | call a:cmdline.setpos(a:cmdline.getpos()-1) 142 | else 143 | if exists("self.prefix_key") 144 | call a:cmdline.untap_keyinput(self.prefix_key) 145 | call a:cmdline.enable_keymapping() 146 | unlet! self.prefix_key 147 | endif 148 | endif 149 | endfunction 150 | 151 | 152 | 153 | function! s:make() 154 | return deepcopy(s:module) 155 | endfunction 156 | 157 | let &cpo = s:save_cpo 158 | unlet s:save_cpo 159 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/KeyMapping.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#KeyMapping#import() abort', printf("return map({'_vital_depends': '', 'make_emacs': '', 'make_vim_cmdline_mapping': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:_vital_loaded(V) 16 | let s:Keymapping = a:V.import("Palette.Keymapping") 17 | endfunction 18 | 19 | 20 | function! s:_vital_depends() 21 | return [ 22 | \ "Palette.Keymapping", 23 | \ ] 24 | endfunction 25 | 26 | 27 | let s:emacs = { 28 | \ "name" : "KeyMapping_emacs_like" 29 | \} 30 | 31 | function! s:emacs.keymapping(cmdline) 32 | return { 33 | \ "\" : { 34 | \ "key" : "\", 35 | \ "noremap" : 1, 36 | \ "lock" : 1, 37 | \ }, 38 | \ "\" : { 39 | \ "key" : "\", 40 | \ "noremap" : 1, 41 | \ "lock" : 1, 42 | \ }, 43 | \ "\" : { 44 | \ "key" : "\", 45 | \ "noremap" : 1, 46 | \ "lock" : 1, 47 | \ }, 48 | \ "\" : { 49 | \ "key" : "\", 50 | \ "noremap" : 1, 51 | \ "lock" : 1, 52 | \ }, 53 | \ "\" : { 54 | \ "key" : "\", 55 | \ "noremap" : 1, 56 | \ "lock" : 1, 57 | \ }, 58 | \ "\" : { 59 | \ "key" : "\", 60 | \ "noremap" : 1, 61 | \ "lock" : 1, 62 | \ }, 63 | \ "\" : { 64 | \ "key" : "\", 65 | \ "noremap" : 1, 66 | \ "lock" : 1, 67 | \ }, 68 | \ "\" : { 69 | \ "key" : "\", 70 | \ "noremap" : 1, 71 | \ "lock" : 1, 72 | \ }, 73 | \ "\" : { 74 | \ "key" : "\", 75 | \ "noremap" : 1, 76 | \ "lock" : 1, 77 | \ }, 78 | \ "\" : { 79 | \ "key" : "\", 80 | \ "noremap" : 1, 81 | \ "lock" : 1, 82 | \ }, 83 | \ } 84 | endfunction 85 | 86 | 87 | function! s:make_emacs() 88 | return deepcopy(s:emacs) 89 | endfunction 90 | 91 | 92 | let s:vim_cmdline_mapping = { 93 | \ "name" : "KeyMapping_vim_cmdline_mapping", 94 | \ "_cmaps" : {} 95 | \} 96 | 97 | function! s:_convert_sid(rhs, sid) abort 98 | return substitute(a:rhs, '', '' . a:sid . '_', 'g') 99 | endfunction 100 | 101 | function! s:_auto_cmap() 102 | let cmaps = {} 103 | let cmap_info = s:Keymapping.rhs_key_list("c", 0, 1) 104 | " vital-over currently doesn't support mappings 105 | for c in filter(cmap_info, "v:val['buffer'] ==# 0") 106 | let cmaps[s:Keymapping.escape_special_key(c['lhs'])] = { 107 | \ 'noremap' : c['noremap'], 108 | \ 'key' : s:Keymapping.escape_special_key(s:_convert_sid(c['rhs'], c['sid'])), 109 | \ 'expr' : s:Keymapping.escape_special_key(c['expr']), 110 | \ } 111 | endfor 112 | return cmaps 113 | endfunction 114 | 115 | 116 | function! s:vim_cmdline_mapping.on_enter(cmdline) 117 | let self._cmaps = s:_auto_cmap() 118 | if exists("*execute") 119 | let self._old_cmap = execute("cmap") 120 | endif 121 | endfunction 122 | 123 | 124 | function! s:vim_cmdline_mapping.on_update(cmdline) 125 | if !exists("*execute") 126 | return 127 | endif 128 | 129 | let cmap_ = execute("cmap") 130 | if self._old_cmap != cmap_ 131 | let self._cmaps = s:_auto_cmap() 132 | let self._old_cmap = cmap_ 133 | endif 134 | endfunction 135 | 136 | 137 | function! s:vim_cmdline_mapping.keymapping(cmdline) 138 | return self._cmaps 139 | endfunction 140 | 141 | 142 | function! s:make_vim_cmdline_mapping() 143 | return deepcopy(s:vim_cmdline_mapping) 144 | endfunction 145 | 146 | 147 | 148 | let &cpo = s:save_cpo 149 | unlet s:save_cpo 150 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/LiteralInsert.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#LiteralInsert#import() abort', printf("return map({'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | let s:module = { 16 | \ "name" : "LiteralInsert", 17 | \} 18 | 19 | function! s:module.on_char_pre(cmdline) 20 | if a:cmdline.is_input("\") 21 | \ || a:cmdline.is_input("\") 22 | let old_line = a:cmdline.getline() 23 | let old_pos = a:cmdline.getpos() 24 | call a:cmdline.insert('^') 25 | call a:cmdline.setpos(old_pos) 26 | call a:cmdline.draw() 27 | let char = a:cmdline.getchar() 28 | call a:cmdline.setline(old_line) 29 | call a:cmdline.setpos(old_pos) 30 | call a:cmdline.setchar(char) 31 | endif 32 | endfunction 33 | 34 | function! s:make() 35 | return deepcopy(s:module) 36 | endfunction 37 | 38 | let &cpo = s:save_cpo 39 | unlet s:save_cpo 40 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/NoInsert.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#NoInsert#import() abort', printf("return map({'make_special_chars': '', 'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | let s:module = { 15 | \ "name" : "NoInsert", 16 | \ "chars" : [] 17 | \} 18 | 19 | 20 | function! s:module.is_no_insert(char) 21 | return index(self.chars, a:char) >= 0 22 | endfunction 23 | 24 | 25 | function! s:module.on_char_pre(cmdline) 26 | if self.is_no_insert(a:cmdline.char()) 27 | call a:cmdline.setchar("", 0) 28 | endif 29 | endfunction 30 | 31 | 32 | function! s:make(chars) 33 | let module = deepcopy(s:module) 34 | let module.chars = type(a:chars) == type([]) ? a:chars : [a:chars] 35 | return module 36 | endfunction 37 | 38 | 39 | function! s:make_special_chars() 40 | let module = s:make([]) 41 | function! module.is_no_insert(char) 42 | return char2nr(a:char) == 128 || char2nr(a:char) < 27 43 | endfunction 44 | return module 45 | endfunction 46 | 47 | 48 | let &cpo = s:save_cpo 49 | unlet s:save_cpo 50 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/Paste.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#Paste#import() abort', printf("return map({'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | let s:module = { 16 | \ "name" : "Paste" 17 | \} 18 | 19 | function! s:module.on_char_pre(cmdline) 20 | if a:cmdline.is_input("(paste)") 21 | let register = v:register == "" ? '"' : v:register 22 | call a:cmdline.insert(tr(getreg("*"), "\n", "\r")) 23 | call a:cmdline.setchar('') 24 | endif 25 | endfunction 26 | 27 | 28 | function! s:make() 29 | return deepcopy(s:module) 30 | endfunction 31 | 32 | 33 | let &cpo = s:save_cpo 34 | unlet s:save_cpo 35 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/Redraw.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#Redraw#import() abort', printf("return map({'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | let s:module = { 16 | \ "name" : "Redraw", 17 | \} 18 | 19 | function! s:module.on_execute_pre(cmdline) 20 | call self.redraw(a:cmdline) 21 | endfunction 22 | 23 | function! s:module.on_enter(...) 24 | let self.is_execute = 0 25 | endfunction 26 | 27 | function! s:module.on_execute(...) 28 | let self.is_execute = 1 29 | endfunction 30 | 31 | function! s:module.on_execute_failed(...) 32 | let self.is_execute = 0 33 | endfunction 34 | 35 | function! s:module.on_leave(cmdline) 36 | if self.is_execute == 0 && a:cmdline.exit_code() != -1 37 | call self.redraw(a:cmdline) 38 | endif 39 | endfunction 40 | 41 | 42 | " function! s:module.on_draw_pre(cmdline) 43 | " call self.redraw(a:cmdline) 44 | " endfunction 45 | 46 | 47 | function! s:module.redraw(cmdline) 48 | redraw 49 | " Workaround for the :set cedit= 50 | " https://github.com/osyo-manga/vital-over/issues/52 51 | " https://github.com/Lokaltog/vim-easymotion/issues/177#issuecomment-53663431 52 | if &cedit != "" 53 | \ ||(v:version > 704 || v:version == 704 && has("patch441")) 54 | normal! : 55 | else 56 | execute "normal! :\" 57 | endif 58 | endfunction 59 | 60 | function! s:make() 61 | return deepcopy(s:module) 62 | endfunction 63 | 64 | 65 | let &cpo = s:save_cpo 66 | unlet s:save_cpo 67 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Commandline/Modules/Scroll.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Commandline#Modules#Scroll#import() abort', printf("return map({'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | let s:module = { 16 | \ "name" : "Scroll" 17 | \} 18 | function! s:module.on_char_pre(cmdline) 19 | if a:cmdline.is_input("(scroll-y)") 20 | execute "normal! \" 21 | call a:cmdline.setchar('') 22 | elseif a:cmdline.is_input("(scroll-u)") 23 | execute "normal! \" 24 | call a:cmdline.setchar('') 25 | elseif a:cmdline.is_input("(scroll-f)") 26 | execute "normal! \" 27 | call a:cmdline.setchar('') 28 | elseif a:cmdline.is_input("(scroll-e)") 29 | execute "normal! \" 30 | call a:cmdline.setchar('') 31 | elseif a:cmdline.is_input("(scroll-d)") 32 | execute "normal! \" 33 | call a:cmdline.setchar('') 34 | elseif a:cmdline.is_input("(scroll-b)") 35 | execute "normal! \" 36 | call a:cmdline.setchar('') 37 | endif 38 | endfunction 39 | 40 | 41 | function! s:make() 42 | return deepcopy(s:module) 43 | endfunction 44 | 45 | let &cpo = s:save_cpo 46 | unlet s:save_cpo 47 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Exception.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Exception#import() abort', printf("return map({'throw': '', 'throw_cmd': '', 'set_prefix': '', 'error': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | let s:vname = expand(":h:h:t") 16 | let s:prefix = printf("vital-over(%s) Exception", s:vname) 17 | 18 | function! s:set_prefix(prefix) 19 | let s:prefix = a:prefix 20 | endfunction 21 | 22 | function! s:throw_cmd(exp, where) 23 | return 'throw ' . string(s:prefix . " : " . a:exp . " in " . a:where) 24 | endfunction 25 | 26 | 27 | function! s:throw(exp, where) 28 | execute s:throw_cmd(a:exp, a:where) 29 | endfunction 30 | 31 | 32 | function! s:error(text, where) 33 | echohl ErrorMsg 34 | echom s:prefix . " : " . a:text . " in " . a:where 35 | echohl None 36 | endfunction 37 | 38 | 39 | let &cpo = s:save_cpo 40 | unlet s:save_cpo 41 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Input.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Input#import() abort', printf("return map({'getchar': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:getchar(...) 16 | let mode = get(a:, 1, 0) 17 | while 1 18 | " Workaround for https://github.com/osyo-manga/vital-over/issues/53 19 | try 20 | let char = call("getchar", a:000) 21 | catch /^Vim:Interrupt$/ 22 | let char = 3 " 23 | endtry 24 | " Workaround for the mappings 25 | if string(char) !=# "\x80\xfd`" 26 | return mode == 1 ? !!char 27 | \ : type(char) == type(0) ? nr2char(char) : char 28 | endif 29 | endwhile 30 | endfunction 31 | 32 | 33 | let &cpo = s:save_cpo 34 | unlet s:save_cpo 35 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Keymapping.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Keymapping#import() abort', printf("return map({'_vital_depends': '', 'unmapping': '', 'as_key_config': '', 'match_key': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | 16 | function! s:_vital_loaded(V) 17 | let s:V = a:V 18 | let s:String = s:V.import("Over.String") 19 | endfunction 20 | 21 | 22 | function! s:_vital_depends() 23 | return [ 24 | \ "Over.String", 25 | \ ] 26 | endfunction 27 | 28 | 29 | function! s:as_key_config(config) 30 | let base = { 31 | \ "noremap" : 0, 32 | \ "lock" : 0, 33 | \ "expr" : 0, 34 | \ } 35 | return type(a:config) == type({}) ? extend(base, a:config) 36 | \ : extend(base, { 37 | \ "key" : a:config, 38 | \ }) 39 | endfunction 40 | 41 | 42 | function! s:match_key(keymapping, key) 43 | let keys = sort(keys(a:keymapping)) 44 | return get(filter(keys, 'stridx(a:key, v:val) == 0'), -1, '') 45 | endfunction 46 | 47 | 48 | function! s:_safe_eval(expr, ...) 49 | call extend(l:, get(a:, 1, {})) 50 | let result = get(a:, 2, "") 51 | try 52 | let result = eval(a:expr) 53 | catch 54 | echohl ErrorMsg | echom v:exception | echohl None 55 | endtry 56 | return result 57 | endfunction 58 | 59 | 60 | function! s:_get_key(conf) 61 | " call extend(l:, a:conf) 62 | let self = a:conf 63 | return get(a:conf, "expr", 0) ? s:_safe_eval(a:conf.key, l:) : a:conf.key 64 | endfunction 65 | 66 | 67 | function! s:unmapping(keymapping, key, ...) 68 | let is_locking = get(a:, 1, 0) 69 | let key = s:match_key(a:keymapping, a:key) 70 | if key == "" 71 | return s:String.length(a:key) <= 1 ? a:key : s:unmapping(a:keymapping, a:key[0], is_locking) . s:unmapping(a:keymapping, a:key[1:], is_locking) 72 | endif 73 | 74 | let map_conf = s:as_key_config(a:keymapping[key]) 75 | 76 | let next_input = s:unmapping(a:keymapping, a:key[len(key) : ], is_locking) 77 | if map_conf.lock == 0 && is_locking 78 | return key . next_input 79 | elseif map_conf.lock 80 | return s:unmapping(a:keymapping, s:_get_key(map_conf), is_locking) . next_input 81 | else 82 | return s:unmapping(a:keymapping, s:_get_key(map_conf), map_conf.noremap) . next_input 83 | endif 84 | endfunction 85 | 86 | 87 | 88 | let &cpo = s:save_cpo 89 | unlet s:save_cpo 90 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/Signals.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#Signals#import() abort', printf("return map({'_vital_depends': '', 'call': '', 'make': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:_vital_loaded(V) 16 | let s:V = a:V 17 | let s:L = s:V.import("Data.List") 18 | endfunction 19 | 20 | 21 | function! s:_vital_depends() 22 | return ["Data.List"] 23 | endfunction 24 | 25 | 26 | let s:base = { 27 | \ "variables" : { 28 | \ "slots" : [], 29 | \ "counter" : 0, 30 | \ } 31 | \} 32 | 33 | 34 | function! s:base.connect(slot) 35 | let self.variables.counter += 1 36 | let slot = { "id" : self.variables.counter, "slot" : a:slot } 37 | call add(self.variables.slots, slot) 38 | return slot 39 | endfunction 40 | 41 | 42 | function! s:base.disconnect(slot) 43 | if empty(a:slot) 44 | return -1 45 | endif 46 | for i in range(len(self.variables.slots)) 47 | if self.variables.slots[i].id == a:slot.id 48 | unlet self.variables.slots[i] 49 | return 50 | endif 51 | endfor 52 | return -1 53 | endfunction 54 | 55 | 56 | function! s:base.disconnect_by(expr) 57 | return self.disconnect(self.find_first_by(a:expr)) 58 | endfunction 59 | 60 | 61 | function! s:call(list, func, ...) 62 | let args = get(a:, 1, []) 63 | let def = get(a:, 2, 0) 64 | return map(copy(a:list), "has_key(v:val, a:func) ? call(v:val.".a:func.", args, v:val) : def") 65 | endfunction 66 | 67 | function! s:base.call(func, ...) 68 | return call("s:call", [self.slots(), a:func] + a:000) 69 | endfunction 70 | 71 | 72 | function! s:base.find_by(expr) 73 | return filter(copy(self.variables.slots), a:expr) 74 | endfunction 75 | 76 | 77 | function! s:base.find_first_by(expr) 78 | return get(self.find_by(a:expr), 0, {}) 79 | endfunction 80 | 81 | 82 | function! s:base.sort_by(expr) 83 | let self.variables.slots = s:L.sort_by(self.variables.slots, a:expr) 84 | endfunction 85 | 86 | 87 | function! s:base.get_slot(val) 88 | return a:val.slot 89 | endfunction 90 | 91 | 92 | function! s:base.slots() 93 | return map(copy(self.variables.slots), "self.get_slot(v:val)") 94 | endfunction 95 | 96 | 97 | " function! s:base.dict() 98 | " let result = {} 99 | " for _ in self.variables.slots 100 | " let result[_.id] = _.value 101 | " endfor 102 | " return result 103 | " endfunction 104 | 105 | 106 | function! s:make() 107 | let result = deepcopy(s:base) 108 | return result 109 | endfunction 110 | 111 | 112 | let &cpo = s:save_cpo 113 | unlet s:save_cpo 114 | -------------------------------------------------------------------------------- /autoload/vital/_over/Over/String.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Over#String#import() abort', printf("return map({'_vital_depends': '', 'length': '', 'index': '', 'split_by_keys': '', 'make': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:_vital_loaded(V) 16 | let s:V = a:V 17 | let s:List = s:V.import("Data.List") 18 | endfunction 19 | 20 | 21 | function! s:_vital_depends() 22 | return [ 23 | \ "Data.List", 24 | \ ] 25 | endfunction 26 | 27 | 28 | function! s:_clamp(x, max, min) 29 | return min([max([a:x, a:max]), a:min]) 30 | endfunction 31 | 32 | 33 | let s:base = {} 34 | 35 | function! s:base.set(item) 36 | return type(a:item) == type("") ? self.set_str(a:item) 37 | \ : type(a:item) == type(0) ? self.set_pos(a:item) 38 | \ : self 39 | endfunction 40 | 41 | function! s:base.str() 42 | return join(self.list, "") 43 | endfunction 44 | 45 | function! s:base.set_pos(pos) 46 | let self.col = s:_clamp(a:pos, 0, self.length()) 47 | return self 48 | endfunction 49 | 50 | function! s:base.backward() 51 | return self.col > 0 ? join(self.list[ : self.col-1], '') : "" 52 | endfunction 53 | 54 | function! s:base.forward() 55 | return join(self.list[self.col+1 : ], '') 56 | endfunction 57 | 58 | function! s:base.pos_char() 59 | return get(self.list, self.col, "") 60 | endfunction 61 | 62 | function! s:base.set_str(str) 63 | let self.list = split(a:str, '\zs') 64 | let self.col = strchars(a:str, 1) 65 | return self 66 | endfunction 67 | 68 | function! s:base.pos() 69 | return self.col 70 | endfunction 71 | 72 | function! s:base.input(str) 73 | call extend(self.list, split(a:str, '\zs'), self.col) 74 | let self.col += len(split(a:str, '\zs')) 75 | return self 76 | endfunction 77 | 78 | function! s:base.length() 79 | return len(self.list) 80 | endfunction 81 | 82 | function! s:base.next() 83 | return self.set_pos(self.col + 1) 84 | endfunction 85 | 86 | function! s:base.prev() 87 | return self.set_pos(self.col - 1) 88 | endfunction 89 | 90 | function! s:base.remove(index) 91 | if a:index < 0 || self.length() <= a:index 92 | return "" 93 | endif 94 | let result = self.list[a:index] 95 | unlet self.list[a:index] 96 | if a:index < self.col 97 | call self.set(self.col - 1) 98 | endif 99 | return result 100 | endfunction 101 | 102 | function! s:base.remove_pos() 103 | return self.remove(self.col) 104 | endfunction 105 | 106 | function! s:base.remove_prev() 107 | return self.remove(self.col - 1) 108 | endfunction 109 | 110 | function! s:base.remove_next() 111 | return self.remove(self.col + 1) 112 | endfunction 113 | 114 | 115 | function! s:make(...) 116 | let default = get(a:, 1, "") 117 | let result = deepcopy(s:base) 118 | call result.set(default) 119 | return result 120 | endfunction 121 | 122 | " NOTE: old regexpengine has a bug with string which contains binary 123 | " :echo "\x80" =~ "\\%#=1\x80" | " => 0 124 | " But it matches correctly with :h /collection 125 | " :echo "\x80" =~ "\\%#=1[\x80]" | " => 1 126 | " http://lingr.com/room/vim/archives/2015/02/13#message-21261450 127 | let s:_engine = exists("+regexpengine") ? '\%#=2' : '' 128 | " \ => Û\xfdQ 129 | " \ => À\xfeX 130 | let s:_regex = exists("+regexpengine") 131 | \ ? "\\%(Û\xfdQ\\|À\xfeX\\|\x80\xfc.\\%(\x80..\\|.\\)\\|\x80..\\|.\\)\\zs" 132 | \ : "\\%(Û[\xfd]Q\\|À[\xfe]X\\|[\x80][\xfc].\\%([\x80]..\\|.\\)\\|[\x80]..\\|.\\)\\zs" 133 | function! s:_split_keystring(str, ...) 134 | return split(a:str, s:_engine . '\m\%(' . get(a:, 1, '') . s:_regex . '\)') 135 | endfunction 136 | 137 | function! s:split_by_keys(str) 138 | return s:_split_keystring(a:str, "\\%(\\\|\\)(.\\{-})\\zs\\|") 139 | endfunction 140 | 141 | function! s:index(haystack, needle, ...) 142 | let start = get(a:, 1, 0) 143 | let ignorecase = get(a:, 2, &ignorecase) 144 | if ignorecase 145 | return stridx(tolower(a:haystack), tolower(a:needle), start) 146 | else 147 | return stridx(a:haystack, a:needle, start) 148 | endif 149 | endfunction 150 | 151 | 152 | function! s:length(str) 153 | return len(s:split_by_keys(a:str)) 154 | endfunction 155 | 156 | 157 | let &cpo = s:save_cpo 158 | unlet s:save_cpo 159 | -------------------------------------------------------------------------------- /autoload/vital/_over/Palette/Capture.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Palette#Capture#import() abort', printf("return map({'help': '', 'extend': '', 'command': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | let s:verbosefiles = [] 16 | 17 | function! s:_verbosefile_push(file) 18 | call add(s:verbosefiles, &verbosefile) 19 | let &verbosefile = a:file 20 | return a:file 21 | endfunction 22 | 23 | 24 | function! s:_verbosefile_pop() 25 | let filename = &verbosefile 26 | let &verbosefile = get(s:verbosefiles, -1) 27 | call remove(s:verbosefiles, -1) 28 | return filename 29 | endfunction 30 | 31 | 32 | function! s:_reset() 33 | let s:verbosefiles = [] 34 | endfunction 35 | 36 | 37 | function! s:extend(dict, src) 38 | for [key, value] in items(a:src) 39 | let a:dict[key] = value 40 | unlet value 41 | endfor 42 | endfunction 43 | 44 | 45 | function! s:command(cmd, ...) 46 | " Workaround : Vim 7.3.xxx in Travis and Ubuntu 47 | " https://github.com/osyo-manga/vital-palette/issues/5 48 | " call extend(l:, get(a:, 1, {})) 49 | if a:0 > 0 50 | call s:extend(l:, a:1) 51 | endif 52 | 53 | call s:_verbosefile_push(tempname()) 54 | try 55 | redir =>result 56 | silent! execute a:cmd 57 | finally 58 | redir END 59 | endtry 60 | call s:_verbosefile_pop() 61 | " let result = substitute(result, "", "\", "g") 62 | " let result = substitute(result, "", "\", "g") 63 | return result 64 | endfunction 65 | 66 | 67 | function! s:_is_help_open() 68 | return index(map(range(1, winnr("$")), "getbufvar(winbufnr(v:val), '&buftype')"), "help") >= 0 69 | endfunction 70 | 71 | 72 | function! s:help(word) 73 | let opened = s:_is_help_open() 74 | silent execute "help" a:word 75 | endfunction 76 | 77 | 78 | let &cpo = s:save_cpo 79 | unlet s:save_cpo 80 | -------------------------------------------------------------------------------- /autoload/vital/_over/Palette/Highlight.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Palette#Highlight#import() abort', printf("return map({'capture': '', '_vital_depends': '', 'parse': '', 'group_list': '', 'set': '', 'parse_to_name': '', 'links_to': '', 'get': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:_vital_loaded(V) 16 | let s:V = a:V 17 | let s:Message = s:V.import("Vim.Message") 18 | endfunction 19 | 20 | 21 | function! s:_vital_depends() 22 | return [ 23 | \ "Vim.Message", 24 | \ ] 25 | endfunction 26 | 27 | 28 | function! s:_execute(cmd) 29 | execute a:cmd 30 | endfunction 31 | 32 | 33 | function! s:capture(name) 34 | if hlexists(a:name) == 0 35 | return "" 36 | endif 37 | return s:Message.capture("highlight " . a:name) 38 | endfunction 39 | 40 | 41 | function! s:links_to(highlight) 42 | return matchstr(a:highlight, '^\S\+\s\+xxx links to \zs.*\ze$') 43 | endfunction 44 | 45 | 46 | function! s:parse_to_name(highlight) 47 | return matchstr(a:highlight, '^\zs\w\+\ze') 48 | endfunction 49 | 50 | 51 | function! s:parse(highlight) 52 | let highlight = a:highlight 53 | 54 | if highlight !~# '^\w\+\s\+xxx\s' 55 | return {} 56 | endif 57 | 58 | let name = s:parse_to_name(a:highlight) 59 | let result = { "_name" : name } 60 | 61 | if highlight =~# '^\w\+\s\+xxx cleared' 62 | let result.cleared = 1 63 | return result 64 | endif 65 | 66 | let link = s:links_to(highlight) 67 | if link != "" 68 | let result.link = link 69 | return result 70 | endif 71 | 72 | let attrs = [ 73 | \ "term", 74 | \ "cterm", 75 | \ "ctermfg", 76 | \ "ctermbg", 77 | \ "gui", 78 | \ "font", 79 | \ "guifg", 80 | \ "guibg", 81 | \ "guisp", 82 | \ ] 83 | for attr in attrs 84 | let item = matchstr(highlight, '\s' . attr . '=\zs#\?\w\+\ze') 85 | if item != "" 86 | let result[attr] = item 87 | endif 88 | endfor 89 | return result 90 | endfunction 91 | 92 | 93 | function! s:get(name, ...) 94 | if !hlexists(a:name) 95 | return {} 96 | endif 97 | let result = s:parse(substitute(s:capture(a:name), "\n", "", "g")) 98 | if has_key(result, "link") && get(a:, 1, 0) 99 | return s:get(result.link, get(a:, 1, 0)) 100 | else 101 | return result 102 | endif 103 | endfunction 104 | 105 | 106 | function! s:set(name, config) 107 | if type(a:config) == type("") 108 | return s:set(a:config, s:get(a:config)) 109 | endif 110 | if has_key(a:config, "cleared") 111 | return s:_execute("highlight clear " . a:name) 112 | endif 113 | if has_key(a:config, "link") 114 | return s:_execute("highlight link " . a:name . " " . a:config.link) 115 | endif 116 | return s:_execute("highlight " . a:name . " " . join(map(items(filter(a:config, "v:key !=# '_name'")), "v:val[0] . '=' . v:val[1]"), " ")) 117 | endfunction 118 | 119 | 120 | function! s:group_list() 121 | let highlights = split(s:Message.capture("highlight"), "\n") 122 | return filter(map(highlights, "s:parse_to_name(v:val)"), "v:val != ''") 123 | endfunction 124 | 125 | 126 | let &cpo = s:save_cpo 127 | unlet s:save_cpo 128 | -------------------------------------------------------------------------------- /autoload/vital/_over/Palette/Keymapping.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#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': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | let s:modep = "[nvoicsxl]" 16 | 17 | 18 | function! s:_vital_loaded(V) 19 | let s:V = a:V 20 | let s:Capture = s:V.import("Palette.Capture") 21 | endfunction 22 | 23 | 24 | function! s:_vital_depends() 25 | return [ 26 | \ "Palette.Capture", 27 | \ ] 28 | endfunction 29 | 30 | 31 | function! s:_capture(mode) 32 | let cmd = "map" 33 | if a:mode ==# "!" 34 | let cmd = cmd . "!" 35 | elseif a:mode =~# "[nvoicsxl]" 36 | let cmd = a:mode . cmd 37 | endif 38 | return s:Capture.command(cmd) 39 | endfunction 40 | 41 | 42 | function! s:capture(...) 43 | let mode = get(a:, 1, "") 44 | let modes = split(mode, '\zs') 45 | return join(map(modes, "s:_capture(v:val)"), "\n") 46 | endfunction 47 | 48 | 49 | function! s:_keymapping(str) 50 | return a:str =~ '^[!nvoicsxl]\s' 51 | endfunction 52 | 53 | 54 | function! s:capture_list(...) 55 | let mode = get(a:, 1, "") 56 | return filter(split(s:capture(mode), "\n"), "s:_keymapping(v:val)") 57 | endfunction 58 | 59 | 60 | function! s:escape_special_key(key) 61 | " Workaround : https://github.com/osyo-manga/vital-palette/issues/5 62 | if a:key ==# "<^?>" 63 | return "\" 64 | endif 65 | execute 'let result = "' . substitute(escape(a:key, '\"'), '\(<.\{-}>\)', '\\\1', 'g') . '"' 66 | return result 67 | endfunction 68 | 69 | 70 | function! s:parse_lhs(text, ...) 71 | let mode = get(a:, 1, '[!nvoicsxl]') 72 | " NOTE: :map! Surpport : https://github.com/osyo-manga/vital-palette/issues/4 73 | if get(a:, 1, "") =~# '[!ci]' 74 | let mode = '[!ci]' 75 | endif 76 | return matchstr(a:text, mode . '\{1,3\}\s*\zs\S\{-}\ze\s\+') 77 | endfunction 78 | 79 | 80 | function! s:parse_lhs_list(...) 81 | let mode = get(a:, 1, "") 82 | return map(s:capture_list(mode), "s:parse_lhs(v:val, mode)") 83 | endfunction 84 | 85 | 86 | function! s:lhs_key_list(...) 87 | let mode = get(a:, 1, "") 88 | return map(s:parse_lhs_list(mode), "s:escape_special_key(v:val)") 89 | endfunction 90 | 91 | 92 | function! s:_maparg(name, mode, abbr, dict) 93 | " Workaround : https://github.com/osyo-manga/vital-palette/issues/5 94 | if a:name ==# "<^?>" 95 | return maparg("\", a:mode, a:abbr, a:dict) 96 | endif 97 | return maparg(a:name, a:mode, a:abbr, a:dict) 98 | endfunction 99 | 100 | 101 | function! s:rhs_key_list(...) 102 | let mode = get(a:, 1, "") 103 | let abbr = get(a:, 2, 0) 104 | let dict = get(a:, 3, 0) 105 | 106 | let result = [] 107 | for m in split(mode, '\zs') 108 | let result += map(s:parse_lhs_list(m), "s:_maparg(v:val, m, abbr, dict)") 109 | endfor 110 | return filter(result, "empty(v:val) == 0") 111 | endfunction 112 | 113 | 114 | let &cpo = s:save_cpo 115 | unlet s:save_cpo 116 | -------------------------------------------------------------------------------- /autoload/vital/_over/Unlocker/Holder.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Unlocker#Holder#import() abort', printf("return map({'_vital_depends': '', 'as_get_deepcopy': '', 'exists': '', 'as_set_extend': '', 'get': '', 'make': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:_glob(expr, dir) 16 | let cwd = getcwd() 17 | try 18 | execute "lcd" fnameescape(a:dir) 19 | return filter(split(glob(a:expr), '\n'), "!isdirectory(v:val)") 20 | finally 21 | execute "lcd" fnameescape(cwd) 22 | endtry 23 | endfunction 24 | 25 | 26 | let s:holder_files = s:_glob("Holder/**", expand(":h")) 27 | 28 | function! s:_to_modulename(file) 29 | let result = substitute(a:file, '^Holder[\/]', '', 'g') 30 | let result = fnamemodify(result, ':r') 31 | let result = substitute(result, '[\/]', ".", "g") 32 | return result 33 | endfunction 34 | 35 | 36 | let s:holder_module_names = map(copy(s:holder_files), "s:_to_modulename(v:val)") 37 | 38 | 39 | let s:holder_module = {} 40 | function! s:_vital_loaded(V) 41 | let s:V = a:V 42 | for name in s:holder_module_names 43 | let s:holder_module[name] = a:V.import("Unlocker.Holder." . name) 44 | endfor 45 | endfunction 46 | 47 | 48 | function! s:_vital_depends() 49 | return map(copy(s:holder_module_names), "'Unlocker.Holder.' . v:val") 50 | endfunction 51 | 52 | 53 | function! s:as_get_deepcopy(holder) 54 | if has_key(a:holder, "__holder_as_get_deepcopy_get") 55 | return a:holder 56 | endif 57 | let result = copy(a:holder) 58 | let result.__holder_as_get_deepcopy_get = result.get 59 | function! result.get() 60 | return deepcopy(self.__holder_as_get_deepcopy_get()) 61 | endfunction 62 | return result 63 | endfunction 64 | 65 | 66 | function! s:as_set_extend(holder) 67 | if has_key(a:holder, "__holder_as_set_extend_set") 68 | return a:holder 69 | endif 70 | let result = copy(a:holder) 71 | let result.__holder_as_set_extend_set = result.set 72 | function! result.set(value) 73 | let result = deepcopy(extend(self.get(), a:value)) 74 | call self.__holder_as_set_extend_set(result) 75 | endfunction 76 | return result 77 | endfunction 78 | 79 | 80 | function! s:get(name) 81 | return get(s:holder_module, a:name, {}) 82 | endfunction 83 | 84 | 85 | function! s:exists(name) 86 | return has_key(s:holder_module, a:name) 87 | endfunction 88 | 89 | 90 | function! s:make(name, ...) 91 | let module = s:get(a:name) 92 | if empty(module) 93 | return {} 94 | endif 95 | return call(module.make, a:000, module) 96 | endfunction 97 | 98 | 99 | " for s:name in s:holder_module_names 100 | " execute 101 | " \ "function! s:" . tolower(substitute(s:name, '\.', '_', 'g')) . "(...)\n" 102 | " \ " return call(s:" . s:name . ".make, a:000, s:" . s:name . ")\n" 103 | " \ "endfunction\n" 104 | " endfor 105 | 106 | 107 | let &cpo = s:save_cpo 108 | unlet s:save_cpo 109 | -------------------------------------------------------------------------------- /autoload/vital/_over/Unlocker/Holder/Any.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Unlocker#Holder#Any#import() abort', printf("return map({'is_option': '', '_vital_depends': '', 'throw': '', 'is_variable': '', 'is_value': '', 'is_holder': '', 'make': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:_is_string(src) 16 | return type(a:src) == type("") 17 | endfunction 18 | 19 | function! s:_vital_loaded(V) 20 | let s:V = a:V 21 | let s:Value = a:V.import("Unlocker.Holder.Value") 22 | let s:Variable = a:V.import("Unlocker.Holder.Variable") 23 | let s:Multi = a:V.import("Unlocker.Holder.Multi") 24 | let s:Register = a:V.import("Unlocker.Holder.Register") 25 | endfunction 26 | 27 | 28 | function! s:_vital_depends() 29 | return [ 30 | \ "Unlocker.Holder.Variable", 31 | \ "Unlocker.Holder.Value", 32 | \ "Unlocker.Holder.Multi", 33 | \ "Unlocker.Holder.Register", 34 | \ ] 35 | endfunction 36 | 37 | 38 | function! s:is_holder(rhs) 39 | return type(a:rhs) == type({}) 40 | \ && type(get(a:rhs, "get", "")) == type(function("tr")) 41 | \ && type(get(a:rhs, "set", "")) == type(function("tr")) 42 | endfunction 43 | 44 | 45 | function! s:is_option(rhs) 46 | return type(a:rhs) == type("") 47 | \ && exists("&" . a:rhs) 48 | endfunction 49 | 50 | 51 | function! s:is_variable(rhs) 52 | return !s:is_option(a:rhs) 53 | \ && s:_is_string(a:rhs) 54 | \ && a:rhs =~ '^[a-zA-Z&]' 55 | \ && exists(a:rhs) 56 | endfunction 57 | 58 | 59 | function! s:is_value(rhs) 60 | let type = type(a:rhs) 61 | return type == type({}) || type == type([]) 62 | endfunction 63 | 64 | 65 | function! s:throw(exp) 66 | execute "throw" string(a:exp) 67 | endfunction 68 | 69 | 70 | function! s:make(rhs, ...) 71 | return a:0 >= 1 ? s:Multi.make(map([a:rhs] + a:000, "s:make(v:val)")) 72 | \ : s:is_holder(a:rhs) ? a:rhs 73 | \ : s:Value.is_makeable(a:rhs) ? s:Value.make(a:rhs) 74 | \ : s:Variable.is_makeable(a:rhs) ? s:Variable.make(a:rhs) 75 | \ : s:Register.is_makeable(a:rhs) ? s:Register.make(a:rhs) 76 | \ : s:is_option(a:rhs) ? s:Variable.make("&" . a:rhs) 77 | \ : s:throw("vital-unlocker Unlocker.Holder.Any.make() : No supported value.") 78 | endfunction 79 | 80 | 81 | let &cpo = s:save_cpo 82 | unlet s:save_cpo 83 | -------------------------------------------------------------------------------- /autoload/vital/_over/Unlocker/Holder/Buffer/Text.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Unlocker#Holder#Buffer#Text#import() abort', printf("return map({'_vital_depends': '', 'is_makeable': '', 'make': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | let s:obj = {} 14 | 15 | 16 | 17 | function! s:_vital_loaded(V) 18 | let s:Buffer = a:V.import("Coaster.Buffer") 19 | endfunction 20 | 21 | 22 | function! s:_vital_depends() 23 | return [ 24 | \ "Coaster.Buffer", 25 | \ ] 26 | endfunction 27 | 28 | 29 | 30 | function! s:obj.get() 31 | return getbufline(self.__expr, self.__lnum, self.__end) 32 | endfunction 33 | 34 | 35 | function! s:obj.set(value) 36 | if bufnr(self.__expr) == bufnr("%") 37 | call setline(self.__lnum, a:value) 38 | else 39 | call s:Buffer.setbufline(self.__expr, self.__lnum, a:value) 40 | endif 41 | return self 42 | endfunction 43 | 44 | 45 | function! s:is_makeable(rhs) 46 | return bufexists(a:rhs) 47 | endfunction 48 | 49 | 50 | function! s:make(expr, ...) 51 | let result = deepcopy(s:obj) 52 | let result.__expr = a:expr 53 | let result.__lnum = get(a:, 1, 1) 54 | let result.__end = get(a:, 2, "$") 55 | return result 56 | endfunction 57 | 58 | 59 | let &cpo = s:save_cpo 60 | unlet s:save_cpo 61 | -------------------------------------------------------------------------------- /autoload/vital/_over/Unlocker/Holder/Buffer/Undofile.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Unlocker#Holder#Buffer#Undofile#import() abort', printf("return map({'is_makeable': '', 'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | let s:obj = {} 14 | 15 | 16 | function! s:obj.get() 17 | let file = get(a:, 1, tempname()) 18 | execute "wundo!" file 19 | return file 20 | endfunction 21 | 22 | 23 | function! s:obj.set(value) 24 | if filereadable(a:value) 25 | silent execute "rundo" a:value 26 | else 27 | throw "vital-unlocker Unlocker.Holder.Buffer.Undofile : No filereadable '" . a:value . "'." 28 | endif 29 | return self 30 | endfunction 31 | 32 | 33 | function! s:is_makeable(rhs) 34 | return filereadable(a:rhs) 35 | endfunction 36 | 37 | 38 | function! s:make() 39 | let result = deepcopy(s:obj) 40 | return result 41 | endfunction 42 | 43 | 44 | let &cpo = s:save_cpo 45 | unlet s:save_cpo 46 | -------------------------------------------------------------------------------- /autoload/vital/_over/Unlocker/Holder/File.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Unlocker#Holder#File#import() abort', printf("return map({'is_makeable': '', 'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | let s:obj = {} 15 | 16 | function! s:obj.get() 17 | return readfile(self.__file) 18 | endfunction 19 | 20 | 21 | function! s:obj.set(value) 22 | call writefile(a:value, self.__file) 23 | return self 24 | endfunction 25 | 26 | 27 | function! s:is_makeable(expr) 28 | return filereadable(a:expr) 29 | endfunction 30 | 31 | 32 | function! s:make(expr) 33 | let result = deepcopy(s:obj) 34 | let result.__file = a:expr 35 | return result 36 | endfunction 37 | 38 | 39 | let &cpo = s:save_cpo 40 | unlet s:save_cpo 41 | -------------------------------------------------------------------------------- /autoload/vital/_over/Unlocker/Holder/Multi.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Unlocker#Holder#Multi#import() abort', printf("return map({'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:_as_list(value) 16 | return type(a:value) == type([]) ? a:value : [a:value] 17 | endfunction 18 | 19 | let s:obj = {} 20 | 21 | function! s:obj.get() 22 | return map(copy(self.__holders), "v:val.get()") 23 | endfunction 24 | 25 | 26 | function! s:obj.set(values) 27 | call map(copy(self.__holders), "v:val.set(a:values[v:key])") 28 | return self 29 | endfunction 30 | 31 | 32 | function! s:make(holders) 33 | let result = deepcopy(s:obj) 34 | let result.__holders = s:_as_list(a:holders) 35 | return result 36 | endfunction 37 | 38 | 39 | 40 | 41 | 42 | let &cpo = s:save_cpo 43 | unlet s:save_cpo 44 | -------------------------------------------------------------------------------- /autoload/vital/_over/Unlocker/Holder/Option.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Unlocker#Holder#Option#import() abort', printf("return map({'is_makeable': '', 'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | let s:obj = {} 14 | 15 | 16 | function! s:obj.get() 17 | return eval(self.__name) 18 | endfunction 19 | 20 | 21 | function! s:obj.set(value) 22 | execute "let " . self.__name . " = a:value" 23 | return self 24 | endfunction 25 | 26 | 27 | function! s:is_makeable(rhs) 28 | return type(a:rhs) == type("") 29 | \ && a:rhs =~ '^[a-zA-Z&]' 30 | \ && exists(a:rhs) 31 | endfunction 32 | 33 | 34 | function! s:make(name) 35 | let result = deepcopy(s:obj) 36 | let result.__name = a:name 37 | return result 38 | endfunction 39 | 40 | 41 | let &cpo = s:save_cpo 42 | unlet s:save_cpo 43 | -------------------------------------------------------------------------------- /autoload/vital/_over/Unlocker/Holder/Position.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Unlocker#Holder#Position#import() abort', printf("return map({'is_makeable': '', 'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | let s:obj = {} 15 | 16 | function! s:obj.get() 17 | return getpos(self.__expr) 18 | endfunction 19 | 20 | 21 | function! s:obj.set(value) 22 | call setpos(self.__expr, a:value) 23 | return self 24 | endfunction 25 | 26 | 27 | function! s:is_makeable(expr) 28 | return a:expr =~ '\.\|''[a-zA-Z]' 29 | endfunction 30 | 31 | 32 | function! s:make(expr) 33 | let result = deepcopy(s:obj) 34 | let result.__expr = a:expr 35 | return result 36 | endfunction 37 | 38 | 39 | let &cpo = s:save_cpo 40 | unlet s:save_cpo 41 | -------------------------------------------------------------------------------- /autoload/vital/_over/Unlocker/Holder/Register.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Unlocker#Holder#Register#import() abort', printf("return map({'is_makeable': '', 'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | let s:obj = {} 15 | 16 | function! s:obj.get() 17 | return getreg(self.__name) 18 | endfunction 19 | 20 | 21 | function! s:obj.set(value) 22 | if self.__option == "" 23 | call setreg(self.__name, a:value) 24 | else 25 | call setreg(self.__name, a:value, self.__option) 26 | endif 27 | return self 28 | endfunction 29 | 30 | 31 | function! s:is_makeable(expr) 32 | return type(a:expr) == type("") && a:expr =~# '^@.\+' 33 | endfunction 34 | 35 | 36 | function! s:make(expr, ...) 37 | let result = deepcopy(s:obj) 38 | let result.__name = (strlen(a:expr) == 1 ? a:expr : a:expr[1:]) 39 | let result.__option = get(a:, 1, "") 40 | return result 41 | endfunction 42 | 43 | 44 | let &cpo = s:save_cpo 45 | unlet s:save_cpo 46 | -------------------------------------------------------------------------------- /autoload/vital/_over/Unlocker/Holder/Value.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Unlocker#Holder#Value#import() abort', printf("return map({'is_makeable': '', 'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:_copy_list(lhs, rhs) 16 | call filter(a:lhs, "0") 17 | for i in range(len(a:rhs)) 18 | call add(a:lhs, a:rhs[i]) 19 | endfor 20 | endfunction 21 | 22 | 23 | function! s:_copy_dict(lhs, rhs) 24 | call filter(a:lhs, "0") 25 | call extend(a:lhs, a:rhs) 26 | endfunction 27 | 28 | 29 | function! s:_copy(lhs, rhs) 30 | return type(a:lhs) == type({}) ? s:_copy_dict(a:lhs, a:rhs) 31 | \ : type(a:lhs) == type([]) ? s:_copy_list(a:lhs, a:rhs) 32 | \ : 0 33 | endfunction 34 | 35 | 36 | let s:obj = {} 37 | 38 | function! s:obj.get() 39 | return self.__value 40 | endfunction 41 | 42 | 43 | function! s:obj.set(value) 44 | call s:_copy(self.__value, a:value) 45 | return self 46 | endfunction 47 | 48 | 49 | function! s:is_makeable(rhs) 50 | let type = type(a:rhs) 51 | return type == type({}) || type == type([]) 52 | endfunction 53 | 54 | 55 | function! s:make(value) 56 | if !(type(a:value) == type([]) 57 | \ || type(a:value) == type({})) 58 | throw "vital-unlocker Unlocker.Holder.Value.make() : No supported value type." 59 | endif 60 | let result = deepcopy(s:obj) 61 | let result.__value = a:value 62 | return result 63 | endfunction 64 | 65 | 66 | let &cpo = s:save_cpo 67 | unlet s:save_cpo 68 | -------------------------------------------------------------------------------- /autoload/vital/_over/Unlocker/Holder/Variable.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Unlocker#Holder#Variable#import() abort', printf("return map({'is_makeable': '', 'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | let s:obj = {} 14 | 15 | 16 | function! s:obj.get() 17 | return eval(self.__name) 18 | endfunction 19 | 20 | 21 | function! s:obj.set(value) 22 | execute "let " . self.__name . " = a:value" 23 | return self 24 | endfunction 25 | 26 | 27 | function! s:is_makeable(rhs) 28 | return type(a:rhs) == type("") 29 | \ && a:rhs =~ '^[a-zA-Z&]' 30 | \ && exists(a:rhs) 31 | endfunction 32 | 33 | 34 | function! s:make(name) 35 | let result = deepcopy(s:obj) 36 | let result.__name = a:name 37 | return result 38 | endfunction 39 | 40 | 41 | let &cpo = s:save_cpo 42 | unlet s:save_cpo 43 | -------------------------------------------------------------------------------- /autoload/vital/_over/Unlocker/Holder/Winview.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Unlocker#Holder#Winview#import() abort', printf("return map({'is_makeable': '', 'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | let s:obj = {} 15 | 16 | function! s:obj.get() 17 | return winsaveview() 18 | endfunction 19 | 20 | 21 | function! s:obj.set(value) 22 | call winrestview(a:value) 23 | return self 24 | endfunction 25 | 26 | 27 | function! s:is_makeable(expr) 28 | return 0 29 | endfunction 30 | 31 | 32 | function! s:make() 33 | let result = deepcopy(s:obj) 34 | return result 35 | endfunction 36 | 37 | 38 | let &cpo = s:save_cpo 39 | unlet s:save_cpo 40 | -------------------------------------------------------------------------------- /autoload/vital/_over/Unlocker/Rocker.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Unlocker#Rocker#import() abort', printf("return map({'file': '', '_vital_depends': '', 'as_locker_by_holder': '', 'any_by_holder': '', 'is_locker': '', 'any': '', 'option': '', 'variable': '', 'as_locker': '', 'get': '', 'lock': '', 'value': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:_vital_loaded(V) 16 | let s:V = a:V 17 | let s:Holder = a:V.import("Unlocker.Holder") 18 | let s:Multi = a:V.import("Unlocker.Rocker.Multi") 19 | let s:HolderBase = a:V.import("Unlocker.Rocker.HolderBase") 20 | endfunction 21 | 22 | 23 | function! s:_vital_depends() 24 | return [ 25 | \ "Unlocker.Rocker.HolderBase", 26 | \ "Unlocker.Rocker.Multi", 27 | \ "Unlocker.Holder", 28 | \ ] 29 | endfunction 30 | 31 | 32 | 33 | function! s:is_locker(obj) 34 | return type(a:obj) == type({}) 35 | \ && type(get(a:obj, "lock", "")) == type(function("tr")) 36 | \ && type(get(a:obj, "unlock", "")) == type(function("tr")) 37 | endfunction 38 | 39 | 40 | function! s:as_locker_by_holder(obj) 41 | return s:HolderBase.make(s:Holder.as_get_deepcopy(a:obj)) 42 | endfunction 43 | 44 | 45 | function! s:as_locker(obj) 46 | return s:is_locker(a:obj) ? a:obj : s:as_locker_by_holder(a:obj) 47 | endfunction 48 | 49 | 50 | function! s:any_by_holder(...) 51 | let any = s:Holder.get("Any") 52 | return s:as_locker_by_holder(call(any.make, a:000, any)) 53 | endfunction 54 | 55 | 56 | function! s:any(obj) 57 | return s:is_locker(a:obj) ? a:obj : s:any_by_holder(a:obj) 58 | endfunction 59 | 60 | 61 | function! s:lock(...) 62 | return s:Multi.make(map(copy(a:000), "s:any(v:val)")).lock() 63 | endfunction 64 | 65 | 66 | function! s:get(holdername) 67 | let holder = s:Holder.get(a:holdername) 68 | return s:as_locker_by_holder(call(holder.make, a:000, holder)) 69 | endfunction 70 | 71 | 72 | let s:holders = [ 73 | \ "Value", 74 | \ "Variable", 75 | \ "Option", 76 | \ "File", 77 | \] 78 | 79 | 80 | for s:name in s:holders 81 | execute join([ 82 | \ "function! s:" . tolower(s:name) . "(...)", 83 | \ " let holder = s:Holder.get('". s:name . "')", 84 | \ " return s:as_locker_by_holder(call(holder.make, a:000, holder))", 85 | \ "endfunction", 86 | \ ], "\n") 87 | endfor 88 | 89 | 90 | " function! s:value(value) 91 | " return s:as_locker_by_holder(s:Holder.value(a:value)) 92 | " endfunction 93 | " 94 | " 95 | " function! s:variable(value) 96 | " return s:as_locker_by_holder(s:Holder.variable(a:value)) 97 | " endfunction 98 | 99 | let &cpo = s:save_cpo 100 | unlet s:save_cpo 101 | -------------------------------------------------------------------------------- /autoload/vital/_over/Unlocker/Rocker/HolderBase.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Unlocker#Rocker#HolderBase#import() abort', printf("return map({'make': '', 'has_concept': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | let s:locker = {} 16 | function! s:locker.lock() 17 | let self.__old = self.get() 18 | return self 19 | endfunction 20 | 21 | 22 | function! s:locker.unlock() 23 | if !has_key(self, "__old") 24 | return -1 25 | endif 26 | call self.set(self.__old) 27 | unlet self.__old 28 | endfunction 29 | 30 | 31 | function! s:locker.relock() 32 | call self.unlock() 33 | call self.lock() 34 | endfunction 35 | 36 | 37 | function! s:has_concept(obj) 38 | return type(a:obj) == type({}) 39 | \ && type(get(a:obj, "get", "")) == type(function("tr")) 40 | \ && type(get(a:obj, "set", "")) == type(function("tr")) 41 | endfunction 42 | 43 | 44 | function! s:make(derived) 45 | if !s:has_concept(a:derived) 46 | throw "vital-unlocker Unlocker.Rocker.HolderBase.make() : Don't has locker concept." 47 | endif 48 | let result = extend(deepcopy(s:locker), a:derived) 49 | return result 50 | endfunction 51 | 52 | 53 | 54 | let &cpo = s:save_cpo 55 | unlet s:save_cpo 56 | -------------------------------------------------------------------------------- /autoload/vital/_over/Unlocker/Rocker/Multi.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Unlocker#Rocker#Multi#import() abort', printf("return map({'make': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:_as_list(value) 16 | return type(a:value) == type([]) ? a:value : [a:value] 17 | endfunction 18 | 19 | let s:obj = {} 20 | 21 | function! s:obj.lock() 22 | call map(copy(self.__rockers), "v:val.lock()") 23 | return self 24 | endfunction 25 | 26 | 27 | function! s:obj.unlock() 28 | call map(copy(self.__rockers), "v:val.unlock()") 29 | endfunction 30 | 31 | 32 | function! s:obj.relock() 33 | call map(copy(self.__rockers), "v:val.relock()") 34 | endfunction 35 | 36 | 37 | function! s:make(rockers) 38 | let result = deepcopy(s:obj) 39 | let result.__rockers = s:_as_list(a:rockers) 40 | return result 41 | endfunction 42 | 43 | 44 | let &cpo = s:save_cpo 45 | unlet s:save_cpo 46 | -------------------------------------------------------------------------------- /autoload/vital/_over/Unlocker/Rocker/Undotree.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Unlocker#Rocker#Undotree#import() abort', printf("return map({'_vital_depends': '', 'make': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | scriptencoding utf-8 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | 15 | function! s:_vital_loaded(V) 16 | let s:Undofile = a:V.import("Unlocker.Holder.Buffer.Undofile") 17 | let s:Option = a:V.import("Unlocker.Holder.Option") 18 | let s:Base = a:V.import("Unlocker.Rocker.HolderBase") 19 | endfunction 20 | 21 | 22 | function! s:_vital_depends() 23 | return [ 24 | \ "Unlocker.Holder.Buffer.Undofile", 25 | \ "Unlocker.Rocker.HolderBase", 26 | \ ] 27 | endfunction 28 | 29 | 30 | let s:obj = {} 31 | 32 | function! s:obj.lock() 33 | if undotree().seq_last == 0 34 | call self.__undolevels.lock() 35 | let &l:undolevels = -1 36 | else 37 | call self.__undofile.lock() 38 | endif 39 | return self 40 | endfunction 41 | 42 | 43 | function! s:obj.unlock() 44 | call self.__undolevels.unlock() 45 | try 46 | call self.__undofile.unlock() 47 | catch /^Vim\%((\a\+)\)\=:E605/ 48 | endtry 49 | return self 50 | endfunction 51 | 52 | 53 | function! s:obj.relock() 54 | call self.unlock() 55 | call self.lock() 56 | endfunction 57 | 58 | 59 | function! s:make() 60 | let result = deepcopy(s:obj) 61 | let result.__undolevels = s:Base.make(s:Option.make("&l:undolevels")) 62 | let result.__undofile = s:Base.make(s:Undofile.make()) 63 | return result 64 | endfunction 65 | 66 | 67 | let &cpo = s:save_cpo 68 | unlet s:save_cpo 69 | -------------------------------------------------------------------------------- /autoload/vital/_over/Vim/Buffer.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Vim#Buffer#import() abort', printf("return map({'parse_cmdarg': '', '_vital_depends': '', 'read_content': '', 'get_selected_text': '', 'is_cmdwin': '', 'edit_content': '', 'open': '', 'get_last_selected': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | let s:save_cpo = &cpo 11 | set cpo&vim 12 | 13 | let s:t_funcref = type(function('tr')) 14 | let s:t_string = type('') 15 | let s:t_number = type(0) 16 | 17 | function! s:_vital_loaded(V) abort 18 | let s:V = a:V 19 | let s:Guard = s:V.import('Vim.Guard') 20 | endfunction 21 | 22 | function! s:_vital_depends() abort 23 | return ['Vim.Guard'] 24 | endfunction 25 | 26 | if exists('*getcmdwintype') 27 | function! s:is_cmdwin() abort 28 | return getcmdwintype() !=# '' 29 | endfunction 30 | else 31 | function! s:is_cmdwin() abort 32 | return bufname('%') ==# '[Command Line]' 33 | endfunction 34 | endif 35 | 36 | function! s:open(buffer, ...) abort 37 | if a:0 == 1 && (type(a:1) == s:t_string || type(a:1) == s:t_funcref) 38 | " For backward compatibility 39 | let options = {'opener': a:1} 40 | else 41 | let options = get(a:000, 0, {}) 42 | endif 43 | let options = extend({ 44 | \ 'mods': '', 45 | \ 'cmdarg': '', 46 | \ 'opener': empty(a:buffer) ? 'enew' : 'edit', 47 | \}, options 48 | \) 49 | 50 | let guard = s:Guard.store(['&wildignore']) 51 | try 52 | let &wildignore = '' 53 | if type(options.opener) == s:t_funcref 54 | let loaded = !bufloaded(a:buffer) 55 | call options.opener(a:buffer) 56 | elseif a:buffer is 0 || a:buffer is# '' 57 | let loaded = 1 58 | silent execute options.mods options.opener 59 | enew 60 | else 61 | let loaded = !bufloaded(a:buffer) 62 | if type(a:buffer) == s:t_string 63 | execute options.mods options.opener options.cmdarg '`=a:buffer`' 64 | elseif type(a:buffer) == s:t_number 65 | silent execute options.mods options.opener 66 | execute a:buffer 'buffer' 67 | else 68 | throw 'vital: Vim.Buffer: Unknown {buffer} type.' 69 | endif 70 | endif 71 | finally 72 | call guard.restore() 73 | endtry 74 | return loaded 75 | endfunction 76 | 77 | function! s:get_selected_text(...) abort 78 | echohl WarningMsg 79 | echom "vital: Vim.Buffer: Warning: s:get_selected_text() is deprecated. Use 's:get_last_selected()'." 80 | echohl None 81 | return call('s:get_last_selected', a:000) 82 | endfunction 83 | 84 | " Get the last selected text in visual mode 85 | " without using |gv| to avoid |textlock|. 86 | " NOTE: 87 | " * This function uses |gv| only when using |CTRL-V| 88 | " because |gv| is the only way to get selected text 89 | " when using $ . 90 | " Please see #192 for the details. 91 | " * If you don't care about |textlock|, 92 | " you can use simple version of this function. 93 | " https://github.com/vim-jp/vital.vim/commit/39aae80f3839fdbeebd838ff14d87327a6b889a9 94 | function! s:get_last_selected() abort 95 | if visualmode() ==# "\" 96 | let save = getreg('"', 1) 97 | let save_type = getregtype('"') 98 | try 99 | normal! gv""y 100 | return @" 101 | finally 102 | call setreg('"', save, save_type) 103 | endtry 104 | else 105 | let [begin, end] = [getpos("'<"), getpos("'>")] 106 | let lastchar = matchstr(getline(end[1])[end[2]-1 :], '.') 107 | if begin[1] ==# end[1] 108 | let lines = [getline(begin[1])[begin[2]-1 : end[2]-2]] 109 | else 110 | let lines = [getline(begin[1])[begin[2]-1 :]] 111 | \ + (end[1] - begin[1] <# 2 ? [] : getline(begin[1]+1, end[1]-1)) 112 | \ + [getline(end[1])[: end[2]-2]] 113 | endif 114 | return join(lines, "\n") . lastchar . (visualmode() ==# 'V' ? "\n" : '') 115 | endif 116 | endfunction 117 | 118 | function! s:read_content(content, ...) abort 119 | let options = extend({ 120 | \ 'tempfile': '', 121 | \ 'fileformat': '', 122 | \ 'encoding': '', 123 | \ 'binary': 0, 124 | \ 'nobinary': 0, 125 | \ 'bad': '', 126 | \ 'edit': 0, 127 | \ 'line': '', 128 | \ 'lockmarks': 0, 129 | \}, get(a:000, 0, {})) 130 | let tempfile = empty(options.tempfile) ? tempname() : options.tempfile 131 | let optnames = [ 132 | \ empty(options.fileformat) ? '' : '++ff=' . options.fileformat, 133 | \ empty(options.encoding) ? '' : '++enc=' . options.encoding, 134 | \ empty(options.binary) ? '' : '++bin', 135 | \ empty(options.nobinary) ? '' : '++nobin', 136 | \ empty(options.bad) ? '' : '++bad=' . options.bad, 137 | \ empty(options.edit) ? '' : '++edit', 138 | \] 139 | let optname = join(filter(optnames, '!empty(v:val)')) 140 | try 141 | call writefile(a:content, tempfile) 142 | execute printf('keepalt keepjumps %s%sread %s%s', 143 | \ options.lockmarks ? 'lockmarks ' : '', 144 | \ options.line, 145 | \ empty(optname) ? '' : optname . ' ', 146 | \ fnameescape(tempfile), 147 | \) 148 | finally 149 | call delete(tempfile) 150 | " To remove 'tempfile' from unlisted-buffer #439 151 | silent execute 'bwipeout!' fnameescape(tempfile) 152 | endtry 153 | endfunction 154 | 155 | function! s:edit_content(content, ...) abort 156 | let options = extend({ 157 | \ 'edit': 1, 158 | \ 'lockmarks': 0, 159 | \}, get(a:000, 0, {})) 160 | let guard = s:Guard.store(['&l:modifiable']) 161 | let saved_view = winsaveview() 162 | try 163 | let &l:modifiable=1 164 | silent execute printf( 165 | \ 'keepjumps %s%%delete _', 166 | \ options.lockmarks ? 'lockmarks ' : '', 167 | \) 168 | silent call s:read_content(a:content, options) 169 | silent execute printf( 170 | \ 'keepjumps %s1delete _', 171 | \ options.lockmarks ? 'lockmarks ' : '', 172 | \) 173 | finally 174 | keepjumps call winrestview(saved_view) 175 | call guard.restore() 176 | endtry 177 | setlocal nomodified 178 | endfunction 179 | 180 | function! s:parse_cmdarg(...) abort 181 | let cmdarg = get(a:000, 0, v:cmdarg) 182 | let options = {} 183 | if cmdarg =~# '++enc=' 184 | let options.encoding = matchstr(cmdarg, '++enc=\zs[^ ]\+\ze') 185 | endif 186 | if cmdarg =~# '++ff=' 187 | let options.fileformat = matchstr(cmdarg, '++ff=\zs[^ ]\+\ze') 188 | endif 189 | if cmdarg =~# '++bad=' 190 | let options.bad = matchstr(cmdarg, '++bad=\zs[^ ]\+\ze') 191 | endif 192 | if cmdarg =~# '++bin' 193 | let options.binary = 1 194 | endif 195 | if cmdarg =~# '++nobin' 196 | let options.nobinary = 1 197 | endif 198 | if cmdarg =~# '++edit' 199 | let options.edit = 1 200 | endif 201 | return options 202 | endfunction 203 | 204 | let &cpo = s:save_cpo 205 | unlet s:save_cpo 206 | 207 | " vim:set et ts=2 sts=2 sw=2 tw=0: 208 | -------------------------------------------------------------------------------- /autoload/vital/_over/Vim/Guard.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Vim#Guard#import() abort', printf("return map({'_vital_depends': '', '_vital_created': '', 'store': '', '_vital_loaded': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | let s:save_cpo = &cpo 11 | set cpo&vim 12 | 13 | " Use a Funcref as a special term _UNDEFINED 14 | function! s:_undefined() abort 15 | return 'undefined' 16 | endfunction 17 | let s:_UNDEFINED = function('s:_undefined') 18 | 19 | function! s:_vital_loaded(V) abort 20 | let s:V = a:V 21 | let s:Prelude = s:V.import('Prelude') 22 | let s:List = s:V.import('Data.List') 23 | let s:Dict = s:V.import('Data.Dict') 24 | endfunction 25 | function! s:_vital_depends() abort 26 | return ['Prelude', 'Data.List', 'Data.Dict'] 27 | endfunction 28 | function! s:_vital_created(module) abort 29 | " define constant variables 30 | if !exists('s:const') 31 | let s:const = {} 32 | let s:const.is_local_variable_supported = 33 | \ v:version > 703 || (v:version == 703 && has('patch560')) 34 | " NOTE: 35 | " The third argument is available from 7.4.242 but it had bug and that 36 | " bug was fixed from 7.4.513 37 | let s:const.is_third_argument_of_getreg_supported = has('patch-7.4.513') 38 | lockvar s:const 39 | endif 40 | call extend(a:module, s:const) 41 | endfunction 42 | function! s:_throw(msg) abort 43 | throw printf('vital: Vim.Guard: %s', a:msg) 44 | endfunction 45 | 46 | let s:option = {} 47 | function! s:_new_option(name) abort 48 | if a:name !~# '^&' 49 | call s:_throw(printf( 50 | \'An option name "%s" requires to be started from "&"', a:name 51 | \)) 52 | elseif !exists(a:name) 53 | call s:_throw(printf( 54 | \'An option name "%s" does not exist', a:name 55 | \)) 56 | endif 57 | let option = copy(s:option) 58 | let option.name = a:name 59 | let option.value = eval(a:name) 60 | return option 61 | endfunction 62 | function! s:option.restore() abort 63 | execute printf('let %s = %s', self.name, string(self.value)) 64 | endfunction 65 | 66 | let s:register = {} 67 | function! s:_new_register(name) abort 68 | if len(a:name) != 2 69 | call s:_throw(printf( 70 | \'A register name "%s" requires to be "@" + a single character', a:name 71 | \)) 72 | elseif a:name !~# '^@' 73 | call s:_throw(printf( 74 | \'A register name "%s" requires to be started from "@"', a:name 75 | \)) 76 | elseif a:name =~# '^@[:.%]$' 77 | call s:_throw(printf( 78 | \'A register name "%s" is read only', a:name 79 | \)) 80 | elseif a:name !~# '^@[@0-9a-zA-Z#=*+~_/-]$' 81 | call s:_throw(printf( 82 | \'A register name "%s" does not exist. See ":help let-register"', a:name 83 | \)) 84 | endif 85 | let name = a:name ==# '@@' ? '' : a:name[1] 86 | let register = copy(s:register) 87 | let register.name = name 88 | if s:const.is_third_argument_of_getreg_supported 89 | let register.value = getreg(name, 1, 1) 90 | else 91 | let register.value = getreg(name, 1) 92 | endif 93 | let register.type = getregtype(name) 94 | return register 95 | endfunction 96 | function! s:register.restore() abort 97 | " https://github.com/vim/vim/commit/5a50c2255c447838d08d3b4895a3be3a41cd8eda 98 | if has('patch-7.4.243') || self.name !=# '=' 99 | call setreg(self.name, self.value, self.type) 100 | else 101 | let @= = self.value 102 | endif 103 | endfunction 104 | 105 | let s:environment = {} 106 | function! s:_new_environment(name) abort 107 | if a:name !~# '^\$' 108 | call s:_throw(printf( 109 | \'An environment variable name "%s" requires to be started from "$"', a:name 110 | \)) 111 | elseif !exists(a:name) 112 | call s:_throw(printf( 113 | \'An environment variable name "%s" does not exist. While Vim cannot unlet environment variable, it requires to exist', a:name 114 | \)) 115 | endif 116 | let environment = copy(s:environment) 117 | let environment.name = a:name 118 | let environment.value = eval(a:name) 119 | return environment 120 | endfunction 121 | function! s:environment.restore() abort 122 | execute printf('let %s = %s', self.name, string(self.value)) 123 | endfunction 124 | 125 | let s:variable = {} 126 | function! s:_new_variable(name, ...) abort 127 | if a:0 == 0 128 | let m = matchlist(a:name, '^\([bwtg]:\)\(.*\)$') 129 | if empty(m) 130 | call s:_throw(printf( 131 | \ join([ 132 | \ 'An variable name "%s" requires to start from b:, w:, t:, or g:', 133 | \ 'while no {namespace} is specified', 134 | \ ]), 135 | \ a:name, 136 | \)) 137 | endif 138 | let [prefix, name] = m[1 : 2] 139 | let namespace = eval(prefix) 140 | else 141 | let name = a:name 142 | let namespace = a:1 143 | endif 144 | let variable = copy(s:variable) 145 | let variable.name = name 146 | let variable.value = get(namespace, name, s:_UNDEFINED) 147 | let variable.value = 148 | \ type(variable.value) == type({}) || type(variable.value) == type([]) 149 | \ ? deepcopy(variable.value) 150 | \ : variable.value 151 | let variable._namespace = namespace 152 | return variable 153 | endfunction 154 | function! s:variable.restore() abort 155 | " unlet the variable to prevent variable type mis-match in case 156 | silent! unlet! self._namespace[self.name] 157 | if type(self.value) == type(s:_UNDEFINED) && self.value == s:_UNDEFINED 158 | " do nothing, leave the variable as undefined 159 | else 160 | let self._namespace[self.name] = self.value 161 | endif 162 | endfunction 163 | 164 | let s:instance = {} 165 | function! s:_new_instance(instance, ...) abort 166 | let shallow = get(a:000, 0, 0) 167 | if !s:Prelude.is_list(a:instance) && !s:Prelude.is_dict(a:instance) 168 | call s:_throw(printf( 169 | \'An instance "%s" requires to be List or Dictionary', string(a:instance) 170 | \)) 171 | endif 172 | let instance = copy(s:instance) 173 | let instance.instance = a:instance 174 | let instance.values = shallow ? copy(a:instance) : deepcopy(a:instance) 175 | return instance 176 | endfunction 177 | function! s:instance.restore() abort 178 | if s:Prelude.is_list(self.instance) 179 | call s:List.clear(self.instance) 180 | else 181 | call s:Dict.clear(self.instance) 182 | endif 183 | call extend(self.instance, self.values) 184 | endfunction 185 | 186 | let s:guard = {} 187 | function! s:store(targets) abort 188 | let resources = [] 189 | for meta in a:targets 190 | if s:Prelude.is_list(meta) 191 | if len(meta) == 1 192 | call add(resources, s:_new_instance(meta[0])) 193 | elseif len(meta) == 2 194 | if s:Prelude.is_string(meta[0]) 195 | call add(resources, call('s:_new_variable', meta)) 196 | else 197 | call add(resources, call('s:_new_instance', meta)) 198 | endif 199 | else 200 | call s:_throw('List assignment requires one or two elements') 201 | endif 202 | elseif type(meta) == type('') 203 | if meta =~# '^[bwtgls]:' 204 | " Note: 205 | " To improve an error message, handle l:XXX or s:XXX as well 206 | call add(resources, s:_new_variable(meta)) 207 | elseif meta =~# '^&' 208 | call add(resources, s:_new_option(meta)) 209 | elseif meta =~# '^@' 210 | call add(resources, s:_new_register(meta)) 211 | elseif meta =~# '^\$' 212 | call add(resources, s:_new_environment(meta)) 213 | else 214 | call s:_throw(printf( 215 | \ 'Unknown value "%s" was specified', 216 | \ meta 217 | \)) 218 | endif 219 | endif 220 | unlet meta 221 | endfor 222 | let guard = copy(s:guard) 223 | let guard._resources = resources 224 | return guard 225 | endfunction 226 | function! s:guard.restore() abort 227 | for resource in self._resources 228 | call resource.restore() 229 | endfor 230 | endfunction 231 | 232 | let &cpo = s:save_cpo 233 | unlet! s:save_cpo 234 | " vim:set et ts=2 sts=2 sw=2 tw=0 fdm=marker: 235 | -------------------------------------------------------------------------------- /autoload/vital/_over/Vim/Message.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Vim#Message#import() abort', printf("return map({'capture': '', 'echomsg': '', 'echo': '', 'warn': '', 'get_hit_enter_max_length': '', 'error': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | let s:save_cpo = &cpo 11 | set cpo&vim 12 | 13 | 14 | 15 | function! s:echo(hl, msg) abort 16 | execute 'echohl' a:hl 17 | try 18 | echo a:msg 19 | finally 20 | echohl None 21 | endtry 22 | endfunction 23 | 24 | function! s:echomsg(hl, msg) abort 25 | execute 'echohl' a:hl 26 | try 27 | for m in split(a:msg, "\n") 28 | echomsg m 29 | endfor 30 | finally 31 | echohl None 32 | endtry 33 | endfunction 34 | 35 | function! s:error(msg) abort 36 | call s:echomsg('ErrorMsg', a:msg) 37 | endfunction 38 | 39 | function! s:warn(msg) abort 40 | call s:echomsg('WarningMsg', a:msg) 41 | endfunction 42 | 43 | function! s:capture(command) abort 44 | try 45 | redir => out 46 | silent execute a:command 47 | finally 48 | redir END 49 | endtry 50 | return out 51 | endfunction 52 | 53 | " * Get max length of |hit-enter|. 54 | " If a string length of a message is greater than the max length, 55 | " Vim waits for user input according to |hit-enter|. 56 | " XXX: Those fixed values may be different between different OSes? 57 | " Currently tested on only Windows. 58 | function! s:get_hit_enter_max_length() abort 59 | let maxlen = &columns * &cmdheight - 1 60 | if &ruler 61 | " TODO 62 | endif 63 | if &showcmd 64 | let maxlen -= 11 65 | endif 66 | return maxlen 67 | endfunction 68 | 69 | 70 | 71 | let &cpo = s:save_cpo 72 | unlet s:save_cpo 73 | 74 | " vim:set et ts=2 sts=2 sw=2 tw=0: 75 | -------------------------------------------------------------------------------- /autoload/vital/_over/Vim/Type.vim: -------------------------------------------------------------------------------- 1 | " ___vital___ 2 | " NOTE: lines between '" ___vital___' is generated by :Vitalize. 3 | " Do not mofidify the code nor insert new lines before '" ___vital___' 4 | function! s:_SID() abort 5 | return matchstr(expand(''), '\zs\d\+\ze__SID$') 6 | endfunction 7 | execute join(['function! vital#_over#Vim#Type#import() abort', printf("return map({'is_comparable': '', '_vital_created': '', 'is_predicate': '', 'is_numeric': '', 'is_special': ''}, \"vital#_over#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") 8 | delfunction s:_SID 9 | " ___vital___ 10 | let s:types = { 11 | \ 'number': 0, 12 | \ 'string': 1, 13 | \ 'func': 2, 14 | \ 'list': 3, 15 | \ 'dict': 4, 16 | \ 'float': 5, 17 | \ 'bool': 6, 18 | \ 'none': 7, 19 | \ 'job': 8, 20 | \ 'channel': 9, 21 | \ } 22 | lockvar 1 s:types 23 | 24 | let s:type_names = { 25 | \ '0': 'number', 26 | \ '1': 'string', 27 | \ '2': 'func', 28 | \ '3': 'list', 29 | \ '4': 'dict', 30 | \ '5': 'float', 31 | \ '6': 'bool', 32 | \ '7': 'none', 33 | \ '8': 'job', 34 | \ '9': 'channel', 35 | \ } 36 | lockvar 1 s:type_names 37 | 38 | function! s:_vital_created(module) abort 39 | let a:module.types = s:types 40 | let a:module.type_names = s:type_names 41 | endfunction 42 | 43 | 44 | function! s:is_numeric(value) abort 45 | let t = type(a:value) 46 | return t == s:types.number || t == s:types.float 47 | endfunction 48 | 49 | function! s:is_special(value) abort 50 | let t = type(a:value) 51 | return t == s:types.bool || t == s:types.none 52 | endfunction 53 | 54 | function! s:is_predicate(value) abort 55 | let t = type(a:value) 56 | return t == s:types.number || t == s:types.string || 57 | \ t == s:types.bool || t == s:types.none 58 | endfunction 59 | 60 | function! s:is_comparable(value1, value2) abort 61 | if !exists('s:is_comparable_cache') 62 | let s:is_comparable_cache = s:_make_is_comparable_cache() 63 | endif 64 | return s:is_comparable_cache[type(a:value1)][type(a:value2)] 65 | endfunction 66 | 67 | function! s:_make_is_comparable_cache() abort 68 | let vals = [ 69 | \ 0, '', function('type'), [], {}, 0.0, 70 | \ get(v:, 'false'), 71 | \ get(v:, 'null'), 72 | \ exists('*test_null_job') ? test_null_job() : 0, 73 | \ exists('*test_null_channel') ? test_null_channel() : 0, 74 | \ ] 75 | 76 | let result = [] 77 | for l:V1 in vals 78 | let result_V1 = [] 79 | let result += [result_V1] 80 | for l:V2 in vals 81 | try 82 | let _ = V1 == V2 83 | let result_V1 += [1] 84 | catch 85 | let result_V1 += [0] 86 | endtry 87 | unlet V2 88 | endfor 89 | unlet V1 90 | endfor 91 | return result 92 | endfunction 93 | -------------------------------------------------------------------------------- /autoload/vital/over.vital: -------------------------------------------------------------------------------- 1 | over 2 | e67960bda7f797f9a494215e624950346a1c43cd 3 | 4 | Over 5 | Over.Commandline 6 | Over.Commandline.Modules.Doautocmd 7 | Over.Commandline.Base 8 | Over.Commandline.Maker 9 | Over.Commandline.Modules 10 | Over.Commandline.Modules.All 11 | Over.Commandline.Modules.BufferComplete 12 | Over.Commandline.Modules.Cancel 13 | Over.Commandline.Modules.CursorMove 14 | Over.Commandline.Modules.Delete 15 | Over.Commandline.Modules.DrawCommandline 16 | Over.Commandline.Modules.ExceptionExit 17 | Over.Commandline.Modules.ExceptionMessage 18 | Over.Commandline.Modules.Execute 19 | Over.Commandline.Modules.ExecuteFailedMessage 20 | Over.Commandline.Modules.Exit 21 | Over.Commandline.Modules.HighlightBufferCursor 22 | Over.Commandline.Modules.HistAdd 23 | Over.Commandline.Modules.History 24 | Over.Commandline.Modules.Incsearch 25 | Over.Commandline.Modules.InsertRegister 26 | Over.Commandline.Modules.KeyMapping 27 | Over.Commandline.Modules.NoInsert 28 | Over.Commandline.Modules.Paste 29 | Over.Commandline.Modules.Redraw 30 | Over.Commandline.Modules.Scroll 31 | Over.Signals 32 | Over.String 33 | Over.Commandline.Modules.AsyncUpdate 34 | Over.Commandline.Modules.Digraphs 35 | Over.Commandline.Modules.IgnoreRegexpBackwardWord 36 | Over.Input 37 | Over.Keymapping 38 | Over.Commandline.Modules.LiteralInsert 39 | Over.Exception 40 | Unlocker.Rocker 41 | Unlocker.Rocker.Undotree 42 | Unlocker.Holder 43 | Coaster.Highlight 44 | -------------------------------------------------------------------------------- /doc/over.jax: -------------------------------------------------------------------------------- 1 | *over.txt* |:s| のパターンをハイライトするプラグイン 2 | 3 | ============================================================================== 4 | 目次 *over-contents* 5 | 6 | 概要 |over-introduction| 7 | インターフェース |over-interface| 8 | コマンド |over-commands| 9 | 設定 |over-setting| 10 | over の変数 |over-variables| 11 | over のコマンドラインのハイライト |over-command_line-highlight| 12 | over のコマンドラインのキーマッピング |over-command_line-key-mappings| 13 | over のコマンドラインの autocmd |over-command_line-autocmd| 14 | 15 | 16 | ============================================================================== 17 | 概要 *over-introduction* 18 | 19 | *over.vim* は |:substitute| の {pattern} をハイライトするプラグインです。 20 | この機能を使用する場合、コマンドラインではなくてコマンドラインウィンドウから 21 | |:substitute| を行う必要があります。 22 | また、この場合は {pattern} のみがハイライトされます。 23 | 24 | |:OverCommandLine| を使用すると {pattern} がハイライトされ、{string} のプレ 25 | ビューも行われます。 26 | 27 | Requirements: 28 | Vim 7.3 or above. 29 | |strchars()| and |+conceal| 30 | 31 | 32 | ============================================================================== 33 | インターフェース *over-interface* 34 | 35 | ------------------------------------------------------------------------------ 36 | コマンド *over-commands* 37 | 38 | :OverCommandLine [{input}] *:OverCommandLine* 39 | |over.vim| 独自のコマンドラインを使用して |:substitute| を行います。 40 | このコマンドラインを使用すると {pattern} のハイライトを行い、{string} 41 | のプレビューも行われます。 42 | ただし、独自のコマンドラインなので特定のキーマッピングのみ使用できま 43 | す。 44 | 使用できるキーマッピングは |over-command_line-key-mappings| を参照して 45 | 下さい。 46 | {input} を渡すとその文字列が入力された状態で開始されます。 47 | 48 | :OverCommandLineNoremap {lhs} {rhs} *:OverCommandLineNoremap* 49 | コマンドラインで使用するキーを設定します。 50 | {lhs} のキーが {rhs} に割り当てられます。 51 | また、再マップは行われません。 52 | この設定は |g:over_command_line_key_mappings| に反映されます。 53 | Example: > 54 | OverCommandLineNoremap 55 | OverCommandLineNoremap 56 | < 57 | 58 | :OverCommandLineMap {lhs} {rhs} *:OverCommandLineMap* 59 | |:OverCommandLineNoremap| と同等ですが再マップされます。 60 | 61 | :OverCommandLineUnmap {lhs} *:OverCommandLineUnmap* 62 | {lhs} に設定されているキーマッピングを削除します。 63 | 64 | 65 | ============================================================================== 66 | 設定 *over-setting* 67 | 68 | ------------------------------------------------------------------------------ 69 | over の変数 *over-variables* 70 | 71 | g:over_enable_auto_nohlsearch *g:over_enable_auto_nohlsearch* 72 | 1 が設定されていればコマンドラインウィンドウで |:s| した後に自動的に 73 | |nohlsearch| を呼び出します。 74 | Default: > 75 | let g:over_enable_auto_nohlsearch = 1 76 | < 77 | 78 | g:over_enable_cmd_window *g:over_enable_cmd_window* 79 | 1 が設定されていればコマンドラインウィンドウで |:s| 時にパターン箇所の 80 | ハイライトを行います。 81 | Default: > 82 | let g:over_enable_cmd_window = 1 83 | < 84 | 85 | g:over_command_line_prompt *g:over_command_line_prompt* 86 | |:OverCommandLine| のプロンプトです。 87 | Default: > 88 | let g:over_command_line_prompt = "> " 89 | < 90 | 91 | g:over_command_line_key_mappings *g:over_command_line_key_mappings* 92 | コマンドラインで使用されるキーマッピングを設定します。 93 | {lhs} に複数のキーを設定することもできます。 94 | Example: > 95 | " に 96 | " に割り当てる 97 | " でコマンドラインを抜ける 98 | let g:over_command_line_key_mappings = { 99 | \ "\" : "\", 100 | \ "\" : "\", 101 | \ "\\" : "\", 102 | \} 103 | < 104 | また、以下のようにして式を展開することも出います。 105 | Example: > 106 | " を入力すると "expand('%')" を評価した値が挿入される 107 | let g:over_command_line_key_mappings = { 108 | \ "\" : { 109 | \ "expr" : 1, 110 | \ "key" : "expand('%')", 111 | \ } 112 | \} 113 | < 114 | 115 | *g:over#command_line#search#enable_incsearch* 116 | g:over#command_line#search#enable_incsearch 117 | 0 以外が設定されていれば :/ or :? 時にそのパータンをハイライトする。 118 | Default: > 119 | let g:over#command_line#search#enable_incsearch = 1 120 | < 121 | *g:over#command_line#search#enable_move_cursor* 122 | g:over#command_line#search#enable_move_cursor 123 | 0 以外が設定されていれば :/ or :? 時にそのパータンへカーソルを移動す 124 | る。 125 | Default: > 126 | let g:over#command_line#search#enable_move_cursor = 0 127 | < 128 | *g:over#command_line#paste_escape_chars* 129 | g:over#command_line#paste_escape_chars 130 | 時に挿入するテキストを \ でエスケープする文字を設定する。 131 | Example: > 132 | " $foo.bar / 2 + 1 を挿入すると 133 | " \$foo\.bar \/ 2 + 1 が挿入される 134 | let g:over#command_line#paste_escape_chars = '/.*$^~' 135 | < 136 | 137 | g:over#command_line#paste_filters *g:over#command_line#paste_filters* 138 | 時に挿入するテキストを任意の文字で置換える設定をする。 139 | Default: > 140 | " 改行コードを "\n" や "\r" に置き換えて挿入する 141 | let g:over#command_line#paste_filters = { 142 | \ "\n" : '\\n', 143 | \ "\r" : '\\r', 144 | \} 145 | < 146 | 147 | *g:over#command_line#substitute#highlight_pattern* 148 | g:over#command_line#substitute#highlight_pattern 149 | |:substitute| の {pattern} をハイライトするグループ名です。 150 | 151 | Default: > 152 | let g:over#command_line#substitute#highlight_pattern = "Search" 153 | < 154 | *g:over#command_line#substitute#highlight_string* 155 | g:over#command_line#substitute#highlight_string 156 | |:substitute| の {string} をハイライトするグループ名です。 157 | 158 | Default: > 159 | let g:over#command_line#substitute#highlight_string = "Error" 160 | < 161 | *g:over#command_line#enable_Digraphs* 162 | g:over#command_line#enable_Digraphs 163 | 0 が設定されている場合 |Digraphs| が無効になります。 164 | Default: > 165 | le g:over#command_line#enable_Digraphs = 1 166 | < 167 | NONE:|Digraphs| を有効にすると GUI 版の Vim で起動時にちらつく問題が 168 | あるので、それを抑制したい場合はこの設定を利用してください。 169 | https://github.com/osyo-manga/vital-over/issues 170 | 171 | *g:over#command_line#enable_import_commandline_map* 172 | g:over#command_line#enable_import_commandline_map 173 | 0 が設定されている場合、|:cmap| |:cnoremap| の設定が反映されなくな 174 | ります。 175 | |:cmap| |:cnoremap| の設定が競合してしまう場合は 0 を設定してく 176 | ださい。 177 | 178 | 179 | ============================================================================== 180 | over のコマンドラインのハイライト *over-command_line-highlight* 181 | 182 | |over.vim| で使用される |:highlight| です。 183 | 184 | OverCommandLineCursor *OverCommandLineCursor* 185 | カーソル位置のハイライトです。 186 | コマンドラインの末尾で使用されます。 187 | デフォルトでは |hl-Cursor| が使用されます。 188 | 189 | OverCommandLineCursorInsert *OverCommandLineCursorInsert* 190 | カーソル位置のハイライトです。 191 | コマンドラインの文字上で使用されます。 192 | デフォルトでは |hl-Cursor| を使用し、|underline| が設定されます。 193 | 194 | 195 | 196 | ============================================================================== 197 | over のコマンドラインのキーマッピング *over-command_line-key-mappings* 198 | 199 | コマンドラインで使用できるキーマッピングです。 200 | このキーマッピングは |g:over_command_line_key_map| で変更することが可能で 201 | す。 202 | また、|:cmap| |:cnoremap| で設定したキーマッピングも反映されます。 203 | |:cmap| |:cnoremap| よりも |g:over_command_line_key_map| 等で設定した 204 | キーマッピングが優先されることに注意してください。 205 | 206 | 207 | キー 処理~ 208 | ----------- ------------------------------- 209 | コマンドの実行 210 | コマンドラインから抜ける 211 | 最後にヤンクしたテキストを挿入する 212 | or 1文字削除 213 | カーソルの前にある単語を削除 214 | or カーソルを右に移動 215 | or カーソルを左に移動 216 | or カーソル上の文字を削除 217 | or カーソルを先頭へ移動 218 | or カーソルを末尾へ移動 219 | or 1つ前のコマンド履歴を挿入 220 | or 1つ後のコマンド履歴を挿入 221 | カーソル下のファイル名を挿入 222 | カーソル下の word を挿入 223 | カーソル下の WORD を挿入 224 | バッファ上のワードで補完を行う 225 | {0-9a-z"%#:-.*=} 番号/名前付きレジスタの挿入 226 | 次に打ち込まれた非数字文字をその通りに挿入 227 | 228 | 229 | 以下は特殊なマッピングです。 230 | 使用する場合は |OverCommandLineNoremap| で任意のキーに割り当てて下さい。 231 | 232 | キー 処理~ 233 | (over-cmdline-substitute-jump-pattern) |:substitute| の {pattenr} へ 234 | カーソルを移動 235 | (over-cmdline-substitute-jump-string) |:substitute| の {string} へ 236 | カーソルを移動 237 | (over-cmdline-scroll-y) |CTRL-y| 相当 238 | (over-cmdline-scroll-u) |CTRL-u| 相当 239 | (over-cmdline-scroll-f) |CTRL-f| 相当 240 | (over-cmdline-scroll-e) |CTRL-e| 相当 241 | (over-cmdline-scroll-d) |CTRL-d| 相当 242 | (over-cmdline-scroll-b) |CTRL-b| 相当 243 | 244 | Example: > 245 | OverCommandLineNoremap (over-cmdline-substitute-jump-string) 246 | OverCommandLineNoremap (over-cmdline-substitute-jump-pattern) 247 | < 248 | 249 | 250 | ============================================================================== 251 | over のコマンドラインの autocmd *over-command_line-autocmd* 252 | 253 | |:OverCommandLine| から発行される |autocmd| |User| です。 254 | 255 | 名前 発生するとき~ 256 | OverCmdLineEnter コマンドラインが開始された時 257 | OverCmdLineLeave コマンドラインが終了した時 258 | OverCmdLineExecutePre コマンドが実行される直前 259 | OverCmdLineExecute コマンドが実行された後 260 | OverCmdLineCharPre いずれかのキーが入力された時 261 | コマンドラインにキーが追加される前 262 | OverCmdLineChar いずれかのキーが入力されてコマンドラインに追加された後 263 | OverCmdLineCancel コマンドラインを実行しないで終了した時 264 | 265 | 266 | ============================================================================== 267 | FAQ *over-command_line-faq* 268 | 269 | Q. 時に特殊文字を挿入したい 270 | 271 | A. 次のマッピングを追加してください 272 | 273 | > 274 | OverCommandLineMap 275 | < 276 | 277 | 278 | ============================================================================== 279 | 更新履歴 *over-changelog* 280 | 281 | 3.0 (2015/04/01) 282 | - cmap/cnoremap の設定のインポート 283 | - 時に正規表現を考慮した単語を削除 284 | - digraph の対応 285 | - ( )機能の追加 286 | - キーマッピング時の lhs に複数キーの割り当に対応 287 | - の対応 288 | 289 | 2.0 290 | - リファクタリング 291 | - カーソルのハイライトを変更 292 | - |:/|,:%g/ 時のハイライトを追加 293 | - 特殊キー(CTRL + 文字等)が入力されないように変更 294 | 295 | 296 | ============================================================================== 297 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 298 | -------------------------------------------------------------------------------- /doc/over.txt: -------------------------------------------------------------------------------- 1 | *over.txt* highlighter for |:s| 2 | 3 | ============================================================================== 4 | CONTENTS *over-contents* 5 | 6 | Overview |over-introduction| 7 | Interface |over-interface| 8 | Commands |over-commands| 9 | Settings |over-setting| 10 | Variables |over-variables| 11 | Highlight settings |over-command_line-highlight| 12 | Key mappings |over-command_line-key-mappings| 13 | autocmd |over-command_line-autocmd| 14 | Change log |over-changelog| 15 | 16 | 17 | ============================================================================== 18 | OVERVIEW *over-introduction* 19 | 20 | *over.vim* is a plug-in that highlights the {pattern} parameter 21 | from |:substitute| {pattern}. 22 | 23 | Alternatively you can switch to the command line with |:OverCommandLine|. 24 | Here, you can directly type your {pattern} and it will be automatically 25 | highlighted and the {string} replacement will be previewed. 26 | 27 | Requirements: 28 | Vim 7.3 or above. 29 | |strchars()| and |+conceal| 30 | 31 | 32 | ============================================================================== 33 | INTERFACE *over-interface* 34 | 35 | ------------------------------------------------------------------------------ 36 | COMMANDS *over-commands* 37 | 38 | :OverCommandLine [{input}] *:OverCommandLine* 39 | |over.vim| standalone command line mode emulating |:substitute|. 40 | It will highlight your {pattern} and the {string} replacement will be 41 | previewed. 42 | 43 | While in command line mode, only a subset of key mappings are available see 44 | |over-command_line-key-mappings| for details. 45 | 46 | {input} pre-feed the command line with the given input. 47 | 48 | :OverCommandLineNoremap {lhs} {rhs} *:OverCommandLineNoremap* 49 | It is the same as :OverCommandLine but with a specified key remap. 50 | {lhs} will be substitued by {rhs}. 51 | You can only substitute one key or one key with at most one modifier. 52 | You can set it up in |g:over_command_line_key_mappings|. 53 | Example: > 54 | OverCommandLineNoremap 55 | OverCommandLineNoremap 56 | < 57 | 58 | ============================================================================== 59 | SETTINGS *over-setting* 60 | 61 | ------------------------------------------------------------------------------ 62 | VARIABLES *over-variables* 63 | 64 | g:over_enable_auto_nohlsearch *g:over_enable_auto_nohlsearch* 65 | set to 1 to enable the highlighting from the command line automatically 66 | Default: > 67 | let g:over_enable_auto_nohlsearch = 1 68 | < 69 | 70 | g:over_enable_cmd_window *g:over_enable_cmd_window* 71 | set to 1 in order to enable the command line 72 | 73 | Default: > 74 | let g:over_enable_cmd_window = 1 75 | < 76 | 77 | g:over_command_line_prompt *g:over_command_line_prompt* 78 | sets the |:OverCommandLine| prompt. 79 | Default: > 80 | let g:over_command_line_prompt = "> " 81 | < 82 | 83 | g:over_command_line_key_mappings *g:over_command_line_key_mappings* 84 | Sets the key mapping used on the command line. 85 | You can only substitute one key or one key with at most one modifier. 86 | Example: > 87 | " assigned to 88 | " assigned to 89 | let g:over_command_line_key_mappings = { 90 | \ "\" : "\", 91 | \ "\" : "\", 92 | \} 93 | < 94 | *g:over#command_line#search#enable_incsearch* 95 | g:over#command_line#search#enable_incsearch 96 | Set to 1 if you want to highlight :/ or :? searches. 97 | Default: > 98 | let g:over#command_line#search#enable_incsearch = 1 99 | < 100 | *g:over#command_line#search#enable_move_cursor* 101 | g:over#command_line#search#enable_move_cursor 102 | Set to 1 the pattern highlight will follow the cursor on the 103 | :/ or :? command. 104 | Default: > 105 | let g:over#command_line#search#enable_move_cursor = 0 106 | < 107 | *g:over#command_line#paste_escape_chars* 108 | g:over#command_line#paste_escape_chars 109 | Sets the set of characters to be automatically escaped when a buffer is 110 | pasted on the command line with . 111 | Example: > 112 | " If you paste $foo.bar / 2 + 1 113 | " \$foo\.bar \/ 2 + 1 will be generated on the command line 114 | let g:over#command_line#paste_escape_chars = '/.*$^~' 115 | < 116 | 117 | g:over#command_line#paste_filters *g:over#command_line#paste_filters* 118 | This is a generic way of remplacing the content of the paste buffer 119 | when you paste on the command line with . 120 | Default: > 121 | " This will escape "\n" and "\r" automatically. 122 | let g:over#command_line#paste_filters = { 123 | \ "\n" : '\\n', 124 | \ "\r" : '\\r', 125 | \} 126 | < 127 | g:over#command_line#substitute#replace_pattern_visually 128 | *g:over#command_line#substitute#replace_pattern_visually* 129 | Instead of previewing the replacement next to the replaced pattern, it 130 | visually replaces the pattern instead. 131 | Default: 132 | Not enabled. To enable, set it to 1. 133 | Example: > 134 | The wolf jumps over the sheep. 135 | /\ 136 | || --- You want to replace 'wolf' with 'bear'. 137 | 138 | The [wolf][bear] jumps over the sheep. 139 | /\ 140 | || --- Here is how vim-over will show you the preview normally. 141 | 142 | The [bear] jumps over the sheep. 143 | /\ 144 | || --- Here is how vim-over will show you the preview with this 145 | option enabled. 146 | < 147 | 148 | 149 | ============================================================================== 150 | HIGHLIGHT SETTINGS *over-command_line-highlight* 151 | 152 | |:highlight| color settings are used by |over.vim|. 153 | 154 | OverCommandLineCursor *OverCommandLineCursor* 155 | This is the highlight color of the current cursor position. 156 | The default value is |hl-Cursor|. 157 | 158 | OverCommandLineCursorInsert *OverCommandLineCursorInsert* 159 | This is the highlight color of the current cursor position in insert mode. 160 | The default value is |hl-Cursor| with |underline| set. 161 | 162 | 163 | ============================================================================== 164 | KEY MAPPINGS *over-command_line-key-mappings* 165 | 166 | This is the key mapping that can be used on the command line. 167 | It is specified by setting |g:over_command_line_key_map|. 168 | 169 | Key Action~ 170 | ----------- ------------------------------- 171 | Executes the command 172 | Exits from the command line 173 | Yank into the command line 174 | or Deletes the character the cursor is on 175 | Deletes the previous character 176 | or Moves the cursor to the right 177 | or Moves the cursor to the left 178 | or Deletes the character the cursor is on 179 | or Moves the cursor at the beginning on the line 180 | or Moves the cursor at the end of the line 181 | or Moves up in the command history 182 | or Moves down in the command history 183 | Inserts the name of the current file 184 | Inserts word from under the cursor 185 | Inserts WORD from under the cursor 186 | Autocomplete from the words in the file 187 | {0-9a-z"%#:-.*=} Insert the specified register or named register 188 | 189 | 190 | You can also specify those specific mapping that can be 191 | assigned from |OverCommandLineNoremap|. 192 | 193 | Key Action 194 | ----------- -------- 195 | (over-cmdline-substitute-jump-pattern) Move the cursor to the next 196 | |:substitute| {pattern} 197 | (over-cmdline-substitute-jump-string) Move the cursor to the next 198 | |:substitute| {string} 199 | (over-cmdline-scroll-y) |CTRL-y| equivalent 200 | (over-cmdline-scroll-u) |CTRL-u| equivalent 201 | (over-cmdline-scroll-f) |CTRL-f| equivalent 202 | (over-cmdline-scroll-e) |CTRL-e| equivalent 203 | (over-cmdline-scroll-d) |CTRL-d| equivalent 204 | (over-cmdline-scroll-b) |CTRL-b| equivalent 205 | 206 | Example: > 207 | OverCommandLineNoremap (over-cmdline-substitute-jump-string) 208 | OverCommandLineNoremap (over-cmdline-substitute-jump-pattern) 209 | < 210 | 211 | ============================================================================== 212 | AUTOCMD *over-command_line-autocmd* 213 | 214 | |:OverCommandLine| triggers those following |User| |autocmd|. 215 | 216 | Function Event 217 | OverCmdLineEnter triggered when you enter the command line mode 218 | OverCmdLineLeave triggered when you leave the command line mode 219 | OverCmdLineExecutePre triggered before a command execution 220 | OverCmdLineExecute triggered after a command execution 221 | OverCmdLineCharPre triggered before every character insertion 222 | OverCmdLineChar triggered after every character insertion 223 | OverCmdLineCancel triggered when you exit without running the line 224 | 225 | 226 | ============================================================================== 227 | CHANGE LOG *over-changelog* 228 | 229 | 2.0 230 | - Refactoring 231 | - Change cursor highlight 232 | - Add highlighting :/ and :%g/ 233 | - No input special keys(e.g. , ) 234 | 235 | ============================================================================== 236 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 237 | -------------------------------------------------------------------------------- /plugin/over.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | if exists('g:loaded_over') 3 | finish 4 | endif 5 | let g:loaded_over = 1 6 | 7 | let s:save_cpo = &cpo 8 | set cpo&vim 9 | 10 | 11 | let g:over_enable_auto_nohlsearch = get(g:, "over_enable_auto_nohlsearch", 1) 12 | let g:over_enable_cmd_window = get(g:, "over_enable_cmd_window", 1) 13 | let g:over_command_line_prompt = get(g:, "over_command_line_prompt", "> ") 14 | let g:over_command_line_key_mappings = get(g:, "over_command_line_key_mappings", {}) 15 | 16 | 17 | augroup plugin-over 18 | autocmd! 19 | autocmd CmdwinEnter * if g:over_enable_cmd_window | call over#setup() | endif 20 | autocmd CmdwinLeave * if g:over_enable_cmd_window | call over#unsetup() | endif 21 | augroup END 22 | 23 | 24 | command! -range -nargs=* 25 | \ OverCommandLine 26 | \ call over#command_line( 27 | \ g:over_command_line_prompt, 28 | \ != ? printf("'<,'>%s", ) : , 29 | \ { "line1" : , "line2" : } 30 | \ ) 31 | 32 | 33 | function! s:key_mapping(lhs, rhs, noremap) 34 | let g:over_command_line_key_mappings[a:lhs] = { 35 | \ "key" : a:rhs, 36 | \ "noremap" : a:noremap, 37 | \ } 38 | endfunction 39 | 40 | function! s:as_keymapping(key) 41 | execute 'let result = "' . substitute(a:key, '\(<.\{-}>\)', '\\\1', 'g') . '"' 42 | return result 43 | endfunction 44 | 45 | function! s:unmapping(key) 46 | execute 'let key = "' . substitute(a:key, '\(<.\{-}>\)', '\\\1', 'g') . '"' 47 | unlet g:over_command_line_key_mappings[key] 48 | endfunction 49 | 50 | command! -nargs=* 51 | \ OverCommandLineNoremap 52 | \ call call("s:key_mapping", map([], "s:as_keymapping(v:val)") + [1]) 53 | 54 | command! -nargs=* 55 | \ OverCommandLineMap 56 | \ call call("s:key_mapping", map([], "s:as_keymapping(v:val)") + [0]) 57 | 58 | command! -nargs=* 59 | \ OverCommandLineUnmap call s:unmapping() 60 | 61 | 62 | let &cpo = s:save_cpo 63 | unlet s:save_cpo 64 | -------------------------------------------------------------------------------- /test/autoload/over.vim: -------------------------------------------------------------------------------- 1 | 2 | function! s:test_parse_substitute() 3 | let owl_SID = owl#filename_to_SID("vim-over/autoload/over.vim") 4 | 5 | OwlCheck s:parse_substitute('/homu') == [] 6 | OwlCheck s:parse_substitute('s/homu') == ["", "homu", "", ""] 7 | OwlCheck s:parse_substitute('%s/homu') == ["%", "homu", "", ""] 8 | OwlCheck s:parse_substitute("'<,'>s/homu") == ["'<,'>", "homu", "", ""] 9 | OwlCheck s:parse_substitute("'<,'>s/homu/mami") == ["'<,'>", "homu", "mami", ""] 10 | OwlCheck s:parse_substitute('''<,''>s/ho\/ou/ma\/mi') == ["'<,'>", 'ho\/ou', 'ma\/mi', ""] 11 | OwlCheck s:parse_substitute('%sa/a//g') == [] 12 | endfunction 13 | 14 | -------------------------------------------------------------------------------- /test/autoload/over/command_line/complete.vim: -------------------------------------------------------------------------------- 1 | 2 | function! s:test_parse_line() 3 | let owl_SID = owl#filename_to_SID("vim-over/autoload/over/command_line/complete.vim") 4 | 5 | OwlCheck s:parse_line("homu/h") == [5, "h"] 6 | OwlCheck s:parse_line("homu") == [0, "homu"] 7 | OwlCheck s:parse_line("//") == [2, ""] 8 | 9 | endfunction 10 | 11 | -------------------------------------------------------------------------------- /test/autoload/over/command_line/substitute.vim: -------------------------------------------------------------------------------- 1 | 2 | function! s:test_restore_option() 3 | let conceallevel = &conceallevel 4 | let &conceallevel = 3 5 | call over#command_line#do("%s/mado/mado\") 6 | echo &conceallevel 7 | OwlCheck &conceallevel == 3 8 | let &conceallevel = conceallevel 9 | endfunction 10 | 11 | 12 | function! s:test_setting_option() 13 | let conceallevel = &conceallevel 14 | let &conceallevel = 3 15 | call over#command_line#do("set conceallevel=0\") 16 | echo &conceallevel 17 | OwlCheck &conceallevel == 0 18 | let &conceallevel = conceallevel 19 | endfunction 20 | 21 | --------------------------------------------------------------------------------