Created
April 21, 2015 04:49
-
-
Save ptzz/1e8c8ac7a92c7e679487 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SCRIPT /Users/ptzz/.vim/bundle/vim-multiple-cursors/autoload/multiple_cursors.vim | |
Sourced 1 time | |
Total time: 0.002148 | |
Self time: 0.002101 | |
count total (s) self (s) | |
"=============================================================================== | |
" Initialization | |
"=============================================================================== | |
" Tweak key settings. If the key is set using 'expr-quote' (h: expr-quote), then | |
" there's nothing that we need to do. If it's set using raw strings, then we | |
" need to convert it. We need to resort to such voodoo exec magic here to get | |
" it to work the way we like. '<C-n>' is converted to '\<C-n>' by the end and | |
" the global vars are replaced by their new value. This is ok since the mapping | |
" using '<C-n>' should already have completed in the plugin file. | |
1 0.000018 for s:key in [ 'g:multi_cursor_next_key', | |
\ 'g:multi_cursor_prev_key', | |
\ 'g:multi_cursor_skip_key', | |
4 0.000008 \ 'g:multi_cursor_quit_key' ] | |
4 0.000020 if exists(s:key) | |
" Translate raw strings like "<C-n>" into key code like "\<C-n>" | |
4 0.000032 exec 'let s:temp = '.s:key | |
4 0.000034 if s:temp =~ '^<.*>$' | |
4 0.000037 exec 'let '.s:key.' = "\'.s:temp.'"' | |
4 0.000007 endif | |
4 0.000004 else | |
" If the user didn't define it, initialize it to an empty string so the | |
" logic later don't break | |
exec 'let '.s:key.' = ""' | |
endif | |
4 0.000009 endfor | |
1 0.000004 unlet! s:key s:temp | |
" These keys will not be replicated at every cursor location. Make sure that | |
" this assignment happens AFTER the key tweak setting above | |
1 0.000012 let s:special_keys = { | |
\ 'v': [ g:multi_cursor_next_key, g:multi_cursor_prev_key, g:multi_cursor_skip_key ], | |
\ 'n': [ g:multi_cursor_next_key ], | |
\ } | |
" The highlight group we use for all the cursors | |
1 0.000004 let s:hi_group_cursor = 'multiple_cursors_cursor' | |
" The highlight group we use for all the visual selection | |
1 0.000004 let s:hi_group_visual = 'multiple_cursors_visual' | |
" Used for preventing multiple calls on before function | |
1 0.000004 let s:before_function_called = 0 | |
" Used for searching whole words (search pattern is wrapped with \< and \>) | |
" Keep old behaviour by default (act like g*) | |
1 0.000003 let s:use_word_boundary = 0 | |
" Set up highlighting | |
1 0.000011 if !hlexists(s:hi_group_cursor) | |
1 0.000017 exec "highlight ".s:hi_group_cursor." term=reverse cterm=reverse gui=reverse" | |
1 0.000001 endif | |
1 0.000006 if !hlexists(s:hi_group_visual) | |
1 0.000011 exec "highlight link ".s:hi_group_visual." Visual" | |
1 0.000002 endif | |
" Temporary buffer that is used for individual paste buffer save/restore | |
" operations | |
1 0.000005 let s:paste_buffer_temporary_text = '' | |
1 0.000003 let s:paste_buffer_temporary_type = '' | |
"=============================================================================== | |
" Internal Mappings | |
"=============================================================================== | |
1 0.000042 inoremap <silent> <Plug>(multiple-cursors-input) <C-o>:call <SID>process_user_input()<CR> | |
1 0.000024 nnoremap <silent> <Plug>(multiple-cursors-input) :call <SID>process_user_input()<CR> | |
1 0.000021 xnoremap <silent> <Plug>(multiple-cursors-input) :<C-u>call <SID>process_user_input()<CR> | |
1 0.000022 inoremap <silent> <Plug>(multiple-cursors-apply) <C-o>:call <SID>apply_user_input_next('i')<CR> | |
1 0.000023 nnoremap <silent> <Plug>(multiple-cursors-apply) :call <SID>apply_user_input_next('n')<CR> | |
1 0.000021 xnoremap <silent> <Plug>(multiple-cursors-apply) :<C-u>call <SID>apply_user_input_next('v')<CR> | |
1 0.000020 inoremap <silent> <Plug>(multiple-cursors-detect) <C-o>:call <SID>detect_bad_input()<CR> | |
1 0.000021 nnoremap <silent> <Plug>(multiple-cursors-detect) :call <SID>detect_bad_input()<CR> | |
1 0.000020 xnoremap <silent> <Plug>(multiple-cursors-detect) :<C-u>call <SID>detect_bad_input()<CR> | |
1 0.000021 inoremap <silent> <Plug>(multiple-cursors-wait) <C-o>:call <SID>wait_for_user_input('')<CR> | |
1 0.000021 nnoremap <silent> <Plug>(multiple-cursors-wait) :call <SID>wait_for_user_input('')<CR> | |
1 0.000021 xnoremap <silent> <Plug>(multiple-cursors-wait) :<C-u>call <SID>wait_for_user_input('')<CR> | |
" Note that although these mappings are seemingly triggerd from Visual mode, | |
" they are in fact triggered from Normal mode. We quit visual mode to allow the | |
" virtual highlighting to take over | |
1 0.000020 nnoremap <silent> <Plug>(multiple-cursors-prev) :<C-u>call multiple_cursors#prev()<CR> | |
1 0.000021 nnoremap <silent> <Plug>(multiple-cursors-skip) :<C-u>call multiple_cursors#skip()<CR> | |
1 0.000028 nnoremap <silent> <Plug>(multiple-cursors-new) :<C-u>call multiple_cursors#new('v', 0)<CR> | |
1 0.000027 nnoremap <silent> <Plug>(multiple-cursors-new-word) :<C-u>call multiple_cursors#new('v', 1)<CR> | |
"=============================================================================== | |
" Public Functions | |
"=============================================================================== | |
" Print some debugging info | |
1 0.000006 function! multiple_cursors#debug() | |
call s:cm.debug() | |
endfunction | |
1 0.000005 function! multiple_cursors#get_latency_debug_file() | |
return s:latency_debug_file | |
endfunction | |
" Creates a new cursor. Different logic applies depending on the mode the user | |
" is in and the current state of the buffer. | |
" 1. In normal mode, a new cursor is created at the end of the word under Vim's | |
" normal cursor | |
" 2. In visual mode, if the visual selection covers more than one line, a new | |
" cursor is created at the beginning of each line | |
" 3. In visual mode, if the visual selection covers a single line, a new cursor | |
" is created at the end of the visual selection. Another cursor will be | |
" attempted to be created at the next occurrence of the visual selection | |
1 0.000004 function! multiple_cursors#new(mode, word_boundary) | |
" Call before function if exists only once until it is canceled (<Esc>) | |
if exists('*Multiple_cursors_before') && !s:before_function_called | |
exe "call Multiple_cursors_before()" | |
let s:before_function_called = 1 | |
endif | |
let s:use_word_boundary = a:word_boundary | |
if a:mode ==# 'n' | |
" Reset all existing cursors, don't restore view and setting | |
call s:cm.reset(0, 0) | |
" Select the word under cursor to set the '< and '> marks | |
exec "normal! viw" | |
call s:exit_visual_mode() | |
" Add cursor with the current visual selection | |
call s:cm.add(s:pos("'>"), s:region("'<", "'>")) | |
call s:wait_for_user_input('v') | |
elseif a:mode ==# 'v' | |
" If the visual area covers the same line, then do a search for next | |
" occurrence | |
let start = line("'<") | |
let finish = line("'>") | |
if start != finish | |
call s:cm.reset(0, 0) | |
let col = col("'<") | |
for line in range(line("'<"), line("'>")) | |
let pos = [line, col] | |
call s:cm.add(pos) | |
endfor | |
" Start in normal mode | |
call s:wait_for_user_input('n') | |
else | |
" Came directly from visual mode | |
if s:cm.is_empty() | |
call s:cm.reset(0, 0) | |
if visualmode() ==# 'V' | |
let left = [line('.'), 1] | |
let right = [line('.'), col('$')-1] | |
if right[1] == 0 " empty line | |
return | |
endif | |
call s:cm.add(right, [left, right]) | |
else | |
call s:cm.add(s:pos("'>"), s:region("'<", "'>")) | |
endif | |
endif | |
let content = s:get_text(s:region("'<", "'>")) | |
let next = s:find_next(content) | |
if s:cm.add(next[1], next) | |
call s:update_visual_markers(next) | |
else | |
call cursor(s:cm.get_current().position) | |
echohl WarningMsg | echo 'No more matches' | echohl None | |
endif | |
call s:wait_for_user_input('v') | |
endif | |
endif | |
endfunction | |
" Delete the current cursor. If there's no more cursors, stop the loop | |
1 0.000004 function! multiple_cursors#prev() | |
call s:cm.delete_current() | |
if !s:cm.is_empty() | |
call s:update_visual_markers(s:cm.get_current().visual) | |
call cursor(s:cm.get_current().position) | |
call s:wait_for_user_input('v') | |
endif | |
endfunction | |
" Skip the current cursor and move to the next cursor | |
1 0.000006 function! multiple_cursors#skip() | |
call s:cm.delete_current() | |
let content = s:get_text(s:region("'<", "'>")) | |
let next = s:find_next(content) | |
call s:cm.add(next[1], next) | |
call s:update_visual_markers(next) | |
call s:wait_for_user_input('v') | |
endfunction | |
" Search for pattern between the start and end line number. For each match, add | |
" a virtual cursor at the end and start multicursor mode | |
" This function is called from a command. User commands in Vim do not support | |
" passing in column ranges. If the user selects a block of text in visual mode, | |
" but not visual line mode, we only want to match patterns within the actual | |
" visual selection. We get around this by checking the last visual selection and | |
" see if its start and end lines match the input. If so, we assume that the user | |
" did a normal visual selection and we use the '< and '> marks to define the | |
" region instead of start and end from the method parameter. | |
1 0.000005 function! multiple_cursors#find(start, end, pattern) | |
let s:cm.saved_winview = winsaveview() | |
let s:cm.start_from_find = 1 | |
if visualmode() ==# 'v' && a:start == line("'<") && a:end == line("'>") | |
let pos1 = s:pos("'<") | |
let pos2 = s:pos("'>") | |
else | |
let pos1 = [a:start, 1] | |
let pos2 = [a:end, col([a:end, '$'])] | |
endif | |
call cursor(pos1) | |
let first = 1 | |
while 1 | |
if first | |
" First search starts from the current position | |
let match = search(a:pattern, 'cW') | |
let first = 0 | |
else | |
let match = search(a:pattern, 'W') | |
endif | |
if !match | |
break | |
endif | |
let left = s:pos('.') | |
call search(a:pattern, 'ceW') | |
let right = s:pos('.') | |
if s:compare_pos(right, pos2) > 0 | |
break | |
endif | |
call s:cm.add(right, [left, right]) | |
" Redraw here forces the cursor movement to be updated. This prevents the | |
" jerky behavior when doing any action once the cursors are added. But it | |
" also slows down adding the cursors dramatically. We need to a better | |
" solution here | |
" redraw | |
endwhile | |
if s:cm.is_empty() | |
call winrestview(s:cm.saved_winview) | |
echohl ErrorMsg | echo 'No match found' | echohl None | |
return | |
else | |
echohl Normal | echo 'Added '.s:cm.size().' cursor'.(s:cm.size()>1?'s':'') | echohl None | |
" If we've created any cursors, we need to call the before function, end | |
" function will be called via normal routes | |
if exists('*Multiple_cursors_before') && !s:before_function_called | |
exe "call Multiple_cursors_before()" | |
let s:before_function_called = 1 | |
endif | |
call s:wait_for_user_input('v') | |
endif | |
endfunction | |
"=============================================================================== | |
" Cursor class | |
"=============================================================================== | |
1 0.000004 let s:Cursor = {} | |
" Create a new cursor. Highlight it and save the current line length | |
1 0.000003 function! s:Cursor.new(position) | |
let obj = copy(self) | |
let obj.position = copy(a:position) | |
let obj.visual = [] | |
" Stores text that was yanked after any commands in Normal or Visual mode | |
let obj.paste_buffer_text = getreg('"') | |
let obj.paste_buffer_type = getregtype('"') | |
let obj.cursor_hi_id = s:highlight_cursor(a:position) | |
let obj.visual_hi_id = 0 | |
let obj.line_length = col([a:position[0], '$']) | |
if has('folding') | |
silent! execute a:position[0] . "foldopen!" | |
endif | |
return obj | |
endfunction | |
" Return the line the cursor is on | |
1 0.000003 function! s:Cursor.line() dict | |
return self.position[0] | |
endfunction | |
" Return the column the cursor is on | |
1 0.000002 function! s:Cursor.column() dict | |
return self.position[1] | |
endfunction | |
" Move the cursor location by the number of lines and columns specified in the | |
" input. The input can be negative. | |
1 0.000002 function! s:Cursor.move(line, column) dict | |
let self.position[0] += a:line | |
let self.position[1] += a:column | |
if !empty(self.visual) | |
let self.visual[0][0] += a:line | |
let self.visual[0][1] += a:column | |
let self.visual[1][0] += a:line | |
let self.visual[1][1] += a:column | |
endif | |
call self.update_highlight() | |
endfunction | |
" Update the current position of the cursor | |
1 0.000003 function! s:Cursor.update_position(pos) dict | |
let self.position[0] = a:pos[0] | |
let self.position[1] = a:pos[1] | |
call self.update_highlight() | |
endfunction | |
" Reapply the highlight on the cursor | |
1 0.000003 function! s:Cursor.update_highlight() dict | |
call s:cm.remove_highlight(self.cursor_hi_id) | |
let self.cursor_hi_id = s:highlight_cursor(self.position) | |
endfunction | |
" Refresh the length of the line the cursor is on. This could change from | |
" underneath | |
1 0.000003 function! s:Cursor.update_line_length() dict | |
let self.line_length = col([self.line(), '$']) | |
endfunction | |
" Update the visual selection and its highlight | |
1 0.000003 function! s:Cursor.update_visual_selection(region) dict | |
let self.visual = deepcopy(a:region) | |
call s:cm.remove_highlight(self.visual_hi_id) | |
let self.visual_hi_id = s:highlight_region(a:region) | |
endfunction | |
" Remove the visual selection and its highlight | |
1 0.000003 function! s:Cursor.remove_visual_selection() dict | |
let self.visual = [] | |
" TODO(terryma): Move functionality into separate class | |
call s:cm.remove_highlight(self.visual_hi_id) | |
let self.visual_hi_id = 0 | |
endfunction | |
" Restore unnamed register from paste buffer | |
1 0.000002 function! s:Cursor.restore_unnamed_register() dict | |
call setreg('"', self.paste_buffer_text, self.paste_buffer_type) | |
endfunction | |
" Save contents of the unnamed register into paste buffer | |
1 0.000002 function! s:Cursor.save_unnamed_register() dict | |
let self.paste_buffer_text = getreg('"') | |
let self.paste_buffer_type = getregtype('"') | |
endfunction | |
"=============================================================================== | |
" CursorManager class | |
"=============================================================================== | |
1 0.000003 let s:CursorManager = {} | |
" Constructor | |
1 0.000002 function! s:CursorManager.new() | |
let obj = copy(self) | |
" List of Cursors we're managing | |
let obj.cursors = [] | |
" Current index into the s:cursors array | |
let obj.current_index = -1 | |
" This marks the starting cursor index into the s:cursors array | |
let obj.starting_index = -1 | |
" We save some user settings when the plugin loads initially | |
let obj.saved_settings = { | |
\ 'virtualedit': &virtualedit, | |
\ 'cursorline': &cursorline, | |
\ 'lazyredraw': &lazyredraw, | |
\ 'paste': &paste, | |
\ 'clipboard': &clipboard, | |
\ } | |
" We save the window view when multicursor mode is entered | |
let obj.saved_winview = [] | |
" Track whether we started multicursor mode from calling multiple_cursors#find | |
let obj.start_from_find = 0 | |
return obj | |
endfunction | |
" Clear all cursors and their highlights | |
1 0.000004 function! s:CursorManager.reset(restore_view, restore_setting, ...) dict | |
if a:restore_view | |
" Return the view back to the beginning | |
if !empty(self.saved_winview) | |
call winrestview(self.saved_winview) | |
endif | |
" If the cursor moved, just restoring the view could get confusing, let's | |
" put the cursor at where the user left it. Only do this if we didn't start | |
" from find mode | |
if !self.is_empty() && !self.start_from_find | |
call cursor(self.get(0).position) | |
endif | |
endif | |
" Delete all cursors and clear their highlights. Don't do clearmatches() as | |
" that will potentially interfere with other plugins | |
if !self.is_empty() | |
for i in range(self.size()) | |
call self.remove_highlight(self.get(i).cursor_hi_id) | |
call self.remove_highlight(self.get(i).visual_hi_id) | |
endfor | |
endif | |
let self.cursors = [] | |
let self.current_index = -1 | |
let self.starting_index = -1 | |
let self.saved_winview = [] | |
let self.start_from_find = 0 | |
let s:char = '' | |
if a:restore_setting | |
call self.restore_user_settings() | |
endif | |
" Call after function if exists and only if action is canceled (<Esc>) | |
if exists('*Multiple_cursors_after') && a:0 && s:before_function_called | |
exe "call Multiple_cursors_after()" | |
let s:before_function_called = 0 | |
endif | |
endfunction | |
" Returns 0 if it's not managing any cursors at the moment | |
1 0.000002 function! s:CursorManager.is_empty() dict | |
return self.size() == 0 | |
endfunction | |
" Returns the number of cursors it's managing | |
1 0.000002 function! s:CursorManager.size() dict | |
return len(self.cursors) | |
endfunction | |
" Returns the current cursor | |
1 0.000002 function! s:CursorManager.get_current() dict | |
return self.cursors[self.current_index] | |
endfunction | |
" Returns the cursor at index i | |
1 0.000002 function! s:CursorManager.get(i) dict | |
return self.cursors[a:i] | |
endfunction | |
" Removes the current cursor and all its associated highlighting. Also update | |
" the current index | |
1 0.000002 function! s:CursorManager.delete_current() dict | |
call self.remove_highlight(self.get_current().cursor_hi_id) | |
call self.remove_highlight(self.get_current().visual_hi_id) | |
call remove(self.cursors, self.current_index) | |
let self.current_index -= 1 | |
endfunction | |
" Remove the highlighting if its matchid exists | |
1 0.000003 function! s:CursorManager.remove_highlight(hi_id) dict | |
if a:hi_id | |
" If the user did a matchdelete or a clearmatches, we don't want to barf if | |
" the matchid is no longer valid | |
silent! call matchdelete(a:hi_id) | |
endif | |
endfunction | |
1 0.000002 function! s:CursorManager.debug() dict | |
let i = 0 | |
for c in self.cursors | |
echom 'cursor #'.i.': pos='.string(c.position).' visual='.string(c.visual) | |
let i+=1 | |
endfor | |
echom 'input = '.s:char | |
echom 'index = '.self.current_index | |
echom 'pos = '.string(s:pos('.')) | |
echom '''< = '.string(s:pos("'<")) | |
echom '''> = '.string(s:pos("'>")) | |
echom 'to mode = '.s:to_mode | |
echom 'from mode = '.s:from_mode | |
" echom 'special keys = '.string(s:special_keys) | |
echom ' ' | |
endfunction | |
" Sync the current cursor to the current Vim cursor. This includes updating its | |
" location, its highlight, and potentially its visual region. Return true if the | |
" position changed, false otherwise | |
1 0.000003 function! s:CursorManager.update_current() dict | |
let cur = self.get_current() | |
if s:to_mode ==# 'v' || s:to_mode ==# 'V' | |
" If we're in visual line mode, we need to go to visual mode before we can | |
" update the visual region | |
if s:to_mode ==# 'V' | |
exec "normal! gvv\<Esc>" | |
endif | |
" Sets the cursor at the right place | |
exec "normal! gv\<Esc>" | |
call cur.update_visual_selection(s:get_visual_region(s:pos('.'))) | |
elseif s:from_mode ==# 'v' || s:from_mode ==# 'V' | |
" Save contents of unnamed register after each operation in Visual mode. | |
" This should be executed after user input is processed, when unnamed | |
" register already contains the text. | |
call cur.save_unnamed_register() | |
call cur.remove_visual_selection() | |
elseif s:from_mode ==# 'i' && s:to_mode ==# 'n' && self.current_index != self.size() - 1 | |
normal! h | |
elseif s:from_mode ==# 'n' | |
" Save contents of unnamed register after each operation in Normal mode. | |
call cur.save_unnamed_register() | |
endif | |
let vdelta = line('$') - s:saved_linecount | |
" If the total number of lines changed in the buffer, we need to potentially | |
" adjust other cursor locations | |
if vdelta != 0 | |
if self.current_index != self.size() - 1 | |
let cur_line_length = len(getline(cur.line())) | |
let new_line_length = len(getline('.')) | |
for i in range(self.current_index+1, self.size()-1) | |
let hdelta = 0 | |
" Note: some versions of Vim don't like chaining function calls like | |
" a.b().c(). For compatibility reasons, don't do it | |
let c = self.get(i) | |
" If there're other cursors on the same line, we need to adjust their | |
" columns. This needs to happen before we adjust their line! | |
if cur.line() == c.line() | |
if vdelta > 0 | |
" Added a line | |
let hdelta = cur_line_length * -1 | |
else | |
" Removed a line | |
let hdelta = new_line_length | |
endif | |
endif | |
call c.move(vdelta, hdelta) | |
endfor | |
endif | |
else | |
" If the line length changes, for all the other cursors on the same line as | |
" the current one, update their cursor location as well | |
let hdelta = col('$') - cur.line_length | |
" Only do this if we're still on the same line as before | |
if hdelta != 0 && cur.line() == line('.') | |
" Update all the cursor's positions that occur after the current cursor on | |
" the same line | |
if self.current_index != self.size() - 1 | |
for i in range(self.current_index+1, self.size()-1) | |
let c = self.get(i) | |
" Only do it for cursors on the same line | |
if cur.line() == c.line() | |
call c.move(0, hdelta) | |
else | |
" Early exit, if we're not on the same line, neither will any cursor | |
" that come after this | |
break | |
endif | |
endfor | |
endif | |
endif | |
endif | |
let pos = s:pos('.') | |
if cur.position == pos | |
return 0 | |
endif | |
call cur.update_position(pos) | |
return 1 | |
endfunction | |
" Advance to the next cursor | |
1 0.000002 function! s:CursorManager.next() dict | |
let self.current_index = (self.current_index + 1) % self.size() | |
endfunction | |
" Start tracking cursor updates | |
1 0.000003 function! s:CursorManager.start_loop() dict | |
let self.starting_index = self.current_index | |
endfunction | |
" Returns true if we're cycled through all the cursors | |
1 0.000002 function! s:CursorManager.loop_done() dict | |
return self.current_index == self.starting_index | |
endfunction | |
" Tweak some user settings, and save our current window view. This is called | |
" every time multicursor mode is entered. | |
" virtualedit needs to be set to onemore for updates to work correctly | |
" cursorline needs to be turned off for the cursor highlight to work on the line | |
" where the real vim cursor is | |
" lazyredraw needs to be turned on to prevent jerky screen behavior with many | |
" cursors on screen | |
" paste mode needs to be switched off since it turns off a bunch of features | |
" that's critical for the plugin to function | |
" clipboard should not have unnamed and unnamedplus otherwise plugin cannot | |
" reliably use unnamed register ('"') | |
1 0.000002 function! s:CursorManager.initialize() dict | |
let self.saved_settings['virtualedit'] = &virtualedit | |
let self.saved_settings['cursorline'] = &cursorline | |
let self.saved_settings['lazyredraw'] = &lazyredraw | |
let self.saved_settings['paste'] = &paste | |
let self.saved_settings['clipboard'] = &clipboard | |
let &virtualedit = "onemore" | |
let &cursorline = 0 | |
let &lazyredraw = 1 | |
let &paste = 0 | |
set clipboard-=unnamed clipboard-=unnamedplus | |
" We could have already saved the view from multiple_cursors#find | |
if !self.start_from_find | |
let self.saved_winview = winsaveview() | |
endif | |
" Save contents and type of unnamed register upon entering multicursor mode | |
" to restore it later when leaving mode | |
let s:paste_buffer_temporary_text = getreg('"') | |
let s:paste_buffer_temporary_type = getregtype('"') | |
endfunction | |
" Restore user settings. | |
1 0.000003 function! s:CursorManager.restore_user_settings() dict | |
if !empty(self.saved_settings) | |
let &virtualedit = self.saved_settings['virtualedit'] | |
let &cursorline = self.saved_settings['cursorline'] | |
let &lazyredraw = self.saved_settings['lazyredraw'] | |
let &paste = self.saved_settings['paste'] | |
let &clipboard = self.saved_settings['clipboard'] | |
endif | |
" Restore original contents and type of unnamed register. This method is | |
" called from reset, which calls us only when restore_setting argument is | |
" true, which happens only when we leave multicursor mode. This should be | |
" symmetrical to saving of unnamed register upon the start of multicursor | |
" mode. | |
call setreg('"', s:paste_buffer_temporary_text, s:paste_buffer_temporary_type) | |
endfunction | |
" Reselect the current cursor's region in visual mode | |
1 0.000002 function! s:CursorManager.reapply_visual_selection() dict | |
call s:select_in_visual_mode(self.get_current().visual) | |
endfunction | |
" Creates a new virtual cursor as 'pos' | |
" Optionally a 'region' object can be passed in as second argument. If set, the | |
" visual region of the cursor will be set to it | |
" Return true if the cursor has been successfully added, false otherwise | |
" Mode change: Normal -> Normal | |
" Cursor change: None (TODO Should we set Vim's cursor to pos?) | |
1 0.000002 function! s:CursorManager.add(pos, ...) dict | |
" Lazy init | |
if self.is_empty() | |
call self.initialize() | |
endif | |
" Don't add duplicates | |
let i = 0 | |
for c in self.cursors | |
if c.position == a:pos | |
return 0 | |
endif | |
let i+=1 | |
endfor | |
let cursor = s:Cursor.new(a:pos) | |
" Save the visual selection | |
if a:0 > 0 | |
call cursor.update_visual_selection(a:1) | |
endif | |
call add(self.cursors, cursor) | |
let self.current_index += 1 | |
return 1 | |
endfunction | |
"=============================================================================== | |
" Variables | |
"=============================================================================== | |
" This is the last user input that we're going to replicate, in its string form | |
1 0.000003 let s:char = '' | |
" This is the mode the user is in before s:char | |
1 0.000003 let s:from_mode = '' | |
" This is the mode the user is in after s:char | |
1 0.000003 let s:to_mode = '' | |
" This is the total number of lines in the buffer before processing s:char | |
1 0.000003 let s:saved_linecount = -1 | |
" This is used to apply the highlight fix. See s:apply_highight_fix() | |
1 0.000003 let s:saved_line = 0 | |
" This is the number of cursor locations where we detected an input that we | |
" cannot play back | |
1 0.000004 let s:bad_input = 0 | |
" Singleton cursor manager instance | |
1 0.000060 0.000013 let s:cm = s:CursorManager.new() | |
"=============================================================================== | |
" Utility functions | |
"=============================================================================== | |
" Return the position of the input marker as a two element array. First element | |
" is the line number, second element is the column number | |
1 0.000004 function! s:pos(mark) | |
let pos = getpos(a:mark) | |
return [pos[1], pos[2]] | |
endfunction | |
" Return the region covered by the input markers as a two element array. First | |
" element is the position of the start marker, second element is the position of | |
" the end marker | |
1 0.000004 function! s:region(start_mark, end_mark) | |
return [s:pos(a:start_mark), s:pos(a:end_mark)] | |
endfunction | |
" Exit visual mode and go back to normal mode | |
" The reason for the additional gv\<Esc> is that it allows the cursor to stay | |
" on where it was before exiting | |
" Mode change: Normal -> Normal or Visual -> Normal | |
" Cursor change: If in visual mode, changed to exactly where it was on screen in | |
" visual mode. If in normal mode, changed to where the cursor was when the last | |
" visual selection ended | |
1 0.000004 function! s:exit_visual_mode() | |
exec "normal! \<Esc>gv\<Esc>" | |
" Call before function if exists only once until it is canceled (<Esc>) | |
if exists('*Multiple_cursors_before') && !s:before_function_called | |
exe "call Multiple_cursors_before()" | |
let s:before_function_called = 1 | |
endif | |
endfunction | |
" Visually select input region, where region is an array containing the start | |
" and end position. If start is after end, the selection simply goes backwards. | |
" Typically m<, m>, and gv would be a simple way of accomplishing this, but on | |
" some systems, the m< and m> marks are not supported. Note that v`` has random | |
" behavior if `` is the same location as the cursor location. | |
" Mode change: Normal -> Visual | |
" Cursor change: Set to end of region | |
" TODO: Refactor this and s:update_visual_markers | |
" FIXME: By using m` we're destroying the user's jumplist. We should use a | |
" different mark and use :keepjump | |
1 0.000004 function! s:select_in_visual_mode(region) | |
if a:region[0] == a:region[1] | |
normal! v | |
else | |
call cursor(a:region[1]) | |
normal! m` | |
call cursor(a:region[0]) | |
normal! v`` | |
endif | |
" Unselect and reselect it again to properly set the '< and '> markers | |
exec "normal! \<Esc>gv" | |
endfunction | |
" Update '< and '> to the input region | |
" Mode change: Normal -> Normal | |
" Cursor change: Set to the end of the region | |
1 0.000004 function! s:update_visual_markers(region) | |
if a:region[0] == a:region[1] | |
normal! v | |
else | |
call cursor(a:region[1]) | |
normal! m` | |
call cursor(a:region[0]) | |
normal! v`` | |
endif | |
call s:exit_visual_mode() | |
endfunction | |
" Finds the next occurrence of the input text in the current buffer. | |
" Search is case sensitive | |
" Mode change: Normal -> Normal | |
" Cursor change: Set to the end of the match | |
1 0.000003 function! s:find_next(text) | |
let pattern = substitute(escape(a:text, '\'), '\n', '\\n', 'g') | |
if s:use_word_boundary == 1 | |
let pattern = '\<'.pattern.'\>' | |
endif | |
let pattern = '\V\C'.pattern | |
call search(pattern) | |
let start = s:pos('.') | |
call search(pattern, 'ce') | |
let end = s:pos('.') | |
return [start, end] | |
endfunction | |
" Highlight the position using the cursor highlight group | |
1 0.000003 function! s:highlight_cursor(pos) | |
" Give cursor highlight high priority, to overrule visual selection | |
return matchadd(s:hi_group_cursor, '\%'.a:pos[0].'l\%'.a:pos[1].'c', 99999) | |
endfunction | |
" Compare two position arrays. Return a negative value if lhs occurs before rhs, | |
" positive value if after, and 0 if they are the same. | |
1 0.000003 function! s:compare_pos(l, r) | |
" If number lines are the same, compare columns | |
return a:l[0] ==# a:r[0] ? a:l[1] - a:r[1] : a:l[0] - a:r[0] | |
endfunction | |
" Highlight the area bounded by the input region. The logic here really stinks, | |
" it's frustrating that Vim doesn't have a built in easier way to do this. None | |
" of the \%V or \%'m solutions work because we need the highlighting to stay for | |
" multiple places. | |
1 0.000006 function! s:highlight_region(region) | |
let s = sort(copy(a:region), "s:compare_pos") | |
if s:to_mode ==# 'V' | |
let pattern = '\%>'.(s[0][0]-1).'l\%<'.(s[1][0]+1).'l.*\ze.\_$' | |
else | |
if (s[0][0] == s[1][0]) | |
" Same line | |
let pattern = '\%'.s[0][0].'l\%>'.(s[0][1]-1).'c.*\%<'.(s[1][1]+1).'c.' | |
else | |
" Two lines | |
let s1 = '\%'.s[0][0].'l.\%>'.s[0][1].'c.*' | |
let s2 = '\%'.s[1][0].'l.*\%<'.s[1][1].'c..' | |
let pattern = s1.'\|'.s2 | |
" More than two lines | |
if (s[1][0] - s[0][0] > 1) | |
let pattern = pattern.'\|\%>'.s[0][0].'l\%<'.s[1][0].'l.*\ze.\_$' | |
endif | |
endif | |
endif | |
return matchadd(s:hi_group_visual, pattern) | |
endfunction | |
" Perform the operation that's necessary to revert us from one mode to another | |
1 0.000003 function! s:revert_mode(from, to) | |
if a:to ==# 'v' | |
call s:cm.reapply_visual_selection() | |
elseif a:to ==# 'V' | |
call s:cm.reapply_visual_selection() | |
normal! V | |
elseif a:to ==# 'n' && a:from ==# 'i' | |
stopinsert | |
endif | |
endfunction | |
" Consume all the additional character the user typed between the last | |
" getchar() and here, to avoid potential race condition. | |
1 0.000003 let s:saved_keys = "" | |
1 0.000004 function! s:feedkeys(keys) | |
while 1 | |
let c = getchar(0) | |
let char_type = type(c) | |
" Checking type is important, when strings are compared with integers, | |
" strings are always converted to ints, and all strings are equal to 0 | |
if char_type == 0 | |
if c == 0 | |
break | |
else | |
let s:saved_keys .= nr2char(c) | |
endif | |
elseif char_type == 1 " char with more than 8 bits (as string) | |
let s:saved_keys .= c | |
endif | |
endwhile | |
call feedkeys(a:keys) | |
endfunction | |
" Take the user input and apply it at every cursor | |
1 0.000003 function! s:process_user_input() | |
" Grr this is frustrating. In Insert mode, between the feedkey call and here, | |
" the current position could actually CHANGE for some odd reason. Forcing a | |
" position reset here | |
call cursor(s:cm.get_current().position) | |
" Before applying the user input, we need to revert back to the mode the user | |
" was in when the input was entered | |
call s:revert_mode(s:to_mode, s:from_mode) | |
" Update the line length BEFORE applying any actions. TODO(terryma): Is there | |
" a better place to do this? | |
call s:cm.get_current().update_line_length() | |
let s:saved_linecount = line('$') | |
" Restore unnamed register only in Normal mode. This should happen before user | |
" input is processed. | |
if s:from_mode ==# 'n' || s:from_mode ==# 'v' || s:from_mode ==# 'V' | |
call s:cm.get_current().restore_unnamed_register() | |
endif | |
" Apply the user input. Note that the above could potentially change mode, we | |
" use the mapping below to help us determine what the new mode is | |
" Note that it's possible that \<Plug>(multiple-cursors-apply) never gets called, we have a | |
" detection mechanism using \<Plug>(multiple-cursors-detect). See its documentation for more details | |
" Assume that input is not valid | |
let s:valid_input = 0 | |
" If we're coming from insert mode or going into insert mode, always chain the | |
" undos together. | |
" FIXME(terryma): Undo always places the cursor at the beginning of the line. | |
" Figure out why. | |
if s:from_mode ==# 'i' || s:to_mode ==# 'i' | |
silent! undojoin | call s:feedkeys(s:char."\<Plug>(multiple-cursors-apply)") | |
else | |
call s:feedkeys(s:char."\<Plug>(multiple-cursors-apply)") | |
endif | |
" Even when s:char produces invalid input, this method is always called. The | |
" 't' here is important | |
call feedkeys("\<Plug>(multiple-cursors-detect)", 't') | |
endfunction | |
" This method is always called during fanout, even when a bad user input causes | |
" s:apply_user_input_next to not be called. We detect that and force the method | |
" to be called to continue the fanout process | |
1 0.000003 function! s:detect_bad_input() | |
if !s:valid_input | |
" We ignore the bad input and force invoke s:apply_user_input_next | |
call feedkeys("\<Plug>(multiple-cursors-apply)") | |
let s:bad_input += 1 | |
endif | |
endfunction | |
" Apply the user input at the next cursor location | |
1 0.000004 function! s:apply_user_input_next(mode) | |
let s:valid_input = 1 | |
" Save the current mode, only if we haven't already | |
if empty(s:to_mode) | |
let s:to_mode = a:mode | |
if s:to_mode ==# 'v' | |
if visualmode() ==# 'V' | |
let s:to_mode = 'V' | |
endif | |
endif | |
endif | |
" Update the current cursor's information | |
let changed = s:cm.update_current() | |
" Advance the cursor index | |
call s:cm.next() | |
" We're done if we're made the full round | |
if s:cm.loop_done() | |
if s:to_mode ==# 'v' || s:to_mode ==# 'V' | |
" This is necessary to set the "'<" and "'>" markers properly | |
call s:update_visual_markers(s:cm.get_current().visual) | |
endif | |
call feedkeys("\<Plug>(multiple-cursors-wait)") | |
else | |
" Continue to next | |
call feedkeys("\<Plug>(multiple-cursors-input)") | |
endif | |
endfunction | |
" If pos is equal to the left side of the visual selection, the region start | |
" from end to start | |
1 0.000004 function! s:get_visual_region(pos) | |
let left = s:pos("'<") | |
let right = s:pos("'>") | |
if a:pos == left | |
let region = [right, left] | |
else | |
let region = [left, right] | |
endif | |
return region | |
endfunction | |
" Return the content of the buffer between the input region. This is used to | |
" find the next match in the buffer | |
" Mode change: Normal -> Normal | |
" Cursor change: None | |
1 0.000003 function! s:get_text(region) | |
let lines = getline(a:region[0][0], a:region[1][0]) | |
let lines[-1] = lines[-1][:a:region[1][1] - 1] | |
let lines[0] = lines[0][a:region[0][1] - 1:] | |
return join(lines, "\n") | |
endfunction | |
" Wrapper around getchar() that returns the string representation of the user | |
" input | |
1 0.000002 function! s:get_char() | |
let c = getchar() | |
" If the character is a number, then it's not a special key | |
if type(c) == 0 | |
let c = nr2char(c) | |
endif | |
return c | |
endfunction | |
" Quits multicursor mode and clears all cursors. Return true if exited | |
" successfully. | |
1 0.000003 function! s:exit() | |
if s:last_char() !=# g:multi_cursor_quit_key | |
return 0 | |
endif | |
let exit = 0 | |
if s:from_mode ==# 'n' | |
let exit = 1 | |
elseif (s:from_mode ==# 'v' || s:from_mode ==# 'V') && | |
\ g:multi_cursor_exit_from_visual_mode | |
let exit = 1 | |
elseif s:from_mode ==# 'i' && g:multi_cursor_exit_from_insert_mode | |
stopinsert | |
let exit = 1 | |
endif | |
if exit | |
call s:cm.reset(1, 1, 1) | |
return 1 | |
endif | |
return 0 | |
endfunction | |
" These keys don't get faned out to all cursor locations. Instead, they're used | |
" to add new / remove existing cursors | |
" Precondition: The function is only called when the keys and mode respect the | |
" setting in s:special_keys | |
1 0.000004 function! s:handle_special_key(key, mode) | |
" Use feedkeys here instead of calling the function directly to prevent | |
" increasing the call stack, since feedkeys execute after the current call | |
" finishes | |
if a:key == g:multi_cursor_next_key | |
if s:use_word_boundary == 1 | |
call s:feedkeys("\<Plug>(multiple-cursors-new-word)") | |
else | |
call s:feedkeys("\<Plug>(multiple-cursors-new)") | |
endif | |
elseif a:key == g:multi_cursor_prev_key | |
call s:feedkeys("\<Plug>(multiple-cursors-prev)") | |
elseif a:key == g:multi_cursor_skip_key | |
call s:feedkeys("\<Plug>(multiple-cursors-skip)") | |
endif | |
endfunction | |
" The last line where the normal Vim cursor is always seems to highlighting | |
" issues if the cursor is on the last column. Vim's cursor seems to override the | |
" highlight of the virtual cursor. This won't happen if the virtual cursor isn't | |
" the last character on the line. This is a hack to add an empty space on the | |
" Vim cursor line right before we do the redraw, we'll revert the change | |
" immedidately after the redraw so the change should not be intrusive to the | |
" user's buffer content | |
1 0.000003 function! s:apply_highlight_fix() | |
" Only do this if we're on the last character of the line | |
if col('.') == col('$') | |
let s:saved_line = getline('.') | |
if s:from_mode ==# 'i' | |
silent! undojoin | call setline('.', s:saved_line.' ') | |
else | |
call setline('.', s:saved_line.' ') | |
endif | |
endif | |
endfunction | |
" Revert the fix if it was applied earlier | |
1 0.000003 function! s:revert_highlight_fix() | |
if type(s:saved_line) == 1 | |
if s:from_mode ==# 'i' | |
silent! undojoin | call setline('.', s:saved_line) | |
else | |
call setline('.', s:saved_line) | |
endif | |
endif | |
let s:saved_line = 0 | |
endfunction | |
1 0.000004 let s:retry_keys = "" | |
1 0.000006 function! s:display_error() | |
if s:bad_input == s:cm.size() | |
\ && s:from_mode ==# 'n' | |
\ && has_key(g:multi_cursor_normal_maps, s:char[0]) | |
" we couldn't replay it anywhere but we're told it's the beginning of a | |
" multi-character map like the `d` in `dw` | |
let s:retry_keys = s:char | |
else | |
let s:retry_keys = "" | |
if s:bad_input > 0 | |
echohl ErrorMsg | | |
\ echo "Key '".s:char."' cannot be replayed at ". | |
\ s:bad_input." cursor location".(s:bad_input == 1 ? '' : 's') | | |
\ echohl Normal | |
endif | |
endif | |
let s:bad_input = 0 | |
endfunction | |
1 0.000004 let s:latency_debug_file = '' | |
1 0.000004 function! s:start_latency_measure() | |
if g:multi_cursor_debug_latency | |
let s:start_time = reltime() | |
endif | |
endfunction | |
1 0.000003 function! s:skip_latency_measure() | |
if g:multi_cursor_debug_latency | |
let s:skip_latency_measure = 1 | |
endif | |
endfunction | |
1 0.000006 function! s:end_latency_measure() | |
if g:multi_cursor_debug_latency && !empty(s:char) | |
if empty(s:latency_debug_file) | |
let s:latency_debug_file = tempname() | |
exec 'redir >> '.s:latency_debug_file | |
silent! echom "Starting latency debug at ".reltimestr(reltime()) | |
redir END | |
endif | |
if !s:skip_latency_measure | |
exec 'redir >> '.s:latency_debug_file | |
silent! echom "Processing '".s:char."' took ".string(str2float(reltimestr(reltime(s:start_time)))*1000).' ms in '.s:cm.size().' cursors. mode = '.s:from_mode | |
redir END | |
endif | |
endif | |
let s:skip_latency_measure = 0 | |
endfunction | |
1 0.000002 function! s:last_char() | |
return s:char[len(s:char)-1] | |
endfunction | |
1 0.000003 function! s:wait_for_user_input(mode) | |
call s:display_error() | |
let s:from_mode = a:mode | |
if empty(a:mode) | |
let s:from_mode = s:to_mode | |
endif | |
let s:to_mode = '' | |
" Right before redraw, apply the highlighting bug fix | |
call s:apply_highlight_fix() | |
redraw | |
" Immediately revert the change to leave the user's buffer unchanged | |
call s:revert_highlight_fix() | |
call s:end_latency_measure() | |
let s:char = s:retry_keys . s:saved_keys | |
if len(s:saved_keys) == 0 | |
let s:char .= s:get_char() | |
else | |
let s:saved_keys = "" | |
endif | |
if s:from_mode ==# 'i' && has_key(g:multi_cursor_insert_maps, s:last_char()) | |
let c = getchar(0) | |
let char_type = type(c) | |
let poll_count = 0 | |
while char_type == 0 && c == 0 && poll_count < &timeoutlen | |
sleep 1m | |
let c = getchar(0) | |
let char_type = type(c) | |
let poll_count += 1 | |
endwhile | |
if char_type == 0 && c != 0 | |
let s:char .= nr2char(c) | |
elseif char_type == 1 " char with more than 8 bits (as string) | |
let s:char .= c | |
endif | |
elseif s:from_mode !=# 'i' && s:char[0] ==# ":" | |
call feedkeys(s:char) | |
call s:cm.reset(1, 1) | |
return | |
elseif s:from_mode ==# 'n' | |
while match(s:last_char(), "\\d") == 0 | |
let s:char .= s:get_char() | |
endwhile | |
endif | |
call s:start_latency_measure() | |
" Clears any echoes we might've added | |
normal! :<Esc> | |
if s:exit() | |
return | |
endif | |
" If the key is a special key and we're in the right mode, handle it | |
if index(get(s:special_keys, s:from_mode, []), s:last_char()) != -1 | |
call s:handle_special_key(s:last_char(), s:from_mode) | |
call s:skip_latency_measure() | |
else | |
call s:cm.start_loop() | |
call s:feedkeys("\<Plug>(multiple-cursors-input)") | |
endif | |
endfunction | |
FUNCTION <SNR>139_revert_highlight_fix() | |
Called 3 times | |
Total time: 0.000086 | |
Self time: 0.000086 | |
count total (s) self (s) | |
3 0.000022 if type(s:saved_line) == 1 | |
if s:from_mode ==# 'i' | |
silent! undojoin | call setline('.', s:saved_line) | |
else | |
call setline('.', s:saved_line) | |
endif | |
endif | |
3 0.000009 let s:saved_line = 0 | |
FUNCTION <SNR>82_exec_separator() | |
Called 24 times | |
Total time: 0.007314 | |
Self time: 0.000851 | |
count total (s) self (s) | |
24 0.002913 0.000134 let l:from = airline#themes#get_highlight(a:from.a:suffix) | |
24 0.002932 0.000125 let l:to = airline#themes#get_highlight(a:to.a:suffix) | |
24 0.000092 let group = a:from.'_to_'.a:to.a:suffix | |
24 0.000027 if a:inverse | |
10 0.000054 let colors = [ l:from[1], l:to[1], l:from[3], l:to[3] ] | |
10 0.000010 else | |
14 0.000069 let colors = [ l:to[1], l:from[1], l:to[3], l:from[3] ] | |
14 0.000012 endif | |
24 0.000076 let a:dict[group] = colors | |
24 0.000992 0.000115 call airline#highlighter#exec(group, colors) | |
FUNCTION Multiple_cursors_before() | |
Called 1 time | |
Total time: 0.000042 | |
Self time: 0.000017 | |
count total (s) self (s) | |
1 0.000040 0.000015 exe 'NeoCompleteLock' | |
FUNCTION neocomplete#is_cache_disabled() | |
Called 513 times | |
Total time: 0.018728 | |
Self time: 0.010943 | |
count total (s) self (s) | |
513 0.001761 let ignore_filetypes = ['fuf', 'ku'] | |
513 0.002188 let bufnr = a:0 > 0 ? a:1 : bufnr('%') | |
513 0.014225 0.006440 return !neocomplete#is_enabled() || index(ignore_filetypes, &filetype) >= 0 || neocomplete#get_current_neocomplete().lock || (g:neocomplete#lock_buffer_name_pattern != '' && bufname(bufnr) =~ g:neocomplete#lock_buffer_name_pattern) | |
FUNCTION neocomplete#util#uniq() | |
Called 965 times | |
Total time: 4.940251 | |
Self time: 0.011181 | |
count total (s) self (s) | |
965 4.939396 0.010326 return call(s:get_list().uniq, a:000) | |
FUNCTION neocomplete#context_filetype#set() | |
Called 579 times | |
Total time: 0.017010 | |
Self time: 0.012139 | |
count total (s) self (s) | |
579 0.007539 0.002668 let neocomplete = neocomplete#get_current_neocomplete() | |
579 0.002982 let context_filetype = s:exists_context_filetype ? context_filetype#get_filetype() : &filetype | |
579 0.001291 if context_filetype == '' | |
let context_filetype = 'nothing' | |
endif | |
579 0.001599 let neocomplete.context_filetype = context_filetype | |
579 0.000980 return neocomplete.context_filetype | |
FUNCTION airline#statusline() | |
Called 8 times | |
Total time: 0.000188 | |
Self time: 0.000188 | |
count total (s) self (s) | |
8 0.000084 if has_key(s:contexts, a:winnr) | |
8 0.000081 return '%{airline#check_mode('.a:winnr.')}'.s:contexts[a:winnr].line | |
endif | |
" in rare circumstances this happens...see #276 | |
return '' | |
FUNCTION airline#check_mode() | |
Called 8 times | |
Total time: 0.014248 | |
Self time: 0.000870 | |
count total (s) self (s) | |
8 0.000041 let context = s:contexts[a:winnr] | |
8 0.000031 if get(w:, 'airline_active', 1) | |
8 0.000031 let l:m = mode() | |
8 0.000022 if l:m ==# "i" | |
let l:mode = ['insert'] | |
elseif l:m ==# "R" | |
let l:mode = ['replace'] | |
elseif l:m =~# '\v(v|V||s|S|)' | |
let l:mode = ['visual'] | |
else | |
8 0.000029 let l:mode = ['normal'] | |
8 0.000008 endif | |
8 0.000050 let w:airline_current_mode = get(g:airline_mode_map, l:m, l:m) | |
8 0.000008 else | |
let l:mode = ['inactive'] | |
let w:airline_current_mode = get(g:airline_mode_map, '__') | |
endif | |
8 0.000035 if g:airline_detect_modified && &modified | |
4 0.000018 call add(l:mode, 'modified') | |
4 0.000004 endif | |
8 0.000018 if g:airline_detect_paste && &paste | |
call add(l:mode, 'paste') | |
endif | |
8 0.000014 if &readonly || ! &modifiable | |
call add(l:mode, 'readonly') | |
endif | |
8 0.000053 let mode_string = join(l:mode) | |
8 0.000042 if get(w:, 'airline_lastmode', '') != mode_string | |
1 0.000091 0.000013 call airline#highlighter#highlight_modified_inactive(context.bufnr) | |
1 0.013314 0.000014 call airline#highlighter#highlight(l:mode) | |
1 0.000003 let w:airline_lastmode = mode_string | |
1 0.000000 endif | |
8 0.000009 return '' | |
FUNCTION <SNR>54_RelativeNumberOnLeave() | |
Called 193 times | |
Total time: 0.005091 | |
Self time: 0.004172 | |
count total (s) self (s) | |
193 0.002111 0.001192 if s:LocalNumber() == 2 | |
193 0.000640 let w:relativenumber = &l:number " Store the 'number' option that configures how the current relative line is displayed (:help number_relativenumber). | |
193 0.001174 setlocal norelativenumber number | |
193 0.000188 else | |
unlet! w:relativenumber | |
endif | |
FUNCTION airline#util#append() | |
Called 24 times | |
Total time: 0.000329 | |
Self time: 0.000329 | |
count total (s) self (s) | |
24 0.000061 if a:minwidth > 0 && winwidth(0) < a:minwidth | |
return '' | |
endif | |
24 0.000110 let prefix = s:spc == "\ua0" ? s:spc : s:spc.s:spc | |
24 0.000088 return empty(a:text) ? '' : prefix.g:airline_left_alt_sep.s:spc.a:text | |
FUNCTION <SNR>139_apply_user_input_next() | |
Called 64 times | |
Total time: 0.024584 | |
Self time: 0.004146 | |
count total (s) self (s) | |
64 0.000252 let s:valid_input = 1 | |
" Save the current mode, only if we haven't already | |
64 0.000234 if empty(s:to_mode) | |
2 0.000006 let s:to_mode = a:mode | |
2 0.000004 if s:to_mode ==# 'v' | |
if visualmode() ==# 'V' | |
let s:to_mode = 'V' | |
endif | |
endif | |
2 0.000002 endif | |
" Update the current cursor's information | |
64 0.020174 0.000648 let changed = s:cm.update_current() | |
" Advance the cursor index | |
64 0.000942 0.000260 call s:cm.next() | |
" We're done if we're made the full round | |
64 0.000607 0.000377 if s:cm.loop_done() | |
2 0.000005 if s:to_mode ==# 'v' || s:to_mode ==# 'V' | |
" This is necessary to set the "'<" and "'>" markers properly | |
call s:update_visual_markers(s:cm.get_current().visual) | |
endif | |
2 0.000017 call feedkeys("\<Plug>(multiple-cursors-wait)") | |
2 0.000002 else | |
" Continue to next | |
62 0.000555 call feedkeys("\<Plug>(multiple-cursors-input)") | |
62 0.000051 endif | |
FUNCTION <SNR>68_sync_active_winnr() | |
Called 97 times | |
Total time: 0.000944 | |
Self time: 0.000944 | |
count total (s) self (s) | |
97 0.000558 if exists('#airline') && winnr() != s:active_winnr | |
call airline#update_statusline() | |
endif | |
FUNCTION <SNR>133_check_in_do_auto_complete() | |
Called 353 times | |
Total time: 0.017599 | |
Self time: 0.002077 | |
count total (s) self (s) | |
353 0.016851 0.001329 if neocomplete#is_locked() | |
353 0.000421 return 1 | |
endif | |
" Detect completefunc. | |
if &l:completefunc != '' && &l:buftype =~ 'nofile' | |
return 1 | |
endif | |
" Detect AutoComplPop. | |
if exists('g:acp_enableAtStartup') && g:acp_enableAtStartup | |
call neocomplete#print_error( 'Detected enabled AutoComplPop! Disabled neocomplete.') | |
NeoCompleteLock | |
return 1 | |
endif | |
FUNCTION airline#themes#get_highlight() | |
Called 48 times | |
Total time: 0.005586 | |
Self time: 0.000357 | |
count total (s) self (s) | |
48 0.005568 0.000339 return call('airline#highlighter#get_highlight', [a:group] + a:000) | |
FUNCTION neocomplete#handler#_do_auto_complete() | |
Called 353 times | |
Total time: 0.020051 | |
Self time: 0.002452 | |
count total (s) self (s) | |
353 0.019358 0.001759 if s:check_in_do_auto_complete() | |
353 0.000371 return | |
endif | |
let neocomplete = neocomplete#get_current_neocomplete() | |
let neocomplete.skipped = 0 | |
let neocomplete.event = a:event | |
let cur_text = neocomplete#get_cur_text(1) | |
call neocomplete#print_debug('cur_text = ' . cur_text) | |
" Prevent infinity loop. | |
if s:is_skip_auto_complete(cur_text) | |
call neocomplete#print_debug('Skipped.') | |
return | |
endif | |
let complete_pos = neocomplete#helper#get_force_omni_complete_pos(cur_text) | |
if complete_pos >= 0 | |
if !s:check_previous_position(cur_text, complete_pos) | |
call s:set_previous_position(cur_text, complete_pos) | |
call s:complete_key("\<Plug>(neocomplete_start_omni_complete)") | |
endif | |
return | |
endif | |
" Check multibyte input or eskk or spaces. | |
if cur_text =~ '^\s*$' || neocomplete#is_eskk_enabled() || neocomplete#is_multibyte_input(cur_text) | |
call neocomplete#print_debug('Skipped.') | |
return | |
endif | |
" Check complete position. | |
let complete_sources = neocomplete#complete#_set_results_pos(cur_text) | |
if empty(complete_sources) | |
call neocomplete#print_debug('Skipped.') | |
return | |
endif | |
" Check previous position | |
let complete_pos = neocomplete#complete#_get_complete_pos(complete_sources) | |
if s:check_previous_position(cur_text, complete_pos) | |
" Same position. | |
return | |
endif | |
call s:set_previous_position(cur_text, complete_pos) | |
try | |
let neocomplete.is_auto_complete = 1 | |
" Do prefetch. | |
let neocomplete.complete_sources = neocomplete#complete#_get_results(cur_text) | |
finally | |
let neocomplete.is_auto_complete = 0 | |
endtry | |
if empty(neocomplete.complete_sources) | |
if !empty(g:neocomplete#fallback_mappings) && len(matchstr(cur_text, '\h\w*$')) >= g:neocomplete#auto_completion_start_length | |
let key = '' | |
for i in range(0, len(g:neocomplete#fallback_mappings)-1) | |
let key .= '<C-r>=neocomplete#mappings#fallback(' . i . ')<CR>' | |
endfor | |
execute 'inoremap <silent> <Plug>(neocomplete_fallback)' key | |
" Fallback to omnifunc | |
call s:complete_key("\<Plug>(neocomplete_fallback)") | |
else | |
call neocomplete#print_debug('Skipped.') | |
return | |
endif | |
return | |
endif | |
let complete_pos = neocomplete#complete#_get_complete_pos( neocomplete.complete_sources) | |
let base = cur_text[complete_pos :] | |
let neocomplete.candidates = neocomplete#complete#_get_words( neocomplete.complete_sources, complete_pos, base) | |
" Start auto complete. | |
call s:complete_key( "\<Plug>(neocomplete_start_auto_complete)") | |
FUNCTION <SNR>139_start_latency_measure() | |
Called 3 times | |
Total time: 0.000021 | |
Self time: 0.000021 | |
count total (s) self (s) | |
3 0.000008 if g:multi_cursor_debug_latency | |
let s:start_time = reltime() | |
endif | |
FUNCTION <SNR>139_exit() | |
Called 3 times | |
Total time: 0.001936 | |
Self time: 0.000123 | |
count total (s) self (s) | |
3 0.000090 0.000060 if s:last_char() !=# g:multi_cursor_quit_key | |
2 0.000003 return 0 | |
endif | |
1 0.000003 let exit = 0 | |
1 0.000004 if s:from_mode ==# 'n' | |
let exit = 1 | |
elseif (s:from_mode ==# 'v' || s:from_mode ==# 'V') && g:multi_cursor_exit_from_visual_mode | |
let exit = 1 | |
elseif s:from_mode ==# 'i' && g:multi_cursor_exit_from_insert_mode | |
1 0.000002 stopinsert | |
1 0.000003 let exit = 1 | |
1 0.000002 endif | |
1 0.000002 if exit | |
1 0.001804 0.000021 call s:cm.reset(1, 1, 1) | |
1 0.000001 return 1 | |
endif | |
return 0 | |
FUNCTION <SNR>139_display_error() | |
Called 3 times | |
Total time: 0.000180 | |
Self time: 0.000165 | |
count total (s) self (s) | |
3 0.000060 0.000045 if s:bad_input == s:cm.size() && s:from_mode ==# 'n' && has_key(g:multi_cursor_normal_maps, s:char[0]) | |
" we couldn't replay it anywhere but we're told it's the beginning of a | |
" multi-character map like the `d` in `dw` | |
let s:retry_keys = s:char | |
else | |
3 0.000028 let s:retry_keys = "" | |
3 0.000008 if s:bad_input > 0 | |
echohl ErrorMsg | echo "Key '".s:char."' cannot be replayed at ". s:bad_input." cursor location".(s:bad_input == 1 ? '' : 's') | echohl Normal | |
endif | |
3 0.000002 endif | |
3 0.000008 let s:bad_input = 0 | |
FUNCTION neocomplete#variables#get_sources() | |
Called 643 times | |
Total time: 0.004900 | |
Self time: 0.004900 | |
count total (s) self (s) | |
643 0.002097 if !exists('s:sources') | |
let s:sources = {} | |
endif | |
643 0.000828 return s:sources | |
FUNCTION airline#parts#filetype() | |
Called 8 times | |
Total time: 0.000021 | |
Self time: 0.000021 | |
count total (s) self (s) | |
8 0.000018 return &filetype | |
FUNCTION airline#parts#iminsert() | |
Called 8 times | |
Total time: 0.000061 | |
Self time: 0.000061 | |
count total (s) self (s) | |
8 0.000025 if g:airline_detect_iminsert && &iminsert && exists('b:keymap_name') | |
return toupper(b:keymap_name) | |
endif | |
8 0.000006 return '' | |
FUNCTION neocomplete#get_context_filetype() | |
Called 579 times | |
Total time: 0.027923 | |
Self time: 0.010913 | |
count total (s) self (s) | |
579 0.003391 let neocomplete = exists('b:neocomplete') ? b:neocomplete : neocomplete#get_current_neocomplete() | |
579 0.001903 if a:0 != 0 || mode() !=# 'i' || neocomplete.context_filetype == '' | |
579 0.019989 0.002979 call neocomplete#context_filetype#set() | |
579 0.000466 endif | |
579 0.000769 return neocomplete.context_filetype | |
FUNCTION <SNR>127_get_member_pattern() | |
Called 579 times | |
Total time: 0.004403 | |
Self time: 0.004403 | |
count total (s) self (s) | |
579 0.003937 return get(g:neocomplete#sources#member#input_patterns, a:filetype, get(g:neocomplete#sources#member#input_patterns, '_', '')) | |
FUNCTION <SNR>139_process_user_input() | |
Called 64 times | |
Total time: 0.017433 | |
Self time: 0.006473 | |
count total (s) self (s) | |
" Grr this is frustrating. In Insert mode, between the feedkey call and here, | |
" the current position could actually CHANGE for some odd reason. Forcing a | |
" position reset here | |
64 0.001159 0.000758 call cursor(s:cm.get_current().position) | |
" Before applying the user input, we need to revert back to the mode the user | |
" was in when the input was entered | |
64 0.005457 0.000631 call s:revert_mode(s:to_mode, s:from_mode) | |
" Update the line length BEFORE applying any actions. TODO(terryma): Is there | |
" a better place to do this? | |
64 0.002678 0.000629 call s:cm.get_current().update_line_length() | |
64 0.000312 let s:saved_linecount = line('$') | |
" Restore unnamed register only in Normal mode. This should happen before user | |
" input is processed. | |
64 0.000274 if s:from_mode ==# 'n' || s:from_mode ==# 'v' || s:from_mode ==# 'V' | |
32 0.000580 0.000227 call s:cm.get_current().restore_unnamed_register() | |
32 0.000030 endif | |
" Apply the user input. Note that the above could potentially change mode, we | |
" use the mapping below to help us determine what the new mode is | |
" Note that it's possible that \<Plug>(multiple-cursors-apply) never gets called, we have a | |
" detection mechanism using \<Plug>(multiple-cursors-detect). See its documentation for more details | |
" Assume that input is not valid | |
64 0.000139 let s:valid_input = 0 | |
" If we're coming from insert mode or going into insert mode, always chain the | |
" undos together. | |
" FIXME(terryma): Undo always places the cursor at the beginning of the line. | |
" Figure out why. | |
64 0.000178 if s:from_mode ==# 'i' || s:to_mode ==# 'i' | |
63 0.004192 0.000933 silent! undojoin | call s:feedkeys(s:char."\<Plug>(multiple-cursors-apply)") | |
63 0.000058 else | |
1 0.000084 0.000012 call s:feedkeys(s:char."\<Plug>(multiple-cursors-apply)") | |
1 0.000001 endif | |
" Even when s:char produces invalid input, this method is always called. The | |
" 't' here is important | |
64 0.000515 call feedkeys("\<Plug>(multiple-cursors-detect)", 't') | |
FUNCTION <SNR>54_RelativeNumberOnEnter() | |
Called 193 times | |
Total time: 0.004856 | |
Self time: 0.003873 | |
count total (s) self (s) | |
"****D echomsg '****' bufnr('').'/'.winnr() s:LocalNumber() exists('w:relativenumber') | |
193 0.002550 0.001567 if exists('w:relativenumber') && s:LocalNumber() == 1 | |
193 0.000945 setlocal relativenumber | |
193 0.000654 let &l:number = w:relativenumber | |
193 0.000177 endif | |
FUNCTION neocomplete#sources#member#make_cache_current_line() | |
Called 579 times | |
Total time: 0.360603 | |
Self time: 0.010326 | |
count total (s) self (s) | |
579 0.006053 0.002225 if !neocomplete#is_enabled() | |
call neocomplete#initialize() | |
endif | |
" Make cache from current line. | |
579 0.351890 0.005441 return s:make_cache_current_buffer(line('.')-1, line('.')+1) | |
FUNCTION <SNR>54_AdaptNumberwidth() | |
Called 193 times | |
Total time: 0.002508 | |
Self time: 0.002508 | |
count total (s) self (s) | |
193 0.002389 let &l:numberwidth = max([len(string(&lines)), len(string(line('$')))]) + 1 | |
FUNCTION <SNR>139_apply_highlight_fix() | |
Called 3 times | |
Total time: 0.000088 | |
Self time: 0.000088 | |
count total (s) self (s) | |
" Only do this if we're on the last character of the line | |
3 0.000017 if col('.') == col('$') | |
let s:saved_line = getline('.') | |
if s:from_mode ==# 'i' | |
silent! undojoin | call setline('.', s:saved_line.' ') | |
else | |
call setline('.', s:saved_line.' ') | |
endif | |
endif | |
FUNCTION <SNR>133_make_cache_current_line() | |
Called 193 times | |
Total time: 2.309435 | |
Self time: 0.007106 | |
count total (s) self (s) | |
193 0.002545 0.000918 let neocomplete = neocomplete#get_current_neocomplete() | |
193 0.047704 0.001133 if neocomplete#helper#is_enabled_source('buffer', neocomplete.context_filetype) | |
" Caching current cache line. | |
193 2.093469 0.001136 call neocomplete#sources#buffer#make_cache_current_line() | |
193 0.000305 endif | |
193 0.048713 0.001721 if neocomplete#helper#is_enabled_source('member', neocomplete.context_filetype) | |
" Caching current cache line. | |
193 0.115867 0.001061 call neocomplete#sources#member#make_cache_current_line() | |
193 0.000158 endif | |
FUNCTION 39() | |
Called 8 times | |
Total time: 0.000096 | |
Self time: 0.000096 | |
count total (s) self (s) | |
8 0.000045 if !exists('b:syntastic_loclist') || empty(b:syntastic_loclist) | |
let b:syntastic_loclist = g:SyntasticLoclist.New([]) | |
endif | |
8 0.000014 return b:syntastic_loclist | |
FUNCTION neocomplete#init#_context() | |
Called 2313 times | |
Total time: 0.024700 | |
Self time: 0.024700 | |
count total (s) self (s) | |
2313 0.023460 return extend(a:context, { 'input' : '', 'prev_complete_pos' : -1, 'prev_candidates' : [], 'complete_pos' : -1, 'complete_str' : '', 'candidates' : [] }) | |
FUNCTION 48() | |
Called 8 times | |
Total time: 0.000548 | |
Self time: 0.000548 | |
count total (s) self (s) | |
8 0.000031 if !exists('self._stl_format') | |
let self._stl_format = '' | |
endif | |
8 0.000025 if !exists('self._stl_flag') | |
let self._stl_flag = '' | |
endif | |
8 0.000020 if g:syntastic_stl_format !=# self._stl_format | |
let self._stl_format = g:syntastic_stl_format | |
if !empty(self._rawLoclist) | |
let errors = self.errors() | |
let warnings = self.warnings() | |
let num_errors = len(errors) | |
let num_warnings = len(warnings) | |
let num_issues = len(self._rawLoclist) | |
let output = self._stl_format | |
"hide stuff wrapped in %E(...) unless there are errors | |
let output = substitute(output, '\m\C%E{\([^}]*\)}', num_errors ? '\1' : '' , 'g') | |
"hide stuff wrapped in %W(...) unless there are warnings | |
let output = substitute(output, '\m\C%W{\([^}]*\)}', num_warnings ? '\1' : '' , 'g') | |
"hide stuff wrapped in %B(...) unless there are both errors and warnings | |
let output = substitute(output, '\m\C%B{\([^}]*\)}', (num_warnings && num_errors) ? '\1' : '' , 'g') | |
"sub in the total errors/warnings/both | |
let output = substitute(output, '\m\C%w', num_warnings, 'g') | |
let output = substitute(output, '\m\C%e', num_errors, 'g') | |
let output = substitute(output, '\m\C%t', num_issues, 'g') | |
"first error/warning line num | |
let output = substitute(output, '\m\C%F', num_issues ? self._rawLoclist[0]['lnum'] : '', 'g') | |
"first error line num | |
let output = substitute(output, '\m\C%fe', num_errors ? errors[0]['lnum'] : '', 'g') | |
"first warning line num | |
let output = substitute(output, '\m\C%fw', num_warnings ? warnings[0]['lnum'] : '', 'g') | |
let self._stl_flag = output | |
else | |
let self._stl_flag = '' | |
endif | |
endif | |
8 0.000012 return self._stl_flag | |
FUNCTION 135() | |
Called 7 times | |
Total time: 0.000056 | |
Self time: 0.000056 | |
count total (s) self (s) | |
7 0.000026 let idx = self.kinddict[a:kind] | |
7 0.000021 return self.kinds[idx] | |
FUNCTION <SNR>82_get_array() | |
Called 48 times | |
Total time: 0.000657 | |
Self time: 0.000657 | |
count total (s) self (s) | |
48 0.000087 let fg = a:fg | |
48 0.000065 let bg = a:bg | |
48 0.000462 return has('gui_running') || (has("termtruecolor") && &guicolors == 1) ? [ fg, bg, '', '', join(a:opts, ',') ] : [ '', '', fg, bg, join(a:opts, ',') ] | |
FUNCTION 143() | |
Called 7 times | |
Total time: 0.000035 | |
Self time: 0.000035 | |
count total (s) self (s) | |
7 0.000014 if !s:paused || a:forcecurrent | |
7 0.000011 return self._current | |
else | |
return self._paused | |
endif | |
FUNCTION <SNR>113_should_create_cache() | |
Called 579 times | |
Total time: 0.038848 | |
Self time: 0.038848 | |
count total (s) self (s) | |
579 0.026236 let filepath = fnamemodify(bufname(a:bufnr), ':p') | |
579 0.011807 return getfsize(filepath) < g:neocomplete#sources#buffer#cache_limit_size && getbufvar(a:bufnr, '&modifiable') && !getwinvar(bufwinnr(a:bufnr), '&previewwindow') && (g:neocomplete#sources#buffer#disabled_pattern == '' || filepath !~# g:neocomplete#sources#buffer#disabled_pattern) | |
FUNCTION neocomplete#helper#ftdictionary2list() | |
Called 386 times | |
Total time: 0.080294 | |
Self time: 0.005359 | |
count total (s) self (s) | |
386 0.080006 0.005071 return map(filter(neocomplete#get_source_filetypes(a:filetype), 'has_key(a:dictionary, v:val)'), 'a:dictionary[v:val]') | |
FUNCTION <SNR>139_end_latency_measure() | |
Called 3 times | |
Total time: 0.000103 | |
Self time: 0.000103 | |
count total (s) self (s) | |
3 0.000011 if g:multi_cursor_debug_latency && !empty(s:char) | |
if empty(s:latency_debug_file) | |
let s:latency_debug_file = tempname() | |
exec 'redir >> '.s:latency_debug_file | |
silent! echom "Starting latency debug at ".reltimestr(reltime()) | |
redir END | |
endif | |
if !s:skip_latency_measure | |
exec 'redir >> '.s:latency_debug_file | |
silent! echom "Processing '".s:char."' took ".string(str2float(reltimestr(reltime(s:start_time)))*1000).' ms in '.s:cm.size().' cursors. mode = '.s:from_mode | |
redir END | |
endif | |
endif | |
3 0.000008 let s:skip_latency_measure = 0 | |
FUNCTION neocomplete#get_current_neocomplete() | |
Called 2316 times | |
Total time: 0.020412 | |
Self time: 0.020412 | |
count total (s) self (s) | |
2316 0.007502 if !exists('b:neocomplete') | |
call neocomplete#init#_current_neocomplete() | |
endif | |
2316 0.003177 return b:neocomplete | |
FUNCTION <SNR>139_highlight_region() | |
Called 32 times | |
Total time: 0.002081 | |
Self time: 0.001724 | |
count total (s) self (s) | |
32 0.000713 0.000356 let s = sort(copy(a:region), "s:compare_pos") | |
32 0.000074 if s:to_mode ==# 'V' | |
let pattern = '\%>'.(s[0][0]-1).'l\%<'.(s[1][0]+1).'l.*\ze.\_$' | |
else | |
32 0.000101 if (s[0][0] == s[1][0]) | |
" Same line | |
32 0.000299 let pattern = '\%'.s[0][0].'l\%>'.(s[0][1]-1).'c.*\%<'.(s[1][1]+1).'c.' | |
32 0.000030 else | |
" Two lines | |
let s1 = '\%'.s[0][0].'l.\%>'.s[0][1].'c.*' | |
let s2 = '\%'.s[1][0].'l.*\%<'.s[1][1].'c..' | |
let pattern = s1.'\|'.s2 | |
" More than two lines | |
if (s[1][0] - s[0][0] > 1) | |
let pattern = pattern.'\|\%>'.s[0][0].'l\%<'.s[1][0].'l.*\ze.\_$' | |
endif | |
endif | |
32 0.000024 endif | |
32 0.000263 return matchadd(s:hi_group_visual, pattern) | |
FUNCTION airline#util#wrap() | |
Called 64 times | |
Total time: 0.000414 | |
Self time: 0.000414 | |
count total (s) self (s) | |
64 0.000174 if a:minwidth > 0 && winwidth(0) < a:minwidth | |
return '' | |
endif | |
64 0.000075 return a:text | |
FUNCTION <SNR>139_select_in_visual_mode() | |
Called 32 times | |
Total time: 0.002943 | |
Self time: 0.002943 | |
count total (s) self (s) | |
32 0.000209 if a:region[0] == a:region[1] | |
normal! v | |
else | |
32 0.000187 call cursor(a:region[1]) | |
32 0.000711 normal! m` | |
32 0.000259 call cursor(a:region[0]) | |
32 0.000592 normal! v`` | |
32 0.000048 endif | |
" Unselect and reselect it again to properly set the '< and '> markers | |
32 0.000634 exec "normal! \<Esc>gv" | |
FUNCTION 212() | |
Called 2 times | |
Total time: 0.000009 | |
Self time: 0.000009 | |
count total (s) self (s) | |
2 0.000008 let self.starting_index = self.current_index | |
FUNCTION <SNR>139_pos() | |
Called 128 times | |
Total time: 0.001087 | |
Self time: 0.001087 | |
count total (s) self (s) | |
128 0.000545 let pos = getpos(a:mark) | |
128 0.000429 return [pos[1], pos[2]] | |
FUNCTION airline#extensions#whitespace#check() | |
Called 8 times | |
Total time: 0.000381 | |
Self time: 0.000381 | |
count total (s) self (s) | |
8 0.000042 if &readonly || !&modifiable || !s:enabled || line('$') > s:max_lines | |
return '' | |
endif | |
8 0.000031 if !exists('b:airline_whitespace_check') | |
let b:airline_whitespace_check = '' | |
let checks = get(g:, 'airline#extensions#whitespace#checks', s:default_checks) | |
let trailing = 0 | |
if index(checks, 'trailing') > -1 | |
let trailing = search('\s$', 'nw') | |
endif | |
let mixed = 0 | |
if index(checks, 'indent') > -1 | |
let mixed = s:check_mixed_indent() | |
endif | |
if trailing != 0 || mixed != 0 | |
let b:airline_whitespace_check = s:symbol | |
if s:show_message | |
if trailing != 0 | |
let b:airline_whitespace_check .= (g:airline_symbols.space).printf(s:trailing_format, trailing) | |
endif | |
if mixed != 0 | |
let b:airline_whitespace_check .= (g:airline_symbols.space).printf(s:mixed_indent_format, mixed) | |
endif | |
endif | |
endif | |
endif | |
8 0.000014 return b:airline_whitespace_check | |
FUNCTION 191() | |
Called 252 times | |
Total time: 0.000864 | |
Self time: 0.000864 | |
count total (s) self (s) | |
252 0.000690 return self.position[0] | |
FUNCTION 194() | |
Called 64 times | |
Total time: 0.003504 | |
Self time: 0.000834 | |
count total (s) self (s) | |
64 0.000250 let self.position[0] = a:pos[0] | |
64 0.000201 let self.position[1] = a:pos[1] | |
64 0.002971 0.000301 call self.update_highlight() | |
FUNCTION 195() | |
Called 64 times | |
Total time: 0.002670 | |
Self time: 0.000818 | |
count total (s) self (s) | |
64 0.000961 0.000331 call s:cm.remove_highlight(self.cursor_hi_id) | |
64 0.001659 0.000437 let self.cursor_hi_id = s:highlight_cursor(self.position) | |
FUNCTION 196() | |
Called 64 times | |
Total time: 0.001708 | |
Self time: 0.001443 | |
count total (s) self (s) | |
64 0.001649 0.001384 let self.line_length = col([self.line(), '$']) | |
FUNCTION airline#extensions#tagbar#currenttag() | |
Called 8 times | |
Total time: 0.003662 | |
Self time: 0.000200 | |
count total (s) self (s) | |
8 0.000026 if get(w:, 'airline_active', 0) | |
8 0.000032 if s:airline_tagbar_last_lookup_time != localtime() | |
7 0.003532 0.000070 let s:airline_tagbar_last_lookup_val = tagbar#currenttag('%s', '', s:flags) | |
7 0.000029 let s:airline_tagbar_last_lookup_time = localtime() | |
7 0.000007 endif | |
8 0.000016 return s:airline_tagbar_last_lookup_val | |
endif | |
return '' | |
FUNCTION 198() | |
Called 32 times | |
Total time: 0.001057 | |
Self time: 0.000658 | |
count total (s) self (s) | |
32 0.000208 let self.visual = [] | |
" TODO(terryma): Move functionality into separate class | |
32 0.000681 0.000282 call s:cm.remove_highlight(self.visual_hi_id) | |
32 0.000099 let self.visual_hi_id = 0 | |
FUNCTION 199() | |
Called 32 times | |
Total time: 0.000250 | |
Self time: 0.000250 | |
count total (s) self (s) | |
32 0.000228 call setreg('"', self.paste_buffer_text, self.paste_buffer_type) | |
FUNCTION 214() | |
Called 1 time | |
Total time: 0.000063 | |
Self time: 0.000063 | |
count total (s) self (s) | |
1 0.000006 let self.saved_settings['virtualedit'] = &virtualedit | |
1 0.000003 let self.saved_settings['cursorline'] = &cursorline | |
1 0.000002 let self.saved_settings['lazyredraw'] = &lazyredraw | |
1 0.000003 let self.saved_settings['paste'] = &paste | |
1 0.000003 let self.saved_settings['clipboard'] = &clipboard | |
1 0.000005 let &virtualedit = "onemore" | |
1 0.000004 let &cursorline = 0 | |
1 0.000003 let &lazyredraw = 1 | |
1 0.000002 let &paste = 0 | |
1 0.000008 set clipboard-=unnamed clipboard-=unnamedplus | |
" We could have already saved the view from multiple_cursors#find | |
1 0.000002 if !self.start_from_find | |
let self.saved_winview = winsaveview() | |
endif | |
" Save contents and type of unnamed register upon entering multicursor mode | |
" to restore it later when leaving mode | |
1 0.000006 let s:paste_buffer_temporary_text = getreg('"') | |
1 0.000005 let s:paste_buffer_temporary_type = getregtype('"') | |
FUNCTION 216() | |
Called 32 times | |
Total time: 0.003482 | |
Self time: 0.000415 | |
count total (s) self (s) | |
32 0.003460 0.000393 call s:select_in_visual_mode(self.get_current().visual) | |
FUNCTION <SNR>129_uniq_by() | |
Called 965 times | |
Total time: 4.876134 | |
Self time: 4.876134 | |
count total (s) self (s) | |
965 0.390987 let list = map(copy(a:list), printf('[v:val, %s]', a:f)) | |
965 0.002194 let i = 0 | |
965 0.001642 let seen = {} | |
280820 0.459481 while i < len(list) | |
279855 1.053299 let key = string(list[i][1]) | |
279855 0.618339 if has_key(seen, key) | |
13035 0.036251 call remove(list, i) | |
13035 0.008383 else | |
266820 0.612840 let seen[key] = 1 | |
266820 0.315819 let i += 1 | |
266820 0.171338 endif | |
279855 0.176107 endwhile | |
965 0.315995 return map(list, 'v:val[0]') | |
FUNCTION neocomplete#handler#_on_insert_char_pre() | |
Called 160 times | |
Total time: 0.006838 | |
Self time: 0.001156 | |
count total (s) self (s) | |
160 0.006550 0.000868 if neocomplete#is_cache_disabled() | |
160 0.000144 return | |
endif | |
let neocomplete = neocomplete#get_current_neocomplete() | |
if neocomplete.old_char != ' ' && v:char == ' ' && v:count == 0 | |
call s:make_cache_current_line() | |
endif | |
let neocomplete.old_char = v:char | |
FUNCTION multiple_cursors#find() | |
Called 1 time | |
Total time: 0.023071 | |
Self time: 0.002101 | |
count total (s) self (s) | |
1 0.000008 let s:cm.saved_winview = winsaveview() | |
1 0.000003 let s:cm.start_from_find = 1 | |
1 0.000006 if visualmode() ==# 'v' && a:start == line("'<") && a:end == line("'>") | |
let pos1 = s:pos("'<") | |
let pos2 = s:pos("'>") | |
else | |
1 0.000004 let pos1 = [a:start, 1] | |
1 0.000010 let pos2 = [a:end, col([a:end, '$'])] | |
1 0.000001 endif | |
1 0.000005 call cursor(pos1) | |
1 0.000003 let first = 1 | |
33 0.000026 while 1 | |
33 0.000035 if first | |
" First search starts from the current position | |
1 0.000023 let match = search(a:pattern, 'cW') | |
1 0.000002 let first = 0 | |
1 0.000001 else | |
32 0.000409 let match = search(a:pattern, 'W') | |
32 0.000031 endif | |
33 0.000035 if !match | |
1 0.000001 break | |
endif | |
32 0.000469 0.000210 let left = s:pos('.') | |
32 0.000217 call search(a:pattern, 'ceW') | |
32 0.000430 0.000186 let right = s:pos('.') | |
32 0.000367 0.000175 if s:compare_pos(right, pos2) > 0 | |
break | |
endif | |
32 0.009854 0.000208 call s:cm.add(right, [left, right]) | |
" Redraw here forces the cursor movement to be updated. This prevents the | |
" jerky behavior when doing any action once the cursors are added. But it | |
" also slows down adding the cursors dramatically. We need to a better | |
" solution here | |
" redraw | |
32 0.000031 endwhile | |
1 0.000012 0.000004 if s:cm.is_empty() | |
call winrestview(s:cm.saved_winview) | |
echohl ErrorMsg | echo 'No match found' | echohl None | |
return | |
else | |
1 0.000048 0.000042 echohl Normal | echo 'Added '.s:cm.size().' cursor'.(s:cm.size()>1?'s':'') | echohl None | |
" If we've created any cursors, we need to call the before function, end | |
" function will be called via normal routes | |
1 0.000005 if exists('*Multiple_cursors_before') && !s:before_function_called | |
1 0.000054 0.000012 exe "call Multiple_cursors_before()" | |
1 0.000002 let s:before_function_called = 1 | |
1 0.000000 endif | |
1 0.010585 0.000012 call s:wait_for_user_input('v') | |
1 0.000001 endif | |
FUNCTION airline#highlighter#highlight() | |
Called 1 time | |
Total time: 0.013300 | |
Self time: 0.003263 | |
count total (s) self (s) | |
1 0.000004 let p = g:airline#themes#{g:airline_theme}#palette | |
" draw the base mode, followed by any overrides | |
1 0.000013 let mapped = map(a:modes, 'v:val == a:modes[0] ? v:val : a:modes[0]."_".v:val') | |
1 0.000003 let suffix = a:modes[0] == 'inactive' ? '_inactive' : '' | |
3 0.000006 for mode in mapped | |
2 0.000014 if exists('g:airline#themes#{g:airline_theme}#palette[mode]') | |
2 0.000008 let dict = g:airline#themes#{g:airline_theme}#palette[mode] | |
23 0.000064 for kvp in items(dict) | |
21 0.000090 let mode_colors = kvp[1] | |
21 0.001075 0.000189 call airline#highlighter#exec(kvp[0].suffix, mode_colors) | |
63 0.000131 for accent in keys(s:accents) | |
42 0.000117 if !has_key(p.accents, accent) | |
continue | |
endif | |
42 0.000194 let colors = copy(mode_colors) | |
42 0.000133 if p.accents[accent][0] != '' | |
let colors[0] = p.accents[accent][0] | |
endif | |
42 0.000119 if p.accents[accent][2] != '' | |
21 0.000068 let colors[2] = p.accents[accent][2] | |
21 0.000013 endif | |
42 0.000083 if len(colors) >= 5 | |
14 0.000058 let colors[4] = get(p.accents[accent], 4, '') | |
14 0.000012 else | |
28 0.000126 call add(colors, get(p.accents[accent], 4, '')) | |
28 0.000027 endif | |
42 0.002179 0.000342 call airline#highlighter#exec(kvp[0].suffix.'_'.accent, colors) | |
42 0.000035 endfor | |
21 0.000024 endfor | |
" TODO: optimize this | |
26 0.000062 for sep in items(s:separators) | |
24 0.007589 0.000275 call <sid>exec_separator(dict, sep[1][0], sep[1][1], sep[1][2], suffix) | |
24 0.000027 endfor | |
2 0.000002 endif | |
2 0.000001 endfor | |
FUNCTION airline#parts#ffenc() | |
Called 8 times | |
Total time: 0.000118 | |
Self time: 0.000118 | |
count total (s) self (s) | |
8 0.000113 return printf('%s%s', &fenc, strlen(&ff) > 0 ? '['.&ff.']' : '') | |
FUNCTION <SNR>1_Cursor_Moved() | |
Called 97 times | |
Total time: 0.003480 | |
Self time: 0.003480 | |
count total (s) self (s) | |
97 0.000438 let cur_pos = line(".") | |
97 0.000191 if g:last_pos == 0 | |
highlight CursorLine ctermbg=235 guibg=Grey40 | |
let g:last_pos = cur_pos | |
return | |
endif | |
97 0.000292 let diff = g:last_pos - cur_pos | |
97 0.000196 if diff > 1 || diff < -1 | |
6 0.000079 highlight CursorLine ctermbg=235 guibg=Grey40 | |
6 0.000005 else | |
91 0.001096 highlight CursorLine ctermbg=NONE guibg=NONE | |
91 0.000074 endif | |
97 0.000183 let g:last_pos = cur_pos | |
FUNCTION tagbar#currenttag() | |
Called 7 times | |
Total time: 0.003462 | |
Self time: 0.000442 | |
count total (s) self (s) | |
" Indicate that the statusline functionality is being used. This prevents | |
" the CloseWindow() function from removing the autocommands. | |
7 0.000020 let s:statusline_in_use = 1 | |
7 0.000009 if a:0 > 0 | |
" also test for non-zero value for backwards compatibility | |
7 0.000066 let longsig = a:1 =~# 's' || (type(a:1) == type(0) && a:1 != 0) | |
7 0.000031 let fullpath = a:1 =~# 'f' | |
7 0.000025 let prototype = a:1 =~# 'p' | |
7 0.000007 else | |
let longsig = 0 | |
let fullpath = 0 | |
let prototype = 0 | |
endif | |
7 0.000281 0.000038 if !s:Init(1) | |
return a:default | |
endif | |
7 0.002834 0.000057 let tag = s:GetNearbyTag(0, 1) | |
7 0.000014 if !empty(tag) | |
if prototype | |
return tag.getPrototype(1) | |
else | |
return printf(a:fmt, tag.str(longsig, fullpath)) | |
endif | |
else | |
7 0.000010 return a:default | |
endif | |
FUNCTION neocomplete#is_text_mode() | |
Called 386 times | |
Total time: 0.007215 | |
Self time: 0.003943 | |
count total (s) self (s) | |
386 0.005278 0.002006 let neocomplete = neocomplete#get_current_neocomplete() | |
386 0.001556 return get(g:neocomplete#text_mode_filetypes, neocomplete.context_filetype, 0) | |
FUNCTION <SNR>139_highlight_cursor() | |
Called 96 times | |
Total time: 0.001675 | |
Self time: 0.001675 | |
count total (s) self (s) | |
" Give cursor highlight high priority, to overrule visual selection | |
96 0.001525 return matchadd(s:hi_group_cursor, '\%'.a:pos[0].'l\%'.a:pos[1].'c', 99999) | |
FUNCTION airline#parts#paste() | |
Called 8 times | |
Total time: 0.000036 | |
Self time: 0.000036 | |
count total (s) self (s) | |
8 0.000031 return g:airline_detect_paste && &paste ? g:airline_symbols.paste : '' | |
FUNCTION neocomplete#init#is_enabled() | |
Called 1285 times | |
Total time: 0.003067 | |
Self time: 0.003067 | |
count total (s) self (s) | |
1285 0.002310 return s:is_enabled | |
FUNCTION <SNR>54_LocalNumber() | |
Called 386 times | |
Total time: 0.001902 | |
Self time: 0.001902 | |
count total (s) self (s) | |
386 0.001614 return (&l:relativenumber ? 2 : (&l:number ? 1 : 0)) | |
FUNCTION airline#parts#readonly() | |
Called 8 times | |
Total time: 0.000029 | |
Self time: 0.000029 | |
count total (s) self (s) | |
8 0.000023 return &readonly ? g:airline_symbols.readonly : '' | |
FUNCTION <SNR>127_make_cache_current_buffer() | |
Called 579 times | |
Total time: 0.346449 | |
Self time: 0.018721 | |
count total (s) self (s) | |
579 0.031400 0.003477 let filetype = neocomplete#get_context_filetype(1) | |
579 0.002889 if !has_key(s:member_sources, bufnr('%')) | |
call s:initialize_source(bufnr('%'), filetype) | |
endif | |
579 0.308395 0.008590 call s:make_cache_lines(bufnr('%'), filetype, getline(a:start, a:end)) | |
FUNCTION airline#highlighter#exec() | |
Called 88 times | |
Total time: 0.003644 | |
Self time: 0.003644 | |
count total (s) self (s) | |
88 0.000201 let colors = a:colors | |
88 0.000105 if s:is_win32term | |
let colors[2] = s:gui2cui(get(colors, 0, ''), get(colors, 2, '')) | |
let colors[3] = s:gui2cui(get(colors, 1, ''), get(colors, 3, '')) | |
endif | |
88 0.002510 exec printf('hi %s %s %s %s %s %s %s %s', a:group, get(colors, 0, '') != '' ? 'guifg='.colors[0] : '', get(colors, 1, '') != '' ? 'guibg='.colors[1] : '', get(colors, 2, '') != '' ? 'ctermfg='.colors[2] : '', get(colors, 3, '') != '' ? 'ctermbg='.colors[3] : '', get(colors, 4, '') != '' ? 'gui='.colors[4] : '', get(colors, 4, '') != '' ? 'cterm='.colors[4] : '', get(colors, 4, '') != '' ? 'term='.colors[4] : '') | |
FUNCTION <SNR>104_get_list() | |
Called 965 times | |
Total time: 0.009776 | |
Self time: 0.009776 | |
count total (s) self (s) | |
965 0.003498 if !exists('s:List') | |
let s:List = neocomplete#util#get_vital().import('Data.List') | |
endif | |
965 0.001135 return s:List | |
FUNCTION neocomplete#commands#_unlock() | |
Called 1 time | |
Total time: 0.000022 | |
Self time: 0.000011 | |
count total (s) self (s) | |
1 0.000018 0.000007 let neocomplete = neocomplete#get_current_neocomplete() | |
1 0.000002 let neocomplete.lock = 0 | |
FUNCTION neocomplete#get_source_filetypes() | |
Called 386 times | |
Total time: 0.074935 | |
Self time: 0.002329 | |
count total (s) self (s) | |
386 0.074682 0.002076 return neocomplete#helper#get_source_filetypes(a:filetype) | |
FUNCTION <SNR>139_get_char() | |
Called 2 times | |
Total time: 0.000208 | |
Self time: 0.000208 | |
count total (s) self (s) | |
2 0.000142 let c = getchar() | |
" If the character is a number, then it's not a special key | |
2 0.000026 if type(c) == 0 | |
2 0.000015 let c = nr2char(c) | |
2 0.000005 endif | |
2 0.000007 return c | |
FUNCTION neocomplete#helper#get_source_filetypes() | |
Called 386 times | |
Total time: 0.072606 | |
Self time: 0.028191 | |
count total (s) self (s) | |
386 0.001673 let filetype = (a:filetype == '') ? 'nothing' : a:filetype | |
386 0.000977 let filetypes = [filetype] | |
386 0.002609 if filetype =~ '\.' | |
if exists('g:neocomplete#ignore_composite_filetypes') && has_key(g:neocomplete#ignore_composite_filetypes, filetype) | |
let filetypes = [g:neocomplete#ignore_composite_filetypes[filetype]] | |
else | |
" Set composite filetype. | |
let filetypes += split(filetype, '\.') | |
endif | |
endif | |
386 0.001152 if exists('g:neocomplete#same_filetypes') | |
772 0.002082 for ft in copy(filetypes) | |
386 0.004221 let filetypes += split(get(g:neocomplete#same_filetypes, ft, get(g:neocomplete#same_filetypes, '_', '')), ',') | |
386 0.000444 endfor | |
386 0.000262 endif | |
386 0.008847 0.001632 if neocomplete#is_text_mode() | |
call add(filetypes, 'text') | |
endif | |
386 0.000799 if len(filetypes) > 1 | |
386 0.039490 0.002290 let filetypes = neocomplete#util#uniq(filetypes) | |
386 0.000366 endif | |
386 0.000456 return filetypes | |
FUNCTION 190() | |
Called 32 times | |
Total time: 0.002169 | |
Self time: 0.001716 | |
count total (s) self (s) | |
32 0.000230 let obj = copy(self) | |
32 0.000124 let obj.position = copy(a:position) | |
32 0.000067 let obj.visual = [] | |
" Stores text that was yanked after any commands in Normal or Visual mode | |
32 0.000121 let obj.paste_buffer_text = getreg('"') | |
32 0.000127 let obj.paste_buffer_type = getregtype('"') | |
32 0.000673 0.000220 let obj.cursor_hi_id = s:highlight_cursor(a:position) | |
32 0.000077 let obj.visual_hi_id = 0 | |
32 0.000195 let obj.line_length = col([a:position[0], '$']) | |
32 0.000105 if has('folding') | |
32 0.000274 silent! execute a:position[0] . "foldopen!" | |
32 0.000028 endif | |
32 0.000040 return obj | |
FUNCTION <SNR>92_GetNearbyTag() | |
Called 7 times | |
Total time: 0.002777 | |
Self time: 0.002686 | |
count total (s) self (s) | |
7 0.000014 if s:nearby_disabled | |
return {} | |
endif | |
7 0.000086 0.000051 let fileinfo = s:known_files.getCurrent(a:forcecurrent) | |
7 0.000015 if empty(fileinfo) | |
return {} | |
endif | |
7 0.000014 let typeinfo = fileinfo.typeinfo | |
7 0.000008 if a:0 > 0 | |
let curline = a:1 | |
else | |
7 0.000023 let curline = line('.') | |
7 0.000007 endif | |
7 0.000013 let tag = {} | |
" If a tag appears in a file more than once (for example namespaces in | |
" C++) only one of them has a 'tline' entry and can thus be highlighted. | |
" The only way to solve this would be to go over the whole tag list again, | |
" making everything slower. Since this should be a rare occurence and | |
" highlighting isn't /that/ important ignore it for now. | |
216 0.000261 for line in range(curline, 1, -1) | |
209 0.000523 if has_key(fileinfo.fline, line) | |
7 0.000024 let curtag = fileinfo.fline[line] | |
7 0.000113 0.000057 if a:all || typeinfo.getKind(curtag.fields.kind).stl | |
let tag = curtag | |
break | |
endif | |
7 0.000005 endif | |
209 0.000166 endfor | |
7 0.000008 return tag | |
FUNCTION <SNR>127_make_cache_lines() | |
Called 579 times | |
Total time: 0.299805 | |
Self time: 0.295402 | |
count total (s) self (s) | |
579 0.001585 let filetype = a:filetype | |
579 0.002864 if get(g:neocomplete#sources#member#prefix_patterns, filetype, '') == '' | |
return | |
endif | |
579 0.001866 if !has_key(s:member_sources, a:srcname) | |
call s:initialize_source(a:srcname, filetype) | |
endif | |
579 0.002127 let source = s:member_sources[a:srcname] | |
579 0.008058 0.003655 let member_pattern = s:get_member_pattern(filetype) | |
579 0.003704 let prefix_pattern = member_pattern . '\m\%(' . g:neocomplete#sources#member#prefix_patterns[filetype] . '\m\)' | |
579 0.001965 let keyword_pattern = prefix_pattern . member_pattern | |
" Cache member pattern. | |
2316 0.003606 for line in a:lines | |
1737 0.027505 let match = match(line, keyword_pattern) | |
5067 0.007406 while match >= 0 "{{{ | |
3330 0.038415 let match_str = matchstr(line, '^'.keyword_pattern, match) | |
" Next match. | |
3330 0.030831 let match = matchend(line, prefix_pattern, match) | |
3330 0.030916 let member_name = matchstr(match_str, member_pattern . '$') | |
3330 0.007300 if member_name == '' | |
1665 0.003374 continue | |
endif | |
1665 0.009042 let var_name = match_str[ : -len(member_name)-1] | |
1665 0.005447 if !has_key(source.member_cache, var_name) | |
21 0.000094 let source.member_cache[var_name] = {} | |
21 0.000023 endif | |
1665 0.005505 if !has_key(source.member_cache[var_name], member_name) | |
21 0.000087 let source.member_cache[var_name][member_name] = 1 | |
21 0.000020 endif | |
1665 0.019747 let match_str = matchstr(var_name, '^'.keyword_pattern) | |
1665 0.003784 endwhile"}}} | |
1737 0.001333 endfor | |
FUNCTION 197() | |
Called 32 times | |
Total time: 0.002860 | |
Self time: 0.000570 | |
count total (s) self (s) | |
32 0.000157 let self.visual = deepcopy(a:region) | |
32 0.000368 0.000159 call s:cm.remove_highlight(self.visual_hi_id) | |
32 0.002307 0.000226 let self.visual_hi_id = s:highlight_region(a:region) | |
FUNCTION 200() | |
Called 32 times | |
Total time: 0.000452 | |
Self time: 0.000452 | |
count total (s) self (s) | |
32 0.000232 let self.paste_buffer_text = getreg('"') | |
32 0.000175 let self.paste_buffer_type = getregtype('"') | |
FUNCTION 201() | |
Called 1 time | |
Total time: 0.000046 | |
Self time: 0.000046 | |
count total (s) self (s) | |
1 0.000012 let obj = copy(self) | |
" List of Cursors we're managing | |
1 0.000003 let obj.cursors = [] | |
" Current index into the s:cursors array | |
1 0.000003 let obj.current_index = -1 | |
" This marks the starting cursor index into the s:cursors array | |
1 0.000003 let obj.starting_index = -1 | |
" We save some user settings when the plugin loads initially | |
1 0.000012 let obj.saved_settings = { 'virtualedit': &virtualedit, 'cursorline': &cursorline, 'lazyredraw': &lazyredraw, 'paste': &paste, 'clipboard': &clipboard, } | |
" We save the window view when multicursor mode is entered | |
1 0.000002 let obj.saved_winview = [] | |
" Track whether we started multicursor mode from calling multiple_cursors#find | |
1 0.000002 let obj.start_from_find = 0 | |
1 0.000002 return obj | |
FUNCTION 202() | |
Called 1 time | |
Total time: 0.001783 | |
Self time: 0.000951 | |
count total (s) self (s) | |
1 0.000004 if a:restore_view | |
" Return the view back to the beginning | |
1 0.000006 if !empty(self.saved_winview) | |
1 0.000018 call winrestview(self.saved_winview) | |
1 0.000002 endif | |
" If the cursor moved, just restoring the view could get confusing, let's | |
" put the cursor at where the user left it. Only do this if we didn't start | |
" from find mode | |
1 0.000030 0.000012 if !self.is_empty() && !self.start_from_find | |
call cursor(self.get(0).position) | |
endif | |
1 0.000001 endif | |
" Delete all cursors and clear their highlights. Don't do clearmatches() as | |
" that will potentially interfere with other plugins | |
1 0.000018 0.000007 if !self.is_empty() | |
33 0.000065 0.000061 for i in range(self.size()) | |
32 0.000635 0.000242 call self.remove_highlight(self.get(i).cursor_hi_id) | |
32 0.000557 0.000241 call self.remove_highlight(self.get(i).visual_hi_id) | |
32 0.000036 endfor | |
1 0.000000 endif | |
1 0.000228 let self.cursors = [] | |
1 0.000004 let self.current_index = -1 | |
1 0.000002 let self.starting_index = -1 | |
1 0.000004 let self.saved_winview = [] | |
1 0.000002 let self.start_from_find = 0 | |
1 0.000002 let s:char = '' | |
1 0.000001 if a:restore_setting | |
1 0.000056 0.000008 call self.restore_user_settings() | |
1 0.000001 endif | |
" Call after function if exists and only if action is canceled (<Esc>) | |
1 0.000006 if exists('*Multiple_cursors_after') && a:0 && s:before_function_called | |
1 0.000054 0.000012 exe "call Multiple_cursors_after()" | |
1 0.000003 let s:before_function_called = 0 | |
1 0.000001 endif | |
FUNCTION 203() | |
Called 35 times | |
Total time: 0.000300 | |
Self time: 0.000186 | |
count total (s) self (s) | |
35 0.000281 0.000167 return self.size() == 0 | |
FUNCTION 204() | |
Called 231 times | |
Total time: 0.000730 | |
Self time: 0.000730 | |
count total (s) self (s) | |
231 0.000595 return len(self.cursors) | |
FUNCTION 205() | |
Called 256 times | |
Total time: 0.001784 | |
Self time: 0.001784 | |
count total (s) self (s) | |
256 0.001544 return self.cursors[self.current_index] | |
FUNCTION 206() | |
Called 126 times | |
Total time: 0.000444 | |
Self time: 0.000444 | |
count total (s) self (s) | |
126 0.000364 return self.cursors[a:i] | |
FUNCTION 208() | |
Called 192 times | |
Total time: 0.001717 | |
Self time: 0.001717 | |
count total (s) self (s) | |
192 0.000342 if a:hi_id | |
" If the user did a matchdelete or a clearmatches, we don't want to barf if | |
" the matchid is no longer valid | |
128 0.000640 silent! call matchdelete(a:hi_id) | |
128 0.000120 endif | |
FUNCTION neocomplete#handler#_on_insert_leave() | |
Called 193 times | |
Total time: 2.359891 | |
Self time: 0.005994 | |
count total (s) self (s) | |
193 0.041879 0.000892 call neocomplete#helper#clear_result() | |
193 0.002783 0.001013 call s:close_preview_window() | |
193 2.310443 0.001008 call s:make_cache_current_line() | |
193 0.002731 0.001026 let neocomplete = neocomplete#get_current_neocomplete() | |
193 0.000487 let neocomplete.cur_text = '' | |
193 0.000451 let neocomplete.completed_item = {} | |
193 0.000418 let neocomplete.overlapped_items = {} | |
FUNCTION 210() | |
Called 64 times | |
Total time: 0.019526 | |
Self time: 0.011911 | |
count total (s) self (s) | |
64 0.001318 0.000503 let cur = self.get_current() | |
64 0.000291 if s:to_mode ==# 'v' || s:to_mode ==# 'V' | |
" If we're in visual line mode, we need to go to visual mode before we can | |
" update the visual region | |
if s:to_mode ==# 'V' | |
exec "normal! gvv\<Esc>" | |
endif | |
" Sets the cursor at the right place | |
exec "normal! gv\<Esc>" | |
call cur.update_visual_selection(s:get_visual_region(s:pos('.'))) | |
elseif s:from_mode ==# 'v' || s:from_mode ==# 'V' | |
" Save contents of unnamed register after each operation in Visual mode. | |
" This should be executed after user input is processed, when unnamed | |
" register already contains the text. | |
32 0.000667 0.000215 call cur.save_unnamed_register() | |
32 0.001295 0.000238 call cur.remove_visual_selection() | |
32 0.000112 elseif s:from_mode ==# 'i' && s:to_mode ==# 'n' && self.current_index != self.size() - 1 | |
normal! h | |
elseif s:from_mode ==# 'n' | |
" Save contents of unnamed register after each operation in Normal mode. | |
call cur.save_unnamed_register() | |
endif | |
64 0.000412 let vdelta = line('$') - s:saved_linecount | |
" If the total number of lines changed in the buffer, we need to potentially | |
" adjust other cursor locations | |
64 0.000139 if vdelta != 0 | |
if self.current_index != self.size() - 1 | |
let cur_line_length = len(getline(cur.line())) | |
let new_line_length = len(getline('.')) | |
for i in range(self.current_index+1, self.size()-1) | |
let hdelta = 0 | |
" Note: some versions of Vim don't like chaining function calls like | |
" a.b().c(). For compatibility reasons, don't do it | |
let c = self.get(i) | |
" If there're other cursors on the same line, we need to adjust their | |
" columns. This needs to happen before we adjust their line! | |
if cur.line() == c.line() | |
if vdelta > 0 | |
" Added a line | |
let hdelta = cur_line_length * -1 | |
else | |
" Removed a line | |
let hdelta = new_line_length | |
endif | |
endif | |
call c.move(vdelta, hdelta) | |
endfor | |
endif | |
else | |
" If the line length changes, for all the other cursors on the same line as | |
" the current one, update their cursor location as well | |
64 0.000360 let hdelta = col('$') - cur.line_length | |
" Only do this if we're still on the same line as before | |
64 0.000730 0.000468 if hdelta != 0 && cur.line() == line('.') | |
" Update all the cursor's positions that occur after the current cursor on | |
" the same line | |
64 0.000548 0.000331 if self.current_index != self.size() - 1 | |
62 0.000754 0.000581 for i in range(self.current_index+1, self.size()-1) | |
62 0.000561 0.000347 let c = self.get(i) | |
" Only do it for cursors on the same line | |
62 0.000721 0.000384 if cur.line() == c.line() | |
call c.move(0, hdelta) | |
else | |
" Early exit, if we're not on the same line, neither will any cursor | |
" that come after this | |
62 0.000076 break | |
endif | |
endfor | |
62 0.000047 endif | |
64 0.000041 endif | |
64 0.000038 endif | |
64 0.001008 0.000424 let pos = s:pos('.') | |
64 0.000134 if cur.position == pos | |
return 0 | |
endif | |
64 0.003784 0.000280 call cur.update_position(pos) | |
64 0.000098 return 1 | |
FUNCTION 211() | |
Called 64 times | |
Total time: 0.000682 | |
Self time: 0.000481 | |
count total (s) self (s) | |
64 0.000635 0.000434 let self.current_index = (self.current_index + 1) % self.size() | |
FUNCTION 213() | |
Called 64 times | |
Total time: 0.000230 | |
Self time: 0.000230 | |
count total (s) self (s) | |
64 0.000175 return self.current_index == self.starting_index | |
FUNCTION <SNR>113_check_changed_buffer() | |
Called 579 times | |
Total time: 0.016987 | |
Self time: 0.016987 | |
count total (s) self (s) | |
579 0.002565 let source = s:buffer_sources[a:bufnr] | |
579 0.002514 let ft = getbufvar(a:bufnr, '&filetype') | |
579 0.001172 if ft == '' | |
let ft = 'nothing' | |
endif | |
579 0.002781 let filename = fnamemodify(bufname(a:bufnr), ':t') | |
579 0.001093 if filename == '' | |
let filename = '[No Name]' | |
endif | |
579 0.002324 return source.name != filename || source.filetype != ft | |
FUNCTION 215() | |
Called 1 time | |
Total time: 0.000048 | |
Self time: 0.000048 | |
count total (s) self (s) | |
1 0.000004 if !empty(self.saved_settings) | |
1 0.000009 let &virtualedit = self.saved_settings['virtualedit'] | |
1 0.000006 let &cursorline = self.saved_settings['cursorline'] | |
1 0.000005 let &lazyredraw = self.saved_settings['lazyredraw'] | |
1 0.000004 let &paste = self.saved_settings['paste'] | |
1 0.000005 let &clipboard = self.saved_settings['clipboard'] | |
1 0.000001 endif | |
" Restore original contents and type of unnamed register. This method is | |
" called from reset, which calls us only when restore_setting argument is | |
" true, which happens only when we leave multicursor mode. This should be | |
" symmetrical to saving of unnamed register upon the start of multicursor | |
" mode. | |
1 0.000009 call setreg('"', s:paste_buffer_temporary_text, s:paste_buffer_temporary_type) | |
FUNCTION 217() | |
Called 32 times | |
Total time: 0.009646 | |
Self time: 0.004291 | |
count total (s) self (s) | |
" Lazy init | |
32 0.000390 0.000127 if self.is_empty() | |
1 0.000074 0.000011 call self.initialize() | |
1 0.000001 endif | |
" Don't add duplicates | |
32 0.000049 let i = 0 | |
528 0.000528 for c in self.cursors | |
496 0.000622 if c.position == a:pos | |
return 0 | |
endif | |
496 0.000590 let i+=1 | |
496 0.000420 endfor | |
32 0.002377 0.000208 let cursor = s:Cursor.new(a:pos) | |
" Save the visual selection | |
32 0.000050 if a:0 > 0 | |
32 0.003001 0.000141 call cursor.update_visual_selection(a:1) | |
32 0.000032 endif | |
32 0.000103 call add(self.cursors, cursor) | |
32 0.000068 let self.current_index += 1 | |
32 0.000034 return 1 | |
FUNCTION <SNR>139_feedkeys() | |
Called 66 times | |
Total time: 0.003505 | |
Self time: 0.003505 | |
count total (s) self (s) | |
71 0.000145 while 1 | |
71 0.001183 let c = getchar(0) | |
71 0.000281 let char_type = type(c) | |
" Checking type is important, when strings are compared with integers, | |
" strings are always converted to ints, and all strings are equal to 0 | |
71 0.000134 if char_type == 0 | |
71 0.000091 if c == 0 | |
66 0.000101 break | |
else | |
5 0.000020 let s:saved_keys .= nr2char(c) | |
5 0.000011 endif | |
5 0.000008 elseif char_type == 1 " char with more than 8 bits (as string) | |
let s:saved_keys .= c | |
endif | |
5 0.000008 endwhile | |
66 0.000421 call feedkeys(a:keys) | |
FUNCTION airline#extensions#branch#head() | |
Called 8 times | |
Total time: 0.000066 | |
Self time: 0.000066 | |
count total (s) self (s) | |
8 0.000045 if exists('b:airline_head') && !empty(b:airline_head) | |
8 0.000015 return b:airline_head | |
endif | |
let b:airline_head = '' | |
let found_fugitive_head = 0 | |
if s:has_fugitive && !exists('b:mercurial_dir') | |
let b:airline_head = fugitive#head(7) | |
let found_fugitive_head = 1 | |
if empty(b:airline_head) && !exists('b:git_dir') | |
let b:airline_head = s:get_git_branch(expand("%:p:h")) | |
endif | |
endif | |
if empty(b:airline_head) | |
if s:has_lawrencium | |
let b:airline_head = lawrencium#statusline() | |
endif | |
endif | |
if empty(b:airline_head) | |
if s:has_vcscommand | |
call VCSCommandEnableBufferSetup() | |
if exists('b:VCSCommandBufferInfo') | |
let b:airline_head = get(b:VCSCommandBufferInfo, 0, '') | |
endif | |
endif | |
endif | |
if empty(b:airline_head) || !found_fugitive_head && !s:check_in_path() | |
let b:airline_head = '' | |
endif | |
let b:airline_head = s:format_name(b:airline_head) | |
if exists("g:airline#extensions#branch#displayed_head_limit") | |
let w:displayed_head_limit = g:airline#extensions#branch#displayed_head_limit | |
if len(b:airline_head) > w:displayed_head_limit - 1 | |
let b:airline_head = b:airline_head[0:w:displayed_head_limit - 1].'…' | |
endif | |
endif | |
return b:airline_head | |
FUNCTION <SNR>139_last_char() | |
Called 7 times | |
Total time: 0.000054 | |
Self time: 0.000054 | |
count total (s) self (s) | |
7 0.000047 return s:char[len(s:char)-1] | |
FUNCTION <SNR>139_revert_mode() | |
Called 64 times | |
Total time: 0.004826 | |
Self time: 0.001344 | |
count total (s) self (s) | |
64 0.000287 if a:to ==# 'v' | |
32 0.003688 0.000206 call s:cm.reapply_visual_selection() | |
32 0.000063 elseif a:to ==# 'V' | |
call s:cm.reapply_visual_selection() | |
normal! V | |
elseif a:to ==# 'n' && a:from ==# 'i' | |
stopinsert | |
endif | |
FUNCTION airline#parts#mode() | |
Called 8 times | |
Total time: 0.000040 | |
Self time: 0.000040 | |
count total (s) self (s) | |
8 0.000032 return get(w:, 'airline_current_mode', '') | |
FUNCTION <SNR>139_wait_for_user_input() | |
Called 3 times | |
Total time: 0.044398 | |
Self time: 0.041569 | |
count total (s) self (s) | |
3 0.000225 0.000045 call s:display_error() | |
3 0.000008 let s:from_mode = a:mode | |
3 0.000009 if empty(a:mode) | |
2 0.000005 let s:from_mode = s:to_mode | |
2 0.000003 endif | |
3 0.000006 let s:to_mode = '' | |
" Right before redraw, apply the highlighting bug fix | |
3 0.000122 0.000034 call s:apply_highlight_fix() | |
3 0.040531 redraw | |
" Immediately revert the change to leave the user's buffer unchanged | |
3 0.000133 0.000047 call s:revert_highlight_fix() | |
3 0.000131 0.000028 call s:end_latency_measure() | |
3 0.000014 let s:char = s:retry_keys . s:saved_keys | |
3 0.000009 if len(s:saved_keys) == 0 | |
2 0.000248 0.000040 let s:char .= s:get_char() | |
2 0.000002 else | |
1 0.000002 let s:saved_keys = "" | |
1 0.000001 endif | |
3 0.000081 0.000067 if s:from_mode ==# 'i' && has_key(g:multi_cursor_insert_maps, s:last_char()) | |
let c = getchar(0) | |
let char_type = type(c) | |
let poll_count = 0 | |
while char_type == 0 && c == 0 && poll_count < &timeoutlen | |
sleep 1m | |
let c = getchar(0) | |
let char_type = type(c) | |
let poll_count += 1 | |
endwhile | |
if char_type == 0 && c != 0 | |
let s:char .= nr2char(c) | |
elseif char_type == 1 " char with more than 8 bits (as string) | |
let s:char .= c | |
endif | |
elseif s:from_mode !=# 'i' && s:char[0] ==# ":" | |
call feedkeys(s:char) | |
call s:cm.reset(1, 1) | |
return | |
elseif s:from_mode ==# 'n' | |
while match(s:last_char(), "\\d") == 0 | |
let s:char .= s:get_char() | |
endwhile | |
endif | |
3 0.000053 0.000032 call s:start_latency_measure() | |
" Clears any echoes we might've added | |
3 0.000287 normal! :<Esc> | |
3 0.001993 0.000057 if s:exit() | |
1 0.000001 return | |
endif | |
" If the key is a special key and we're in the right mode, handle it | |
2 0.000030 0.000020 if index(get(s:special_keys, s:from_mode, []), s:last_char()) != -1 | |
call s:handle_special_key(s:last_char(), s:from_mode) | |
call s:skip_latency_measure() | |
else | |
2 0.000023 0.000014 call s:cm.start_loop() | |
2 0.000204 0.000030 call s:feedkeys("\<Plug>(multiple-cursors-input)") | |
2 0.000003 endif | |
FUNCTION sy#repo#get_stats() | |
Called 8 times | |
Total time: 0.000088 | |
Self time: 0.000088 | |
count total (s) self (s) | |
8 0.000044 if !exists('b:sy') || !has_key(b:sy, 'stats') | |
return [-1, -1, -1] | |
endif | |
8 0.000012 return b:sy.stats | |
FUNCTION <SNR>60_Highlight_Matching_Pair() | |
Called 160 times | |
Total time: 0.010824 | |
Self time: 0.010824 | |
count total (s) self (s) | |
" Remove any previous match. | |
160 0.000574 if exists('w:paren_hl_on') && w:paren_hl_on | |
silent! call matchdelete(3) | |
let w:paren_hl_on = 0 | |
endif | |
" Avoid that we remove the popup menu. | |
" Return when there are no colors (looks like the cursor jumps). | |
160 0.000664 if pumvisible() || (&t_Co < 8 && !has("gui_running")) | |
return | |
endif | |
" Get the character under the cursor and check if it's in 'matchpairs'. | |
160 0.000437 let c_lnum = line('.') | |
160 0.000428 let c_col = col('.') | |
160 0.000228 let before = 0 | |
160 0.000502 let text = getline(c_lnum) | |
160 0.000586 let c = text[c_col - 1] | |
160 0.002679 let plist = split(&matchpairs, '.\zs[:,]') | |
160 0.000623 let i = index(plist, c) | |
160 0.000216 if i < 0 | |
" not found, in Insert mode try character before the cursor | |
160 0.000614 if c_col > 1 && (mode() == 'i' || mode() == 'R') | |
let before = 1 | |
let c = text[c_col - 2] | |
let i = index(plist, c) | |
endif | |
160 0.000150 if i < 0 | |
" not found, nothing to do | |
160 0.000148 return | |
endif | |
endif | |
" Figure out the arguments for searchpairpos(). | |
if i % 2 == 0 | |
let s_flags = 'nW' | |
let c2 = plist[i + 1] | |
else | |
let s_flags = 'nbW' | |
let c2 = c | |
let c = plist[i - 1] | |
endif | |
if c == '[' | |
let c = '\[' | |
let c2 = '\]' | |
endif | |
" Find the match. When it was just before the cursor move it there for a | |
" moment. | |
if before > 0 | |
let has_getcurpos = exists("*getcurpos") | |
if has_getcurpos | |
" getcurpos() is more efficient but doesn't exist before 7.4.313. | |
let save_cursor = getcurpos() | |
else | |
let save_cursor = winsaveview() | |
endif | |
call cursor(c_lnum, c_col - before) | |
endif | |
" Build an expression that detects whether the current cursor position is in | |
" certain syntax types (string, comment, etc.), for use as searchpairpos()'s | |
" skip argument. | |
" We match "escape" for special items, such as lispEscapeSpecial. | |
let s_skip = '!empty(filter(map(synstack(line("."), col(".")), ''synIDattr(v:val, "name")''), ' . '''v:val =~? "string\\|character\\|singlequote\\|escape\\|comment"''))' | |
" If executing the expression determines that the cursor is currently in | |
" one of the syntax types, then we want searchpairpos() to find the pair | |
" within those syntax types (i.e., not skip). Otherwise, the cursor is | |
" outside of the syntax types and s_skip should keep its value so we skip any | |
" matching pair inside the syntax types. | |
execute 'if' s_skip '| let s_skip = 0 | endif' | |
" Limit the search to lines visible in the window. | |
let stoplinebottom = line('w$') | |
let stoplinetop = line('w0') | |
if i % 2 == 0 | |
let stopline = stoplinebottom | |
else | |
let stopline = stoplinetop | |
endif | |
" Limit the search time to 300 msec to avoid a hang on very long lines. | |
" This fails when a timeout is not supported. | |
if mode() == 'i' || mode() == 'R' | |
let timeout = exists("b:matchparen_insert_timeout") ? b:matchparen_insert_timeout : g:matchparen_insert_timeout | |
else | |
let timeout = exists("b:matchparen_timeout") ? b:matchparen_timeout : g:matchparen_timeout | |
endif | |
try | |
let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline, timeout) | |
catch /E118/ | |
" Can't use the timeout, restrict the stopline a bit more to avoid taking | |
" a long time on closed folds and long lines. | |
" The "viewable" variables give a range in which we can scroll while | |
" keeping the cursor at the same position. | |
" adjustedScrolloff accounts for very large numbers of scrolloff. | |
let adjustedScrolloff = min([&scrolloff, (line('w$') - line('w0')) / 2]) | |
let bottom_viewable = min([line('$'), c_lnum + &lines - adjustedScrolloff - 2]) | |
let top_viewable = max([1, c_lnum-&lines+adjustedScrolloff + 2]) | |
" one of these stoplines will be adjusted below, but the current values are | |
" minimal boundaries within the current window | |
if i % 2 == 0 | |
if has("byte_offset") && has("syntax_items") && &smc > 0 | |
let stopbyte = min([line2byte("$"), line2byte(".") + col(".") + &smc * 2]) | |
let stopline = min([bottom_viewable, byte2line(stopbyte)]) | |
else | |
let stopline = min([bottom_viewable, c_lnum + 100]) | |
endif | |
let stoplinebottom = stopline | |
else | |
if has("byte_offset") && has("syntax_items") && &smc > 0 | |
let stopbyte = max([1, line2byte(".") + col(".") - &smc * 2]) | |
let stopline = max([top_viewable, byte2line(stopbyte)]) | |
else | |
let stopline = max([top_viewable, c_lnum - 100]) | |
endif | |
let stoplinetop = stopline | |
endif | |
let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline) | |
endtry | |
if before > 0 | |
if has_getcurpos | |
call setpos('.', save_cursor) | |
else | |
call winrestview(save_cursor) | |
endif | |
endif | |
" If a match is found setup match highlighting. | |
if m_lnum > 0 && m_lnum >= stoplinetop && m_lnum <= stoplinebottom | |
if exists('*matchaddpos') | |
call matchaddpos('MatchParen', [[c_lnum, c_col - before], [m_lnum, m_col]], 10, 3) | |
else | |
exe '3match MatchParen /\(\%' . c_lnum . 'l\%' . (c_col - before) . 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/' | |
endif | |
let w:paren_hl_on = 1 | |
endif | |
FUNCTION neocomplete#helper#is_enabled_source() | |
Called 386 times | |
Total time: 0.093563 | |
Self time: 0.010357 | |
count total (s) self (s) | |
386 0.007139 0.004227 let source = type(a:source) == type('') ? get(neocomplete#variables#get_sources(), a:source, {}) : a:source | |
386 0.085715 0.005421 return !empty(source) && (empty(source.filetypes) || !empty(neocomplete#helper#ftdictionary2list( source.filetypes, a:filetype))) && (!get(source.disabled_filetypes, '_', 0) && empty(neocomplete#helper#ftdictionary2list( source.disabled_filetypes, a:filetype))) | |
FUNCTION <SNR>92_Init() | |
Called 7 times | |
Total time: 0.000243 | |
Self time: 0.000243 | |
count total (s) self (s) | |
7 0.000015 if s:checked_ctags == 2 && a:silent | |
return 0 | |
elseif s:checked_ctags != 1 | |
if !s:CheckForExCtags(a:silent) | |
return 0 | |
endif | |
endif | |
7 0.000013 if !s:checked_ctags_types | |
call s:GetSupportedFiletypes() | |
endif | |
7 0.000012 if !s:type_init_done | |
call s:InitTypes() | |
endif | |
7 0.000012 if !s:autocommands_done | |
call s:CreateAutocommands() | |
call s:AutoUpdate(fnamemodify(expand('%'), ':p'), 0) | |
endif | |
7 0.000005 return 1 | |
FUNCTION <SNR>139_compare_pos() | |
Called 96 times | |
Total time: 0.000549 | |
Self time: 0.000549 | |
count total (s) self (s) | |
" If number lines are the same, compare columns | |
96 0.000452 return a:l[0] ==# a:r[0] ? a:l[1] - a:r[1] : a:l[0] - a:r[0] | |
FUNCTION <SNR>113_exists_current_source() | |
Called 579 times | |
Total time: 0.023677 | |
Self time: 0.006690 | |
count total (s) self (s) | |
579 0.023301 0.006314 return has_key(s:buffer_sources, bufnr('%')) && !s:check_changed_buffer(bufnr('%')) | |
FUNCTION neocomplete#sources#buffer#make_cache_current_line() | |
Called 579 times | |
Total time: 6.261745 | |
Self time: 0.010729 | |
count total (s) self (s) | |
" let start = reltime() | |
579 6.260189 0.009173 call s:make_cache_current_buffer( max([1, line('.')-10]), min([line('$'), line('.') + 10])) | |
" echomsg reltimestr(reltime(start)) | |
FUNCTION <SNR>72_get_hunks() | |
Called 8 times | |
Total time: 0.000384 | |
Self time: 0.000205 | |
count total (s) self (s) | |
8 0.000026 if empty(s:source_func) | |
if get(g:, 'loaded_signify', 0) | |
let s:source_func = 's:get_hunks_signify' | |
elseif exists('*GitGutterGetHunkSummary') | |
let s:source_func = 's:get_hunks_gitgutter' | |
elseif exists('*changes#GetStats') | |
let s:source_func = 's:get_hunks_changes' | |
else | |
let s:source_func = 's:get_hunks_empty' | |
endif | |
endif | |
8 0.000244 0.000065 return {s:source_func}() | |
FUNCTION <SNR>72_get_hunks_signify() | |
Called 8 times | |
Total time: 0.000179 | |
Self time: 0.000091 | |
count total (s) self (s) | |
8 0.000136 0.000048 let hunks = sy#repo#get_stats() | |
8 0.000023 if hunks[0] >= 0 | |
8 0.000013 return hunks | |
endif | |
return [] | |
FUNCTION <SNR>139_detect_bad_input() | |
Called 64 times | |
Total time: 0.000768 | |
Self time: 0.000768 | |
count total (s) self (s) | |
64 0.000236 if !s:valid_input | |
" We ignore the bad input and force invoke s:apply_user_input_next | |
call feedkeys("\<Plug>(multiple-cursors-apply)") | |
let s:bad_input += 1 | |
endif | |
FUNCTION neocomplete#handler#_on_insert_enter() | |
Called 193 times | |
Total time: 0.027386 | |
Self time: 0.006797 | |
count total (s) self (s) | |
193 0.002885 0.001131 if !neocomplete#is_enabled() | |
return | |
endif | |
193 0.003305 0.001265 let neocomplete = neocomplete#get_current_neocomplete() | |
193 0.000713 if neocomplete.linenr != line('.') | |
64 0.017137 0.000342 call neocomplete#helper#clear_result() | |
64 0.000054 endif | |
193 0.000663 let neocomplete.linenr = line('.') | |
193 0.000784 if &l:foldmethod ==# 'expr' && foldlevel('.') != 0 | |
foldopen | |
endif | |
FUNCTION neocomplete#is_enabled() | |
Called 1285 times | |
Total time: 0.008899 | |
Self time: 0.005832 | |
count total (s) self (s) | |
1285 0.008206 0.005139 return neocomplete#init#is_enabled() | |
FUNCTION neocomplete#is_locked() | |
Called 353 times | |
Total time: 0.015522 | |
Self time: 0.002476 | |
count total (s) self (s) | |
353 0.015282 0.002236 return neocomplete#is_cache_disabled() || &paste || (&t_Co != '' && &t_Co < 8) || g:neocomplete#disable_auto_complete | |
FUNCTION airline#highlighter#get_highlight() | |
Called 48 times | |
Total time: 0.005229 | |
Self time: 0.001625 | |
count total (s) self (s) | |
48 0.001695 0.000247 let fg = s:get_syn(a:group, 'fg') | |
48 0.001734 0.000235 let bg = s:get_syn(a:group, 'bg') | |
48 0.000747 let reverse = has('gui_running') || (has("termtruecolor") && &guicolors == 1) ? synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'gui') : synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'cterm')|| synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'term') | |
48 0.001003 0.000346 return reverse ? s:get_array(bg, fg, a:000) : s:get_array(fg, bg, a:000) | |
FUNCTION airline#extensions#syntastic#get_warnings() | |
Called 8 times | |
Total time: 0.000831 | |
Self time: 0.000111 | |
count total (s) self (s) | |
8 0.000766 0.000046 let errors = SyntasticStatuslineFlag() | |
8 0.000022 if strlen(errors) > 0 | |
return errors.(g:airline_symbols.space) | |
endif | |
8 0.000006 return '' | |
FUNCTION airline#highlighter#highlight_modified_inactive() | |
Called 1 time | |
Total time: 0.000078 | |
Self time: 0.000034 | |
count total (s) self (s) | |
1 0.000004 if getbufvar(a:bufnr, '&modified') | |
1 0.000012 let colors = exists('g:airline#themes#{g:airline_theme}#palette.inactive_modified.airline_c') ? g:airline#themes#{g:airline_theme}#palette.inactive_modified.airline_c : [] | |
1 0.000001 else | |
let colors = exists('g:airline#themes#{g:airline_theme}#palette.inactive.airline_c') ? g:airline#themes#{g:airline_theme}#palette.inactive.airline_c : [] | |
endif | |
1 0.000002 if !empty(colors) | |
1 0.000054 0.000010 call airline#highlighter#exec('airline_c'.(a:bufnr).'_inactive', colors) | |
1 0.000001 endif | |
FUNCTION airline#extensions#branch#get_head() | |
Called 8 times | |
Total time: 0.000295 | |
Self time: 0.000229 | |
count total (s) self (s) | |
8 0.000114 0.000048 let head = airline#extensions#branch#head() | |
8 0.000054 let empty_message = get(g:, 'airline#extensions#branch#empty_message', get(g:, 'airline_branch_empty_message', '')) | |
8 0.000038 let symbol = get(g:, 'airline#extensions#branch#symbol', g:airline_symbols.branch) | |
8 0.000074 return empty(head) ? empty_message : printf('%s%s', empty(symbol) ? '' : symbol.(g:airline_symbols.space), head) | |
FUNCTION <SNR>129_uniq() | |
Called 965 times | |
Total time: 4.919294 | |
Self time: 0.043160 | |
count total (s) self (s) | |
965 4.918711 0.042577 return s:uniq_by(a:list, 'v:val') | |
FUNCTION neocomplete#helper#clear_result() | |
Called 257 times | |
Total time: 0.057782 | |
Self time: 0.028686 | |
count total (s) self (s) | |
257 0.003821 0.001413 let neocomplete = neocomplete#get_current_neocomplete() | |
257 0.000744 let neocomplete.complete_str = '' | |
257 0.000675 let neocomplete.candidates = [] | |
257 0.000555 let neocomplete.complete_sources = [] | |
257 0.000450 let neocomplete.complete_pos = -1 | |
" Restore completeopt. | |
257 0.000895 if neocomplete.completeopt !=# &completeopt | |
" Restore completeopt. | |
let &completeopt = neocomplete.completeopt | |
endif | |
" Clear context. | |
2570 0.006995 0.005007 for source in values(neocomplete#variables#get_sources()) | |
2313 0.037144 0.012444 let source.neocomplete__context = neocomplete#init#_context( source.neocomplete__context) | |
2313 0.002747 endfor | |
FUNCTION airline#extensions#hunks#get_hunks() | |
Called 8 times | |
Total time: 0.000958 | |
Self time: 0.000574 | |
count total (s) self (s) | |
8 0.000027 if !get(w:, 'airline_active', 0) | |
return '' | |
endif | |
8 0.000442 0.000058 let hunks = s:get_hunks() | |
8 0.000016 let string = '' | |
8 0.000017 if !empty(hunks) | |
32 0.000055 for i in [0, 1, 2] | |
24 0.000057 if s:non_zero_only == 0 || hunks[i] > 0 | |
24 0.000184 let string .= printf('%s%s ', s:hunk_symbols[i], hunks[i]) | |
24 0.000022 endif | |
24 0.000017 endfor | |
8 0.000007 endif | |
8 0.000009 return string | |
FUNCTION <SNR>113_make_cache_current_buffer() | |
Called 579 times | |
Total time: 6.251016 | |
Self time: 1.285440 | |
count total (s) self (s) | |
579 0.002454 let srcname = bufnr('%') | |
" Make cache from current buffer. | |
579 0.042229 0.003381 if !s:should_create_cache(srcname) | |
return | |
endif | |
579 0.026793 0.003116 if !s:exists_current_source() | |
call s:initialize_source(srcname) | |
endif | |
579 0.002058 let source = s:buffer_sources[srcname] | |
579 0.001563 let keyword_pattern = source.keyword_pattern | |
579 0.001081 if keyword_pattern == '' | |
return | |
endif | |
579 0.000941 let words = [] | |
579 0.000745 lua << EOF | |
do | |
local words = vim.eval('words') | |
local dup = {} | |
local b = vim.buffer() | |
local min_length = vim.eval('g:neocomplete#min_keyword_length') | |
for linenr = vim.eval('a:start'), vim.eval('a:end') do | |
local match = 0 | |
while 1 do | |
local match_str = vim.eval('matchstr(getline('..linenr.. | |
'), keyword_pattern, ' .. match .. ')') | |
if match_str == '' then | |
break | |
end | |
if dup[match_str] == nil | |
and string.len(match_str) >= min_length then | |
dup[match_str] = 1 | |
words:add(match_str) | |
end | |
-- Next match. | |
match = vim.eval('matchend(getline(' .. linenr .. | |
'), keyword_pattern, ' .. match .. ')') | |
end | |
end | |
end | |
EOF | |
579 5.073251 0.170200 let source.words = neocomplete#util#uniq(source.words + words) | |
FUNCTION Multiple_cursors_after() | |
Called 1 time | |
Total time: 0.000042 | |
Self time: 0.000020 | |
count total (s) self (s) | |
1 0.000042 0.000020 exe 'NeoCompleteUnlock' | |
FUNCTION <SNR>133_close_preview_window() | |
Called 193 times | |
Total time: 0.001770 | |
Self time: 0.001770 | |
count total (s) self (s) | |
193 0.001160 if g:neocomplete#enable_auto_close_preview && bufname('%') !=# '[Command Line]' && winnr('$') != 1 && !&l:previewwindow && !s:check_in_do_auto_complete() | |
" Close preview window. | |
pclose! | |
endif | |
FUNCTION SyntasticStatuslineFlag() | |
Called 8 times | |
Total time: 0.000720 | |
Self time: 0.000076 | |
count total (s) self (s) | |
8 0.000716 0.000072 return g:SyntasticLoclist.current().getStatuslineFlag() | |
FUNCTION neocomplete#commands#_lock() | |
Called 1 time | |
Total time: 0.000025 | |
Self time: 0.000015 | |
count total (s) self (s) | |
1 0.000021 0.000011 let neocomplete = neocomplete#get_current_neocomplete() | |
1 0.000002 let neocomplete.lock = 1 | |
FUNCTION airline#util#prepend() | |
Called 8 times | |
Total time: 0.000072 | |
Self time: 0.000072 | |
count total (s) self (s) | |
8 0.000022 if a:minwidth > 0 && winwidth(0) < a:minwidth | |
return '' | |
endif | |
8 0.000029 return empty(a:text) ? '' : a:text.s:spc.g:airline_right_alt_sep.s:spc | |
FUNCTION <SNR>82_get_syn() | |
Called 96 times | |
Total time: 0.002947 | |
Self time: 0.002947 | |
count total (s) self (s) | |
" need to pass in mode, known to break on 7.3.547 | |
96 0.000666 let mode = has('gui_running') || (has("termtruecolor") && &guicolors == 1) ? 'gui' : 'cterm' | |
96 0.000620 let color = synIDattr(synIDtrans(hlID(a:group)), a:what, mode) | |
96 0.000232 if empty(color) || color == -1 | |
4 0.000024 let color = synIDattr(synIDtrans(hlID('Normal')), a:what, mode) | |
4 0.000003 endif | |
96 0.000188 if empty(color) || color == -1 | |
if has('gui_running') || (has("termtruecolor") && &guicolors == 1) | |
let color = a:what ==# 'fg' ? '#000000' : '#FFFFFF' | |
else | |
let color = a:what ==# 'fg' ? 0 : 1 | |
endif | |
endif | |
96 0.000086 return color | |
FUNCTIONS SORTED ON TOTAL TIME | |
count total (s) self (s) function | |
579 6.261745 0.010729 neocomplete#sources#buffer#make_cache_current_line() | |
579 6.251016 1.285440 <SNR>113_make_cache_current_buffer() | |
965 4.940251 0.011181 neocomplete#util#uniq() | |
965 4.919294 0.043160 <SNR>129_uniq() | |
965 4.876134 <SNR>129_uniq_by() | |
193 2.359891 0.005994 neocomplete#handler#_on_insert_leave() | |
193 2.309435 0.007106 <SNR>133_make_cache_current_line() | |
579 0.360603 0.010326 neocomplete#sources#member#make_cache_current_line() | |
579 0.346449 0.018721 <SNR>127_make_cache_current_buffer() | |
579 0.299805 0.295402 <SNR>127_make_cache_lines() | |
386 0.093563 0.010357 neocomplete#helper#is_enabled_source() | |
386 0.080294 0.005359 neocomplete#helper#ftdictionary2list() | |
386 0.074935 0.002329 neocomplete#get_source_filetypes() | |
386 0.072606 0.028191 neocomplete#helper#get_source_filetypes() | |
257 0.057782 0.028686 neocomplete#helper#clear_result() | |
3 0.044398 0.041569 <SNR>139_wait_for_user_input() | |
579 0.038848 <SNR>113_should_create_cache() | |
579 0.027923 0.010913 neocomplete#get_context_filetype() | |
193 0.027386 0.006797 neocomplete#handler#_on_insert_enter() | |
2313 0.024700 neocomplete#init#_context() | |
FUNCTIONS SORTED ON SELF TIME | |
count total (s) self (s) function | |
965 4.876134 <SNR>129_uniq_by() | |
579 6.251016 1.285440 <SNR>113_make_cache_current_buffer() | |
579 0.299805 0.295402 <SNR>127_make_cache_lines() | |
965 4.919294 0.043160 <SNR>129_uniq() | |
3 0.044398 0.041569 <SNR>139_wait_for_user_input() | |
579 0.038848 <SNR>113_should_create_cache() | |
257 0.057782 0.028686 neocomplete#helper#clear_result() | |
386 0.072606 0.028191 neocomplete#helper#get_source_filetypes() | |
2313 0.024700 neocomplete#init#_context() | |
2316 0.020412 neocomplete#get_current_neocomplete() | |
579 0.346449 0.018721 <SNR>127_make_cache_current_buffer() | |
579 0.016987 <SNR>113_check_changed_buffer() | |
579 0.017010 0.012139 neocomplete#context_filetype#set() | |
64 0.019526 0.011911 210() | |
965 4.940251 0.011181 neocomplete#util#uniq() | |
513 0.018728 0.010943 neocomplete#is_cache_disabled() | |
579 0.027923 0.010913 neocomplete#get_context_filetype() | |
160 0.010824 <SNR>60_Highlight_Matching_Pair() | |
579 6.261745 0.010729 neocomplete#sources#buffer#make_cache_current_line() | |
386 0.093563 0.010357 neocomplete#helper#is_enabled_source() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment