Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set keymaps overwrites mapping of :help #439

Closed
rowsephx opened this issue Aug 15, 2022 · 6 comments
Closed

set keymaps overwrites mapping of :help #439

rowsephx opened this issue Aug 15, 2022 · 6 comments

Comments

@rowsephx
Copy link

I have the lspsaga hover set to K, and it only attaches during lsp:

M.on_attach = function(client, bufnr)
    local map = vim.keymap.set
    local bufopts = { noremap = true, silent = true, buffer = bufnr }

    map("n", "K", require("lspsaga.hover").render_hover_doc, { desc = "lsp hover" }, bufopts)

The problem is if the keymap gets attached, the K inside help no longer works. If you don't know what I'm referring to, check :h K

This only happens when I use lspsaga's hover, and not with vim.lsp.buf.hover. I can technically just use this, but it takes up the whole width of my window if the content is lengthy, which bothers me. I can also just bind the hover with a different key, but I'm already used to using K.

Related:
lewis6991/hover.nvim#1
neovim/neovim#18997

@glepnir
Copy link
Member

glepnir commented Aug 15, 2022

so you can use that function in hover#1 just check the current filetype is help or not

@rowsephx
Copy link
Author

use that function in hover#1 just check the current filetype is help or not

Oh my, I'm blind...

map('n', 'K', function()
    if vim.bo.filetype == 'help' then
        vim.api.nvim_feedkeys('K', 'ni', true)
    end
    require("lspsaga.hover").render_hover_doc()
end, { desc = "lsp hover" }, bufopts)

Dunno if this is the best way of doing it, what do you think?

@glepnir
Copy link
Member

glepnir commented Aug 15, 2022

right. which keyowordprg you set or default?

@rowsephx
Copy link
Author

which keyowordprg you set or default?

I haven't touch that, so I would assume default

@glepnir
Copy link
Member

glepnir commented Aug 15, 2022

aha. okay. maybe we can add this function into default hover function . then no need this hack.

@rowsephx
Copy link
Author

aha. okay. maybe we can add this function into default hover function . then no need this hack.

That would be great actually, makes the config file cleaner hehe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants