Nvim lua custom source?
- [x] I have fzf 0.23.0 or above
- [x] I have read through https://github.com/junegunn/fzf.vim/blob/master/README.md
- [x] I have read through https://github.com/junegunn/fzf/blob/master/README-VIM.md
- [x] I have read through the manual page of fzf (
man fzf) - [x] I have searched through the existing issues
I wasn't able to find any examples of filtering results returned from the nvim's lua api...
Can someone please point me to any source or example integrationg fzf with lua?
The actual point is - I'm using fzf#vim all the time, and would like to search through vim.lsp.diagnostic.get_all()
I have developed a Neovim plugin in Lua that makes the LSP client use FZF: nvim-lspfuzzy. If you're interested only in the part where I integrate FZF, here are the relevant functions.
There are basically two functions: fzf() calls FZF and feeds it with lines and jump() is the sink function that gets called when the user has made its selection. Hope that'll help.
thanks! but i would wait for maybe solution from fzf, cause if choosing new plugin i can use something like telescope :)
Sorry to resurrect a zombie issue. I recently encountered the same problem and ended up with a solution that's good enough for me.
local function fzf_table(sources)
table.foreach(sources, function (k, v) sources[k] = vim.fn.shellescape(v) end)
local query = table.concat(sources, ' ')
vim.fn['fzf#vim#grep']("rg --column --line-number --no-heading --color=always --smart-case -g '*.lean' -- '' " .. query, 1, vim.fn['fzf#vim#with_preview'](), 0)
end
The gist is that vim.fn can call a Vim function from Lua. The command is adapted from the built-in :Rg. This function accepts a list of directories from Lua and run fzf#vim#with_preview similar to :Rg.
Note that:
- A
-gfilter is used for globbing files. You might want to change/abstract it for your use case. - The second argument to
fzf#vim#grep,has_column, is deprecate. You might need to change it according to your version.