Install using vim-plug.
Put this in your init.vim
.
Plug 'gfanto/fzf-lsp.nvim'
Plug 'nvim-lua/plenary.nvim'
fzf
installed in addition to use this plugin. See https://github.com/junegunn/fzf/blob/master/README-VIM.md#installation.bat
installed for the preview. See https://github.com/sharkdp/batThis is an extension for fzf that give you the ability to search for symbols using the neovim builtin lsp.
If you have fzf.vim installed,
this plugin will respect your g:fzf_command_prefix
setting.
In general fzf-lsp.vim will respect your fzf.vim settings, alternatively you can override a specific settings with the fzf-lsp.vim equivalent:
g:fzf_lsp_action
: the equivalent of g:fzf_action
, it's a dictionary containing all the actions that fzf will do in case of specific inputg:fzf_lsp_layout
: the equivalent of g:fzf_layout
, dictionary with the fzf_window layoutg:fzf_lsp_colors
: the equivalent of g:fzf_colors
, it's a string that will be passed to fzf to set colorsg:fzf_lsp_preview_window
: the equivalent of g:fzf_preview_window
, it's a list containing the preview windows position and key bindingsf:fzf_lsp_command_prefix
: the equivalent of g:fzf_command_prefix
, it's the prefix applied to all commandsfzf-lsp.vim only settings:
g:fzf_lsp_timeout
: integer value, number of milliseconds after command calls will go to timeoutg:fzf_lsp_width
: integer value, max width per line, used to truncate the current lineg:fzf_lsp_pretty
: boolean value, select the line format, default is false
(at the moment since the value is process by lua it cannot be used as a
standard vim boolean value, but it must be either v:true
or v:false
)*** Commands accepts and respect the ! if given ***
:Definitions
to show the definition for the symbols under the cursor:Declarations
to show the declaration for the symbols under the cursor*:TypeDefinitions
to show the type definition for the symbols under the cursor*:Implementations
to show the implementation for the symbols under the cursor*:References
to show the references for the symbol under the cursor:DocumentSymbols
to show all the symbols in the current buffer:WorkspaceSymbols
to show all the symbols in the workspace, you can optionally pass the query as argument to the command:IncomingCalls
to show the incoming calls:OutgoingCalls
to show the outgoing calls:CodeActions
to show the list of available code actions:RangeCodeActions
to show the list of available code actions in the visual selection:Diagnostics
to show all the available diagnostic informations in the current buffer, you can optionally pass the desired severity level as first argument or the severity limit level as second argument:DiagnosticsAll
to show all the available diagnostic informations in all the opened buffers, you can optionally pass the desired severity level as first argument or the severity limit level as second argumentNote(*): this methods may not be implemented in your language server, especially textDocument/declaration (Declarations
) it's usually not implemented in favour of textDocument/definition (Definitions
).
Commands are just wrappers to the following function, each function take one optional parameter: a dictionary containing the options.
require'fzf_lsp'.code_action_call
require'fzf_lsp'.range_code_action_call
require'fzf_lsp'.definition_call
require'fzf_lsp'.declaration_call
require'fzf_lsp'.type_definition_call
require'fzf_lsp'.implementation_call
require'fzf_lsp'.references_call
require'fzf_lsp'.document_symbol_call
require'fzf_lsp'.workspace_symbol_call
require'fzf_lsp'.incoming_calls_call
require'fzf_lsp'.outgoing_calls_call
require'fzf_lsp'.diagnostic_call
Functions and commands are implemented using sync calls, if you want your calls to be async you can use the standard neovim calls setting his relative handler.
To do that you can use the provided setup
function, keeping in mind that this will replace all your handlers:
require'fzf_lsp'.setup()
or you can manually setup your handlers. The provided handlers are:
vim.lsp.handlers["textDocument/codeAction"] = require'fzf_lsp'.code_action_handler
vim.lsp.handlers["textDocument/definition"] = require'fzf_lsp'.definition_handler
vim.lsp.handlers["textDocument/declaration"] = require'fzf_lsp'.declaration_handler
vim.lsp.handlers["textDocument/typeDefinition"] = require'fzf_lsp'.type_definition_handler
vim.lsp.handlers["textDocument/implementation"] = require'fzf_lsp'.implementation_handler
vim.lsp.handlers["textDocument/references"] = require'fzf_lsp'.references_handler
vim.lsp.handlers["textDocument/documentSymbol"] = require'fzf_lsp'.document_symbol_handler
vim.lsp.handlers["workspace/symbol"] = require'fzf_lsp'.workspace_symbol_handler
vim.lsp.handlers["callHierarchy/incomingCalls"] = require'fzf_lsp'.incoming_calls_handler
vim.lsp.handlers["callHierarchy/outgoingCalls"] = require'fzf_lsp'.outgoing_calls_handler
The setup
function optionally takes a table for configuration.
Available options:
override_ui_select
: boolean option to override the vim.ui.select function (only for neovim 0.6+)