autoload/completion.vim
¶
Enforce vim script implementation to reduce ambiguities and improve robustness:
scriptversion 4
- build_complete(arglead: str, cmdline: str, cursorpos: int) List[str] ¶
Completion targets from active project.
This assumes that you are in the base directory for a project, and supports both ninja and make.
- Parameters
arglead – Text of argument being completed
cmdline – Text of the command line
cursorpos – Location within command line
- Returns
Completion candidates
function! completion#build_complete(arglead, cmdline, cursorpos) abort
if filereadable('build.ninja')
const l:targets = systemlist('ninja -t targets | cut -d: -f1')
else
const l:targets = systemlist(
\ 'make -pqrR | ' ..
\ 'sed -n "/^# Files/,$ { s,^\([^#\.].*\): .*,\1,p }"'
\ )
endif
return sort(filter(l:targets, {_, s -> s =~? '^' .. a:arglead}))
endfunction
- set_font_complete(arglead: str, cmdline: str, cursorpos: int) List[str] ¶
Completion options for
set_font()
.
function! completion#set_font_complete(arglead, cmdline, cursorpos) abort
const l:fonts =
\ [escape(g:font_family .. ' ' .. g:font_size, ' '), ]
\ + map(range(8),
\ {n -> escape(g:font_family .. ' ' .. (n * 8 + 16), ' ')})
return sort(
\ filter(l:fonts,
\ {_, s -> strpart(s, 0, len(a:arglead)) ==# a:arglead})
\ )
endfunction
Note
Yeah, some of these are huuuuuge, but I’ll often pop up a snippet for discussion in a meeting and this really helps.
- project_file_complete(arglead: str, cmdline: str, cursorpos: int) List[str] ¶
Completion targets for project-specific configuration files.
- Parameters
arglead – Text of argument being completed
cmdline – Text of the command line
cursorpos – Location within command line
- Returns
Completion candidates
function! completion#project_file_complete(arglead, cmdline, cursorpos) abort
return sort(filter(['abbr.vim', 'project.vim'],
\ {_, s -> s =~? '^' .. a:arglead}))
endfunction