Install using vim-plug.
Put this in your init.vim.
Plug 'gfanto/fzf-lsp.nvim'
Plug 'nvim-lua/plenary.nvim'- Neovim 0.5+
fzfinstalled in addition to use this plugin. See https://github.com/junegunn/fzf/blob/master/README-VIM.md#installation.batinstalled for the preview. See https://github.com/sharkdp/bat
This 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 ofg:fzf_action, it's a dictionary containing all the actions that fzf will do in case of specific inputg:fzf_lsp_layout: the equivalent ofg:fzf_layout, dictionary with the fzf_window layoutg:fzf_lsp_colors: the equivalent ofg:fzf_colors, it's a string that will be passed to fzf to set colorsg:fzf_lsp_preview_window: the equivalent ofg:fzf_preview_window, it's a list containing the preview windows position and key bindingsf:fzf_lsp_command_prefix: the equivalent ofg:fzf_command_prefix, it's the prefix applied to all commands
fzf-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 eitherv:trueorv:false)
*** Commands accepts and respect the ! if given ***
- Call
:Definitionsto show the definition for the symbols under the cursor - Call
:Declarationsto show the declaration for the symbols under the cursor* - Call
:TypeDefinitionsto show the type definition for the symbols under the cursor* - Call
:Implementationsto show the implementation for the symbols under the cursor* - Call
:Referencesto show the references for the symbol under the cursor - Call
:DocumentSymbolsto show all the symbols in the current buffer - Call
:WorkspaceSymbolsto show all the symbols in the workspace, you can optionally pass the query as argument to the command - Call
:IncomingCallsto show the incoming calls - Call
:OutgoingCallsto show the outgoing calls - Call
:CodeActionsto show the list of available code actions - Call
:RangeCodeActionsto show the list of available code actions in the visual selection - Call
:Diagnosticsto 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 - Call
:DiagnosticsAllto 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 argument
Note(*): 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_callrequire'fzf_lsp'.range_code_action_callrequire'fzf_lsp'.definition_callrequire'fzf_lsp'.declaration_callrequire'fzf_lsp'.type_definition_callrequire'fzf_lsp'.implementation_callrequire'fzf_lsp'.references_callrequire'fzf_lsp'.document_symbol_callrequire'fzf_lsp'.workspace_symbol_call- options:
- query
- options:
require'fzf_lsp'.incoming_calls_callrequire'fzf_lsp'.outgoing_calls_callrequire'fzf_lsp'.diagnostic_call- options:
- bufnr: the buffer number, default on current buffer
- severity: the minimum severity level
- severity_limit: the maximum severity level
- options:
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_handlerThe 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+)