[[B]Lines] Default query as the optional argument

Close #143
This commit is contained in:
Junegunn Choi 2016-05-17 00:47:28 +09:00
parent 47806da408
commit 78c3d254ae
No known key found for this signature in database
GPG key ID: 254BC280FEF9C627
4 changed files with 15 additions and 11 deletions

View file

@ -56,8 +56,8 @@ Commands
| `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 |
| `Lines [QUERY]` | Lines in loaded buffers |
| `BLines [QUERY]` | Lines in the current buffer |
| `Tags [QUERY]` | Tags in the project (`ctags -R`) |
| `BTags [QUERY]` | Tags in the current buffer |
| `Marks` | Marks |

View file

@ -259,11 +259,13 @@ endfunction
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(fzf#vim#wrap({
\ 'source': lines,
\ 'sink*': s:function('s:line_handler'),
\ 'options': '+m --tiebreak=index --prompt "Lines> " --ansi --extended --nth='.nth.'.. --reverse --tabstop=1'
\}), a:000)
\ 'options': '+m --tiebreak=index --prompt "Lines> " --ansi --extended --nth='.nth.'.. --reverse --tabstop=1'.s:q(query)
\}), args)
endfunction
" ------------------------------------------------------------------
@ -289,11 +291,13 @@ function! s:buffer_lines()
endfunction
function! fzf#vim#buffer_lines(...)
let [query, args] = (a:0 && type(a:1) == type('')) ?
\ [a:1, a:000[1:]] : ['', a:000]
return s:fzf(fzf#vim#wrap({
\ 'source': s:buffer_lines(),
\ 'sink*': s:function('s:buffer_line_handler'),
\ 'options': '+m --tiebreak=index --prompt "BLines> " --ansi --extended --nth=2.. --reverse --tabstop=1'
\}), a:000)
\ 'options': '+m --tiebreak=index --prompt "BLines> " --ansi --extended --nth=2.. --reverse --tabstop=1'.s:q(query)
\}), args)
endfunction
" ------------------------------------------------------------------
@ -575,7 +579,7 @@ function! s:btags_sink(lines)
endfunction
function! s:q(query)
return ' --query "'.escape(a:query, '"').'"'
return ' --query "'.escape(a:query, '"\').'"'
endfunction
" query, [[tag commands], options]

View file

@ -80,8 +80,8 @@ COMMANDS *fzf-vim-commands*
`Buffers` | Open buffers
`Colors` | Color schemes
`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
`Lines [QUERY]` | Lines in loaded buffers
`BLines [QUERY]` | Lines in the current buffer
`Tags[QUERY]` | Tags in the project ( `ctags-R` )
`BTags[QUERY]` | Tags in the current buffer
`Marks` | Marks

View file

@ -45,8 +45,8 @@ call s:defs([
\'command! -bang -nargs=? -complete=dir Files call fzf#vim#files(<q-args>, s:w(<bang>0))',
\'command! -bang -nargs=? GitFiles call fzf#vim#gitfiles(<q-args>, s:w(<bang>0))',
\'command! -bang Buffers call fzf#vim#buffers(s:w(<bang>0))',
\'command! -bang Lines call fzf#vim#lines(s:w(<bang>0))',
\'command! -bang BLines call fzf#vim#buffer_lines(s:w(<bang>0))',
\'command! -bang -nargs=* Lines call fzf#vim#lines(<q-args>, s:w(<bang>0))',
\'command! -bang -nargs=* BLines call fzf#vim#buffer_lines(<q-args>, s:w(<bang>0))',
\'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))',