[Tags/BTags] Take optional argument as the default query
Related #90. Function signature of s:btags_source has changed. /cc @AdnoC
This commit is contained in:
parent
345dae5a08
commit
b9285c87db
4 changed files with 16 additions and 12 deletions
|
@ -49,14 +49,14 @@ Commands
|
|||
| Command | List |
|
||||
| --- | --- |
|
||||
| `Files [PATH]` | Files (similar to `:FZF`) |
|
||||
| `GitFiles` | Git files
|
||||
| `GitFiles` | Git files |
|
||||
| `Buffers` | Open buffers |
|
||||
| `Colors` | Color schemes |
|
||||
| `Ag [PATTERN]` | [ag][ag] search result (`ALT-A` to select all, `ALT-D` to deselect all) |
|
||||
| `Lines` | Lines in loaded buffers |
|
||||
| `BLines` | Lines in the current buffer |
|
||||
| `Tags` | Tags in the project (`ctags -R`) |
|
||||
| `BTags` | Tags in the current buffer |
|
||||
| `Tags [QUERY]` | Tags in the project (`ctags -R`) |
|
||||
| `BTags [QUERY]` | Tags in the current buffer |
|
||||
| `Marks` | Marks |
|
||||
| `Windows` | Windows |
|
||||
| `Locate PATTERN` | `locate` command output |
|
||||
|
|
|
@ -474,8 +474,12 @@ function! s:btags_sink(lines)
|
|||
normal! zz
|
||||
endfunction
|
||||
|
||||
" [tag commands], options
|
||||
function! fzf#vim#buffer_tags(...)
|
||||
function! s:q(query)
|
||||
return ' --query "'.escape(a:query, '"').'"'
|
||||
endfunction
|
||||
|
||||
" query, [[tag commands], options]
|
||||
function! fzf#vim#buffer_tags(query, ...)
|
||||
let args = copy(a:000)
|
||||
let tag_cmds = len(args) > 1 ? remove(args, 0) : [
|
||||
\ printf('ctags -f - --sort=no --excmd=number --language-force=%s %s', &filetype, expand('%:S')),
|
||||
|
@ -484,7 +488,7 @@ function! fzf#vim#buffer_tags(...)
|
|||
return s:fzf(fzf#vim#wrap({
|
||||
\ 'source': s:btags_source(tag_cmds),
|
||||
\ 'sink*': s:function('s:btags_sink'),
|
||||
\ 'options': '--reverse -m -d "\t" --with-nth 1,4.. -n 1 --prompt "BTags> "'}), args)
|
||||
\ 'options': '--reverse -m -d "\t" --with-nth 1,4.. -n 1 --prompt "BTags> "'.s:q(a:query)}), a:000)
|
||||
catch
|
||||
return s:warn(v:exception)
|
||||
endtry
|
||||
|
@ -518,7 +522,7 @@ function! s:tags_sink(lines)
|
|||
normal! zz
|
||||
endfunction
|
||||
|
||||
function! fzf#vim#tags(...)
|
||||
function! fzf#vim#tags(query, ...)
|
||||
if empty(tagfiles())
|
||||
call s:warn('Preparing tags')
|
||||
call system('ctags -R')
|
||||
|
@ -541,7 +545,7 @@ function! fzf#vim#tags(...)
|
|||
\ 'source': proc.shellescape(fnamemodify(tagfile, ':t')),
|
||||
\ 'sink*': s:function('s:tags_sink'),
|
||||
\ 'dir': fnamemodify(tagfile, ':h'),
|
||||
\ 'options': copt.'-m --tiebreak=begin --prompt "Tags> "'}), a:000)
|
||||
\ 'options': copt.'-m --tiebreak=begin --prompt "Tags> "'.s:q(a:query)}), a:000)
|
||||
endfunction
|
||||
|
||||
" ------------------------------------------------------------------
|
||||
|
|
|
@ -81,8 +81,8 @@ COMMANDS *fzf-vim-commands*
|
|||
`Ag [PATTERN]` | {ag}{5} search result (ALT-A to select all, ALT-D to deselect all)
|
||||
`Lines` | Lines in loaded buffers
|
||||
`BLines` | Lines in the current buffer
|
||||
`Tags` | Tags in the project ( `ctags -R` )
|
||||
`BTags` | Tags in the current buffer
|
||||
`Tags [QUERY]` | Tags in the project ( `ctags -R` )
|
||||
`BTags [QUERY]` | Tags in the current buffer
|
||||
`Marks` | Marks
|
||||
`Windows` | Windows
|
||||
`Locate PATTERN` | `locate` command output
|
||||
|
|
|
@ -50,8 +50,8 @@ call s:defs([
|
|||
\'command! -bang Colors call fzf#vim#colors(s:w(<bang>0))',
|
||||
\'command! -bang -nargs=1 -complete=dir Locate call fzf#vim#locate(<q-args>, s:w(<bang>0))',
|
||||
\'command! -bang -nargs=* Ag call fzf#vim#ag(<q-args>, s:w(<bang>0))',
|
||||
\'command! -bang Tags call fzf#vim#tags(s:w(<bang>0))',
|
||||
\'command! -bang BTags call fzf#vim#buffer_tags(s:w(<bang>0))',
|
||||
\'command! -bang -nargs=* Tags call fzf#vim#tags(<q-args>, s:w(<bang>0))',
|
||||
\'command! -bang -nargs=* BTags call fzf#vim#buffer_tags(<q-args>, s:w(<bang>0))',
|
||||
\'command! -bang Snippets call fzf#vim#snippets(s:w(<bang>0))',
|
||||
\'command! -bang Commands call fzf#vim#commands(s:w(<bang>0))',
|
||||
\'command! -bang Marks call fzf#vim#marks(s:w(<bang>0))',
|
||||
|
|
Loading…
Add table
Reference in a new issue