-
-
Notifications
You must be signed in to change notification settings - Fork 584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fzf with arg or with word under cursor #50
Comments
Seems like the plugin is pretty extensible. I got it to work with fu! FzfTagsCurrWord()
let currWord = expand('<cword>')
if len(currWord) > 0
call fzf#vim#tags({'options': '-q ' . currWord})
else
execute ':Tags'
endif
endfu |
Nice, you can further simplify the code like follows, no need for if-else branch: call fzf#vim#tags({'options': '-q '.shellescape(expand('<cword>'))}) Note that call fzf#vim#tags({'options': '-q '.shellescape(expand('<cword>')), 'down': '~40%'}) Is there anything else you want to know? |
Cool! Is it possible to do this with :Ag too? Provide the word under cursor or a visual selection? |
This is what I have in my .vimrc. nnoremap <silent> <Leader>ag :Ag <C-R><C-W><CR> Looks like we can now close the issue. |
👍 |
@junegunn when I try your solution in nvim I get this error |
@junegunn ah, there we go. thank you! |
@junegunn : it's beautiful. |
Taking cues from this thread, I mapped over function! FzfTagsCurrentWord()
let l:word = expand('<cword>')
let l:list = taglist(l:word)
if len(l:list) == 1
execute ':tag ' . l:word
else
call fzf#vim#tags(l:word)
endif
endfunction
noremap <c-]> :call FzfTagsCurrentWord()<cr> |
Just adding for those preferring to search the current word in " map <Leader>+F to search in ag the word under the cursor
map <Leader>F :call fzf#vim#ag(expand('<cword>'))<kEnter> |
This is pretty awesome! Is there a way to have it show the preview like EDIT: I found that the following does show a preview :) nnoremap <silent><Leader>r :Rg <C-R><C-W><CR> |
Awesome! I stole your version! Why Edit: Oh, to use |
Here's what I ended up with to ripgrep for the token under the cursor (i.e. the whole word, not as a substring of another token): nnoremap <silent>+ :call fzf#vim#grep(
\ "rg --column --line-number --no-heading --color=always --smart-case -- "
\ . fzf#shellescape('\b'.expand('<cword>').'\b'),
\ fzf#vim#with_preview(), 0)<cr> (it's too bad there's no Line 63 in 1e054c1
|
Is it possible to call fzf or fzf#tags with the word under the cursor or pass an argument to fzf.vim so that it expands fzf with the argument? If not, how difficult would this be to implement?
The text was updated successfully, but these errors were encountered: