nvimdev / lspsaga.nvim

improve neovim lsp experience
MIT License
3.41k stars 287 forks source link

Question: Keybinding to open lspsaga peek definition not working #1400

Closed nhussein11 closed 5 months ago

nhussein11 commented 6 months ago

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

winter-again commented 5 months ago

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.

nhussein11 commented 5 months ago

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

nhussein11 commented 5 months ago

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 !