Skip to content

Instantly share code, notes, and snippets.

@joeltaylor
Created May 3, 2019 15:16
Show Gist options
  • Save joeltaylor/c3edc7bd974ab98898ea38ff7dcd732f to your computer and use it in GitHub Desktop.
Save joeltaylor/c3edc7bd974ab98898ea38ff7dcd732f to your computer and use it in GitHub Desktop.
SCRIPT /private/tmp/plugged/fzf.vim/autoload/fzf/vim.vim
Sourced 1 time
Total time: 0.002289
Self time: 0.002155
count total (s) self (s)
" Copyright (c) 2017 Junegunn Choi
"
" MIT License
"
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
" "Software"), to deal in the Software without restriction, including
" without limitation the rights to use, copy, modify, merge, publish,
" distribute, sublicense, and/or sell copies of the Software, and to
" permit persons to whom the Software is furnished to do so, subject to
" the following conditions:
"
" The above copyright notice and this permission notice shall be
" included in all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 0.000011 let s:cpo_save = &cpo
1 0.000009 set cpo&vim
" ------------------------------------------------------------------
" Common
" ------------------------------------------------------------------
1 0.000008 let s:is_win = has('win32') || has('win64')
1 0.000003 let s:layout_keys = ['window', 'up', 'down', 'left', 'right']
1 0.000005 let s:bin_dir = expand('<sfile>:h:h:h').'/bin/'
1 0.000006 let s:bin = {
\ 'preview': s:bin_dir.'preview.sh',
\ 'tags': s:bin_dir.'tags.pl' }
1 0.000014 let s:TYPE = {'dict': type({}), 'funcref': type(function('call')), 'string': type(''), 'list': type([])}
1 0.000002 if s:is_win
if has('nvim')
let s:bin.preview = split(system('for %A in ("'.s:bin.preview.'") do @echo %~sA'), "\n")[0]
else
let s:bin.preview = fnamemodify(s:bin.preview, ':8')
endif
let s:bin.preview = 'bash '.escape(s:bin.preview, '\')
1 0.000001 endif
1 0.000001 let s:wide = 120
1 0.000003 function! s:extend_opts(dict, eopts, prepend)
if empty(a:eopts)
return
endif
if has_key(a:dict, 'options')
if type(a:dict.options) == s:TYPE.list && type(a:eopts) == s:TYPE.list
if a:prepend
let a:dict.options = extend(copy(a:eopts), a:dict.options)
else
call extend(a:dict.options, a:eopts)
endif
else
let all_opts = a:prepend ? [a:eopts, a:dict.options] : [a:dict.options, a:eopts]
let a:dict.options = join(map(all_opts, 'type(v:val) == s:TYPE.list ? join(map(copy(v:val), "fzf#shellescape(v:val)")) : v:val'))
endif
else
let a:dict.options = a:eopts
endif
endfunction
1 0.000006 function! s:merge_opts(dict, eopts)
return s:extend_opts(a:dict, a:eopts, 0)
endfunction
1 0.000001 function! s:prepend_opts(dict, eopts)
return s:extend_opts(a:dict, a:eopts, 1)
endfunction
" [[options to wrap], [preview window expression], [toggle-preview keys...]]
1 0.000001 function! fzf#vim#with_preview(...)
" Default options
let options = {}
let window = 'right'
let args = copy(a:000)
" Options to wrap
if len(args) && type(args[0]) == s:TYPE.dict
let options = copy(args[0])
call remove(args, 0)
endif
" Preview window
if len(args) && type(args[0]) == s:TYPE.string
if args[0] !~# '^\(up\|down\|left\|right\)'
throw 'invalid preview window: '.args[0]
endif
let window = args[0]
call remove(args, 0)
endif
let preview = ['--preview-window', window, '--preview', (s:is_win ? s:bin.preview : fzf#shellescape(s:bin.preview)).' {}']
if len(args)
call extend(preview, ['--bind', join(map(args, 'v:val.":toggle-preview"'), ',')])
endif
call s:merge_opts(options, preview)
return options
endfunction
1 0.000002 function! s:remove_layout(opts)
for key in s:layout_keys
if has_key(a:opts, key)
call remove(a:opts, key)
endif
endfor
return a:opts
endfunction
1 0.000002 function! s:wrap(name, opts, bang)
" fzf#wrap does not append --expect if sink or sink* is found
let opts = copy(a:opts)
let options = ''
if has_key(opts, 'options')
let options = type(opts.options) == s:TYPE.list ? join(opts.options) : opts.options
endif
if options !~ '--expect' && has_key(opts, 'sink*')
let Sink = remove(opts, 'sink*')
let wrapped = fzf#wrap(a:name, opts, a:bang)
let wrapped['sink*'] = Sink
else
let wrapped = fzf#wrap(a:name, opts, a:bang)
endif
return wrapped
endfunction
1 0.000004 function! s:strip(str)
return substitute(a:str, '^\s*\|\s*$', '', 'g')
endfunction
1 0.000002 function! s:chomp(str)
return substitute(a:str, '\n*$', '', 'g')
endfunction
1 0.000002 function! s:escape(path)
let path = fnameescape(a:path)
return s:is_win ? escape(path, '$') : path
endfunction
1 0.000003 if v:version >= 704
1 0.000001 function! s:function(name)
return function(a:name)
endfunction
else
function! s:function(name)
" By Ingo Karkat
return function(substitute(a:name, '^s:', matchstr(expand('<sfile>'), '<SNR>\d\+_\zefunction$'), ''))
endfunction
1 0.000000 endif
1 0.000001 function! s:get_color(attr, ...)
let gui = has('termguicolors') && &termguicolors
let fam = gui ? 'gui' : 'cterm'
let pat = gui ? '^#[a-f0-9]\+' : '^[0-9]\+$'
for group in a:000
let code = synIDattr(synIDtrans(hlID(group)), a:attr, fam)
if code =~? pat
return code
endif
endfor
return ''
endfunction
1 0.000010 let s:ansi = {'black': 30, 'red': 31, 'green': 32, 'yellow': 33, 'blue': 34, 'magenta': 35, 'cyan': 36}
1 0.000002 function! s:csi(color, fg)
let prefix = a:fg ? '38;' : '48;'
if a:color[0] == '#'
return prefix.'2;'.join(map([a:color[1:2], a:color[3:4], a:color[5:6]], 'str2nr(v:val, 16)'), ';')
endif
return prefix.'5;'.a:color
endfunction
1 0.000001 function! s:ansi(str, group, default, ...)
let fg = s:get_color('fg', a:group)
let bg = s:get_color('bg', a:group)
let color = (empty(fg) ? s:ansi[a:default] : s:csi(fg, 1)) .
\ (empty(bg) ? '' : ';'.s:csi(bg, 0))
return printf("\x1b[%s%sm%s\x1b[m", color, a:0 ? ';1' : '', a:str)
endfunction
8 0.000014 for s:color_name in keys(s:ansi)
1 0.000012 execute "function! s:".s:color_name."(str, ...)\n"
\ " return s:ansi(a:str, get(a:, 1, ''), '".s:color_name."')\n"
6 0.000054 \ "endfunction"
8 0.000009 endfor
1 0.000002 function! s:buflisted()
return filter(range(1, bufnr('$')), 'buflisted(v:val) && getbufvar(v:val, "&filetype") != "qf"')
endfunction
1 0.000001 function! s:fzf(name, opts, extra)
let [extra, bang] = [{}, 0]
if len(a:extra) <= 1
let first = get(a:extra, 0, 0)
if type(first) == s:TYPE.dict
let extra = first
else
let bang = first
endif
elseif len(a:extra) == 2
let [extra, bang] = a:extra
else
throw 'invalid number of arguments'
endif
let eopts = has_key(extra, 'options') ? remove(extra, 'options') : ''
let merged = extend(copy(a:opts), extra)
call s:merge_opts(merged, eopts)
return fzf#run(s:wrap(a:name, merged, bang))
endfunction
1 0.000009 let s:default_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
1 0.000002 function! s:action_for(key, ...)
let default = a:0 ? a:1 : ''
let Cmd = get(get(g:, 'fzf_action', s:default_action), a:key, default)
return type(Cmd) == s:TYPE.string ? Cmd : default
endfunction
1 0.000001 function! s:open(cmd, target)
if stridx('edit', a:cmd) == 0 && fnamemodify(a:target, ':p') ==# expand('%:p')
return
endif
execute a:cmd s:escape(a:target)
endfunction
1 0.000002 function! s:align_lists(lists)
let maxes = {}
for list in a:lists
let i = 0
while i < len(list)
let maxes[i] = max([get(maxes, i, 0), len(list[i])])
let i += 1
endwhile
endfor
for list in a:lists
call map(list, "printf('%-'.maxes[v:key].'s', v:val)")
endfor
return a:lists
endfunction
1 0.000005 function! s:warn(message)
echohl WarningMsg
echom a:message
echohl None
return 0
endfunction
1 0.000001 function! s:fill_quickfix(list, ...)
if len(a:list) > 1
call setqflist(a:list)
copen
wincmd p
if a:0
execute a:1
endif
endif
endfunction
1 0.000001 function! fzf#vim#_uniq(list)
let visited = {}
let ret = []
for l in a:list
if !empty(l) && !has_key(visited, l)
call add(ret, l)
let visited[l] = 1
endif
endfor
return ret
endfunction
" ------------------------------------------------------------------
" Files
" ------------------------------------------------------------------
1 0.000003 function! s:shortpath()
let short = fnamemodify(getcwd(), ':~:.')
if !has('win32unix')
let short = pathshorten(short)
endif
let slash = (s:is_win && !&shellslash) ? '\' : '/'
return empty(short) ? '~'.slash : short . (short =~ escape(slash, '\').'$' ? '' : slash)
endfunction
1 0.000001 function! fzf#vim#files(dir, ...)
let args = {}
if !empty(a:dir)
if !isdirectory(expand(a:dir))
return s:warn('Invalid directory')
endif
let slash = (s:is_win && !&shellslash) ? '\\' : '/'
let dir = substitute(a:dir, '[/\\]*$', slash, '')
let args.dir = dir
else
let dir = s:shortpath()
endif
let args.options = ['-m', '--prompt', strwidth(dir) < &columns / 2 - 20 ? dir : '> ']
call s:merge_opts(args, get(g:, 'fzf_files_options', []))
return s:fzf('files', args, a:000)
endfunction
" ------------------------------------------------------------------
" Lines
" ------------------------------------------------------------------
1 0.000001 function! s:line_handler(lines)
if len(a:lines) < 2
return
endif
normal! m'
let cmd = s:action_for(a:lines[0])
if !empty(cmd) && stridx('edit', cmd) < 0
execute 'silent' cmd
endif
let keys = split(a:lines[1], '\t')
execute 'buffer' keys[0]
execute keys[2]
normal! ^zvzz
endfunction
1 0.000001 function! fzf#vim#_lines(all)
let cur = []
let rest = []
let buf = bufnr('')
let longest_name = 0
let display_bufnames = &columns > s:wide
if display_bufnames
let bufnames = {}
for b in s:buflisted()
let bufnames[b] = pathshorten(fnamemodify(bufname(b), ":~:."))
let longest_name = max([longest_name, len(bufnames[b])])
endfor
endif
let len_bufnames = min([15, longest_name])
for b in s:buflisted()
let lines = getbufline(b, 1, "$")
if empty(lines)
let path = fnamemodify(bufname(b), ':p')
let lines = filereadable(path) ? readfile(path) : []
endif
if display_bufnames
let bufname = bufnames[b]
if len(bufname) > len_bufnames + 1
let bufname = '…' . bufname[-len_bufnames+1:]
endif
let bufname = printf(s:green("%".len_bufnames."s", "Directory"), bufname)
else
let bufname = ''
endif
let linefmt = s:blue("%2d\t", "TabLine")."%s".s:yellow("\t%4d ", "LineNr")."\t%s"
call extend(b == buf ? cur : rest,
\ filter(
\ map(lines,
\ '(!a:all && empty(v:val)) ? "" : printf(linefmt, b, bufname, v:key + 1, v:val)'),
\ 'a:all || !empty(v:val)'))
endfor
return [display_bufnames, extend(cur, rest)]
endfunction
1 0.000001 function! fzf#vim#lines(...)
let [display_bufnames, lines] = fzf#vim#_lines(1)
let nth = display_bufnames ? 3 : 2
let [query, args] = (a:0 && type(a:1) == type('')) ?
\ [a:1, a:000[1:]] : ['', a:000]
return s:fzf('lines', {
\ 'source': lines,
\ 'sink*': s:function('s:line_handler'),
\ 'options': ['+m', '--tiebreak=index', '--prompt', 'Lines> ', '--ansi', '--extended', '--nth='.nth.'..', '--layout=reverse-list', '--tabstop=1', '--query', query]
\}, args)
endfunction
" ------------------------------------------------------------------
" BLines
" ------------------------------------------------------------------
1 0.000002 function! s:buffer_line_handler(lines)
if len(a:lines) < 2
return
endif
let qfl = []
for line in a:lines[1:]
let chunks = split(line, "\t", 1)
let ln = chunks[0]
let ltxt = join(chunks[1:], "\t")
call add(qfl, {'filename': expand('%'), 'lnum': str2nr(ln), 'text': ltxt})
endfor
call s:fill_quickfix(qfl, 'cfirst')
normal! m'
let cmd = s:action_for(a:lines[0])
if !empty(cmd)
execute 'silent' cmd
endif
execute split(a:lines[1], '\t')[0]
normal! ^zvzz
endfunction
1 0.000001 function! s:buffer_lines(query)
let linefmt = s:yellow(" %4d ", "LineNr")."\t%s"
let fmtexpr = 'printf(linefmt, v:key + 1, v:val)'
let lines = getline(1, '$')
if empty(a:query)
return map(lines, fmtexpr)
end
return filter(map(lines, 'v:val =~ a:query ? '.fmtexpr.' : ""'), 'len(v:val)')
endfunction
1 0.000002 function! fzf#vim#buffer_lines(...)
let [query, args] = (a:0 && type(a:1) == type('')) ?
\ [a:1, a:000[1:]] : ['', a:000]
return s:fzf('blines', {
\ 'source': s:buffer_lines(query),
\ 'sink*': s:function('s:buffer_line_handler'),
\ 'options': ['+m', '--tiebreak=index', '--multi', '--prompt', 'BLines> ', '--ansi', '--extended', '--nth=2..', '--layout=reverse-list', '--tabstop=1']
\}, args)
endfunction
" ------------------------------------------------------------------
" Colors
" ------------------------------------------------------------------
1 0.000002 function! fzf#vim#colors(...)
let colors = split(globpath(&rtp, "colors/*.vim"), "\n")
if has('packages')
let colors += split(globpath(&packpath, "pack/*/opt/*/colors/*.vim"), "\n")
endif
return s:fzf('colors', {
\ 'source': fzf#vim#_uniq(map(colors, "substitute(fnamemodify(v:val, ':t'), '\\..\\{-}$', '', '')")),
\ 'sink': 'colo',
\ 'options': '+m --prompt="Colors> "'
\}, a:000)
endfunction
" ------------------------------------------------------------------
" Locate
" ------------------------------------------------------------------
1 0.000002 function! fzf#vim#locate(query, ...)
return s:fzf('locate', {
\ 'source': 'locate '.a:query,
\ 'options': '-m --prompt "Locate> "'
\}, a:000)
endfunction
" ------------------------------------------------------------------
" History[:/]
" ------------------------------------------------------------------
1 0.000001 function! s:all_files()
return fzf#vim#_uniq(map(
\ filter([expand('%')], 'len(v:val)')
\ + filter(map(s:buflisted_sorted(), 'bufname(v:val)'), 'len(v:val)')
\ + filter(copy(v:oldfiles), "filereadable(fnamemodify(v:val, ':p'))"),
\ 'fnamemodify(v:val, ":~:.")'))
endfunction
1 0.000001 function! s:history_source(type)
let max = histnr(a:type)
let fmt = ' %'.len(string(max)).'d '
let list = filter(map(range(1, max), 'histget(a:type, - v:val)'), '!empty(v:val)')
return extend([' :: Press '.s:magenta('CTRL-E', 'Special').' to edit'],
\ map(list, 's:yellow(printf(fmt, len(list) - v:key), "Number")." ".v:val'))
endfunction
1 0.000011 nnoremap <plug>(-fzf-vim-do) :execute g:__fzf_command<cr>
1 0.000005 nnoremap <plug>(-fzf-/) /
1 0.000004 nnoremap <plug>(-fzf-:) :
1 0.000001 function! s:history_sink(type, lines)
if len(a:lines) < 2
return
endif
let prefix = "\<plug>(-fzf-".a:type.')'
let key = a:lines[0]
let item = matchstr(a:lines[1], ' *[0-9]\+ *\zs.*')
if key == 'ctrl-e'
call histadd(a:type, item)
redraw
call feedkeys(a:type."\<up>")
else
if a:type == ':'
call histadd(a:type, item)
endif
let g:__fzf_command = "normal ".prefix.item."\<cr>"
call feedkeys("\<plug>(-fzf-vim-do)")
endif
endfunction
1 0.000002 function! s:cmd_history_sink(lines)
call s:history_sink(':', a:lines)
endfunction
1 0.000001 function! fzf#vim#command_history(...)
return s:fzf('history-command', {
\ 'source': s:history_source(':'),
\ 'sink*': s:function('s:cmd_history_sink'),
\ 'options': '+m --ansi --prompt="Hist:> " --header-lines=1 --expect=ctrl-e --tiebreak=index'}, a:000)
endfunction
1 0.000001 function! s:search_history_sink(lines)
call s:history_sink('/', a:lines)
endfunction
1 0.000001 function! fzf#vim#search_history(...)
return s:fzf('history-search', {
\ 'source': s:history_source('/'),
\ 'sink*': s:function('s:search_history_sink'),
\ 'options': '+m --ansi --prompt="Hist/> " --header-lines=1 --expect=ctrl-e --tiebreak=index'}, a:000)
endfunction
1 0.000001 function! fzf#vim#history(...)
return s:fzf('history-files', {
\ 'source': s:all_files(),
\ 'options': ['-m', '--header-lines', !empty(expand('%')), '--prompt', 'Hist> ']
\}, a:000)
endfunction
" ------------------------------------------------------------------
" GFiles[?]
" ------------------------------------------------------------------
1 0.000001 function! s:get_git_root()
let root = split(system('git rev-parse --show-toplevel'), '\n')[0]
return v:shell_error ? '' : root
endfunction
1 0.000001 function! fzf#vim#gitfiles(args, ...)
let root = s:get_git_root()
if empty(root)
return s:warn('Not in git repo')
endif
if a:args != '?'
return s:fzf('gfiles', {
\ 'source': 'git ls-files '.a:args.(s:is_win ? '' : ' | uniq'),
\ 'dir': root,
\ 'options': '-m --prompt "GitFiles> "'
\}, a:000)
endif
" Here be dragons!
" We're trying to access the common sink function that fzf#wrap injects to
" the options dictionary.
let wrapped = fzf#wrap({
\ 'source': 'git -c color.status=always status --short --untracked-files=all',
\ 'dir': root,
\ 'options': ['--ansi', '--multi', '--nth', '2..,..', '--tiebreak=index', '--prompt', 'GitFiles?> ', '--preview', 'sh -c "(git diff --color=always -- {-1} | sed 1,4d; cat {-1}) | head -500"']
\})
call s:remove_layout(wrapped)
let wrapped.common_sink = remove(wrapped, 'sink*')
function! wrapped.newsink(lines)
let lines = extend(a:lines[0:0], map(a:lines[1:], 'substitute(v:val[3:], ".* -> ", "", "")'))
return self.common_sink(lines)
endfunction
let wrapped['sink*'] = remove(wrapped, 'newsink')
return s:fzf('gfiles-diff', wrapped, a:000)
endfunction
" ------------------------------------------------------------------
" Buffers
" ------------------------------------------------------------------
1 0.000002 function! s:find_open_window(b)
let [tcur, tcnt] = [tabpagenr() - 1, tabpagenr('$')]
for toff in range(0, tabpagenr('$') - 1)
let t = (tcur + toff) % tcnt + 1
let buffers = tabpagebuflist(t)
for w in range(1, len(buffers))
let b = buffers[w - 1]
if b == a:b
return [t, w]
endif
endfor
endfor
return [0, 0]
endfunction
1 0.000001 function! s:jump(t, w)
execute a:t.'tabnext'
execute a:w.'wincmd w'
endfunction
1 0.000001 function! s:bufopen(lines)
if len(a:lines) < 2
return
endif
let b = matchstr(a:lines[1], '\[\zs[0-9]*\ze\]')
if empty(a:lines[0]) && get(g:, 'fzf_buffers_jump')
let [t, w] = s:find_open_window(b)
if t
call s:jump(t, w)
return
endif
endif
let cmd = s:action_for(a:lines[0])
if !empty(cmd)
execute 'silent' cmd
endif
execute 'buffer' b
endfunction
1 0.000002 function! s:format_buffer(b)
let name = bufname(a:b)
let name = empty(name) ? '[No Name]' : fnamemodify(name, ":p:~:.")
let flag = a:b == bufnr('') ? s:blue('%', 'Conditional') :
\ (a:b == bufnr('#') ? s:magenta('#', 'Special') : ' ')
let modified = getbufvar(a:b, '&modified') ? s:red(' [+]', 'Exception') : ''
let readonly = getbufvar(a:b, '&modifiable') ? '' : s:green(' [RO]', 'Constant')
let extra = join(filter([modified, readonly], '!empty(v:val)'), '')
return s:strip(printf("[%s] %s\t%s\t%s", s:yellow(a:b, 'Number'), flag, name, extra))
endfunction
1 0.000001 function! s:sort_buffers(...)
let [b1, b2] = map(copy(a:000), 'get(g:fzf#vim#buffers, v:val, v:val)')
" Using minus between a float and a number in a sort function causes an error
return b1 < b2 ? 1 : -1
endfunction
1 0.000002 function! s:buflisted_sorted()
return sort(s:buflisted(), 's:sort_buffers')
endfunction
1 0.000001 function! fzf#vim#buffers(...)
let [query, args] = (a:0 && type(a:1) == type('')) ?
\ [a:1, a:000[1:]] : ['', a:000]
return s:fzf('buffers', {
\ 'source': map(s:buflisted_sorted(), 's:format_buffer(v:val)'),
\ 'sink*': s:function('s:bufopen'),
\ 'options': ['+m', '-x', '--tiebreak=index', '--header-lines=1', '--ansi', '-d', '\t', '-n', '2,1..2', '--prompt', 'Buf> ', '--query', query]
\}, args)
endfunction
" ------------------------------------------------------------------
" Ag / Rg
" ------------------------------------------------------------------
1 0.000001 function! s:ag_to_qf(line, with_column)
let parts = split(a:line, ':')
let text = join(parts[(a:with_column ? 3 : 2):], ':')
let dict = {'filename': &acd ? fnamemodify(parts[0], ':p') : parts[0], 'lnum': parts[1], 'text': text}
if a:with_column
let dict.col = parts[2]
endif
return dict
endfunction
1 0.000001 function! s:ag_handler(lines, with_column)
if len(a:lines) < 2
return
endif
let cmd = s:action_for(a:lines[0], 'e')
let list = map(filter(a:lines[1:], 'len(v:val)'), 's:ag_to_qf(v:val, a:with_column)')
if empty(list)
return
endif
let first = list[0]
try
call s:open(cmd, first.filename)
execute first.lnum
if a:with_column
execute 'normal!' first.col.'|'
endif
normal! zz
catch
endtry
call s:fill_quickfix(list)
endfunction
" query, [[ag options], options]
1 0.000001 function! fzf#vim#ag(query, ...)
if type(a:query) != s:TYPE.string
return s:warn('Invalid query argument')
endif
let query = empty(a:query) ? '^(?=.)' : a:query
let args = copy(a:000)
let ag_opts = len(args) > 1 && type(args[0]) == s:TYPE.string ? remove(args, 0) : ''
let command = ag_opts . ' ' . fzf#shellescape(query)
return call('fzf#vim#ag_raw', insert(args, command, 0))
endfunction
" ag command suffix, [options]
1 0.000001 function! fzf#vim#ag_raw(command_suffix, ...)
if !executable('ag')
return s:warn('ag is not found')
endif
return call('fzf#vim#grep', extend(['ag --nogroup --column --color '.a:command_suffix, 1], a:000))
endfunction
" command, with_column, [options]
1 0.000002 function! fzf#vim#grep(grep_command, with_column, ...)
let words = []
for word in split(a:grep_command)
if word !~# '^[a-z]'
break
endif
call add(words, word)
endfor
let words = empty(words) ? ['grep'] : words
let name = join(words, '-')
let capname = join(map(words, 'toupper(v:val[0]).v:val[1:]'), '')
let opts = {
\ 'source': a:grep_command,
\ 'column': a:with_column,
\ 'options': ['--ansi', '--prompt', capname.'> ',
\ '--multi', '--bind', 'alt-a:select-all,alt-d:deselect-all',
\ '--color', 'hl:4,hl+:12']
\}
function! opts.sink(lines)
return s:ag_handler(a:lines, self.column)
endfunction
let opts['sink*'] = remove(opts, 'sink')
return s:fzf(name, opts, a:000)
endfunction
" ------------------------------------------------------------------
" BTags
" ------------------------------------------------------------------
1 0.000002 function! s:btags_source(tag_cmds)
if !filereadable(expand('%'))
throw 'Save the file first'
endif
for cmd in a:tag_cmds
let lines = split(system(cmd), "\n")
if !v:shell_error && len(lines)
break
endif
endfor
if v:shell_error
throw get(lines, 0, 'Failed to extract tags')
elseif empty(lines)
throw 'No tags found'
endif
return map(s:align_lists(map(lines, 'split(v:val, "\t")')), 'join(v:val, "\t")')
endfunction
1 0.000002 function! s:btags_sink(lines)
if len(a:lines) < 2
return
endif
normal! m'
let cmd = s:action_for(a:lines[0])
if !empty(cmd)
execute 'silent' cmd '%'
endif
let qfl = []
for line in a:lines[1:]
execute split(line, "\t")[2]
call add(qfl, {'filename': expand('%'), 'lnum': line('.'), 'text': getline('.')})
endfor
call s:fill_quickfix(qfl, 'cfirst')
normal! zz
endfunction
" query, [[tag commands], options]
1 0.000001 function! fzf#vim#buffer_tags(query, ...)
let args = copy(a:000)
let escaped = fzf#shellescape(expand('%'))
let null = s:is_win ? 'nul' : '/dev/null'
let sort = has('unix') && !has('win32unix') && executable('sort') ? '| sort -s -k 5' : ''
let tag_cmds = (len(args) > 1 && type(args[0]) != type({})) ? remove(args, 0) : [
\ printf('ctags -f - --sort=yes --excmd=number --language-force=%s %s 2> %s %s', &filetype, escaped, null, sort),
\ printf('ctags -f - --sort=yes --excmd=number %s 2> %s %s', escaped, null, sort)]
if type(tag_cmds) != type([])
let tag_cmds = [tag_cmds]
endif
try
return s:fzf('btags', {
\ 'source': s:btags_source(tag_cmds),
\ 'sink*': s:function('s:btags_sink'),
\ 'options': ['--layout=reverse-list', '-m', '-d', '\t', '--with-nth', '1,4..', '-n', '1', '--prompt', 'BTags> ', '--query', a:query]}, args)
catch
return s:warn(v:exception)
endtry
endfunction
" ------------------------------------------------------------------
" Tags
" ------------------------------------------------------------------
1 0.000002 function! s:tags_sink(lines)
if len(a:lines) < 2
return
endif
normal! m'
let qfl = []
let cmd = s:action_for(a:lines[0], 'e')
try
let [magic, &magic, wrapscan, &wrapscan, acd, &acd] = [&magic, 0, &wrapscan, 1, &acd, 0]
for line in a:lines[1:]
try
let parts = split(line, '\t\zs')
let excmd = matchstr(join(parts[2:-2], '')[:-2], '^.\{-}\ze;\?"\t')
let base = fnamemodify(parts[-1], ':h')
let relpath = parts[1][:-2]
let abspath = relpath =~ (s:is_win ? '^[A-Z]:\' : '^/') ? relpath : join([base, relpath], '/')
call s:open(cmd, expand(abspath, 1))
execute excmd
call add(qfl, {'filename': expand('%'), 'lnum': line('.'), 'text': getline('.')})
catch /^Vim:Interrupt$/
break
catch
call s:warn(v:exception)
endtry
endfor
finally
let [&magic, &wrapscan, &acd] = [magic, wrapscan, acd]
endtry
call s:fill_quickfix(qfl, 'clast')
normal! zz
endfunction
1 0.000001 function! fzf#vim#tags(query, ...)
if !executable('perl')
return s:warn('Tags command requires perl')
endif
if empty(tagfiles())
call inputsave()
echohl WarningMsg
let gen = input('tags not found. Generate? (y/N) ')
echohl None
call inputrestore()
redraw
if gen =~? '^y'
call s:warn('Preparing tags')
call system(get(g:, 'fzf_tags_command', 'ctags -R'.(s:is_win ? ' --output-format=e-ctags' : '')))
if empty(tagfiles())
return s:warn('Failed to create tags')
endif
else
return s:warn('No tags found')
endif
endif
let tagfiles = tagfiles()
let v2_limit = 1024 * 1024 * 200
for tagfile in tagfiles
let v2_limit -= getfsize(tagfile)
if v2_limit < 0
break
endif
endfor
let opts = v2_limit < 0 ? ['--algo=v1'] : []
return s:fzf('tags', {
\ 'source': 'perl '.fzf#shellescape(s:bin.tags).' '.join(map(tagfiles, 'fzf#shellescape(fnamemodify(v:val, ":p"))')),
\ 'sink*': s:function('s:tags_sink'),
\ 'options': extend(opts, ['--nth', '1..2', '-m', '--tiebreak=begin', '--prompt', 'Tags> ', '--query', a:query])}, a:000)
endfunction
" ------------------------------------------------------------------
" Snippets (UltiSnips)
" ------------------------------------------------------------------
1 0.000005 function! s:inject_snippet(line)
let snip = split(a:line, "\t")[0]
execute 'normal! a'.s:strip(snip)."\<c-r>=UltiSnips#ExpandSnippet()\<cr>"
endfunction
1 0.000001 function! fzf#vim#snippets(...)
if !exists(':UltiSnipsEdit')
return s:warn('UltiSnips not found')
endif
let list = UltiSnips#SnippetsInCurrentScope()
if empty(list)
return s:warn('No snippets available here')
endif
let aligned = sort(s:align_lists(items(list)))
let colored = map(aligned, 's:yellow(v:val[0])."\t".v:val[1]')
return s:fzf('snippets', {
\ 'source': colored,
\ 'options': '--ansi --tiebreak=index +m -n 1 -d "\t"',
\ 'sink': s:function('s:inject_snippet')}, a:000)
endfunction
" ------------------------------------------------------------------
" Commands
" ------------------------------------------------------------------
1 0.000004 let s:nbs = nr2char(0x2007)
1 0.000001 function! s:format_cmd(line)
return substitute(a:line, '\C \([A-Z]\S*\) ',
\ '\=s:nbs.s:yellow(submatch(1), "Function").s:nbs', '')
endfunction
1 0.000002 function! s:command_sink(lines)
if len(a:lines) < 2
return
endif
let cmd = matchstr(a:lines[1], s:nbs.'\zs\S*\ze'.s:nbs)
if empty(a:lines[0])
call feedkeys(':'.cmd.(a:lines[1][0] == '!' ? '' : ' '), 'n')
else
execute cmd
endif
endfunction
1 0.000154 0.000020 let s:fmt_excmd = ' '.s:blue('%-38s', 'Statement').'%s'
1 0.000002 function! s:format_excmd(ex)
let match = matchlist(a:ex, '^|:\(\S\+\)|\s*\S*\(.*\)')
return printf(s:fmt_excmd, s:nbs.match[1].s:nbs, s:strip(match[2]))
endfunction
1 0.000001 function! s:excmds()
let help = globpath($VIMRUNTIME, 'doc/index.txt')
if empty(help)
return []
endif
let commands = []
let command = ''
for line in readfile(help)
if line =~ '^|:[^|]'
if !empty(command)
call add(commands, s:format_excmd(command))
endif
let command = line
elseif line =~ '^\s\+\S' && !empty(command)
let command .= substitute(line, '^\s*', ' ', '')
elseif !empty(commands) && line =~ '^\s*$'
break
endif
endfor
if !empty(command)
call add(commands, s:format_excmd(command))
endif
return commands
endfunction
1 0.000002 function! fzf#vim#commands(...)
redir => cout
silent command
redir END
let list = split(cout, "\n")
return s:fzf('commands', {
\ 'source': extend(extend(list[0:0], map(list[1:], 's:format_cmd(v:val)')), s:excmds()),
\ 'sink*': s:function('s:command_sink'),
\ 'options': '--ansi --expect '.get(g:, 'fzf_commands_expect', 'ctrl-x').
\ ' --tiebreak=index --header-lines 1 -x --prompt "Commands> " -n2,3,2..3 -d'.s:nbs}, a:000)
endfunction
" ------------------------------------------------------------------
" Marks
" ------------------------------------------------------------------
1 0.000002 function! s:format_mark(line)
return substitute(a:line, '\S', '\=s:yellow(submatch(0), "Number")', '')
endfunction
1 0.000002 function! s:mark_sink(lines)
if len(a:lines) < 2
return
endif
let cmd = s:action_for(a:lines[0])
if !empty(cmd)
execute 'silent' cmd
endif
execute 'normal! `'.matchstr(a:lines[1], '\S').'zz'
endfunction
1 0.000001 function! fzf#vim#marks(...)
redir => cout
silent marks
redir END
let list = split(cout, "\n")
return s:fzf('marks', {
\ 'source': extend(list[0:0], map(list[1:], 's:format_mark(v:val)')),
\ 'sink*': s:function('s:mark_sink'),
\ 'options': '+m -x --ansi --tiebreak=index --header-lines 1 --tiebreak=begin --prompt "Marks> "'}, a:000)
endfunction
" ------------------------------------------------------------------
" Help tags
" ------------------------------------------------------------------
1 0.000001 function! s:helptag_sink(line)
let [tag, file, path] = split(a:line, "\t")[0:2]
let rtp = fnamemodify(path, ':p:h:h')
if stridx(&rtp, rtp) < 0
execute 'set rtp+='.s:escape(rtp)
endif
execute 'help' tag
endfunction
1 0.000001 function! fzf#vim#helptags(...)
if !executable('grep') || !executable('perl')
return s:warn('Helptags command requires grep and perl')
endif
let sorted = sort(split(globpath(&runtimepath, 'doc/tags', 1), '\n'))
let tags = exists('*uniq') ? uniq(sorted) : fzf#vim#_uniq(sorted)
if exists('s:helptags_script')
silent! call delete(s:helptags_script)
endif
let s:helptags_script = tempname()
call writefile(['/('.(s:is_win ? '^[A-Z]:\/.*?[^:]' : '.*?').'):(.*?)\t(.*?)\t/; printf(qq('.s:green('%-40s', 'Label').'\t%s\t%s\n), $2, $3, $1)'], s:helptags_script)
return s:fzf('helptags', {
\ 'source': 'grep -H ".*" '.join(map(tags, 'fzf#shellescape(v:val)')).
\ ' | perl -n '.fzf#shellescape(s:helptags_script).' | sort',
\ 'sink': s:function('s:helptag_sink'),
\ 'options': ['--ansi', '+m', '--tiebreak=begin', '--with-nth', '..-2']}, a:000)
endfunction
" ------------------------------------------------------------------
" File types
" ------------------------------------------------------------------
1 0.000001 function! fzf#vim#filetypes(...)
return s:fzf('filetypes', {
\ 'source': fzf#vim#_uniq(sort(map(split(globpath(&rtp, 'syntax/*.vim'), '\n'),
\ 'fnamemodify(v:val, ":t:r")'))),
\ 'sink': 'setf',
\ 'options': '+m --prompt="File types> "'
\}, a:000)
endfunction
" ------------------------------------------------------------------
" Windows
" ------------------------------------------------------------------
1 0.000001 function! s:format_win(tab, win, buf)
let modified = getbufvar(a:buf, '&modified')
let name = bufname(a:buf)
let name = empty(name) ? '[No Name]' : name
let active = tabpagewinnr(a:tab) == a:win
return (active? s:blue('> ', 'Operator') : ' ') . name . (modified? s:red(' [+]', 'Exception') : '')
endfunction
1 0.000001 function! s:windows_sink(line)
let list = matchlist(a:line, '^ *\([0-9]\+\) *\([0-9]\+\)')
call s:jump(list[1], list[2])
endfunction
1 0.000001 function! fzf#vim#windows(...)
let lines = []
for t in range(1, tabpagenr('$'))
let buffers = tabpagebuflist(t)
for w in range(1, len(buffers))
call add(lines,
\ printf('%s %s %s',
\ s:yellow(printf('%3d', t), 'Number'),
\ s:cyan(printf('%3d', w), 'String'),
\ s:format_win(t, w, buffers[w-1])))
endfor
endfor
return s:fzf('windows', {
\ 'source': extend(['Tab Win Name'], lines),
\ 'sink': s:function('s:windows_sink'),
\ 'options': '+m --ansi --tiebreak=begin --header-lines=1'}, a:000)
endfunction
" ------------------------------------------------------------------
" Commits / BCommits
" ------------------------------------------------------------------
1 0.000002 function! s:yank_to_register(data)
let @" = a:data
silent! let @* = a:data
silent! let @+ = a:data
endfunction
1 0.000001 function! s:commits_sink(lines)
if len(a:lines) < 2
return
endif
let pat = '[0-9a-f]\{7,9}'
if a:lines[0] == 'ctrl-y'
let hashes = join(filter(map(a:lines[1:], 'matchstr(v:val, pat)'), 'len(v:val)'))
return s:yank_to_register(hashes)
end
let diff = a:lines[0] == 'ctrl-d'
let cmd = s:action_for(a:lines[0], 'e')
let buf = bufnr('')
for idx in range(1, len(a:lines) - 1)
let sha = matchstr(a:lines[idx], pat)
if !empty(sha)
if diff
if idx > 1
execute 'tab sb' buf
endif
execute 'Gdiff' sha
else
" Since fugitive buffers are unlisted, we can't keep using 'e'
let c = (cmd == 'e' && idx > 1) ? 'tab split' : cmd
execute c FugitiveFind(sha)
endif
endif
endfor
endfunction
1 0.000001 function! s:commits(buffer_local, args)
let s:git_root = s:get_git_root()
if empty(s:git_root)
return s:warn('Not in git repository')
endif
let source = 'git log '.get(g:, 'fzf_commits_log_options', '--color=always '.fzf#shellescape('--format=%C(auto)%h%d %s %C(green)%cr'))
let current = expand('%')
let managed = 0
if !empty(current)
call system('git show '.fzf#shellescape(current).' 2> '.(s:is_win ? 'nul' : '/dev/null'))
let managed = !v:shell_error
endif
if a:buffer_local
if !managed
return s:warn('The current buffer is not in the working tree')
endif
let source .= ' --follow '.fzf#shellescape(current)
else
let source .= ' --graph'
endif
let command = a:buffer_local ? 'BCommits' : 'Commits'
let expect_keys = join(keys(get(g:, 'fzf_action', s:default_action)), ',')
let options = {
\ 'source': source,
\ 'sink*': s:function('s:commits_sink'),
\ 'options': ['--ansi', '--multi', '--tiebreak=index', '--layout=reverse-list',
\ '--inline-info', '--prompt', command.'> ', '--bind=ctrl-s:toggle-sort',
\ '--header', ':: Press '.s:magenta('CTRL-S', 'Special').' to toggle sort, '.s:magenta('CTRL-Y', 'Special').' to yank commit hashes',
\ '--expect=ctrl-y,'.expect_keys]
\ }
if a:buffer_local
let options.options[-2] .= ', '.s:magenta('CTRL-D', 'Special').' to diff'
let options.options[-1] .= ',ctrl-d'
endif
if !s:is_win && &columns > s:wide
call extend(options.options,
\ ['--preview', 'echo {} | grep -o "[a-f0-9]\{7,\}" | head -1 | xargs git show --format=format: --color=always | head -200'])
endif
return s:fzf(a:buffer_local ? 'bcommits' : 'commits', options, a:args)
endfunction
1 0.000001 function! fzf#vim#commits(...)
return s:commits(0, a:000)
endfunction
1 0.000001 function! fzf#vim#buffer_commits(...)
return s:commits(1, a:000)
endfunction
" ------------------------------------------------------------------
" fzf#vim#maps(mode, opts[with count and op])
" ------------------------------------------------------------------
1 0.000001 function! s:align_pairs(list)
let maxlen = 0
let pairs = []
for elem in a:list
let match = matchlist(elem, '^\(\S*\)\s*\(.*\)$')
let [_, k, v] = match[0:2]
let maxlen = max([maxlen, len(k)])
call add(pairs, [k, substitute(v, '^\*\?[@ ]\?', '', '')])
endfor
let maxlen = min([maxlen, 35])
return map(pairs, "printf('%-'.maxlen.'s', v:val[0]).' '.v:val[1]")
endfunction
1 0.000002 function! s:highlight_keys(str)
return substitute(
\ substitute(a:str, '<[^ >]\+>', s:yellow('\0', 'Special'), 'g'),
\ '<Plug>', s:blue('<Plug>', 'SpecialKey'), 'g')
endfunction
1 0.000002 function! s:key_sink(line)
let key = matchstr(a:line, '^\S*')
redraw
call feedkeys(s:map_gv.s:map_cnt.s:map_reg, 'n')
call feedkeys(s:map_op.
\ substitute(key, '<[^ >]\+>', '\=eval("\"\\".submatch(0)."\"")', 'g'))
endfunction
1 0.000004 function! fzf#vim#maps(mode, ...)
let s:map_gv = a:mode == 'x' ? 'gv' : ''
let s:map_cnt = v:count == 0 ? '' : v:count
let s:map_reg = empty(v:register) ? '' : ('"'.v:register)
let s:map_op = a:mode == 'o' ? v:operator : ''
redir => cout
silent execute 'verbose' a:mode.'map'
redir END
let list = []
let curr = ''
for line in split(cout, "\n")
if line =~ "^\t"
let src = ' '.join(reverse(reverse(split(split(line)[-1], '/'))[0:2]), '/')
call add(list, printf('%s %s', curr, s:green(src, 'Comment')))
let curr = ''
else
let curr = line[3:]
endif
endfor
if !empty(curr)
call add(list, curr)
endif
let aligned = s:align_pairs(list)
let sorted = sort(aligned)
let colored = map(sorted, 's:highlight_keys(v:val)')
let pcolor = a:mode == 'x' ? 9 : a:mode == 'o' ? 10 : 12
return s:fzf('maps', {
\ 'source': colored,
\ 'sink': s:function('s:key_sink'),
\ 'options': '--prompt "Maps ('.a:mode.')> " --ansi --no-hscroll --nth 1,.. --color prompt:'.pcolor}, a:000)
endfunction
" ----------------------------------------------------------------------------
" fzf#vim#complete - completion helper
" ----------------------------------------------------------------------------
1 0.000012 inoremap <silent> <Plug>(-fzf-complete-trigger) <c-o>:call <sid>complete_trigger()<cr>
1 0.000002 function! s:pluck(dict, key, default)
return has_key(a:dict, a:key) ? remove(a:dict, a:key) : a:default
endfunction
1 0.000002 function! s:complete_trigger()
let opts = copy(s:opts)
call s:prepend_opts(opts, ['+m', '-q', s:query])
let opts['sink*'] = s:function('s:complete_insert')
let s:reducer = s:pluck(opts, 'reducer', s:function('s:first_line'))
call fzf#run(opts)
endfunction
" The default reducer
1 0.000001 function! s:first_line(lines)
return a:lines[0]
endfunction
1 0.000002 function! s:complete_insert(lines)
if empty(a:lines)
return
endif
let chars = strchars(s:query)
if chars == 0 | let del = ''
elseif chars == 1 | let del = '"_x'
else | let del = (chars - 1).'"_dvh'
endif
let data = call(s:reducer, [a:lines])
let ve = &ve
set ve=
execute 'normal!' ((s:eol || empty(chars)) ? '' : 'h').del.(s:eol ? 'a': 'i').data
let &ve = ve
if mode() =~ 't'
call feedkeys('a', 'n')
else
execute "normal! \<esc>la"
endif
endfunction
1 0.000001 function! s:eval(dict, key, arg)
if has_key(a:dict, a:key) && type(a:dict[a:key]) == s:TYPE.funcref
let ret = copy(a:dict)
let ret[a:key] = call(a:dict[a:key], [a:arg])
return ret
endif
return a:dict
endfunction
1 0.000002 function! fzf#vim#complete(...)
if a:0 == 0
let s:opts = fzf#wrap()
elseif type(a:1) == s:TYPE.dict
let s:opts = copy(a:1)
elseif type(a:1) == s:TYPE.string
let s:opts = extend({'source': a:1}, get(a:000, 1, fzf#wrap()))
else
echoerr 'Invalid argument: '.string(a:000)
return ''
endif
for s in ['sink', 'sink*']
if has_key(s:opts, s)
call remove(s:opts, s)
endif
endfor
let eol = col('$')
let ve = &ve
set ve=all
let s:eol = col('.') == eol
let &ve = ve
let Prefix = s:pluck(s:opts, 'prefix', '\k*$')
if col('.') == 1
let s:query = ''
else
let full_prefix = getline('.')[0 : col('.')-2]
if type(Prefix) == s:TYPE.funcref
let s:query = call(Prefix, [full_prefix])
else
let s:query = matchstr(full_prefix, Prefix)
endif
endif
let s:opts = s:eval(s:opts, 'source', s:query)
let s:opts = s:eval(s:opts, 'options', s:query)
let s:opts = s:eval(s:opts, 'extra_options', s:query)
if has_key(s:opts, 'extra_options')
call s:merge_opts(s:opts, remove(s:opts, 'extra_options'))
endif
if has_key(s:opts, 'options')
if type(s:opts.options) == s:TYPE.list
call add(s:opts.options, '--no-expect')
else
let s:opts.options .= ' --no-expect'
endif
endif
call feedkeys("\<Plug>(-fzf-complete-trigger)")
return ''
endfunction
" ------------------------------------------------------------------
1 0.000010 let &cpo = s:cpo_save
1 0.000001 unlet s:cpo_save
SCRIPT /usr/local/Cellar/vim/8.1.0850/share/vim/vim81/ftplugin/ruby.vim
Sourced 1 time
Total time: 0.136577
Self time: 0.002519
count total (s) self (s)
" Vim filetype plugin
" Language: Ruby
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
" URL: https://github.com/vim-ruby/vim-ruby
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
" Last Change: 2019 Jan 06
1 0.000017 if (exists("b:did_ftplugin"))
finish
1 0.000001 endif
1 0.000003 let b:did_ftplugin = 1
1 0.000007 let s:cpo_save = &cpo
1 0.000010 set cpo&vim
1 0.000006 if has("gui_running") && !has("gui_win32")
setlocal keywordprg=ri\ -T\ -f\ bs
1 0.000001 else
1 0.000004 setlocal keywordprg=ri
1 0.000001 endif
" Matchit support
1 0.000004 if exists("loaded_matchit") && !exists("b:match_words")
let b:match_ignorecase = 0
let b:match_words =
\ '\<\%(if\|unless\|case\|while\|until\|for\|do\|class\|module\|def\|begin\)\>=\@!' .
\ ':' .
\ '\<\%(else\|elsif\|ensure\|when\|rescue\|break\|redo\|next\|retry\)\>' .
\ ':' .
\ '\%(^\|[^.\:@$]\)\@<=\<end\:\@!\>' .
\ ',{:},\[:\],(:)'
let b:match_skip =
\ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '" .
\ "\\<ruby\\%(String\\|StringDelimiter\\|ASCIICode\\|Escape\\|" .
\ "Regexp\\|RegexpDelimiter\\|" .
\ "Interpolation\\|NoInterpolation\\|Comment\\|Documentation\\|" .
\ "ConditionalModifier\\|RepeatModifier\\|OptionalDo\\|" .
\ "Function\\|BlockArgument\\|KeywordAsMethod\\|ClassVariable\\|" .
\ "InstanceVariable\\|GlobalVariable\\|Symbol\\)\\>'"
1 0.000001 endif
1 0.000008 setlocal formatoptions-=t formatoptions+=croql
1 0.000005 setlocal include=^\\s*\\<\\(load\\>\\\|require\\>\\\|autoload\\s*:\\=[\"']\\=\\h\\w*[\"']\\=,\\)
1 0.000007 setlocal suffixesadd=.rb
1 0.000006 if exists("&ofu") && has("ruby")
1 0.000005 setlocal omnifunc=rubycomplete#Complete
1 0.000001 endif
" TODO:
"setlocal define=^\\s*def
1 0.000004 setlocal comments=:#
1 0.000003 setlocal commentstring=#\ %s
1 0.000003 if !exists('g:ruby_version_paths')
1 0.000003 let g:ruby_version_paths = {}
1 0.000001 endif
1 0.000003 function! s:query_path(root) abort
let code = "print $:.join %q{,}"
if &shell =~# 'sh' && empty(&shellxquote)
let prefix = 'env PATH='.shellescape($PATH).' '
else
let prefix = ''
endif
if &shellxquote == "'"
let path_check = prefix.'ruby --disable-gems -e "' . code . '"'
else
let path_check = prefix."ruby --disable-gems -e '" . code . "'"
endif
let cd = haslocaldir() ? 'lcd' : 'cd'
let cwd = fnameescape(getcwd())
try
exe cd fnameescape(a:root)
let path = split(system(path_check),',')
exe cd cwd
return path
finally
exe cd cwd
endtry
endfunction
1 0.000002 function! s:build_path(path) abort
let path = join(map(copy(a:path), 'v:val ==# "." ? "" : v:val'), ',')
if &g:path !~# '\v^\.%(,/%(usr|emx)/include)=,,$'
let path = substitute(&g:path,',,$',',','') . ',' . path
endif
return path
endfunction
1 0.000077 if !exists('b:ruby_version') && !exists('g:ruby_path') && isdirectory(expand('%:p:h'))
1 0.000180 let s:version_file = findfile('.ruby-version', '.;')
1 0.000026 if !empty(s:version_file) && filereadable(s:version_file)
1 0.000147 let b:ruby_version = get(readfile(s:version_file, '', 1), '')
1 0.000007 if !has_key(g:ruby_version_paths, b:ruby_version)
1 0.133563 0.000082 let g:ruby_version_paths[b:ruby_version] = s:query_path(fnamemodify(s:version_file, ':p:h'))
1 0.000007 endif
1 0.000002 endif
1 0.000001 endif
1 0.000007 if exists("g:ruby_path")
let s:ruby_path = type(g:ruby_path) == type([]) ? join(g:ruby_path, ',') : g:ruby_path
1 0.000012 elseif has_key(g:ruby_version_paths, get(b:, 'ruby_version', ''))
1 0.000008 let s:ruby_paths = g:ruby_version_paths[b:ruby_version]
1 0.000123 0.000047 let s:ruby_path = s:build_path(s:ruby_paths)
else
if !exists('g:ruby_default_path')
if has("ruby") && has("win32")
ruby ::VIM::command( 'let g:ruby_default_path = split("%s",",")' % $:.join(%q{,}) )
elseif executable('ruby')
let g:ruby_default_path = s:query_path($HOME)
else
let g:ruby_default_path = map(split($RUBYLIB,':'), 'v:val ==# "." ? "" : v:val')
endif
endif
let s:ruby_paths = g:ruby_default_path
let s:ruby_path = s:build_path(s:ruby_paths)
1 0.000001 endif
1 0.000005 if stridx(&l:path, s:ruby_path) == -1
1 0.000014 let &l:path = s:ruby_path
1 0.000001 endif
1 0.000033 if exists('s:ruby_paths') && stridx(&l:tags, join(map(copy(s:ruby_paths),'v:val."/tags"'),',')) == -1
1 0.000035 let &l:tags = &tags . ',' . join(map(copy(s:ruby_paths),'v:val."/tags"'),',')
1 0.000002 endif
1 0.000404 if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
let b:browsefilter = "Ruby Source Files (*.rb)\t*.rb\n" .
\ "All Files (*.*)\t*.*\n"
1 0.000002 endif
1 0.000008 let b:undo_ftplugin = "setl inc= sua= path= tags= fo< com< cms< kp="
\."| unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip"
\."| if exists('&ofu') && has('ruby') | setl ofu< | endif"
1 0.000004 if get(g:, 'ruby_recommended_style', 1)
1 0.000017 setlocal shiftwidth=2 softtabstop=2 expandtab
1 0.000004 let b:undo_ftplugin .= ' | setl sw< sts< et<'
1 0.000001 endif
" To activate, :set ballooneval
1 0.000005 if exists('+balloonexpr') && get(g:, 'ruby_balloonexpr')
setlocal balloonexpr=RubyBalloonexpr()
let b:undo_ftplugin .= "| setl bexpr="
1 0.000000 endif
1 0.000003 function! s:map(mode, flags, map) abort
let from = matchstr(a:map, '\S\+')
if empty(mapcheck(from, a:mode))
exe a:mode.'map' '<buffer>' a:map
let b:undo_ftplugin .= '|sil! '.a:mode.'unmap <buffer> '.from
endif
endfunction
1 0.000017 cmap <buffer><script><expr> <Plug><ctag> substitute(RubyCursorTag(),'^$',"\022\027",'')
1 0.000013 cmap <buffer><script><expr> <Plug><cfile> substitute(RubyCursorFile(),'^$',"\022\006",'')
1 0.000004 let b:undo_ftplugin .= "| sil! cunmap <buffer> <Plug><ctag>| sil! cunmap <buffer> <Plug><cfile>"
1 0.000004 if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps")
1 0.000006 nmap <buffer><script> <SID>: :<C-U>
1 0.000008 nmap <buffer><script> <SID>c: :<C-U><C-R>=v:count ? v:count : ''<CR>
1 0.000025 nnoremap <silent> <buffer> [m :<C-U>call <SID>searchsyn('\<def\>',['rubyDefine'],'b','n')<CR>
1 0.000009 nnoremap <silent> <buffer> ]m :<C-U>call <SID>searchsyn('\<def\>',['rubyDefine'],'','n')<CR>
1 0.000009 nnoremap <silent> <buffer> [M :<C-U>call <SID>searchsyn('\<end\>',['rubyDefine'],'b','n')<CR>
1 0.000009 nnoremap <silent> <buffer> ]M :<C-U>call <SID>searchsyn('\<end\>',['rubyDefine'],'','n')<CR>
1 0.000012 xnoremap <silent> <buffer> [m :<C-U>call <SID>searchsyn('\<def\>',['rubyDefine'],'b','v')<CR>
1 0.000010 xnoremap <silent> <buffer> ]m :<C-U>call <SID>searchsyn('\<def\>',['rubyDefine'],'','v')<CR>
1 0.000009 xnoremap <silent> <buffer> [M :<C-U>call <SID>searchsyn('\<end\>',['rubyDefine'],'b','v')<CR>
1 0.000009 xnoremap <silent> <buffer> ]M :<C-U>call <SID>searchsyn('\<end\>',['rubyDefine'],'','v')<CR>
1 0.000015 nnoremap <silent> <buffer> [[ :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>',['rubyModule','rubyClass'],'b','n')<CR>
1 0.000013 nnoremap <silent> <buffer> ]] :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>',['rubyModule','rubyClass'],'','n')<CR>
1 0.000011 nnoremap <silent> <buffer> [] :<C-U>call <SID>searchsyn('\<end\>',['rubyModule','rubyClass'],'b','n')<CR>
1 0.000010 nnoremap <silent> <buffer> ][ :<C-U>call <SID>searchsyn('\<end\>',['rubyModule','rubyClass'],'','n')<CR>
1 0.000013 xnoremap <silent> <buffer> [[ :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>',['rubyModule','rubyClass'],'b','v')<CR>
1 0.000012 xnoremap <silent> <buffer> ]] :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>',['rubyModule','rubyClass'],'','v')<CR>
1 0.000011 xnoremap <silent> <buffer> [] :<C-U>call <SID>searchsyn('\<end\>',['rubyModule','rubyClass'],'b','v')<CR>
1 0.000010 xnoremap <silent> <buffer> ][ :<C-U>call <SID>searchsyn('\<end\>',['rubyModule','rubyClass'],'','v')<CR>
1 0.000013 let b:undo_ftplugin = b:undo_ftplugin
\."| sil! exe 'unmap <buffer> [[' | sil! exe 'unmap <buffer> ]]' | sil! exe 'unmap <buffer> []' | sil! exe 'unmap <buffer> ]['"
\."| sil! exe 'unmap <buffer> [m' | sil! exe 'unmap <buffer> ]m' | sil! exe 'unmap <buffer> [M' | sil! exe 'unmap <buffer> ]M'"
1 0.000017 if maparg('im','x') == '' && maparg('im','o') == '' && maparg('am','x') == '' && maparg('am','o') == ''
1 0.000008 onoremap <silent> <buffer> im :<C-U>call <SID>wrap_i('[m',']M')<CR>
1 0.000006 onoremap <silent> <buffer> am :<C-U>call <SID>wrap_a('[m',']M')<CR>
1 0.000006 xnoremap <silent> <buffer> im :<C-U>call <SID>wrap_i('[m',']M')<CR>
1 0.000007 xnoremap <silent> <buffer> am :<C-U>call <SID>wrap_a('[m',']M')<CR>
1 0.000006 let b:undo_ftplugin = b:undo_ftplugin
\."| sil! exe 'ounmap <buffer> im' | sil! exe 'ounmap <buffer> am'"
\."| sil! exe 'xunmap <buffer> im' | sil! exe 'xunmap <buffer> am'"
1 0.000001 endif
1 0.000014 if maparg('iM','x') == '' && maparg('iM','o') == '' && maparg('aM','x') == '' && maparg('aM','o') == ''
1 0.000044 onoremap <silent> <buffer> iM :<C-U>call <SID>wrap_i('[[','][')<CR>
1 0.000006 onoremap <silent> <buffer> aM :<C-U>call <SID>wrap_a('[[','][')<CR>
1 0.000007 xnoremap <silent> <buffer> iM :<C-U>call <SID>wrap_i('[[','][')<CR>
1 0.000007 xnoremap <silent> <buffer> aM :<C-U>call <SID>wrap_a('[[','][')<CR>
1 0.000007 let b:undo_ftplugin = b:undo_ftplugin
\."| sil! exe 'ounmap <buffer> iM' | sil! exe 'ounmap <buffer> aM'"
\."| sil! exe 'xunmap <buffer> iM' | sil! exe 'xunmap <buffer> aM'"
1 0.000001 endif
1 0.000075 0.000033 call s:map('c', '', '<C-R><C-F> <Plug><cfile>')
1 0.000011 cmap <buffer><script><expr> <SID>tagzv &foldopen =~# 'tag' ? '<Bar>norm! zv' : ''
1 0.000053 0.000014 call s:map('n', '<silent>', '<C-]> <SID>:exe v:count1."tag <Plug><ctag>"<SID>tagzv<CR>')
1 0.000050 0.000013 call s:map('n', '<silent>', 'g<C-]> <SID>:exe "tjump <Plug><ctag>"<SID>tagzv<CR>')
1 0.000043 0.000012 call s:map('n', '<silent>', 'g] <SID>:exe "tselect <Plug><ctag>"<SID>tagzv<CR>')
1 0.000046 0.000011 call s:map('n', '<silent>', '<C-W>] <SID>:exe v:count1."stag <Plug><ctag>"<SID>tagzv<CR>')
1 0.000046 0.000011 call s:map('n', '<silent>', '<C-W><C-]> <SID>:exe v:count1."stag <Plug><ctag>"<SID>tagzv<CR>')
1 0.000047 0.000012 call s:map('n', '<silent>', '<C-W>g<C-]> <SID>:exe "stjump <Plug><ctag>"<SID>tagzv<CR>')
1 0.000046 0.000011 call s:map('n', '<silent>', '<C-W>g] <SID>:exe "stselect <Plug><ctag>"<SID>tagzv<CR>')
1 0.000048 0.000011 call s:map('n', '<silent>', '<C-W>} <SID>:exe v:count1."ptag <Plug><ctag>"<CR>')
1 0.000049 0.000012 call s:map('n', '<silent>', '<C-W>g} <SID>:exe "ptjump <Plug><ctag>"<CR>')
1 0.000050 0.000012 call s:map('n', '<silent>', 'gf <SID>c:find <Plug><cfile><CR>')
1 0.000044 0.000011 call s:map('n', '<silent>', '<C-W>f <SID>c:sfind <Plug><cfile><CR>')
1 0.000045 0.000011 call s:map('n', '<silent>', '<C-W><C-F> <SID>c:sfind <Plug><cfile><CR>')
1 0.000044 0.000011 call s:map('n', '<silent>', '<C-W>gf <SID>c:tabfind <Plug><cfile><CR>')
1 0.000001 endif
1 0.000013 let &cpo = s:cpo_save
1 0.000002 unlet s:cpo_save
1 0.000003 if exists("g:did_ruby_ftplugin_functions")
finish
1 0.000000 endif
1 0.000005 let g:did_ruby_ftplugin_functions = 1
1 0.000002 function! RubyBalloonexpr() abort
if !exists('s:ri_found')
let s:ri_found = executable('ri')
endif
if s:ri_found
let line = getline(v:beval_lnum)
let b = matchstr(strpart(line,0,v:beval_col),'\%(\w\|[:.]\)*$')
let a = substitute(matchstr(strpart(line,v:beval_col),'^\w*\%([?!]\|\s*=\)\?'),'\s\+','','g')
let str = b.a
let before = strpart(line,0,v:beval_col-strlen(b))
let after = strpart(line,v:beval_col+strlen(a))
if str =~ '^\.'
let str = substitute(str,'^\.','#','g')
if before =~ '\]\s*$'
let str = 'Array'.str
elseif before =~ '}\s*$'
" False positives from blocks here
let str = 'Hash'.str
elseif before =~ "[\"'`]\\s*$" || before =~ '\$\d\+\s*$'
let str = 'String'.str
elseif before =~ '\$\d\+\.\d\+\s*$'
let str = 'Float'.str
elseif before =~ '\$\d\+\s*$'
let str = 'Integer'.str
elseif before =~ '/\s*$'
let str = 'Regexp'.str
else
let str = substitute(str,'^#','.','')
endif
endif
let str = substitute(str,'.*\.\s*to_f\s*\.\s*','Float#','')
let str = substitute(str,'.*\.\s*to_i\%(nt\)\=\s*\.\s*','Integer#','')
let str = substitute(str,'.*\.\s*to_s\%(tr\)\=\s*\.\s*','String#','')
let str = substitute(str,'.*\.\s*to_sym\s*\.\s*','Symbol#','')
let str = substitute(str,'.*\.\s*to_a\%(ry\)\=\s*\.\s*','Array#','')
let str = substitute(str,'.*\.\s*to_proc\s*\.\s*','Proc#','')
if str !~ '^\w'
return ''
endif
silent! let res = substitute(system("ri -f rdoc -T \"".str.'"'),'\n$','','')
if res =~ '^Nothing known about' || res =~ '^Bad argument:' || res =~ '^More than one method'
return ''
endif
return res
else
return ""
endif
endfunction
1 0.000004 function! s:searchsyn(pattern, syn, flags, mode) abort
let cnt = v:count1
norm! m'
if a:mode ==# 'v'
norm! gv
endif
let i = 0
call map(a:syn, 'hlID(v:val)')
while i < cnt
let i = i + 1
let line = line('.')
let col = col('.')
let pos = search(a:pattern,'W'.a:flags)
while pos != 0 && index(a:syn, s:synid()) < 0
let pos = search(a:pattern,'W'.a:flags)
endwhile
if pos == 0
call cursor(line,col)
return
endif
endwhile
endfunction
1 0.000002 function! s:synid() abort
return synID(line('.'),col('.'),0)
endfunction
1 0.000001 function! s:wrap_i(back,forward) abort
execute 'norm k'.a:forward
let line = line('.')
execute 'norm '.a:back
if line('.') == line - 1
return s:wrap_a(a:back,a:forward)
endif
execute 'norm jV'.a:forward.'k'
endfunction
1 0.000002 function! s:wrap_a(back,forward) abort
execute 'norm '.a:forward
if line('.') < line('$') && getline(line('.')+1) ==# ''
let after = 1
endif
execute 'norm '.a:back
while getline(line('.')-1) =~# '^\s*#' && line('.')
-
endwhile
if exists('after')
execute 'norm V'.a:forward.'j'
elseif line('.') > 1 && getline(line('.')-1) =~# '^\s*$'
execute 'norm kV'.a:forward
else
execute 'norm V'.a:forward
endif
endfunction
1 0.000002 function! RubyCursorIdentifier() abort
let asciicode = '\%(\w\|[]})\"'."'".']\)\@<!\%(?\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\=\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)\)'
let number = '\%(\%(\w\|[]})\"'."'".']\s*\)\@<!-\)\=\%(\<[[:digit:]_]\+\%(\.[[:digit:]_]\+\)\=\%([Ee][[:digit:]_]\+\)\=\>\|\<0[xXbBoOdD][[:xdigit:]_]\+\>\)\|'.asciicode
let operator = '\%(\[\]\|<<\|<=>\|[!<>]=\=\|===\=\|[!=]\~\|>>\|\*\*\|\.\.\.\=\|=>\|[~^&|*/%+-]\)'
let method = '\%(\.[_a-zA-Z]\w*\s*=>\@!\|\<[_a-zA-Z]\w*\>[?!]\=\)'
let global = '$\%([!$&"'."'".'*+,./:;<=>?@\`~]\|-\=\w\+\>\)'
let symbolizable = '\%(\%(@@\=\)\w\+\>\|'.global.'\|'.method.'\|'.operator.'\)'
let pattern = '\C\s*\%('.number.'\|\%(:\@<!:\)\='.symbolizable.'\)'
let [lnum, col] = searchpos(pattern,'bcn',line('.'))
let raw = matchstr(getline('.')[col-1 : ],pattern)
let stripped = substitute(substitute(raw,'\s\+=$','=',''),'^\s*[:.]\=','','')
return stripped == '' ? expand("<cword>") : stripped
endfunction
1 0.000001 function! RubyCursorTag() abort
return substitute(RubyCursorIdentifier(), '^[$@]*', '', '')
endfunction
1 0.000001 function! RubyCursorFile() abort
let isfname = &isfname
try
set isfname+=:
let cfile = expand('<cfile>')
finally
let isfname = &isfname
endtry
let pre = matchstr(strpart(getline('.'), 0, col('.')-1), '.*\f\@<!')
let post = matchstr(strpart(getline('.'), col('.')), '\f\@!.*')
let ext = getline('.') =~# '^\s*\%(require\%(_relative\)\=\|autoload\)\>' && cfile !~# '\.rb$' ? '.rb' : ''
if s:synid() ==# hlID('rubyConstant')
let cfile = substitute(cfile,'\.\w\+[?!=]\=$','','')
let cfile = substitute(cfile,'^::','','')
let cfile = substitute(cfile,'::','/','g')
let cfile = substitute(cfile,'\(\u\+\)\(\u\l\)','\1_\2', 'g')
let cfile = substitute(cfile,'\(\l\|\d\)\(\u\)','\1_\2', 'g')
return tolower(cfile) . '.rb'
elseif getline('.') =~# '^\s*require_relative\s*\(["'']\).*\1\s*$'
let cfile = expand('%:p:h') . '/' . matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') . ext
elseif getline('.') =~# '^\s*\%(require[( ]\|load[( ]\|autoload[( ]:\w\+,\)\s*\%(::\)\=File\.expand_path(\(["'']\)\.\./.*\1,\s*__FILE__)\s*$'
let target = matchstr(getline('.'),'\(["'']\)\.\.\zs/.\{-\}\ze\1')
let cfile = expand('%:p:h') . target . ext
elseif getline('.') =~# '^\s*\%(require \|load \|autoload :\w\+,\)\s*\(["'']\).*\1\s*$'
let cfile = matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') . ext
elseif pre.post =~# '\<File.expand_path[( ].*[''"]\{2\}, *__FILE__\>' && cfile =~# '^\.\.'
let cfile = expand('%:p:h') . strpart(cfile, 2)
else
return substitute(cfile, '\C\v^(.*):(\d+)%(:in)=$', '+\2 \1', '')
endif
let cwdpat = '^\M' . substitute(getcwd(), '[\/]', '\\[\\/]', 'g').'\ze\[\/]'
let cfile = substitute(cfile, cwdpat, '.', '')
if fnameescape(cfile) !=# cfile
return '+ '.fnameescape(cfile)
else
return cfile
endif
endfunction
"
" Instructions for enabling "matchit" support:
"
" 1. Look for the latest "matchit" plugin at
"
" http://www.vim.org/scripts/script.php?script_id=39
"
" It is also packaged with Vim, in the $VIMRUNTIME/macros directory.
"
" 2. Copy "matchit.txt" into a "doc" directory (e.g. $HOME/.vim/doc).
"
" 3. Copy "matchit.vim" into a "plugin" directory (e.g. $HOME/.vim/plugin).
"
" 4. Ensure this file (ftplugin/ruby.vim) is installed.
"
" 5. Ensure you have this line in your $HOME/.vimrc:
" filetype plugin on
"
" 6. Restart Vim and create the matchit documentation:
"
" :helptags ~/.vim/doc
"
" Now you can do ":help matchit", and you should be able to use "%" on Ruby
" keywords. Try ":echo b:match_words" to be sure.
"
" Thanks to Mark J. Reed for the instructions. See ":help vimrc" for the
" locations of plugin directories, etc., as there are several options, and it
" differs on Windows. Email gsinclair@soyabean.com.au if you need help.
"
" vim: nowrap sw=2 sts=2 ts=8:
SCRIPT /usr/local/Cellar/vim/8.1.0850/share/vim/vim81/indent/ruby.vim
Sourced 1 time
Total time: 0.002029
Self time: 0.002029
count total (s) self (s)
" Vim indent file
" Language: Ruby
" Maintainer: Andrew Radev <andrey.radev@gmail.com>
" Previous Maintainer: Nikolai Weibull <now at bitwi.se>
" URL: https://github.com/vim-ruby/vim-ruby
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
" Last Change: 2019 Jan 06
" 0. Initialization {{{1
" =================
" Only load this indent file when no other was loaded.
1 0.000011 if exists("b:did_indent")
finish
1 0.000001 endif
1 0.000003 let b:did_indent = 1
1 0.000004 if !exists('g:ruby_indent_access_modifier_style')
" Possible values: "normal", "indent", "outdent"
1 0.000002 let g:ruby_indent_access_modifier_style = 'normal'
1 0.000001 endif
1 0.000003 if !exists('g:ruby_indent_assignment_style')
" Possible values: "variable", "hanging"
1 0.000002 let g:ruby_indent_assignment_style = 'hanging'
1 0.000014 endif
1 0.000003 if !exists('g:ruby_indent_block_style')
" Possible values: "expression", "do"
1 0.000002 let g:ruby_indent_block_style = 'expression'
1 0.000001 endif
1 0.000010 setlocal nosmartindent
" Now, set up our indentation expression and keys that trigger it.
1 0.000005 setlocal indentexpr=GetRubyIndent(v:lnum)
1 0.000004 setlocal indentkeys=0{,0},0),0],!^F,o,O,e,:,.
1 0.000004 setlocal indentkeys+==end,=else,=elsif,=when,=ensure,=rescue,==begin,==end
1 0.000004 setlocal indentkeys+==private,=protected,=public
" Only define the function once.
1 0.000003 if exists("*GetRubyIndent")
finish
1 0.000001 endif
1 0.000006 let s:cpo_save = &cpo
1 0.000006 set cpo&vim
" 1. Variables {{{1
" ============
" Syntax group names that are strings.
1 0.000006 let s:syng_string =
\ ['String', 'Interpolation', 'InterpolationDelimiter', 'NoInterpolation', 'StringEscape']
" Syntax group names that are strings or documentation.
1 0.000005 let s:syng_stringdoc = s:syng_string + ['Documentation']
" Syntax group names that are or delimit strings/symbols/regexes or are comments.
1 0.000010 let s:syng_strcom = s:syng_stringdoc +
\ ['Regexp', 'RegexpDelimiter', 'RegexpEscape',
\ 'Symbol', 'StringDelimiter', 'ASCIICode', 'Comment']
" Expression used to check whether we should skip a match with searchpair().
1 0.000019 let s:skip_expr =
\ 'index(map('.string(s:syng_strcom).',"hlID(''ruby''.v:val)"), synID(line("."),col("."),1)) >= 0'
" Regex used for words that, at the start of a line, add a level of indent.
1 0.000010 let s:ruby_indent_keywords =
\ '^\s*\zs\<\%(module\|class\|if\|for' .
\ '\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue' .
\ '\|\%(\K\k*[!?]\?\)\=\s*def\):\@!\>' .
\ '\|\%([=,*/%+-]\|<<\|>>\|:\s\)\s*\zs' .
\ '\<\%(if\|for\|while\|until\|case\|unless\|begin\):\@!\>'
" Regex used for words that, at the start of a line, remove a level of indent.
1 0.000004 let s:ruby_deindent_keywords =
\ '^\s*\zs\<\%(ensure\|else\|rescue\|elsif\|when\|end\):\@!\>'
" Regex that defines the start-match for the 'end' keyword.
"let s:end_start_regex = '\%(^\|[^.]\)\<\%(module\|class\|def\|if\|for\|while\|until\|case\|unless\|begin\|do\)\>'
" TODO: the do here should be restricted somewhat (only at end of line)?
1 0.000007 let s:end_start_regex =
\ '\C\%(^\s*\|[=,*/%+\-|;{]\|<<\|>>\|:\s\)\s*\zs' .
\ '\<\%(module\|class\|if\|for\|while\|until\|case\|unless\|begin' .
\ '\|\%(\K\k*[!?]\?\)\=\s*def\):\@!\>' .
\ '\|\%(^\|[^.:@$]\)\@<=\<do:\@!\>'
" Regex that defines the middle-match for the 'end' keyword.
1 0.000003 let s:end_middle_regex = '\<\%(ensure\|else\|\%(\%(^\|;\)\s*\)\@<=\<rescue:\@!\>\|when\|elsif\):\@!\>'
" Regex that defines the end-match for the 'end' keyword.
1 0.000002 let s:end_end_regex = '\%(^\|[^.:@$]\)\@<=\<end:\@!\>'
" Expression used for searchpair() call for finding match for 'end' keyword.
1 0.000010 let s:end_skip_expr = s:skip_expr .
\ ' || (expand("<cword>") == "do"' .
\ ' && getline(".") =~ "^\\s*\\<\\(while\\|until\\|for\\):\\@!\\>")'
" Regex that defines continuation lines, not including (, {, or [.
1 0.000006 let s:non_bracket_continuation_regex =
\ '\%([\\.,:*/%+]\|\<and\|\<or\|\%(<%\)\@<![=-]\|:\@<![^[:alnum:]:][|&?]\|||\|&&\)\s*\%(#.*\)\=$'
" Regex that defines continuation lines.
1 0.000004 let s:continuation_regex =
\ '\%(%\@<![({[\\.,:*/%+]\|\<and\|\<or\|\%(<%\)\@<![=-]\|:\@<![^[:alnum:]:][|&?]\|||\|&&\)\s*\%(#.*\)\=$'
" Regex that defines continuable keywords
1 0.000352 let s:continuable_regex =
\ '\C\%(^\s*\|[=,*/%+\-|;{]\|<<\|>>\|:\s\)\s*\zs' .
\ '\<\%(if\|for\|while\|until\|unless\):\@!\>'
" Regex that defines bracket continuations
1 0.000004 let s:bracket_continuation_regex = '%\@<!\%([({[]\)\s*\%(#.*\)\=$'
" Regex that defines dot continuations
1 0.000003 let s:dot_continuation_regex = '%\@<!\.\s*\%(#.*\)\=$'
" Regex that defines backslash continuations
1 0.000002 let s:backslash_continuation_regex = '%\@<!\\\s*$'
" Regex that defines end of bracket continuation followed by another continuation
1 0.000005 let s:bracket_switch_continuation_regex = '^\([^(]\+\zs).\+\)\+'.s:continuation_regex
" Regex that defines the first part of a splat pattern
1 0.000002 let s:splat_regex = '[[,(]\s*\*\s*\%(#.*\)\=$'
" Regex that describes all indent access modifiers
1 0.000003 let s:access_modifier_regex = '\C^\s*\%(public\|protected\|private\)\s*\%(#.*\)\=$'
" Regex that describes the indent access modifiers (excludes public)
1 0.000003 let s:indent_access_modifier_regex = '\C^\s*\%(protected\|private\)\s*\%(#.*\)\=$'
" Regex that defines blocks.
"
" Note that there's a slight problem with this regex and s:continuation_regex.
" Code like this will be matched by both:
"
" method_call do |(a, b)|
"
" The reason is that the pipe matches a hanging "|" operator.
"
1 0.000003 let s:block_regex =
\ '\%(\<do:\@!\>\|%\@<!{\)\s*\%(|[^|]*|\)\=\s*\%(#.*\)\=$'
1 0.000004 let s:block_continuation_regex = '^\s*[^])}\t ].*'.s:block_regex
" Regex that describes a leading operator (only a method call's dot for now)
1 0.000002 let s:leading_operator_regex = '^\s*[.]'
" 2. GetRubyIndent Function {{{1
" =========================
1 0.000003 function! GetRubyIndent(...) abort
" 2.1. Setup {{{2
" ----------
let indent_info = {}
" The value of a single shift-width
if exists('*shiftwidth')
let indent_info.sw = shiftwidth()
else
let indent_info.sw = &sw
endif
" For the current line, use the first argument if given, else v:lnum
let indent_info.clnum = a:0 ? a:1 : v:lnum
let indent_info.cline = getline(indent_info.clnum)
" Set up variables for restoring position in file. Could use clnum here.
let indent_info.col = col('.')
" 2.2. Work on the current line {{{2
" -----------------------------
let indent_callback_names = [
\ 's:AccessModifier',
\ 's:ClosingBracketOnEmptyLine',
\ 's:BlockComment',
\ 's:DeindentingKeyword',
\ 's:MultilineStringOrLineComment',
\ 's:ClosingHeredocDelimiter',
\ 's:LeadingOperator',
\ ]
for callback_name in indent_callback_names
" Decho "Running: ".callback_name
let indent = call(function(callback_name), [indent_info])
if indent >= 0
" Decho "Match: ".callback_name." indent=".indent." info=".string(indent_info)
return indent
endif
endfor
" 2.3. Work on the previous line. {{{2
" -------------------------------
" Special case: we don't need the real s:PrevNonBlankNonString for an empty
" line inside a string. And that call can be quite expensive in that
" particular situation.
let indent_callback_names = [
\ 's:EmptyInsideString',
\ ]
for callback_name in indent_callback_names
" Decho "Running: ".callback_name
let indent = call(function(callback_name), [indent_info])
if indent >= 0
" Decho "Match: ".callback_name." indent=".indent." info=".string(indent_info)
return indent
endif
endfor
" Previous line number
let indent_info.plnum = s:PrevNonBlankNonString(indent_info.clnum - 1)
let indent_info.pline = getline(indent_info.plnum)
let indent_callback_names = [
\ 's:StartOfFile',
\ 's:AfterAccessModifier',
\ 's:ContinuedLine',
\ 's:AfterBlockOpening',
\ 's:AfterHangingSplat',
\ 's:AfterUnbalancedBracket',
\ 's:AfterLeadingOperator',
\ 's:AfterEndKeyword',
\ 's:AfterIndentKeyword',
\ ]
for callback_name in indent_callback_names
" Decho "Running: ".callback_name
let indent = call(function(callback_name), [indent_info])
if indent >= 0
" Decho "Match: ".callback_name." indent=".indent." info=".string(indent_info)
return indent
endif
endfor
" 2.4. Work on the MSL line. {{{2
" --------------------------
let indent_callback_names = [
\ 's:PreviousNotMSL',
\ 's:IndentingKeywordInMSL',
\ 's:ContinuedHangingOperator',
\ ]
" Most Significant line based on the previous one -- in case it's a
" contination of something above
let indent_info.plnum_msl = s:GetMSL(indent_info.plnum)
for callback_name in indent_callback_names
" Decho "Running: ".callback_name
let indent = call(function(callback_name), [indent_info])
if indent >= 0
" Decho "Match: ".callback_name." indent=".indent." info=".string(indent_info)
return indent
endif
endfor
" }}}2
" By default, just return the previous line's indent
" Decho "Default case matched"
return indent(indent_info.plnum)
endfunction
" 3. Indenting Logic Callbacks {{{1
" ============================
1 0.000006 function! s:AccessModifier(cline_info) abort
let info = a:cline_info
" If this line is an access modifier keyword, align according to the closest
" class declaration.
if g:ruby_indent_access_modifier_style == 'indent'
if s:Match(info.clnum, s:access_modifier_regex)
let class_lnum = s:FindContainingClass()
if class_lnum > 0
return indent(class_lnum) + info.sw
endif
endif
elseif g:ruby_indent_access_modifier_style == 'outdent'
if s:Match(info.clnum, s:access_modifier_regex)
let class_lnum = s:FindContainingClass()
if class_lnum > 0
return indent(class_lnum)
endif
endif
endif
return -1
endfunction
1 0.000003 function! s:ClosingBracketOnEmptyLine(cline_info) abort
let info = a:cline_info
" If we got a closing bracket on an empty line, find its match and indent
" according to it. For parentheses we indent to its column - 1, for the
" others we indent to the containing line's MSL's level. Return -1 if fail.
let col = matchend(info.cline, '^\s*[]})]')
if col > 0 && !s:IsInStringOrComment(info.clnum, col)
call cursor(info.clnum, col)
let closing_bracket = info.cline[col - 1]
let bracket_pair = strpart('(){}[]', stridx(')}]', closing_bracket) * 2, 2)
if searchpair(escape(bracket_pair[0], '\['), '', bracket_pair[1], 'bW', s:skip_expr) > 0
if closing_bracket == ')' && col('.') != col('$') - 1
let ind = virtcol('.') - 1
elseif g:ruby_indent_block_style == 'do'
let ind = indent(line('.'))
else " g:ruby_indent_block_style == 'expression'
let ind = indent(s:GetMSL(line('.')))
endif
endif
return ind
endif
return -1
endfunction
1 0.000002 function! s:BlockComment(cline_info) abort
" If we have a =begin or =end set indent to first column.
if match(a:cline_info.cline, '^\s*\%(=begin\|=end\)$') != -1
return 0
endif
return -1
endfunction
1 0.000002 function! s:DeindentingKeyword(cline_info) abort
let info = a:cline_info
" If we have a deindenting keyword, find its match and indent to its level.
" TODO: this is messy
if s:Match(info.clnum, s:ruby_deindent_keywords)
call cursor(info.clnum, 1)
if searchpair(s:end_start_regex, s:end_middle_regex, s:end_end_regex, 'bW',
\ s:end_skip_expr) > 0
let msl = s:GetMSL(line('.'))
let line = getline(line('.'))
if s:IsAssignment(line, col('.')) &&
\ strpart(line, col('.') - 1, 2) !~ 'do'
" assignment to case/begin/etc, on the same line
if g:ruby_indent_assignment_style == 'hanging'
" hanging indent
let ind = virtcol('.') - 1
else
" align with variable
let ind = indent(line('.'))
endif
elseif g:ruby_indent_block_style == 'do'
" align to line of the "do", not to the MSL
let ind = indent(line('.'))
elseif getline(msl) =~ '=\s*\(#.*\)\=$'
" in the case of assignment to the MSL, align to the starting line,
" not to the MSL
let ind = indent(line('.'))
else
" align to the MSL
let ind = indent(msl)
endif
endif
return ind
endif
return -1
endfunction
1 0.000007 function! s:MultilineStringOrLineComment(cline_info) abort
let info = a:cline_info
" If we are in a multi-line string or line-comment, don't do anything to it.
if s:IsInStringOrDocumentation(info.clnum, matchend(info.cline, '^\s*') + 1)
return indent(info.clnum)
endif
return -1
endfunction
1 0.000002 function! s:ClosingHeredocDelimiter(cline_info) abort
let info = a:cline_info
" If we are at the closing delimiter of a "<<" heredoc-style string, set the
" indent to 0.
if info.cline =~ '^\k\+\s*$'
\ && s:IsInStringDelimiter(info.clnum, 1)
\ && search('\V<<'.info.cline, 'nbW') > 0
return 0
endif
return -1
endfunction
1 0.000001 function! s:LeadingOperator(cline_info) abort
" If the current line starts with a leading operator, add a level of indent.
if s:Match(a:cline_info.clnum, s:leading_operator_regex)
return indent(s:GetMSL(a:cline_info.clnum)) + a:cline_info.sw
endif
return -1
endfunction
1 0.000002 function! s:EmptyInsideString(pline_info) abort
" If the line is empty and inside a string (the previous line is a string,
" too), use the previous line's indent
let info = a:pline_info
let plnum = prevnonblank(info.clnum - 1)
let pline = getline(plnum)
if info.cline =~ '^\s*$'
\ && s:IsInStringOrComment(plnum, 1)
\ && s:IsInStringOrComment(plnum, strlen(pline))
return indent(plnum)
endif
return -1
endfunction
1 0.000002 function! s:StartOfFile(pline_info) abort
" At the start of the file use zero indent.
if a:pline_info.plnum == 0
return 0
endif
return -1
endfunction
1 0.000002 function! s:AfterAccessModifier(pline_info) abort
let info = a:pline_info
if g:ruby_indent_access_modifier_style == 'indent'
" If the previous line was a private/protected keyword, add a
" level of indent.
if s:Match(info.plnum, s:indent_access_modifier_regex)
return indent(info.plnum) + info.sw
endif
elseif g:ruby_indent_access_modifier_style == 'outdent'
" If the previous line was a private/protected/public keyword, add
" a level of indent, since the keyword has been out-dented.
if s:Match(info.plnum, s:access_modifier_regex)
return indent(info.plnum) + info.sw
endif
endif
return -1
endfunction
" Example:
"
" if foo || bar ||
" baz || bing
" puts "foo"
" end
"
1 0.000002 function! s:ContinuedLine(pline_info) abort
let info = a:pline_info
let col = s:Match(info.plnum, s:ruby_indent_keywords)
if s:Match(info.plnum, s:continuable_regex) &&
\ s:Match(info.plnum, s:continuation_regex)
if col > 0 && s:IsAssignment(info.pline, col)
if g:ruby_indent_assignment_style == 'hanging'
" hanging indent
let ind = col - 1
else
" align with variable
let ind = indent(info.plnum)
endif
else
let ind = indent(s:GetMSL(info.plnum))
endif
return ind + info.sw + info.sw
endif
return -1
endfunction
1 0.000006 function! s:AfterBlockOpening(pline_info) abort
let info = a:pline_info
" If the previous line ended with a block opening, add a level of indent.
if s:Match(info.plnum, s:block_regex)
if g:ruby_indent_block_style == 'do'
" don't align to the msl, align to the "do"
let ind = indent(info.plnum) + info.sw
else
let plnum_msl = s:GetMSL(info.plnum)
if getline(plnum_msl) =~ '=\s*\(#.*\)\=$'
" in the case of assignment to the msl, align to the starting line,
" not to the msl
let ind = indent(info.plnum) + info.sw
else
let ind = indent(plnum_msl) + info.sw
endif
endif
return ind
endif
return -1
endfunction
1 0.000003 function! s:AfterLeadingOperator(pline_info) abort
" If the previous line started with a leading operator, use its MSL's level
" of indent
if s:Match(a:pline_info.plnum, s:leading_operator_regex)
return indent(s:GetMSL(a:pline_info.plnum))
endif
return -1
endfunction
1 0.000002 function! s:AfterHangingSplat(pline_info) abort
let info = a:pline_info
" If the previous line ended with the "*" of a splat, add a level of indent
if info.pline =~ s:splat_regex
return indent(info.plnum) + info.sw
endif
return -1
endfunction
1 0.000002 function! s:AfterUnbalancedBracket(pline_info) abort
let info = a:pline_info
" If the previous line contained unclosed opening brackets and we are still
" in them, find the rightmost one and add indent depending on the bracket
" type.
"
" If it contained hanging closing brackets, find the rightmost one, find its
" match and indent according to that.
if info.pline =~ '[[({]' || info.pline =~ '[])}]\s*\%(#.*\)\=$'
let [opening, closing] = s:ExtraBrackets(info.plnum)
if opening.pos != -1
if opening.type == '(' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0
if col('.') + 1 == col('$')
return indent(info.plnum) + info.sw
else
return virtcol('.')
endif
else
let nonspace = matchend(info.pline, '\S', opening.pos + 1) - 1
return nonspace > 0 ? nonspace : indent(info.plnum) + info.sw
endif
elseif closing.pos != -1
call cursor(info.plnum, closing.pos + 1)
normal! %
if s:Match(line('.'), s:ruby_indent_keywords)
return indent('.') + info.sw
else
return indent(s:GetMSL(line('.')))
endif
else
call cursor(info.clnum, info.col)
end
endif
return -1
endfunction
1 0.000002 function! s:AfterEndKeyword(pline_info) abort
let info = a:pline_info
" If the previous line ended with an "end", match that "end"s beginning's
" indent.
let col = s:Match(info.plnum, '\%(^\|[^.:@$]\)\<end\>\s*\%(#.*\)\=$')
if col > 0
call cursor(info.plnum, col)
if searchpair(s:end_start_regex, '', s:end_end_regex, 'bW',
\ s:end_skip_expr) > 0
let n = line('.')
let ind = indent('.')
let msl = s:GetMSL(n)
if msl != n
let ind = indent(msl)
end
return ind
endif
end
return -1
endfunction
1 0.000002 function! s:AfterIndentKeyword(pline_info) abort
let info = a:pline_info
let col = s:Match(info.plnum, s:ruby_indent_keywords)
if col > 0
call cursor(info.plnum, col)
let ind = virtcol('.') - 1 + info.sw
" TODO: make this better (we need to count them) (or, if a searchpair
" fails, we know that something is lacking an end and thus we indent a
" level
if s:Match(info.plnum, s:end_end_regex)
let ind = indent('.')
elseif s:IsAssignment(info.pline, col)
if g:ruby_indent_assignment_style == 'hanging'
" hanging indent
let ind = col + info.sw - 1
else
" align with variable
let ind = indent(info.plnum) + info.sw
endif
endif
return ind
endif
return -1
endfunction
1 0.000003 function! s:PreviousNotMSL(msl_info) abort
let info = a:msl_info
" If the previous line wasn't a MSL
if info.plnum != info.plnum_msl
" If previous line ends bracket and begins non-bracket continuation decrease indent by 1.
if s:Match(info.plnum, s:bracket_switch_continuation_regex)
" TODO (2016-10-07) Wrong/unused? How could it be "1"?
return indent(info.plnum) - 1
" If previous line is a continuation return its indent.
" TODO: the || s:IsInString() thing worries me a bit.
elseif s:Match(info.plnum, s:non_bracket_continuation_regex) || s:IsInString(info.plnum, strlen(line))
return indent(info.plnum)
endif
endif
return -1
endfunction
1 0.000002 function! s:IndentingKeywordInMSL(msl_info) abort
let info = a:msl_info
" If the MSL line had an indenting keyword in it, add a level of indent.
" TODO: this does not take into account contrived things such as
" module Foo; class Bar; end
let col = s:Match(info.plnum_msl, s:ruby_indent_keywords)
if col > 0
let ind = indent(info.plnum_msl) + info.sw
if s:Match(info.plnum_msl, s:end_end_regex)
let ind = ind - info.sw
elseif s:IsAssignment(getline(info.plnum_msl), col)
if g:ruby_indent_assignment_style == 'hanging'
" hanging indent
let ind = col + info.sw - 1
else
" align with variable
let ind = indent(info.plnum_msl) + info.sw
endif
endif
return ind
endif
return -1
endfunction
1 0.000002 function! s:ContinuedHangingOperator(msl_info) abort
let info = a:msl_info
" If the previous line ended with [*+/.,-=], but wasn't a block ending or a
" closing bracket, indent one extra level.
if s:Match(info.plnum_msl, s:non_bracket_continuation_regex) && !s:Match(info.plnum_msl, '^\s*\([\])}]\|end\)')
if info.plnum_msl == info.plnum
let ind = indent(info.plnum_msl) + info.sw
else
let ind = indent(info.plnum_msl)
endif
return ind
endif
return -1
endfunction
" 4. Auxiliary Functions {{{1
" ======================
1 0.000002 function! s:IsInRubyGroup(groups, lnum, col) abort
let ids = map(copy(a:groups), 'hlID("ruby".v:val)')
return index(ids, synID(a:lnum, a:col, 1)) >= 0
endfunction
" Check if the character at lnum:col is inside a string, comment, or is ascii.
1 0.000002 function! s:IsInStringOrComment(lnum, col) abort
return s:IsInRubyGroup(s:syng_strcom, a:lnum, a:col)
endfunction
" Check if the character at lnum:col is inside a string.
1 0.000001 function! s:IsInString(lnum, col) abort
return s:IsInRubyGroup(s:syng_string, a:lnum, a:col)
endfunction
" Check if the character at lnum:col is inside a string or documentation.
1 0.000002 function! s:IsInStringOrDocumentation(lnum, col) abort
return s:IsInRubyGroup(s:syng_stringdoc, a:lnum, a:col)
endfunction
" Check if the character at lnum:col is inside a string delimiter
1 0.000002 function! s:IsInStringDelimiter(lnum, col) abort
return s:IsInRubyGroup(['StringDelimiter'], a:lnum, a:col)
endfunction
1 0.000002 function! s:IsAssignment(str, pos) abort
return strpart(a:str, 0, a:pos - 1) =~ '=\s*$'
endfunction
" Find line above 'lnum' that isn't empty, in a comment, or in a string.
1 0.000002 function! s:PrevNonBlankNonString(lnum) abort
let in_block = 0
let lnum = prevnonblank(a:lnum)
while lnum > 0
" Go in and out of blocks comments as necessary.
" If the line isn't empty (with opt. comment) or in a string, end search.
let line = getline(lnum)
if line =~ '^=begin'
if in_block
let in_block = 0
else
break
endif
elseif !in_block && line =~ '^=end'
let in_block = 1
elseif !in_block && line !~ '^\s*#.*$' && !(s:IsInStringOrComment(lnum, 1)
\ && s:IsInStringOrComment(lnum, strlen(line)))
break
endif
let lnum = prevnonblank(lnum - 1)
endwhile
return lnum
endfunction
" Find line above 'lnum' that started the continuation 'lnum' may be part of.
1 0.000002 function! s:GetMSL(lnum) abort
" Start on the line we're at and use its indent.
let msl = a:lnum
let lnum = s:PrevNonBlankNonString(a:lnum - 1)
while lnum > 0
" If we have a continuation line, or we're in a string, use line as MSL.
" Otherwise, terminate search as we have found our MSL already.
let line = getline(lnum)
if !s:Match(msl, s:backslash_continuation_regex) &&
\ s:Match(lnum, s:backslash_continuation_regex)
" If the current line doesn't end in a backslash, but the previous one
" does, look for that line's msl
"
" Example:
" foo = "bar" \
" "baz"
"
let msl = lnum
elseif s:Match(msl, s:leading_operator_regex)
" If the current line starts with a leading operator, keep its indent
" and keep looking for an MSL.
let msl = lnum
elseif s:Match(lnum, s:splat_regex)
" If the above line looks like the "*" of a splat, use the current one's
" indentation.
"
" Example:
" Hash[*
" method_call do
" something
"
return msl
elseif s:Match(lnum, s:non_bracket_continuation_regex) &&
\ s:Match(msl, s:non_bracket_continuation_regex)
" If the current line is a non-bracket continuation and so is the
" previous one, keep its indent and continue looking for an MSL.
"
" Example:
" method_call one,
" two,
" three
"
let msl = lnum
elseif s:Match(lnum, s:dot_continuation_regex) &&
\ (s:Match(msl, s:bracket_continuation_regex) || s:Match(msl, s:block_continuation_regex))
" If the current line is a bracket continuation or a block-starter, but
" the previous is a dot, keep going to see if the previous line is the
" start of another continuation.
"
" Example:
" parent.
" method_call {
" three
"
let msl = lnum
elseif s:Match(lnum, s:non_bracket_continuation_regex) &&
\ (s:Match(msl, s:bracket_continuation_regex) || s:Match(msl, s:block_continuation_regex))
" If the current line is a bracket continuation or a block-starter, but
" the previous is a non-bracket one, respect the previous' indentation,
" and stop here.
"
" Example:
" method_call one,
" two {
" three
"
return lnum
elseif s:Match(lnum, s:bracket_continuation_regex) &&
\ (s:Match(msl, s:bracket_continuation_regex) || s:Match(msl, s:block_continuation_regex))
" If both lines are bracket continuations (the current may also be a
" block-starter), use the current one's and stop here
"
" Example:
" method_call(
" other_method_call(
" foo
return msl
elseif s:Match(lnum, s:block_regex) &&
\ !s:Match(msl, s:continuation_regex) &&
\ !s:Match(msl, s:block_continuation_regex)
" If the previous line is a block-starter and the current one is
" mostly ordinary, use the current one as the MSL.
"
" Example:
" method_call do
" something
" something_else
return msl
else
let col = match(line, s:continuation_regex) + 1
if (col > 0 && !s:IsInStringOrComment(lnum, col))
\ || s:IsInString(lnum, strlen(line))
let msl = lnum
else
break
endif
endif
let lnum = s:PrevNonBlankNonString(lnum - 1)
endwhile
return msl
endfunction
" Check if line 'lnum' has more opening brackets than closing ones.
1 0.000003 function! s:ExtraBrackets(lnum) abort
let opening = {'parentheses': [], 'braces': [], 'brackets': []}
let closing = {'parentheses': [], 'braces': [], 'brackets': []}
let line = getline(a:lnum)
let pos = match(line, '[][(){}]', 0)
" Save any encountered opening brackets, and remove them once a matching
" closing one has been found. If a closing bracket shows up that doesn't
" close anything, save it for later.
while pos != -1
if !s:IsInStringOrComment(a:lnum, pos + 1)
if line[pos] == '('
call add(opening.parentheses, {'type': '(', 'pos': pos})
elseif line[pos] == ')'
if empty(opening.parentheses)
call add(closing.parentheses, {'type': ')', 'pos': pos})
else
let opening.parentheses = opening.parentheses[0:-2]
endif
elseif line[pos] == '{'
call add(opening.braces, {'type': '{', 'pos': pos})
elseif line[pos] == '}'
if empty(opening.braces)
call add(closing.braces, {'type': '}', 'pos': pos})
else
let opening.braces = opening.braces[0:-2]
endif
elseif line[pos] == '['
call add(opening.brackets, {'type': '[', 'pos': pos})
elseif line[pos] == ']'
if empty(opening.brackets)
call add(closing.brackets, {'type': ']', 'pos': pos})
else
let opening.brackets = opening.brackets[0:-2]
endif
endif
endif
let pos = match(line, '[][(){}]', pos + 1)
endwhile
" Find the rightmost brackets, since they're the ones that are important in
" both opening and closing cases
let rightmost_opening = {'type': '(', 'pos': -1}
let rightmost_closing = {'type': ')', 'pos': -1}
for opening in opening.parentheses + opening.braces + opening.brackets
if opening.pos > rightmost_opening.pos
let rightmost_opening = opening
endif
endfor
for closing in closing.parentheses + closing.braces + closing.brackets
if closing.pos > rightmost_closing.pos
let rightmost_closing = closing
endif
endfor
return [rightmost_opening, rightmost_closing]
endfunction
1 0.000003 function! s:Match(lnum, regex) abort
let line = getline(a:lnum)
let offset = match(line, '\C'.a:regex)
let col = offset + 1
while offset > -1 && s:IsInStringOrComment(a:lnum, col)
let offset = match(line, '\C'.a:regex, offset + 1)
let col = offset + 1
endwhile
if offset > -1
return col
else
return 0
endif
endfunction
" Locates the containing class/module's definition line, ignoring nested classes
" along the way.
"
1 0.000002 function! s:FindContainingClass() abort
let saved_position = getpos('.')
while searchpair(s:end_start_regex, s:end_middle_regex, s:end_end_regex, 'bW',
\ s:end_skip_expr) > 0
if expand('<cword>') =~# '\<class\|module\>'
let found_lnum = line('.')
call setpos('.', saved_position)
return found_lnum
endif
endwhile
call setpos('.', saved_position)
return 0
endfunction
" }}}1
1 0.000011 let &cpo = s:cpo_save
1 0.000003 unlet s:cpo_save
" vim:set sw=2 sts=2 ts=8 et:
SCRIPT /usr/local/Cellar/vim/8.1.0850/share/vim/vim81/syntax/ruby.vim
Sourced 1 time
Total time: 0.004849
Self time: 0.004715
count total (s) self (s)
" Vim syntax file
" Language: Ruby
" Maintainer: Doug Kearns <dougkearns@gmail.com>
" URL: https://github.com/vim-ruby/vim-ruby
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
" Last Change: 2018 Jul 09
" ----------------------------------------------------------------------------
"
" Previous Maintainer: Mirko Nasato
" Thanks to perl.vim authors, and to Reimer Behrends. :-) (MN)
" ----------------------------------------------------------------------------
" Prelude {{{1
1 0.000025 if exists("b:current_syntax")
finish
1 0.000001 endif
" this file uses line continuations
1 0.000009 let s:cpo_sav = &cpo
1 0.000011 set cpo&vim
" Folding Config {{{1
1 0.000006 if has("folding") && exists("ruby_fold")
setlocal foldmethod=syntax
1 0.000000 endif
1 0.000030 let s:foldable_groups = split(
\ get(
\ b:,
\ 'ruby_foldable_groups',
\ get(g:, 'ruby_foldable_groups', 'ALL')
\ )
\ )
1 0.000004 function! s:foldable(...) abort
if index(s:foldable_groups, 'ALL') > -1
return 1
endif
for l:i in a:000
if index(s:foldable_groups, l:i) > -1
return 1
endif
endfor
return 0
endfunction " }}}
1 0.000027 syn cluster rubyNotTop contains=@rubyExtendedStringSpecial,@rubyRegexpSpecial,@rubyDeclaration,rubyConditional,rubyExceptional,rubyMethodExceptional,rubyTodo,rubyModuleName,rubyClassName,rubySymbolDelimiter
" Whitespace Errors {{{1
1 0.000004 if exists("ruby_space_errors")
if !exists("ruby_no_trail_space_error")
syn match rubySpaceError display excludenl "\s\+$"
endif
if !exists("ruby_no_tab_space_error")
syn match rubySpaceError display " \+\t"me=e-1
endif
1 0.000001 endif
" Operators {{{1
1 0.000003 if exists("ruby_operators")
syn match rubyOperator "[~!^|*/%+-]\|&\.\@!\|\%(class\s*\)\@<!<<\|<=>\|<=\|\%(<\|\<class\s\+\u\w*\s*\)\@<!<[^<]\@=\|===\|==\|=\~\|>>\|>=\|=\@1<!>\|\*\*\|\.\.\.\|\.\.\|::"
syn match rubyOperator "->\|-=\|/=\|\*\*=\|\*=\|&&=\|&=\|&&\|||=\||=\|||\|%=\|+=\|!\~\|!="
syn region rubyBracketOperator matchgroup=rubyOperator start="\%(\w[?!]\=\|[]})]\)\@2<=\[\s*" end="\s*]" contains=ALLBUT,@rubyNotTop
1 0.000001 endif
" Expression Substitution and Backslash Notation {{{1
1 0.000008 syn match rubyStringEscape "\\\\\|\\[abefnrstv]\|\\\o\{1,3}\|\\x\x\{1,2}" contained display
1 0.000017 syn match rubyStringEscape "\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)" contained display
1 0.000004 syn match rubyQuoteEscape "\\[\\']" contained display
1 0.000010 syn region rubyInterpolation matchgroup=rubyInterpolationDelimiter start="#{" end="}" contained contains=ALLBUT,@rubyNotTop
1 0.000016 syn match rubyInterpolation "#\%(\$\|@@\=\)\w\+" display contained contains=rubyInterpolationDelimiter,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable,rubyPredefinedVariable
1 0.000009 syn match rubyInterpolationDelimiter "#\ze\%(\$\|@@\=\)\w\+" display contained
1 0.000009 syn match rubyInterpolation "#\$\%(-\w\|\W\)" display contained contains=rubyInterpolationDelimiter,rubyPredefinedVariable,rubyInvalidVariable
1 0.000004 syn match rubyInterpolationDelimiter "#\ze\$\%(-\w\|\W\)" display contained
1 0.000007 syn region rubyNoInterpolation start="\\#{" end="}" contained
1 0.000003 syn match rubyNoInterpolation "\\#{" display contained
1 0.000004 syn match rubyNoInterpolation "\\#\%(\$\|@@\=\)\w\+" display contained
1 0.000004 syn match rubyNoInterpolation "\\#\$\W" display contained
1 0.000011 syn match rubyDelimiterEscape "\\[(<{\[)>}\]]" transparent display contained contains=NONE
1 0.000016 syn region rubyNestedParentheses start="(" skip="\\\\\|\\)" matchgroup=rubyString end=")" transparent contained
1 0.000009 syn region rubyNestedCurlyBraces start="{" skip="\\\\\|\\}" matchgroup=rubyString end="}" transparent contained
1 0.000008 syn region rubyNestedAngleBrackets start="<" skip="\\\\\|\\>" matchgroup=rubyString end=">" transparent contained
1 0.000017 syn region rubyNestedSquareBrackets start="\[" skip="\\\\\|\\\]" matchgroup=rubyString end="\]" transparent contained
" Regular Expression Metacharacters {{{1
" These are mostly Oniguruma ready
1 0.000393 syn region rubyRegexpComment matchgroup=rubyRegexpSpecial start="(?#" skip="\\)" end=")" contained
1 0.000020 syn region rubyRegexpParens matchgroup=rubyRegexpSpecial start="(\(?:\|?<\=[=!]\|?>\|?<[a-z_]\w*>\|?[imx]*-[imx]*:\=\|\%(?#\)\@!\)" skip="\\)" end=")" contained transparent contains=@rubyRegexpSpecial
1 0.000028 syn region rubyRegexpBrackets matchgroup=rubyRegexpCharClass start="\[\^\=" skip="\\\]" end="\]" contained transparent contains=rubyStringEscape,rubyRegexpEscape,rubyRegexpCharClass oneline
1 0.000012 syn match rubyRegexpCharClass "\\[DdHhSsWw]" contained display
1 0.000015 syn match rubyRegexpCharClass "\[:\^\=\%(alnum\|alpha\|ascii\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|xdigit\):\]" contained
1 0.000004 syn match rubyRegexpEscape "\\[].*?+^$|\\/(){}[]" contained
1 0.000005 syn match rubyRegexpQuantifier "[*?+][?+]\=" contained display
1 0.000004 syn match rubyRegexpQuantifier "{\d\+\%(,\d*\)\=}?\=" contained display
1 0.000004 syn match rubyRegexpAnchor "[$^]\|\\[ABbGZz]" contained display
1 0.000004 syn match rubyRegexpDot "\." contained display
1 0.000015 syn match rubyRegexpSpecial "|" contained display
1 0.000005 syn match rubyRegexpSpecial "\\[1-9]\d\=\d\@!" contained display
1 0.000009 syn match rubyRegexpSpecial "\\k<\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\=>" contained display
1 0.000005 syn match rubyRegexpSpecial "\\k'\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\='" contained display
1 0.000010 syn match rubyRegexpSpecial "\\g<\%([a-z_]\w*\|-\=\d\+\)>" contained display
1 0.000004 syn match rubyRegexpSpecial "\\g'\%([a-z_]\w*\|-\=\d\+\)'" contained display
1 0.000007 syn cluster rubyStringSpecial contains=rubyInterpolation,rubyNoInterpolation,rubyStringEscape
1 0.000009 syn cluster rubyExtendedStringSpecial contains=@rubyStringSpecial,rubyNestedParentheses,rubyNestedCurlyBraces,rubyNestedAngleBrackets,rubyNestedSquareBrackets
1 0.000014 syn cluster rubyRegexpSpecial contains=rubyInterpolation,rubyNoInterpolation,rubyStringEscape,rubyRegexpSpecial,rubyRegexpEscape,rubyRegexpBrackets,rubyRegexpCharClass,rubyRegexpDot,rubyRegexpQuantifier,rubyRegexpAnchor,rubyRegexpParens,rubyRegexpComment
" Numbers and ASCII Codes {{{1
1 0.000017 syn match rubyASCIICode "\%(\w\|[]})\"'/]\)\@1<!\%(?\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\=\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)\)"
1 0.000013 syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<0[xX]\x\+\%(_\x\+\)*r\=i\=\>" display
1 0.000011 syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<\%(0[dD]\)\=\%(0\|[1-9]\d*\%(_\d\+\)*\)r\=i\=\>" display
1 0.000006 syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<0[oO]\=\o\+\%(_\o\+\)*r\=i\=\>" display
1 0.000006 syn match rubyInteger "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<0[bB][01]\+\%(_[01]\+\)*r\=i\=\>" display
1 0.000008 syn match rubyFloat "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\.\d\+\%(_\d\+\)*r\=i\=\>" display
1 0.000011 syn match rubyFloat "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\%(\.\d\+\%(_\d\+\)*\)\=\%([eE][-+]\=\d\+\%(_\d\+\)*\)r\=i\=\>" display
" Identifiers {{{1
1 0.000008 syn match rubyLocalVariableOrMethod "\<[_[:lower:]][_[:alnum:]]*[?!=]\=" contains=NONE display transparent
1 0.000011 syn match rubyBlockArgument "&[_[:lower:]][_[:alnum:]]" contains=NONE display transparent
1 0.000009 syn match rubyClassName "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\u\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)\@!" contained
1 0.000015 syn match rubyModuleName "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\u\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)\@!" contained
1 0.000021 syn match rubyConstant "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\u\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)\@!"
1 0.000005 syn match rubyClassVariable "@@\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" display
1 0.000009 syn match rubyInstanceVariable "@\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" display
1 0.000006 syn match rubyGlobalVariable "$\%(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\|-.\)"
1 0.000003 syn match rubySymbolDelimiter ":" contained
1 0.000014 syn match rubySymbol "[]})\"':]\@1<!:\%(\^\|\~@\|\~\|<<\|<=>\|<=\|<\|===\|[=!]=\|[=!]\~\|!@\|!\|>>\|>=\|>\||\|-@\|-\|/\|\[]=\|\[]\|\*\*\|\*\|&\|%\|+@\|+\|`\)" contains=rubySymbolDelimiter
1 0.000015 syn match rubySymbol "[]})\"':]\@1<!:\$\%(-.\|[`~<=>_,;:!?/.'"@$*\&+0]\)" contains=rubySymbolDelimiter
1 0.000055 syn match rubySymbol "[]})\"':]\@1<!:\%(\$\|@@\=\)\=\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" contains=rubySymbolDelimiter
1 0.000013 syn match rubySymbol "[]})\"':]\@1<!:\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\%([?!=]>\@!\)\=" contains=rubySymbolDelimiter
1 0.000037 0.000023 if s:foldable(':')
1 0.000014 syn region rubySymbol matchgroup=rubySymbolDelimiter start="[]})\"':]\@1<!:'" end="'" skip="\\\\\|\\'" contains=rubyQuoteEscape fold
1 0.000016 syn region rubySymbol matchgroup=rubySymbolDelimiter start="[]})\"':]\@1<!:\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial fold
else
syn region rubySymbol matchgroup=rubySymbolDelimiter start="[]})\"':]\@1<!:'" end="'" skip="\\\\\|\\'" contains=rubyQuoteEscape
syn region rubySymbol matchgroup=rubySymbolDelimiter start="[]})\"':]\@1<!:\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial
1 0.000001 endif
1 0.000012 syn match rubyCapitalizedMethod "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\u\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)*\s*(\@="
1 0.000007 syn match rubyBlockParameter "\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" contained
1 0.000010 syn region rubyBlockParameterList start="\%(\%(\<do\>\|{\)\_s*\)\@32<=|" end="|" oneline display contains=rubyBlockParameter
1 0.000007 syn match rubyInvalidVariable "$[^ A-Za-z_-]"
1 0.000007 syn match rubyPredefinedVariable #$[!$&"'*+,./0:;<=>?@\`~]#
1 0.000004 syn match rubyPredefinedVariable "$\d\+" display
1 0.000003 syn match rubyPredefinedVariable "$_\>" display
1 0.000004 syn match rubyPredefinedVariable "$-[0FIKadilpvw]\>" display
1 0.000006 syn match rubyPredefinedVariable "$\%(deferr\|defout\|stderr\|stdin\|stdout\)\>" display
1 0.000008 syn match rubyPredefinedVariable "$\%(DEBUG\|FILENAME\|KCODE\|LOADED_FEATURES\|LOAD_PATH\|PROGRAM_NAME\|SAFE\|VERBOSE\)\>" display
1 0.000017 syn match rubyPredefinedConstant "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\%(ARGF\|ARGV\|ENV\|DATA\|FALSE\|NIL\|STDERR\|STDIN\|STDOUT\|TOPLEVEL_BINDING\|TRUE\)\>\%(\s*(\)\@!"
1 0.000018 syn match rubyPredefinedConstant "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\%(RUBY_\%(VERSION\|RELEASE_DATE\|PLATFORM\|PATCHLEVEL\|REVISION\|DESCRIPTION\|COPYRIGHT\|ENGINE\)\)\>\%(\s*(\)\@!"
" Normal Regular Expression {{{1
1 0.000028 0.000020 if s:foldable('/')
1 0.000025 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\|else\)\|[;\~=!|&(,{[<>?:*+-]\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial fold
1 0.000014 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/\%([ \t=]\|$\)\@!" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial fold
else
syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\|else\)\|[;\~=!|&(,{[<>?:*+-]\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial
syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/\%([ \t=]\|$\)\@!" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial
1 0.000001 endif
" Generalized Regular Expression {{{1
1 0.000019 0.000013 if s:foldable('%')
1 0.000013 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial fold
1 0.000014 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r{" end="}[iomxneus]*" skip="\\\\\|\\}" contains=@rubyRegexpSpecial fold
1 0.000017 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r<" end=">[iomxneus]*" skip="\\\\\|\\>" contains=@rubyRegexpSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape fold
1 0.000009 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\[" end="\][iomxneus]*" skip="\\\\\|\\\]" contains=@rubyRegexpSpecial fold
1 0.000015 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r(" end=")[iomxneus]*" skip="\\\\\|\\)" contains=@rubyRegexpSpecial fold
1 0.000010 syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z(\s\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial fold
else
syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial
syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r{" end="}[iomxneus]*" skip="\\\\\|\\}" contains=@rubyRegexpSpecial
syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r<" end=">[iomxneus]*" skip="\\\\\|\\>" contains=@rubyRegexpSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape
syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\[" end="\][iomxneus]*" skip="\\\\\|\\\]" contains=@rubyRegexpSpecial
syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r(" end=")[iomxneus]*" skip="\\\\\|\\)" contains=@rubyRegexpSpecial
syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z(\s\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial
1 0.000001 endif
" Normal String {{{1
1 0.000008 let s:spell_cluster = exists('ruby_spellcheck_strings') ? ',@Spell' : ''
1 0.000049 0.000038 exe 'syn region rubyString matchgroup=rubyStringDelimiter start="\"" end="\"" skip="\\\\\|\\\"" ' .
\ (s:foldable('%') ? 'fold' : '') . ' contains=@rubyStringSpecial' . s:spell_cluster
1 0.000034 0.000029 exe 'syn region rubyString matchgroup=rubyStringDelimiter start="''" end="''" skip="\\\\\|\\''" ' .
\ (s:foldable('%') ? 'fold' : '') . ' contains=rubyQuoteEscape' . s:spell_cluster
" Shell Command Output {{{1
1 0.000020 0.000015 if s:foldable('%')
1 0.000009 syn region rubyString matchgroup=rubyStringDelimiter start="`" end="`" skip="\\\\\|\\`" contains=@rubyStringSpecial fold
else
syn region rubyString matchgroup=rubyStringDelimiter start="`" end="`" skip="\\\\\|\\`" contains=@rubyStringSpecial
1 0.000001 endif
" Generalized Single Quoted String, Symbol and Array of Strings {{{1
1 0.000025 0.000020 if s:foldable('%')
1 0.000012 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold
1 0.000011 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]{" end="}" skip="\\\\\|\\}" fold contains=rubyNestedCurlyBraces,rubyDelimiterEscape
1 0.000015 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimiterEscape
1 0.000010 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimiterEscape
1 0.000009 syn region rubyString matchgroup=rubyStringDelimiter start="%[qw](" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimiterEscape
1 0.000011 syn region rubyString matchgroup=rubyStringDelimiter start="%q\z(\s\)" end="\z1" skip="\\\\\|\\\z1" fold
1 0.000009 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold
1 0.000011 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s{" end="}" skip="\\\\\|\\}" fold contains=rubyNestedCurlyBraces,rubyDelimiterEscape
1 0.000009 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimiterEscape
1 0.000014 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimiterEscape
1 0.000009 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s(" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimiterEscape
1 0.000008 syn region rubyString matchgroup=rubyStringDelimiter start="%s\z(\s\)" end="\z1" skip="\\\\\|\\\z1" fold
else
syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1"
syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]{" end="}" skip="\\\\\|\\}" contains=rubyNestedCurlyBraces,rubyDelimiterEscape
syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]<" end=">" skip="\\\\\|\\>" contains=rubyNestedAngleBrackets,rubyDelimiterEscape
syn region rubyString matchgroup=rubyStringDelimiter start="%[qw]\[" end="\]" skip="\\\\\|\\\]" contains=rubyNestedSquareBrackets,rubyDelimiterEscape
syn region rubyString matchgroup=rubyStringDelimiter start="%[qw](" end=")" skip="\\\\\|\\)" contains=rubyNestedParentheses,rubyDelimiterEscape
syn region rubyString matchgroup=rubyStringDelimiter start="%q\z(\s\)" end="\z1" skip="\\\\\|\\\z1"
syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1"
syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s{" end="}" skip="\\\\\|\\}" contains=rubyNestedCurlyBraces,rubyDelimiterEscape
syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s<" end=">" skip="\\\\\|\\>" contains=rubyNestedAngleBrackets,rubyDelimiterEscape
syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s\[" end="\]" skip="\\\\\|\\\]" contains=rubyNestedSquareBrackets,rubyDelimiterEscape
syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s(" end=")" skip="\\\\\|\\)" contains=rubyNestedParentheses,rubyDelimiterEscape
syn region rubyString matchgroup=rubyStringDelimiter start="%s\z(\s\)" end="\z1" skip="\\\\\|\\\z1"
1 0.000001 endif
" Generalized Double Quoted String and Array of Strings and Shell Command Output {{{1
" Note: %= is not matched here as the beginning of a double quoted string
1 0.000018 0.000012 if s:foldable('%')
1 0.000036 syn region rubyString matchgroup=rubyStringDelimiter start="%\z([~`!@#$%^&*_\-+|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold
1 0.000056 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold
1 0.000018 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\={" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimiterEscape fold
1 0.000013 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape fold
1 0.000013 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimiterEscape fold
1 0.000011 syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimiterEscape fold
1 0.000016 syn region rubyString matchgroup=rubyStringDelimiter start="%[Qx]\z(\s\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold
else
syn region rubyString matchgroup=rubyStringDelimiter start="%\z([~`!@#$%^&*_\-+|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial
syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial
syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\={" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimiterEscape
syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape
syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimiterEscape
syn region rubyString matchgroup=rubyStringDelimiter start="%[QWx]\=(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimiterEscape
syn region rubyString matchgroup=rubyStringDelimiter start="%[Qx]\z(\s\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial
1 0.000001 endif
" Array of Symbols {{{1
1 0.000030 0.000021 if s:foldable('%')
" Array of Symbols
1 0.000015 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold
1 0.000017 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i{" end="}" skip="\\\\\|\\}" fold contains=rubyNestedCurlyBraces,rubyDelimiterEscape
1 0.000019 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i<" end=">" skip="\\\\\|\\>" fold contains=rubyNestedAngleBrackets,rubyDelimiterEscape
1 0.000010 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i\[" end="\]" skip="\\\\\|\\\]" fold contains=rubyNestedSquareBrackets,rubyDelimiterEscape
1 0.000014 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i(" end=")" skip="\\\\\|\\)" fold contains=rubyNestedParentheses,rubyDelimiterEscape
" Array of interpolated Symbols
1 0.000011 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold
1 0.000015 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I{" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimiterEscape fold
1 0.000019 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape fold
1 0.000032 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimiterEscape fold
1 0.000011 syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimiterEscape fold
else
" Array of Symbols
syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1"
syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i{" end="}" skip="\\\\\|\\}" contains=rubyNestedCurlyBraces,rubyDelimiterEscape
syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i<" end=">" skip="\\\\\|\\>" contains=rubyNestedAngleBrackets,rubyDelimiterEscape
syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i\[" end="\]" skip="\\\\\|\\\]" contains=rubyNestedSquareBrackets,rubyDelimiterEscape
syn region rubySymbol matchgroup=rubySymbolDelimiter start="%i(" end=")" skip="\\\\\|\\)" contains=rubyNestedParentheses,rubyDelimiterEscape
" Array of interpolated Symbols
syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial
syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I{" end="}" skip="\\\\\|\\}" contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimiterEscape
syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I<" end=">" skip="\\\\\|\\>" contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimiterEscape
syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I\[" end="\]" skip="\\\\\|\\\]" contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimiterEscape
syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimiterEscape
1 0.000001 endif
" Here Document {{{1
1 0.000020 syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<[-~]\=\zs\%(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)+ end=+$+ oneline contains=ALLBUT,@rubyNotTop
1 0.000012 syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<[-~]\=\zs"\%([^"]*\)"+ end=+$+ oneline contains=ALLBUT,@rubyNotTop
1 0.000013 syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<[-~]\=\zs'\%([^']*\)'+ end=+$+ oneline contains=ALLBUT,@rubyNotTop
1 0.000009 syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<[-~]\=\zs`\%([^`]*\)`+ end=+$+ oneline contains=ALLBUT,@rubyNotTop
1 0.000022 0.000016 if s:foldable('<<')
1 0.000028 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial fold keepend
1 0.000014 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<"\z([^"]*\)"\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial fold keepend
1 0.000015 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<'\z([^']*\)'\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc fold keepend
1 0.000015 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<`\z([^`]*\)`\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial fold keepend
1 0.000045 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend
1 0.000016 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]"\z([^"]*\)"\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend
1 0.000011 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]'\z([^']*\)'\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart fold keepend
1 0.000010 syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]`\z([^`]*\)`\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend
else
syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial keepend
syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<"\z([^"]*\)"\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial keepend
syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<'\z([^']*\)'\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc keepend
syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<`\z([^`]*\)`\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial keepend
syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial keepend
syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]"\z([^"]*\)"\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial keepend
syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]'\z([^']*\)'\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart keepend
syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]`\z([^`]*\)`\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial keepend
1 0.000001 endif
" eRuby Config {{{1
1 0.000005 if exists('main_syntax') && main_syntax == 'eruby'
let b:ruby_no_expensive = 1
1 0.000001 endif
" Module, Class, Method and Alias Declarations {{{1
1 0.000016 syn match rubyAliasDeclaration "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable nextgroup=rubyAliasDeclaration2 skipwhite
1 0.000008 syn match rubyAliasDeclaration2 "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable
1 0.000049 syn match rubyMethodDeclaration "[^[:space:];#(]\+" contained contains=rubyConstant,rubyBoolean,rubyPseudoVariable,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable
1 0.000008 syn match rubyClassDeclaration "[^[:space:];#<]\+" contained contains=rubyClassName,rubyOperator
1 0.000006 syn match rubyModuleDeclaration "[^[:space:];#<]\+" contained contains=rubyModuleName,rubyOperator
1 0.000011 syn match rubyMethodName "\<[_[:alpha:]][_[:alnum:]]*[?!=]\=[[:alnum:]_.:?!=]\@!" contained containedin=rubyMethodDeclaration
1 0.000009 syn match rubyMethodName "\%(\s\|^\)\@1<=[_[:alpha:]][_[:alnum:]]*[?!=]\=\%(\s\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2
1 0.000016 syn match rubyMethodName "\%([[:space:].]\|^\)\@2<=\%(\[\]=\=\|\*\*\|[-+!~]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|[=!]=\|[=!]\~\|!\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration
1 0.000009 syn cluster rubyDeclaration contains=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration,rubyModuleDeclaration,rubyClassDeclaration,rubyMethodName,rubyBlockParameter
" Keywords {{{1
" Note: the following keywords have already been defined:
" begin case class def do end for if module unless until while
1 0.000011 syn match rubyControl "\<\%(and\|break\|in\|next\|not\|or\|redo\|rescue\|retry\|return\)\>[?!]\@!"
1 0.000003 syn match rubyOperator "\<defined?" display
1 0.000011 syn match rubyKeyword "\<\%(super\|yield\)\>[?!]\@!"
1 0.000007 syn match rubyBoolean "\<\%(true\|false\)\>[?!]\@!"
1 0.000010 syn match rubyPseudoVariable "\<\%(nil\|self\|__ENCODING__\|__dir__\|__FILE__\|__LINE__\|__callee__\|__method__\)\>[?!]\@!" " TODO: reorganise
1 0.000005 syn match rubyBeginEnd "\<\%(BEGIN\|END\)\>[?!]\@!"
" Expensive Mode {{{1
" Match 'end' with the appropriate opening keyword for syntax based folding
" and special highlighting of module/class/method definitions
1 0.000006 if !exists("b:ruby_no_expensive") && !exists("ruby_no_expensive")
1 0.000008 syn match rubyDefine "\<alias\>" nextgroup=rubyAliasDeclaration skipwhite skipnl
1 0.000005 syn match rubyDefine "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl
1 0.000003 syn match rubyDefine "\<undef\>" nextgroup=rubyMethodName skipwhite skipnl
1 0.000004 syn match rubyClass "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl
1 0.000008 syn match rubyModule "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl
1 0.000023 0.000016 if s:foldable('def')
1 0.000011 syn region rubyMethodBlock start="\<def\>" matchgroup=rubyDefine end="\%(\<def\_s\+\)\@<!\<end\>" contains=ALLBUT,@rubyNotTop fold
else
syn region rubyMethodBlock start="\<def\>" matchgroup=rubyDefine end="\%(\<def\_s\+\)\@<!\<end\>" contains=ALLBUT,@rubyNotTop
1 0.000001 endif
1 0.000016 0.000011 if s:foldable('class')
1 0.000012 syn region rubyBlock start="\<class\>" matchgroup=rubyClass end="\<end\>" contains=ALLBUT,@rubyNotTop fold
else
syn region rubyBlock start="\<class\>" matchgroup=rubyClass end="\<end\>" contains=ALLBUT,@rubyNotTop
1 0.000001 endif
1 0.000019 0.000014 if s:foldable('module')
1 0.000007 syn region rubyBlock start="\<module\>" matchgroup=rubyModule end="\<end\>" contains=ALLBUT,@rubyNotTop fold
else
syn region rubyBlock start="\<module\>" matchgroup=rubyModule end="\<end\>" contains=ALLBUT,@rubyNotTop
1 0.000001 endif
" modifiers
1 0.000008 syn match rubyLineContinuation "\\$" nextgroup=rubyConditionalModifier,rubyRepeatModifier skipwhite skipnl
1 0.000004 syn match rubyConditionalModifier "\<\%(if\|unless\)\>"
1 0.000003 syn match rubyRepeatModifier "\<\%(while\|until\)\>"
1 0.000018 0.000014 if s:foldable('do')
1 0.000009 syn region rubyDoBlock matchgroup=rubyControl start="\<do\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold
else
syn region rubyDoBlock matchgroup=rubyControl start="\<do\>" end="\<end\>" contains=ALLBUT,@rubyNotTop
1 0.000001 endif
" curly bracket block or hash literal
1 0.000017 0.000013 if s:foldable('{')
1 0.000009 syn region rubyCurlyBlock matchgroup=rubyCurlyBlockDelimiter start="{" end="}" contains=ALLBUT,@rubyNotTop fold
else
syn region rubyCurlyBlock matchgroup=rubyCurlyBlockDelimiter start="{" end="}" contains=ALLBUT,@rubyNotTop
1 0.000001 endif
1 0.000017 0.000013 if s:foldable('[')
1 0.000015 syn region rubyArrayLiteral matchgroup=rubyArrayDelimiter start="\%(\w\|[\]})]\)\@<!\[" end="]" contains=ALLBUT,@rubyNotTop fold
1 0.000001 endif
" statements without 'do'
1 0.000020 0.000016 if s:foldable('begin')
1 0.000009 syn region rubyBlockExpression matchgroup=rubyControl start="\<begin\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold
else
syn region rubyBlockExpression matchgroup=rubyControl start="\<begin\>" end="\<end\>" contains=ALLBUT,@rubyNotTop
1 0.000001 endif
1 0.000018 0.000013 if s:foldable('case')
1 0.000008 syn region rubyCaseExpression matchgroup=rubyConditional start="\<case\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold
else
syn region rubyCaseExpression matchgroup=rubyConditional start="\<case\>" end="\<end\>" contains=ALLBUT,@rubyNotTop
1 0.000001 endif
1 0.000018 0.000014 if s:foldable('if')
1 0.000019 syn region rubyConditionalExpression matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![?!]\)\s*\)\@<=\%(if\|unless\)\>" end="\%(\%(\%(\.\@1<!\.\)\|::\)\s*\)\@<!\<end\>" contains=ALLBUT,@rubyNotTop fold
else
syn region rubyConditionalExpression matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![?!]\)\s*\)\@<=\%(if\|unless\)\>" end="\%(\%(\%(\.\@1<!\.\)\|::\)\s*\)\@<!\<end\>" contains=ALLBUT,@rubyNotTop
1 0.000001 endif
1 0.000010 syn match rubyConditional "\<\%(then\|else\|when\)\>[?!]\@!" contained containedin=rubyCaseExpression
1 0.000006 syn match rubyConditional "\<\%(then\|else\|elsif\)\>[?!]\@!" contained containedin=rubyConditionalExpression
1 0.000007 syn match rubyExceptional "\<\%(\%(\%(;\|^\)\s*\)\@<=rescue\|else\|ensure\)\>[?!]\@!" contained containedin=rubyBlockExpression
1 0.000006 syn match rubyMethodExceptional "\<\%(\%(\%(;\|^\)\s*\)\@<=rescue\|else\|ensure\)\>[?!]\@!" contained containedin=rubyMethodBlock
" statements with optional 'do'
1 0.000027 syn region rubyOptionalDoLine matchgroup=rubyRepeat start="\<for\>[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyOptionalDo end="\%(\<do\>\)" end="\ze\%(;\|$\)" oneline contains=ALLBUT,@rubyNotTop
1 0.000023 0.000017 if s:foldable('for')
1 0.000018 syn region rubyRepeatExpression start="\<for\>[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyRepeat end="\<end\>" contains=ALLBUT,@rubyNotTop nextgroup=rubyOptionalDoLine fold
else
syn region rubyRepeatExpression start="\<for\>[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyRepeat end="\<end\>" contains=ALLBUT,@rubyNotTop nextgroup=rubyOptionalDoLine
1 0.000001 endif
1 0.000003 if !exists("ruby_minlines")
1 0.000003 let ruby_minlines = 500
1 0.000000 endif
1 0.000006 exec "syn sync minlines=" . ruby_minlines
else
syn match rubyControl "\<def\>[?!]\@!" nextgroup=rubyMethodDeclaration skipwhite skipnl
syn match rubyControl "\<class\>[?!]\@!" nextgroup=rubyClassDeclaration skipwhite skipnl
syn match rubyControl "\<module\>[?!]\@!" nextgroup=rubyModuleDeclaration skipwhite skipnl
syn match rubyControl "\<\%(case\|begin\|do\|for\|if\|unless\|while\|until\|else\|elsif\|ensure\|then\|when\|end\)\>[?!]\@!"
syn match rubyKeyword "\<\%(alias\|undef\)\>[?!]\@!"
1 0.000001 endif
" Special Methods {{{1
1 0.000003 if !exists("ruby_no_special_methods")
1 0.000011 syn keyword rubyAccess public protected private public_class_method private_class_method public_constant private_constant module_function
" attr is a common variable name
1 0.000006 syn match rubyAttribute "\%(\%(^\|;\)\s*\)\@<=attr\>\(\s*[.=]\)\@!"
1 0.000003 syn keyword rubyAttribute attr_accessor attr_reader attr_writer
1 0.000009 syn match rubyControl "\<\%(exit!\|\%(abort\|at_exit\|exit\|fork\|loop\|trap\)\>[?!]\@!\)"
1 0.000005 syn keyword rubyEval eval class_eval instance_eval module_eval
1 0.000003 syn keyword rubyException raise fail catch throw
1 0.000004 syn keyword rubyInclude autoload gem load require require_relative
1 0.000002 syn keyword rubyKeyword callcc caller lambda proc
" false positive with 'include?'
1 0.000004 syn match rubyMacro "\<include\>[?!]\@!"
1 0.000002 syn keyword rubyMacro extend prepend refine using
1 0.000003 syn keyword rubyMacro alias_method define_method define_singleton_method remove_method undef_method
1 0.000001 endif
" Comments and Documentation {{{1
1 0.000009 syn match rubySharpBang "\%^#!.*" display
1 0.000007 syn keyword rubyTodo FIXME NOTE TODO OPTIMIZE HACK REVIEW XXX todo contained
1 0.000010 syn match rubyComment "#.*" contains=rubySharpBang,rubySpaceError,rubyTodo,@Spell
1 0.000026 0.000020 if !exists("ruby_no_comment_fold") && s:foldable('#')
1 0.000015 syn region rubyMultilineComment start="^\s*#.*\n\%(^\s*#\)\@=" end="^\s*#.*\n\%(^\s*#\)\@!" contains=rubyComment transparent fold keepend
1 0.000012 syn region rubyDocumentation start="^=begin\ze\%(\s.*\)\=$" end="^=end\%(\s.*\)\=$" contains=rubySpaceError,rubyTodo,@Spell fold
else
syn region rubyDocumentation start="^=begin\s*$" end="^=end\s*$" contains=rubySpaceError,rubyTodo,@Spell
1 0.000001 endif
" Keyword Nobbling {{{1
" Note: this is a hack to prevent 'keywords' being highlighted as such when called as methods with an explicit receiver
1 0.000013 syn match rubyKeywordAsMethod "\%(\%(\.\@1<!\.\)\|::\)\_s*\%([_[:lower:]][_[:alnum:]]*\|\<\%(BEGIN\|END\)\>\)" transparent contains=NONE
1 0.000007 syn match rubyKeywordAsMethod "\(defined?\|exit!\)\@!\<[_[:lower:]][_[:alnum:]]*[?!]" transparent contains=NONE
" More Symbols {{{1
1 0.000005 syn match rubySymbol "\%([{(,]\_s*\)\zs\l\w*[!?]\=::\@!"he=e-1
1 0.000011 syn match rubySymbol "[]})\"':]\@1<!\<\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],]\@="he=e-1
1 0.000006 syn match rubySymbol "\%([{(,]\_s*\)\zs[[:space:],{]\l\w*[!?]\=::\@!"hs=s+1,he=e-1
1 0.000006 syn match rubySymbol "[[:space:],{(]\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],]\@="hs=s+1,he=e-1
" __END__ Directive {{{1
1 0.000022 0.000017 if s:foldable('__END__')
1 0.000013 syn region rubyData matchgroup=rubyDataDirective start="^__END__$" end="\%$" fold
else
syn region rubyData matchgroup=rubyDataDirective start="^__END__$" end="\%$"
1 0.000001 endif
" Default Highlighting {{{1
1 0.000003 hi def link rubyClass rubyDefine
1 0.000002 hi def link rubyModule rubyDefine
1 0.000002 hi def link rubyMethodExceptional rubyDefine
1 0.000002 hi def link rubyDefine Define
1 0.000001 hi def link rubyAccess rubyMacro
1 0.000001 hi def link rubyAttribute rubyMacro
1 0.000002 hi def link rubyMacro Macro
1 0.000002 hi def link rubyMethodName rubyFunction
1 0.000002 hi def link rubyFunction Function
1 0.000002 hi def link rubyConditional Conditional
1 0.000002 hi def link rubyConditionalModifier rubyConditional
1 0.000002 hi def link rubyExceptional rubyConditional
1 0.000002 hi def link rubyRepeat Repeat
1 0.000002 hi def link rubyRepeatModifier rubyRepeat
1 0.000006 hi def link rubyOptionalDo rubyRepeat
1 0.000002 hi def link rubyControl Statement
1 0.000002 hi def link rubyInclude Include
1 0.000001 hi def link rubyInteger Number
1 0.000001 hi def link rubyASCIICode Character
1 0.000001 hi def link rubyFloat Float
1 0.000002 hi def link rubyBoolean Boolean
1 0.000003 hi def link rubyException Exception
1 0.000003 if !exists("ruby_no_identifiers")
1 0.000003 hi def link rubyIdentifier Identifier
else
hi def link rubyIdentifier NONE
1 0.000001 endif
1 0.000002 hi def link rubyClassVariable rubyIdentifier
1 0.000002 hi def link rubyConstant Type
1 0.000001 hi def link rubyClassName rubyConstant
1 0.000002 hi def link rubyModuleName rubyConstant
1 0.000002 hi def link rubyGlobalVariable rubyIdentifier
1 0.000002 hi def link rubyInstanceVariable rubyIdentifier
1 0.000002 hi def link rubyPredefinedIdentifier rubyIdentifier
1 0.000002 hi def link rubyPredefinedConstant rubyPredefinedIdentifier
1 0.000002 hi def link rubyPredefinedVariable rubyPredefinedIdentifier
1 0.000002 hi def link rubySymbol Constant
1 0.000001 hi def link rubyKeyword Keyword
1 0.000002 hi def link rubyOperator Operator
1 0.000002 hi def link rubyBeginEnd Statement
1 0.000002 hi def link rubyEval Statement
1 0.000002 hi def link rubyPseudoVariable Constant
1 0.000002 hi def link rubyCapitalizedMethod rubyLocalVariableOrMethod
1 0.000002 hi def link rubyComment Comment
1 0.000002 hi def link rubyData Comment
1 0.000007 hi def link rubyDataDirective Delimiter
1 0.000002 hi def link rubyDocumentation Comment
1 0.000002 hi def link rubyTodo Todo
1 0.000002 hi def link rubyQuoteEscape rubyStringEscape
1 0.000002 hi def link rubyStringEscape Special
1 0.000003 hi def link rubyInterpolationDelimiter Delimiter
1 0.000002 hi def link rubyNoInterpolation rubyString
1 0.000001 hi def link rubySharpBang PreProc
1 0.000002 hi def link rubyRegexpDelimiter rubyStringDelimiter
1 0.000002 hi def link rubySymbolDelimiter rubySymbol
1 0.000002 hi def link rubyStringDelimiter Delimiter
1 0.000002 hi def link rubyHeredoc rubyString
1 0.000002 hi def link rubyString String
1 0.000001 hi def link rubyRegexpEscape rubyRegexpSpecial
1 0.000001 hi def link rubyRegexpQuantifier rubyRegexpSpecial
1 0.000002 hi def link rubyRegexpAnchor rubyRegexpSpecial
1 0.000006 hi def link rubyRegexpDot rubyRegexpCharClass
1 0.000002 hi def link rubyRegexpCharClass rubyRegexpSpecial
1 0.000002 hi def link rubyRegexpSpecial Special
1 0.000002 hi def link rubyRegexpComment Comment
1 0.000002 hi def link rubyRegexp rubyString
1 0.000002 hi def link rubyInvalidVariable Error
1 0.000003 hi def link rubyError Error
1 0.000001 hi def link rubySpaceError rubyError
" Postscript {{{1
1 0.000002 let b:current_syntax = "ruby"
1 0.000009 let &cpo = s:cpo_sav
1 0.000002 unlet! s:cpo_sav
" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker:
FUNCTION <SNR>27_build_path()
Defined: /usr/local/Cellar/vim/8.1.0850/share/vim/vim81/ftplugin/ruby.vim line 88
Called 1 time
Total time: 0.000076
Self time: 0.000076
count total (s) self (s)
1 0.000041 let path = join(map(copy(a:path), 'v:val ==# "." ? "" : v:val'), ',')
1 0.000026 if &g:path !~# '\v^\.%(,/%(usr|emx)/include)=,,$'
let path = substitute(&g:path,',,$',',','') . ',' . path
1 0.000001 endif
1 0.000002 return path
FUNCTION <SNR>18_LocalBrowse()
Defined: /usr/local/Cellar/vim/8.1.0850/share/vim/vim81/plugin/netrwPlugin.vim line 102
Called 1 time
Total time: 0.000052
Self time: 0.000052
count total (s) self (s)
" Unfortunate interaction -- only DechoMsg debugging calls can be safely used here.
" Otherwise, the BufEnter event gets triggered when attempts to write to
" the DBG buffer are made.
1 0.000003 if !exists("s:vimentered")
" If s:vimentered doesn't exist, then the VimEnter event hasn't fired. It will,
" and so s:VimEnter() will then be calling this routine, but this time with s:vimentered defined.
" call Dfunc("s:LocalBrowse(dirname<".a:dirname.">) (s:vimentered doesn't exist)")
" call Dret("s:LocalBrowse")
return
1 0.000001 endif
" call Dfunc("s:LocalBrowse(dirname<".a:dirname.">) (s:vimentered=".s:vimentered.")")
1 0.000003 if has("amiga")
" The check against '' is made for the Amiga, where the empty
" string is the current directory and not checking would break
" things such as the help command.
" call Decho("(LocalBrowse) dirname<".a:dirname."> (isdirectory, amiga)")
if a:dirname != '' && isdirectory(a:dirname)
sil! call netrw#LocalBrowseCheck(a:dirname)
if exists("w:netrw_bannercnt") && line('.') < w:netrw_bannercnt
exe w:netrw_bannercnt
endif
endif
1 0.000014 elseif isdirectory(a:dirname)
" call Decho("(LocalBrowse) dirname<".a:dirname."> ft=".&ft." (isdirectory, not amiga)")
" call Dredir("LocalBrowse ft last set: ","verbose set ft")
" call Decho("(s:LocalBrowse) COMBAK#23: buf#".bufnr("%")." file<".expand("%")."> line#".line(".")." col#".col("."))
sil! call netrw#LocalBrowseCheck(a:dirname)
" call Decho("(s:LocalBrowse) COMBAK#24: buf#".bufnr("%")." file<".expand("%")."> line#".line(".")." col#".col("."))
if exists("w:netrw_bannercnt") && line('.') < w:netrw_bannercnt
exe w:netrw_bannercnt
" call Decho("(s:LocalBrowse) COMBAK#25: buf#".bufnr("%")." file<".expand("%")."> line#".line(".")." col#".col("."))
endif
1 0.000000 else
" not a directory, ignore it
" call Decho("(LocalBrowse) dirname<".a:dirname."> not a directory, ignoring...")
1 0.000001 endif
" call Decho("(s:LocalBrowse) COMBAK#26: buf#".bufnr("%")." file<".expand("%")."> line#".line(".")." col#".col("."))
" call Dret("s:LocalBrowse")
FUNCTION <SNR>11_defaults()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 254
Called 1 time
Total time: 0.000013
Self time: 0.000013
count total (s) self (s)
1 0.000003 let rules = copy(get(g:, 'fzf_colors', {}))
1 0.000007 let colors = join(map(items(filter(map(rules, 'call("s:get_color", v:val)'), '!empty(v:val)')), 'join(v:val, ":")'), ',')
1 0.000002 return empty(colors) ? '' : ('--color='.colors)
FUNCTION <SNR>9_SynSet()
Defined: /usr/local/Cellar/vim/8.1.0850/share/vim/vim81/syntax/synload.vim line 33
Called 1 time
Total time: 0.005233
Self time: 0.000332
count total (s) self (s)
" clear syntax for :set syntax=OFF and any syntax name that doesn't exist
1 0.000005 syn clear
1 0.000004 if exists("b:current_syntax")
unlet b:current_syntax
1 0.000001 endif
1 0.000003 let s = expand("<amatch>")
1 0.000002 if s == "ON"
" :set syntax=ON
if &filetype == ""
echohl ErrorMsg
echo "filetype unknown"
echohl None
endif
let s = &filetype
1 0.000002 elseif s == "OFF"
let s = ""
1 0.000000 endif
1 0.000001 if s != ""
" Load the syntax file(s). When there are several, separated by dots,
" load each in sequence.
2 0.000011 for name in split(s, '\.')
1 0.005183 0.000282 exe "runtime! syntax/" . name . ".vim syntax/" . name . "/*.vim"
2 0.000002 endfor
1 0.000001 endif
FUNCTION <SNR>29_foldable()
Defined: /usr/local/Cellar/vim/8.1.0850/share/vim/vim81/syntax/ruby.vim line 35
Called 22 times
Total time: 0.000135
Self time: 0.000135
count total (s) self (s)
22 0.000091 if index(s:foldable_groups, 'ALL') > -1
22 0.000022 return 1
endif
for l:i in a:000
if index(s:foldable_groups, l:i) > -1
return 1
endif
endfor
return 0
FUNCTION <SNR>11_escape()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 155
Called 2 times
Total time: 0.000019
Self time: 0.000019
count total (s) self (s)
2 0.000014 let path = fnameescape(a:path)
2 0.000004 return s:is_win ? escape(path, '$') : path
FUNCTION <SNR>11_use_sh()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 336
Called 1 time
Total time: 0.000014
Self time: 0.000014
count total (s) self (s)
1 0.000003 let [shell, shellslash] = [&shell, &shellslash]
1 0.000001 if s:is_win
set shell=cmd.exe
set noshellslash
1 0.000000 else
1 0.000004 set shell=sh
1 0.000000 endif
1 0.000002 return [shell, shellslash]
FUNCTION <SNR>26_open()
Defined: /private/tmp/plugged/fzf.vim/autoload/fzf/vim.vim line 232
Called 1 time
Total time: 0.151378
Self time: 0.002606
count total (s) self (s)
1 0.000098 if stridx('edit', a:cmd) == 0 && fnamemodify(a:target, ':p') ==# expand('%:p')
return
1 0.000000 endif
1 0.151278 0.002506 execute a:cmd s:escape(a:target)
FUNCTION <SNR>11_exit_handler()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 519
Called 1 time
Total time: 0.000022
Self time: 0.000022
count total (s) self (s)
1 0.000004 if a:code == 130
return 0
1 0.000002 elseif a:code > 1
call s:error('Error running ' . a:command)
if !empty(a:000)
sleep
endif
return 0
1 0.000001 endif
1 0.000001 return 1
FUNCTION <SNR>11_fzf_exec()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 111
Called 1 time
Total time: 0.000083
Self time: 0.000061
count total (s) self (s)
1 0.000003 if !exists('s:exec')
1 0.000024 if executable(s:fzf_go)
1 0.000002 let s:exec = s:fzf_go
elseif executable('fzf')
let s:exec = 'fzf'
elseif s:is_win && !has('win32unix')
call s:warn('fzf executable not found.')
call s:warn('Download fzf binary for Windows from https://github.com/junegunn/fzf-bin/releases/')
call s:warn('and place it as '.s:base_dir.'\bin\fzf.exe')
throw 'fzf executable not found'
elseif !s:installed && executable(s:install) && input('fzf executable not found. Download binary? (y/n) ') =~? '^y'
redraw
echo
call s:warn('Downloading fzf binary. Please wait ...')
let s:installed = 1
call system(s:install.' --bin')
return s:fzf_exec()
else
redraw
throw 'fzf executable not found'
1 0.000000 endif
1 0.000001 endif
1 0.000033 0.000011 return fzf#shellescape(s:exec)
FUNCTION <SNR>11_validate_layout()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 260
Called 1 time
Total time: 0.000017
Self time: 0.000017
count total (s) self (s)
2 0.000005 for key in keys(a:layout)
1 0.000002 if index(s:layout_keys, key) < 0
throw printf('Invalid entry in g:fzf_layout: %s (allowed: %s)%s', key, join(s:layout_keys, ', '), key == 'options' ? '. Use $FZF_DEFAULT_OPTS.' : '')
1 0.000000 endif
2 0.000001 endfor
1 0.000000 return a:layout
FUNCTION <SNR>11_pushd()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 455
Called 1 time
Total time: 0.000168
Self time: 0.000102
count total (s) self (s)
1 0.000016 0.000008 if s:present(a:dict, 'dir')
1 0.000047 0.000011 let cwd = s:fzf_getcwd()
1 0.000009 let w:fzf_pushd = { 'command': haslocaldir() ? 'lcd' : (exists(':tcd') && haslocaldir(-1) ? 'tcd' : 'cd'), 'origin': cwd, 'bufname': bufname('') }
1 0.000062 0.000054 execute 'lcd' s:escape(a:dict.dir)
1 0.000027 0.000013 let cwd = s:fzf_getcwd()
1 0.000002 let w:fzf_pushd.dir = cwd
1 0.000001 let a:dict.pushd = w:fzf_pushd
1 0.000001 return cwd
endif
return ''
FUNCTION <SNR>11_execute()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 532
Called 1 time
Total time: 80.958798
Self time: 0.002345
count total (s) self (s)
1 0.000177 0.000009 call s:pushd(a:dict)
1 0.000003 if has('unix') && !a:use_height
silent! !clear 2> /dev/null
1 0.000001 endif
1 0.000004 let escaped = (a:use_height || s:is_win) ? a:command : escape(substitute(a:command, '\n', '\\n', 'g'), '%#!')
1 0.000002 if has('gui_running')
let Launcher = get(a:dict, 'launcher', get(g:, 'Fzf_launcher', get(g:, 'fzf_launcher', s:launcher)))
let fmt = type(Launcher) == 2 ? call(Launcher, []) : Launcher
if has('unix')
let escaped = "'".substitute(escaped, "'", "'\"'\"'", 'g')."'"
endif
let command = printf(fmt, escaped)
1 0.000000 else
1 0.000002 let command = escaped
1 0.000000 endif
1 0.000001 if s:is_win
let batchfile = s:fzf_tempname().'.bat'
call writefile(s:wrap_cmds(command), batchfile)
let command = batchfile
let a:temps.batchfile = batchfile
if has('nvim')
let fzf = {}
let fzf.dict = a:dict
let fzf.temps = a:temps
function! fzf.on_exit(job_id, exit_status, event) dict
call s:pushd(self.dict)
let lines = s:collect(self.temps)
call s:callback(self.dict, lines)
endfunction
let cmd = 'start /wait cmd /c '.command
call jobstart(cmd, fzf)
return []
endif
1 0.000003 elseif has('win32unix') && $TERM !=# 'cygwin'
let shellscript = s:fzf_tempname()
call writefile([command], shellscript)
let command = 'cmd.exe /C '.fzf#shellescape('set "TERM=" & start /WAIT sh -c '.shellscript)
let a:temps.shellscript = shellscript
1 0.000001 endif
1 0.000001 if a:use_height
1 0.000002 let stdin = has_key(a:dict, 'source') ? '' : '< /dev/tty'
1 80.955402 0.000161 call system(printf('tput cup %d > /dev/tty; tput cnorm > /dev/tty; %s %s 2> /dev/tty', &lines, command, stdin))
else
execute 'silent !'.command
1 0.000001 endif
1 0.000007 let exit_status = v:shell_error
1 0.002015 redraw!
1 0.001122 0.000078 return s:exit_handler(exit_status, command) ? s:collect(a:temps) : []
FUNCTION <SNR>17_Highlight_Matching_Pair()
Defined: /usr/local/Cellar/vim/8.1.0850/share/vim/vim81/plugin/matchparen.vim line 39
Called 3 times
Total time: 0.004383
Self time: 0.004383
count total (s) self (s)
" Remove any previous match.
3 0.000025 if exists('w:paren_hl_on') && w:paren_hl_on
1 0.000007 silent! call matchdelete(3)
1 0.000004 let w:paren_hl_on = 0
3 0.000004 endif
" Avoid that we remove the popup menu.
" Return when there are no colors (looks like the cursor jumps).
3 0.000016 if pumvisible() || (&t_Co < 8 && !has("gui_running"))
return
3 0.000003 endif
" Get the character under the cursor and check if it's in 'matchpairs'.
3 0.000013 let c_lnum = line('.')
3 0.000007 let c_col = col('.')
3 0.000002 let before = 0
3 0.000009 let text = getline(c_lnum)
3 0.000164 let matches = matchlist(text, '\(.\)\=\%'.c_col.'c\(.\=\)')
3 0.000009 if empty(matches)
let [c_before, c] = ['', '']
3 0.000003 else
3 0.000018 let [c_before, c] = matches[1:2]
3 0.000004 endif
3 0.000072 let plist = split(&matchpairs, '.\zs[:,]')
3 0.000012 let i = index(plist, c)
3 0.000004 if i < 0
" not found, in Insert mode try character before the cursor
2 0.000011 if c_col > 1 && (mode() == 'i' || mode() == 'R')
let before = strlen(c_before)
let c = c_before
let i = index(plist, c)
2 0.000002 endif
2 0.000002 if i < 0
" not found, nothing to do
2 0.000003 return
endif
1 0.000000 endif
" Figure out the arguments for searchpairpos().
1 0.000001 if i % 2 == 0
let s_flags = 'nW'
let c2 = plist[i + 1]
1 0.000000 else
1 0.000001 let s_flags = 'nbW'
1 0.000001 let c2 = c
1 0.000002 let c = plist[i - 1]
1 0.000001 endif
1 0.000001 if c == '['
let c = '\['
let c2 = '\]'
1 0.000000 endif
" Find the match. When it was just before the cursor move it there for a
" moment.
1 0.000002 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)
1 0.000001 endif
1 0.000008 if !has("syntax") || !exists("g:syntax_on")
let s_skip = "0"
1 0.000001 else
" 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.
1 0.000005 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.
" Catch if this throws E363: pattern uses more memory than 'maxmempattern'.
1 0.000001 try
1 0.001941 execute 'if ' . s_skip . ' | let s_skip = "0" | endif'
catch /^Vim\%((\a\+)\)\=:E363/
" We won't find anything, so skip searching, should keep Vim responsive.
return
1 0.000001 endtry
1 0.000000 endif
" Limit the search to lines visible in the window.
1 0.000003 let stoplinebottom = line('w$')
1 0.000003 let stoplinetop = line('w0')
1 0.000001 if i % 2 == 0
let stopline = stoplinebottom
1 0.000001 else
1 0.000002 let stopline = stoplinetop
1 0.000000 endif
" Limit the search time to 300 msec to avoid a hang on very long lines.
" This fails when a timeout is not supported.
1 0.000003 if mode() == 'i' || mode() == 'R'
let timeout = exists("b:matchparen_insert_timeout") ? b:matchparen_insert_timeout : g:matchparen_insert_timeout
1 0.000001 else
1 0.000003 let timeout = exists("b:matchparen_timeout") ? b:matchparen_timeout : g:matchparen_timeout
1 0.000001 endif
1 0.000001 try
1 0.001834 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)
1 0.000000 endtry
1 0.000002 if before > 0
if has_getcurpos
call setpos('.', save_cursor)
else
call winrestview(save_cursor)
endif
1 0.000000 endif
" If a match is found setup match highlighting.
1 0.000002 if m_lnum > 0 && m_lnum >= stoplinetop && m_lnum <= stoplinebottom
1 0.000003 if exists('*matchaddpos')
1 0.000014 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\)/'
1 0.000000 endif
1 0.000002 let w:paren_hl_on = 1
1 0.000001 endif
FUNCTION <SNR>11_fzf_tempname()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 97
Called 1 time
Total time: 0.000015
Self time: 0.000011
count total (s) self (s)
1 0.000015 0.000011 return s:fzf_call('tempname')
FUNCTION <SNR>26_get_color()
Defined: /private/tmp/plugged/fzf.vim/autoload/fzf/vim.vim line 159
Called 2 times
Total time: 0.000052
Self time: 0.000052
count total (s) self (s)
2 0.000007 let gui = has('termguicolors') && &termguicolors
2 0.000003 let fam = gui ? 'gui' : 'cterm'
2 0.000002 let pat = gui ? '^#[a-f0-9]\+' : '^[0-9]\+$'
3 0.000003 for group in a:000
2 0.000012 let code = synIDattr(synIDtrans(hlID(group)), a:attr, fam)
2 0.000010 if code =~? pat
1 0.000001 return code
1 0.000001 endif
2 0.000002 endfor
1 0.000001 return ''
FUNCTION fzf#vim#grep()
Defined: /private/tmp/plugged/fzf.vim/autoload/fzf/vim.vim line 699
Called 1 time
Total time: 81.112117
Self time: 0.000102
count total (s) self (s)
1 0.000002 let words = []
2 0.000033 for word in split(a:grep_command)
2 0.000010 if word !~# '^[a-z]'
1 0.000001 break
1 0.000001 endif
1 0.000003 call add(words, word)
2 0.000002 endfor
1 0.000003 let words = empty(words) ? ['grep'] : words
1 0.000002 let name = join(words, '-')
1 0.000009 let capname = join(map(words, 'toupper(v:val[0]).v:val[1:]'), '')
1 0.000007 let opts = { 'source': a:grep_command, 'column': a:with_column, 'options': ['--ansi', '--prompt', capname.'> ', '--multi', '--bind', 'alt-a:select-all,alt-d:deselect-all', '--color', 'hl:4,hl+:12']}
1 0.000001 function! opts.sink(lines)
return s:ag_handler(a:lines, self.column)
endfunction
1 0.000004 let opts['sink*'] = remove(opts, 'sink')
1 81.112032 0.000017 return s:fzf(name, opts, a:000)
FUNCTION <SNR>7_LoadIndent()
Defined: /usr/local/Cellar/vim/8.1.0850/share/vim/vim81/indent.vim line 13
Called 1 time
Total time: 0.002350
Self time: 0.000260
count total (s) self (s)
1 0.000004 if exists("b:undo_indent")
exe b:undo_indent
unlet! b:undo_indent b:did_indent
1 0.000001 endif
1 0.000004 let s = expand("<amatch>")
1 0.000002 if s != ""
1 0.000002 if exists("b:did_indent")
unlet b:did_indent
1 0.000001 endif
" When there is a dot it is used to separate filetype names. Thus for
" "aaa.bbb" load "indent/aaa.vim" and then "indent/bbb.vim".
2 0.000009 for name in split(s, '\.')
1 0.002313 0.000223 exe 'runtime! indent/' . name . '.vim'
2 0.000004 endfor
1 0.000001 endif
FUNCTION <SNR>26_escape()
Defined: /private/tmp/plugged/fzf.vim/autoload/fzf/vim.vim line 143
Called 1 time
Total time: 0.000012
Self time: 0.000012
count total (s) self (s)
1 0.000009 let path = fnameescape(a:path)
1 0.000003 return s:is_win ? escape(path, '$') : path
FUNCTION <SNR>11_has_any()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 187
Called 2 times
Total time: 0.000048
Self time: 0.000048
count total (s) self (s)
9 0.000011 for key in a:keys
7 0.000011 if has_key(a:dict, key)
return 1
7 0.000002 endif
9 0.000010 endfor
2 0.000001 return 0
FUNCTION <SNR>26_ag_to_qf()
Defined: /private/tmp/plugged/fzf.vim/autoload/fzf/vim.vim line 643
Called 1 time
Total time: 0.000039
Self time: 0.000039
count total (s) self (s)
1 0.000013 let parts = split(a:line, ':')
1 0.000006 let text = join(parts[(a:with_column ? 3 : 2):], ':')
1 0.000012 let dict = {'filename': &acd ? fnamemodify(parts[0], ':p') : parts[0], 'lnum': parts[1], 'text': text}
1 0.000002 if a:with_column
1 0.000002 let dict.col = parts[2]
1 0.000001 endif
1 0.000001 return dict
FUNCTION <SNR>26_ag_handler()
Defined: /private/tmp/plugged/fzf.vim/autoload/fzf/vim.vim line 653
Called 1 time
Total time: 0.151660
Self time: 0.000211
count total (s) self (s)
1 0.000004 if len(a:lines) < 2
return
1 0.000001 endif
1 0.000043 0.000022 let cmd = s:action_for(a:lines[0], 'e')
1 0.000069 0.000030 let list = map(filter(a:lines[1:], 'len(v:val)'), 's:ag_to_qf(v:val, a:with_column)')
1 0.000003 if empty(list)
return
1 0.000001 endif
1 0.000001 let first = list[0]
1 0.000000 try
1 0.151394 0.000016 call s:open(cmd, first.filename)
1 0.000004 execute first.lnum
1 0.000002 if a:with_column
1 0.000071 execute 'normal!' first.col.'|'
1 0.000001 endif
1 0.000023 normal! zz
catch
1 0.000001 endtry
1 0.000030 0.000019 call s:fill_quickfix(list)
FUNCTION <SNR>26_extend_opts()
Defined: /private/tmp/plugged/fzf.vim/autoload/fzf/vim.vim line 49
Called 1 time
Total time: 0.000004
Self time: 0.000004
count total (s) self (s)
1 0.000002 if empty(a:eopts)
1 0.000001 return
endif
if has_key(a:dict, 'options')
if type(a:dict.options) == s:TYPE.list && type(a:eopts) == s:TYPE.list
if a:prepend
let a:dict.options = extend(copy(a:eopts), a:dict.options)
else
call extend(a:dict.options, a:eopts)
endif
else
let all_opts = a:prepend ? [a:eopts, a:dict.options] : [a:dict.options, a:eopts]
let a:dict.options = join(map(all_opts, 'type(v:val) == s:TYPE.list ? join(map(copy(v:val), "fzf#shellescape(v:val)")) : v:val'))
endif
else
let a:dict.options = a:eopts
endif
FUNCTION <SNR>11_present()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 423
Called 2 times
Total time: 0.000036
Self time: 0.000036
count total (s) self (s)
6 0.000009 for key in a:000
5 0.000013 if !empty(get(a:dict, key, ''))
1 0.000001 return 1
4 0.000004 endif
5 0.000003 endfor
1 0.000000 return 0
FUNCTION <SNR>26_fill_quickfix()
Defined: /private/tmp/plugged/fzf.vim/autoload/fzf/vim.vim line 261
Called 1 time
Total time: 0.000011
Self time: 0.000011
count total (s) self (s)
1 0.000003 if len(a:list) > 1
call setqflist(a:list)
copen
wincmd p
if a:0
execute a:1
endif
1 0.000001 endif
FUNCTION <SNR>26_ansi()
Defined: /private/tmp/plugged/fzf.vim/autoload/fzf/vim.vim line 182
Called 1 time
Total time: 0.000119
Self time: 0.000056
count total (s) self (s)
1 0.000039 0.000013 let fg = s:get_color('fg', a:group)
1 0.000038 0.000012 let bg = s:get_color('bg', a:group)
1 0.000025 0.000014 let color = (empty(fg) ? s:ansi[a:default] : s:csi(fg, 1)) . (empty(bg) ? '' : ';'.s:csi(bg, 0))
1 0.000016 return printf("\x1b[%s%sm%s\x1b[m", color, a:0 ? ';1' : '', a:str)
FUNCTION <SNR>26_csi()
Defined: /private/tmp/plugged/fzf.vim/autoload/fzf/vim.vim line 174
Called 1 time
Total time: 0.000011
Self time: 0.000011
count total (s) self (s)
1 0.000002 let prefix = a:fg ? '38;' : '48;'
1 0.000003 if a:color[0] == '#'
return prefix.'2;'.join(map([a:color[1:2], a:color[3:4], a:color[5:6]], 'str2nr(v:val, 16)'), ';')
1 0.000001 endif
1 0.000002 return prefix.'5;'.a:color
FUNCTION <SNR>27_map()
Defined: /usr/local/Cellar/vim/8.1.0850/share/vim/vim81/ftplugin/ruby.vim line 152
Called 14 times
Total time: 0.000501
Self time: 0.000501
count total (s) self (s)
14 0.000144 let from = matchstr(a:map, '\S\+')
14 0.000088 if empty(mapcheck(from, a:mode))
14 0.000180 exe a:mode.'map' '<buffer>' a:map
14 0.000069 let b:undo_ftplugin .= '|sil! '.a:mode.'unmap <buffer> '.from
14 0.000013 endif
FUNCTION <SNR>26_action_for()
Defined: /private/tmp/plugged/fzf.vim/autoload/fzf/vim.vim line 226
Called 1 time
Total time: 0.000021
Self time: 0.000021
count total (s) self (s)
1 0.000003 let default = a:0 ? a:1 : ''
1 0.000009 let Cmd = get(get(g:, 'fzf_action', s:default_action), a:key, default)
1 0.000007 return type(Cmd) == s:TYPE.string ? Cmd : default
FUNCTION <SNR>11_evaluate_opts()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 270
Called 3 times
Total time: 0.000260
Self time: 0.000106
count total (s) self (s)
3 0.000259 0.000105 return type(a:options) == type([]) ? join(map(copy(a:options), 'fzf#shellescape(v:val)')) : a:options
FUNCTION fzf#wrap()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 276
Called 1 time
Total time: 0.000482
Self time: 0.000157
count total (s) self (s)
1 0.000002 let args = ['', {}, 0]
1 0.000006 let expects = map(copy(args), 'type(v:val)')
1 0.000001 let tidx = 0
4 0.000005 for arg in copy(a:000)
3 0.000007 let tidx = index(expects, type(arg), tidx)
3 0.000002 if tidx < 0
throw 'Invalid arguments (expected: [name string] [opts dict] [fullscreen boolean])'
3 0.000002 endif
3 0.000005 let args[tidx] = arg
3 0.000003 let tidx += 1
3 0.000001 unlet arg
4 0.000003 endfor
1 0.000002 let [name, opts, bang] = args
1 0.000002 if len(name)
1 0.000002 let opts.name = name
1 0.000000 end
" Layout: g:fzf_layout (and deprecated g:fzf_height)
1 0.000000 if bang
for key in s:layout_keys
if has_key(opts, key)
call remove(opts, key)
endif
endfor
1 0.000041 0.000012 elseif !s:has_any(opts, s:layout_keys)
1 0.000003 if !exists('g:fzf_layout') && exists('g:fzf_height')
let opts.down = g:fzf_height
1 0.000001 else
1 0.000032 0.000015 let opts = extend(opts, s:validate_layout(get(g:, 'fzf_layout', s:default_layout)))
1 0.000000 endif
1 0.000001 endif
" Colors: g:fzf_colors
1 0.000283 0.000023 let opts.options = s:defaults() .' '. s:evaluate_opts(get(opts, 'options', ''))
" History: g:fzf_history_dir
1 0.000004 if len(name) && len(get(g:, 'fzf_history_dir', ''))
let dir = s:fzf_expand(g:fzf_history_dir)
if !isdirectory(dir)
call mkdir(dir, 'p')
endif
let history = fzf#shellescape(dir.'/'.name)
let opts.options = join(['--history', history, opts.options])
1 0.000000 endif
" Action: g:fzf_action
1 0.000027 0.000008 if !s:has_any(opts, ['sink', 'sink*'])
1 0.000003 let opts._action = get(g:, 'fzf_action', s:default_action)
1 0.000005 let opts.options .= ' --expect='.join(keys(opts._action), ',')
1 0.000002 function! opts.sink(lines) abort
return s:common_sink(self._action, a:lines)
endfunction
1 0.000003 let opts['sink*'] = remove(opts, 'sink')
1 0.000000 endif
1 0.000000 return opts
FUNCTION <SNR>26_fzf()
Defined: /private/tmp/plugged/fzf.vim/autoload/fzf/vim.vim line 200
Called 1 time
Total time: 81.112015
Self time: 0.000077
count total (s) self (s)
1 0.000003 let [extra, bang] = [{}, 0]
1 0.000002 if len(a:extra) <= 1
1 0.000002 let first = get(a:extra, 0, 0)
1 0.000002 if type(first) == s:TYPE.dict
let extra = first
1 0.000001 else
1 0.000001 let bang = first
1 0.000000 endif
elseif len(a:extra) == 2
let [extra, bang] = a:extra
else
throw 'invalid number of arguments'
1 0.000001 endif
1 0.000003 let eopts = has_key(extra, 'options') ? remove(extra, 'options') : ''
1 0.000007 let merged = extend(copy(a:opts), extra)
1 0.000026 0.000013 call s:merge_opts(merged, eopts)
1 81.111961 0.000036 return fzf#run(s:wrap(a:name, merged, bang))
FUNCTION <SNR>11_dopopd()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 477
Called 1 time
Total time: 0.000129
Self time: 0.000103
count total (s) self (s)
1 0.000004 if !exists('w:fzf_pushd')
return
1 0.000001 endif
" FIXME: We temporarily change the working directory to 'dir' entry
" of options dictionary (set to the current working directory if not given)
" before running fzf.
"
" e.g. call fzf#run({'dir': '/tmp', 'source': 'ls', 'sink': 'e'})
"
" After processing the sink function, we have to restore the current working
" directory. But doing so may not be desirable if the function changed the
" working directory on purpose.
"
" So how can we tell if we should do it or not? A simple heuristic we use
" here is that we change directory only if the current working directory
" matches 'dir' entry. However, it is possible that the sink function did
" change the directory to 'dir'. In that case, the user will have an
" unexpected result.
1 0.000034 0.000019 if s:fzf_getcwd() ==# w:fzf_pushd.dir && (!&autochdir || w:fzf_pushd.bufname ==# bufname(''))
1 0.000081 0.000070 execute w:fzf_pushd.command s:escape(w:fzf_pushd.origin)
1 0.000001 endif
1 0.000002 unlet w:fzf_pushd
FUNCTION <SNR>11_collect()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 736
Called 1 time
Total time: 0.001022
Self time: 0.001022
count total (s) self (s)
1 0.000002 try
1 0.000840 return filereadable(a:temps.result) ? readfile(a:temps.result) : []
1 0.000004 finally
2 0.000011 for tf in values(a:temps)
1 0.000154 silent! call delete(tf)
2 0.000005 endfor
1 0.000002 endtry
FUNCTION <SNR>11_calc_size()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 597
Called 1 time
Total time: 0.000065
Self time: 0.000058
count total (s) self (s)
1 0.000008 let val = substitute(a:val, '^\~', '', '')
1 0.000003 if val =~ '%$'
1 0.000004 let size = a:max * str2nr(val[:-2]) / 100
else
let size = min([a:max, str2nr(val)])
1 0.000000 endif
1 0.000001 let srcsz = -1
1 0.000004 if type(get(a:dict, 'source', 0)) == type([])
let srcsz = len(a:dict.source)
1 0.000000 endif
1 0.000023 0.000016 let opts = $FZF_DEFAULT_OPTS.' '.s:evaluate_opts(get(a:dict, 'options', ''))
1 0.000005 let margin = stridx(opts, '--inline-info') > stridx(opts, '--no-inline-info') ? 1 : 2
1 0.000004 let margin += stridx(opts, '--border') > stridx(opts, '--no-border') ? 2 : 0
1 0.000003 let margin += stridx(opts, '--header') > stridx(opts, '--no-header')
1 0.000002 return srcsz >= 0 ? min([srcsz + margin, size]) : size
FUNCTION <SNR>11_upgrade()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 161
Called 1 time
Total time: 0.000015
Self time: 0.000015
count total (s) self (s)
1 0.000004 let copy = copy(a:dict)
1 0.000002 if has_key(copy, 'tmux')
let copy.down = remove(copy, 'tmux')
1 0.000000 endif
1 0.000002 if has_key(copy, 'tmux_height')
let copy.down = remove(copy, 'tmux_height')
1 0.000000 endif
1 0.000001 if has_key(copy, 'tmux_width')
let copy.right = remove(copy, 'tmux_width')
1 0.000000 endif
1 0.000001 return copy
FUNCTION fzf#shellescape()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 77
Called 9 times
Total time: 0.000176
Self time: 0.000147
count total (s) self (s)
9 0.000024 let shell = get(a:000, 0, &shell)
9 0.000029 if shell =~# 'cmd.exe$'
return s:shellesc_cmd(a:arg)
9 0.000004 endif
9 0.000100 0.000071 return s:fzf_call('shellescape', a:arg)
FUNCTION <SNR>6_LoadFTPlugin()
Defined: /usr/local/Cellar/vim/8.1.0850/share/vim/vim81/ftplugin.vim line 14
Called 1 time
Total time: 0.137574
Self time: 0.000866
count total (s) self (s)
1 0.000014 if exists("b:undo_ftplugin")
exe b:undo_ftplugin
unlet! b:undo_ftplugin b:did_ftplugin
1 0.000001 endif
1 0.000007 let s = expand("<amatch>")
1 0.000003 if s != ""
1 0.000017 if &cpo =~# "S" && exists("b:did_ftplugin")
" In compatible mode options are reset to the global values, need to
" set the local values also when a plugin was already used.
unlet b:did_ftplugin
1 0.000001 endif
" When there is a dot it is used to separate filetype names. Thus for
" "aaa.bbb" load "aaa" and then "bbb".
2 0.000013 for name in split(s, '\.')
1 0.137491 0.000783 exe 'runtime! ftplugin/' . name . '.vim ftplugin/' . name . '_*.vim ftplugin/' . name . '/*.vim'
2 0.000009 endfor
1 0.000000 endif
FUNCTION <SNR>26_merge_opts()
Defined: /private/tmp/plugged/fzf.vim/autoload/fzf/vim.vim line 69
Called 1 time
Total time: 0.000013
Self time: 0.000009
count total (s) self (s)
1 0.000013 0.000009 return s:extend_opts(a:dict, a:eopts, 0)
FUNCTION <SNR>27_query_path()
Defined: /usr/local/Cellar/vim/8.1.0850/share/vim/vim81/ftplugin/ruby.vim line 63
Called 1 time
Total time: 0.133480
Self time: 0.000633
count total (s) self (s)
1 0.000003 let code = "print $:.join %q{,}"
1 0.000009 if &shell =~# 'sh' && empty(&shellxquote)
1 0.000010 let prefix = 'env PATH='.shellescape($PATH).' '
else
let prefix = ''
1 0.000000 endif
1 0.000002 if &shellxquote == "'"
let path_check = prefix.'ruby --disable-gems -e "' . code . '"'
1 0.000001 else
1 0.000004 let path_check = prefix."ruby --disable-gems -e '" . code . "'"
1 0.000001 endif
1 0.000002 let cd = haslocaldir() ? 'lcd' : 'cd'
1 0.000010 let cwd = fnameescape(getcwd())
1 0.000001 try
1 0.000067 exe cd fnameescape(a:root)
1 0.133135 0.000288 let path = split(system(path_check),',')
1 0.000138 exe cd cwd
1 0.000005 return path
1 0.000002 finally
1 0.000074 exe cd cwd
1 0.000006 endtry
FUNCTION fzf#run()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 347
Called 1 time
Total time: 81.111401
Self time: 0.000429
count total (s) self (s)
1 0.000001 try
1 0.000028 0.000014 let [shell, shellslash] = s:use_sh()
1 0.000025 0.000010 let dict = exists('a:1') ? s:upgrade(a:1) : {}
1 0.000027 0.000012 let temps = { 'result': s:fzf_tempname() }
1 0.000018 0.000012 let optstr = s:evaluate_opts(get(dict, 'options', ''))
1 0.000001 try
1 0.000091 0.000008 let fzf_exec = s:fzf_exec()
catch
throw v:exception
1 0.000001 endtry
1 0.000002 if !has_key(dict, 'dir')
1 0.000053 0.000011 let dict.dir = s:fzf_getcwd()
1 0.000001 endif
1 0.000004 if has('win32unix') && has_key(dict, 'dir')
let dict.dir = fnamemodify(dict.dir, ':p')
1 0.000000 endif
1 0.000002 if !has_key(dict, 'source') && !empty($FZF_DEFAULT_COMMAND) && !s:is_win
let temps.source = s:fzf_tempname()
call writefile(s:wrap_cmds(split($FZF_DEFAULT_COMMAND, "\n")), temps.source)
let dict.source = (empty($SHELL) ? &shell : $SHELL).' '.fzf#shellescape(temps.source)
1 0.000000 endif
1 0.000001 if has_key(dict, 'source')
1 0.000002 let source = dict.source
1 0.000001 let type = type(source)
1 0.000000 if type == 1
1 0.000002 let prefix = '( '.source.' )|'
elseif type == 3
let temps.input = s:fzf_tempname()
call writefile(source, temps.input)
let prefix = (s:is_win ? 'type ' : 'cat ').fzf#shellescape(temps.input).'|'
else
throw 'Invalid source type'
1 0.000001 endif
else
let prefix = ''
1 0.000001 endif
1 0.000002 let prefer_tmux = get(g:, 'fzf_prefer_tmux', 0)
1 0.000181 0.000153 let use_height = has_key(dict, 'down') && !has('gui_running') && !(has('nvim') || s:is_win || has('win32unix') || s:present(dict, 'up', 'left', 'right', 'window')) && executable('tput') && filereadable('/dev/tty')
1 0.000007 let has_vim8_term = has('terminal') && has('patch-8.0.995')
1 0.000005 let has_nvim_term = has('nvim-0.2.1') || has('nvim') && !s:is_win
1 0.000009 let use_term = has_nvim_term || has_vim8_term && !has('win32unix') && (has('gui_running') || s:is_win || !use_height && s:present(dict, 'down', 'up', 'left', 'right', 'window'))
1 0.000005 let use_tmux = (!use_height && !use_term || prefer_tmux) && !has('win32unix') && s:tmux_enabled() && s:splittable(dict)
1 0.000002 if prefer_tmux && use_tmux
let use_height = 0
let use_term = 0
1 0.000001 endif
1 0.000001 if use_height
1 0.000087 0.000022 let height = s:calc_size(&lines, dict.down, dict)
1 0.000003 let optstr .= ' --height='.height
elseif use_term
let optstr .= ' --no-height'
1 0.000001 endif
1 0.000006 let command = prefix.(use_tmux ? s:fzf_tmux(dict) : fzf_exec).' '.optstr.' > '.temps.result
1 0.000001 if use_term
return s:execute_term(dict, command, temps)
1 0.000000 endif
1 80.958837 0.000039 let lines = use_tmux ? s:execute_tmux(dict, command, temps) : s:execute(dict, command, use_height, temps)
1 0.151941 0.000035 call s:callback(dict, lines)
1 0.000002 return lines
1 0.000001 finally
1 0.000008 let [&shell, &shellslash] = [shell, shellslash]
1 0.000003 endtry
FUNCTION <SNR>26_blue()
Defined: /private/tmp/plugged/fzf.vim/autoload/fzf/vim.vim line 191
Called 1 time
Total time: 0.000134
Self time: 0.000015
count total (s) self (s)
1 0.000134 0.000015 return s:ansi(a:str, get(a:, 1, ''), 'blue')
FUNCTION <SNR>11_fzf_call()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 60
Called 14 times
Total time: 0.000100
Self time: 0.000100
count total (s) self (s)
14 0.000098 return call(a:fn, a:000)
FUNCTION <SNR>26_wrap()
Defined: /private/tmp/plugged/fzf.vim/autoload/fzf/vim.vim line 118
Called 1 time
Total time: 0.000524
Self time: 0.000042
count total (s) self (s)
" fzf#wrap does not append --expect if sink or sink* is found
1 0.000003 let opts = copy(a:opts)
1 0.000001 let options = ''
1 0.000002 if has_key(opts, 'options')
1 0.000005 let options = type(opts.options) == s:TYPE.list ? join(opts.options) : opts.options
1 0.000001 endif
1 0.000005 if options !~ '--expect' && has_key(opts, 'sink*')
1 0.000003 let Sink = remove(opts, 'sink*')
1 0.000497 0.000015 let wrapped = fzf#wrap(a:name, opts, a:bang)
1 0.000002 let wrapped['sink*'] = Sink
else
let wrapped = fzf#wrap(a:name, opts, a:bang)
1 0.000000 endif
1 0.000001 return wrapped
FUNCTION <SNR>11_callback()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 746
Called 1 time
Total time: 0.151906
Self time: 0.000083
count total (s) self (s)
1 0.000007 let popd = has_key(a:dict, 'pushd')
1 0.000002 if popd
1 0.000003 let w:fzf_pushd = a:dict.pushd
1 0.000001 endif
1 0.000002 try
1 0.000003 if has_key(a:dict, 'sink')
for line in a:lines
if type(a:dict.sink) == 2
call a:dict.sink(line)
else
execute a:dict.sink s:escape(line)
endif
endfor
1 0.000001 endif
1 0.000003 if has_key(a:dict, 'sink*')
1 0.151709 0.000015 call a:dict['sink*'](a:lines)
1 0.000001 endif
catch
if stridx(v:exception, ':E325:') < 0
echoerr v:exception
endif
1 0.000000 endtry
" We may have opened a new window or tab
1 0.000001 if popd
1 0.000005 let w:fzf_pushd = a:dict.pushd
1 0.000142 0.000013 call s:dopopd()
1 0.000001 endif
FUNCTION <SNR>11_fzf_getcwd()
Defined: /private/tmp/plugged/fzf/plugin/fzf.vim line 85
Called 4 times
Total time: 0.000107
Self time: 0.000040
count total (s) self (s)
4 0.000106 0.000039 return s:fzf_call('getcwd')
FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
1 81.112117 0.000102 fzf#vim#grep()
1 81.112015 0.000077 <SNR>26_fzf()
1 81.111401 0.000429 fzf#run()
1 80.958798 0.002345 <SNR>11_execute()
1 0.151906 0.000083 <SNR>11_callback()
1 0.151660 0.000211 <SNR>26_ag_handler()
1 0.151378 0.002606 <SNR>26_open()
1 0.137574 0.000866 <SNR>6_LoadFTPlugin()
1 0.133480 0.000633 <SNR>27_query_path()
1 0.005233 0.000332 <SNR>9_SynSet()
3 0.004383 <SNR>17_Highlight_Matching_Pair()
1 0.002350 0.000260 <SNR>7_LoadIndent()
1 0.001022 <SNR>11_collect()
1 0.000524 0.000042 <SNR>26_wrap()
14 0.000501 <SNR>27_map()
1 0.000482 0.000157 fzf#wrap()
3 0.000260 0.000106 <SNR>11_evaluate_opts()
9 0.000176 0.000147 fzf#shellescape()
1 0.000168 0.000102 <SNR>11_pushd()
22 0.000135 <SNR>29_foldable()
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
3 0.004383 <SNR>17_Highlight_Matching_Pair()
1 0.151378 0.002606 <SNR>26_open()
1 80.958798 0.002345 <SNR>11_execute()
1 0.001022 <SNR>11_collect()
1 0.137574 0.000866 <SNR>6_LoadFTPlugin()
1 0.133480 0.000633 <SNR>27_query_path()
14 0.000501 <SNR>27_map()
1 81.111401 0.000429 fzf#run()
1 0.005233 0.000332 <SNR>9_SynSet()
1 0.002350 0.000260 <SNR>7_LoadIndent()
1 0.151660 0.000211 <SNR>26_ag_handler()
1 0.000482 0.000157 fzf#wrap()
9 0.000176 0.000147 fzf#shellescape()
22 0.000135 <SNR>29_foldable()
3 0.000260 0.000106 <SNR>11_evaluate_opts()
1 0.000129 0.000103 <SNR>11_dopopd()
1 81.112117 0.000102 fzf#vim#grep()
1 0.000168 0.000102 <SNR>11_pushd()
14 0.000100 <SNR>11_fzf_call()
1 0.151906 0.000083 <SNR>11_callback()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment