2

A plugin unidentified is setting the keywordprg option to :Man but I want it to be LSP based.

So I attempted

set keywordprg=:lua\ vim.lsp.buf.signature_help()

but it gives me the following error and I press K on a NOTE: it for some reason works with vimls but not with pyright of rust-analyzer keyword:

E5107: Error loading lua [string ":lua"]:1: '=' expected near '<eof>'

So how may I fix this error?

1
  • I found that the function which actually does this is vim.lsp.buf.hover() so mapped it but this would be nicer Commented Feb 25, 2022 at 12:39

1 Answer 1

2

The 'keywordprg' setting can take an Ex command (starting with :), but when it does, the Ex command needs to be able to take an argument, and you can't pass one to a Lua function using :lua that way.

The simplest way around this is to define a new user-defined command that calls the LSP function with the passed arguments and then use that in 'keywordprg'.

In your case of calling one of the LSP functions, it's a bit odd that those take into consideration the current location, rather than getting an argument with the term to look up... One alternative here would be to have the user-defined command just ignore its arguments and simply call the LSP function with no arguments at all.

For example:

command -nargs=+ LspHover lua vim.lsp.buf.hover()

And then you could use:

set keywordprg=:LspHover

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.