lspsaga.nvim icon indicating copy to clipboard operation
lspsaga.nvim copied to clipboard

Question: Keybinding to open lspsaga peek definition not working

Open nhussein11 opened this issue 2 years ago • 3 comments

Bug description

I have the following setup for lsp saga:

{
	"nvimdev/lspsaga.nvim",
	config = function()
		require("lspsaga").setup({})
		local opts = { noremap = true, silent = true }
		vim.keymap.set("n", "<leader>rn", ":Lspsaga rename<CR>")
		vim.keymap.set("n", "<leader>K", ":Lspsaga hover_doc<CR>")
		vim.keymap.set("n", "<leader>ca", ":Lspsaga code_action<CR>")
		vim.keymap.set("n", "<leader>gr", ":Lspsaga finder tyd+ref+imp+def<CR>")
		vim.keymap.set("n", "<leader>gd", ":Lspsaga peek_definition<CR>", opts)
		vim.keymap.set("n", "<leader>D", ":Lspsaga show_line_diagnostics<CR>")
		vim.keymap.set("n", "<leader>d", ":Lspsaga show_cursor_diagnostics<CR>")
	end,
	dependencies = {
		"nvim-treesitter/nvim-treesitter",
		"nvim-tree/nvim-web-devicons",
	},
}

I can effectively open a popup that shows a definition using gd, but when I want to maximize that popup in the current pane using the 'o' key, it automatically jumps to a new line under my cursor in insert mode. I've also tried oand many other alternatives.

Is there any way to set the behavior of the 'o' key only for that popup?

Steps to reproduce

  1. run Lspsaga peek_definition
  2. hit letter o or O, trying to open up the pop up and have it completely maximized in your current pane. There you will see that the only thing that will happen would be that your cursor will create a new line up/down your current line

Expected behavior

Have peek definition pop up completely maximized in your current pane

Neovim version (nvim -v)

0.9.5

lspsaga commit

2198c07124bef27ef81335be511c8abfd75db933

Terminal name/version

warp

nhussein11 avatar Feb 26 '24 01:02 nhussein11

Did you try this? This overrides default behavior of having to use <C-c>o to edit inside of the float. For me, using this override means o takes me to definition.

winter-again avatar Mar 03 '24 05:03 winter-again

Yes, however idk why when I press <C-c> I get that line erased before even being able to press o

nhussein11 avatar Mar 07 '24 12:03 nhussein11

Adding the following statement solved the problem for me:

      require("lspsaga").setup({
        definition = {
          keys = {
            edit = 'o'
          }
        }
      })

I had an issue with the configuration of my keyboard though, that's why this answer wasn't working.

Many thanks @winter-again !

nhussein11 avatar Mar 08 '24 18:03 nhussein11