ojroques / nvim-lspfuzzy

A Neovim plugin to make the LSP client use FZF
BSD 2-Clause "Simplified" License
316 stars 11 forks source link

How to use fzf for lsp? #10

Closed TornaxO7 closed 3 years ago

TornaxO7 commented 3 years ago

So this is in your README.md file:

image

But I don't really understand what I have to do in order to be able to use FZF for searching symbols or references. Could you help me please?

ojroques commented 3 years ago

So if you want to use FZF for everything related to LSP (symbols, references, definitions etc) you should just add this to your config:

require('lspfuzzy').setup {}

Nothing more to do.

If you want to enable FZF only for some LSP functions such as code actions and prevent all other functions to use FZF, you can specify them using the method option:

require('lspfuzzy').setup {
  methods = ['textDocument/codeAction']   -- no LSP functions will use FZF except codeAction
}

I hope that's clear.

TornaxO7 commented 3 years ago

Yes, it works now, thank you!

alexzanderr commented 3 years ago

i have methods = all and i dont see any functions to find definition of preview references

require('lspfuzzy').setup {
  methods = 'all',         -- either 'all' or a list of LSP methods (see below)
  jump_one = true,         -- jump immediately if there is only one location
  callback = nil,          -- callback called after jumping to a location
  fzf_preview = {          -- arguments to the FZF '--preview-window' option
    'right:+{2}-/2'          -- preview on the right and centered on entry
  },
  fzf_action = {           -- FZF actions
    ['ctrl-t'] = 'tabedit',  -- go to location in a new tab
    ['ctrl-v'] = 'vsplit',   -- go to location in a vertical split
    ['ctrl-x'] = 'split',    -- go to location in a horizontal split
  },
  fzf_modifier = ':~:.',   -- format FZF entries, see |filename-modifiers|
  fzf_trim = true,         -- trim FZF entries
}

how do i actually call lsp functions for all of the methods? i dont see any example in your readme.

ojroques commented 3 years ago

Not sure I understood your issue correctly but if you want the plugin to be enabled for all LSP methods, you don't actually need to set anything (all is the default value of the methods option) so this should suffice:

require('lspfuzzy').setup {}

Does it solve your problem?

alexzanderr commented 3 years ago

if you say setting all is just like settings require('lspfuzzy').setup {} and there shouldnt be a problem, then why are you asking me to do the same thing?

ojroques commented 3 years ago

You don't have to do anything. The methods option is there is you want to enable the plugin only for some LSP methods, you can pass a list to it like so:

methods = {'textDocument/references', 'textDocument/documentSymbol'}

Otherwise if you want all LSP methods to use the plugin, which is the default, don't change anything just use:

require('lspfuzzy').setup {}