Skip to content

[idea] Expand LSP keymaps — hover, rename, code action, signature help #38

Description

@stanfish06

What

The config currently maps only gd (definition) and gr (references) for LSP. The other high-value LSP actions — hover docs, rename, code action, and insert-mode signature help — have no keymaps and are only reachable via :lua vim.lsp.buf.*().

Where

lua/config/plugin_config.lua — inside a LspAttach autocmd (as already recommended in issue #27).

Why it matters

With six active LSPs (lua, python, c/cpp, ts/js, rust, go, swift), these operations are used constantly. Without keymaps they're effectively inaccessible. K for hover is the Neovim convention (it already falls back to keywordprg in non-LSP buffers so a buffer-local binding is safe). Rename and code action are unavailable any other way.

Suggested keymaps

vim.api.nvim_create_autocmd("LspAttach", {
    callback = function(ev)
        local opts = { buffer = ev.buf }
        -- navigation (see also issue #27)
        vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
        vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
        -- hover / signature
        vim.keymap.set("n", "K",       vim.lsp.buf.hover,          opts)
        vim.keymap.set("i", "<C-k>",   vim.lsp.buf.signature_help, opts)
        -- edit
        vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename,       opts)
        vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action,  opts)
        -- workspace
        vim.keymap.set("n", "<leader>D",  vim.lsp.buf.type_definition, opts)
    end,
})

<leader>rn / <leader>ca are free in the current keymap and follow the convention used by most Neovim starter configs. K is buffer-local so it only overrides the built-in keywordprg lookup in LSP-attached buffers.

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions