Use pylsp as provider
Is there any easy way to set pylsp as provider? I seen in readme that it is possible to make custom provider, but sadly I doesnt know lua at all.
Hey, Thanks for the request. I am not familiar with pylsp, but if you setup your neovim to work with pylsp (e.g. autocompletion or hover works with the built-in hover window), it should work out of the box with hovercraft.nvim.
Is there any particular issue you are facing?
Hover window never appeared for me so I guess there something to do with providers
Interesting! I just tried it locally and for me it appears to be working fine hm.
Can you maybe share a minimal example of your dotfiles + some project where you experience the problem?
The reason the window never shows up, is that the LSP is probably never responding. Maybe some kind of timeout would be a good idea.
I just copied setup to my init.lua file, checked that it is was visible in lazy menu and created new .py to test it out, but nothing happened. Also after starting nvim there is text "No active providers for line!" at the bottom, is that important or not?
Can you maybe share your init.lua file?
init.lua.txt github doesnt allow lua files so I changed extension to txt
Ah I see, you are missing the LSP setup path in nvim. I would recommend having a look at how kickstarter.nvim is doing the setup here.
So I need to copy that code from line 454 to line 666 into my init.lua? Tried that out, but it doesnt seem to help. Could you please explain what is lsp setup path, I dont know lua so it is hard for me to understand how it works.
It seems as if you are new to neovim and therefore I would highly recommend you to read up on the documentation. In the end, the lines you copied on its own will not install any LSP, it will only configure mason.nvim, as well as nvim-lspconfig. You can now run the :Mason command and install pylsp via it. After that you should have the LSP setup.
Overall, I would recommend taking a closer look at kickstarter.nvim and maybe even consider basing your whole config on it.
I think there is some misunderstanding, I have working python lsp in neovim, also I had hover.nvim before and it worked in term of displaying hover window, but there was issue when wrong documentation showed up, so I tried hovercraft and this all started. In summary whole issue is that in same conditions that hover.nvim works, hovercraft doesnt. Sorry for misleading issue title.
Ah ok! Which version of neovim are you using?
0.10
Sorry for the very late response, is the problem still there?
I am pretty sure it is caused by the LSP not being fully initialised and hence will hang when calling the lsp util method to get the data back (here).
Don't know if it's the same issue, but in my case I think the LSP is taking over the keymap during BufferNew or other events. Thus hovercraft doesn't get a chance to bind K again. I'm using LazyVim
Do you by any chance have a minimal example config for me to test this?
I've tried this simple LazyVim installation
.config/nvim/init.lua
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
spec = {
{ "LazyVim/LazyVim", import = "lazyvim.plugins", opts = { colorscheme = "catppuccin" } },
{ import = "plugins/hovercraft" }, -- import/override with your plugins
},
defaults = { lazy = false, version = false },
install = { colorscheme = { "tokyonight", "catppuccin" } },
checker = { enabled = true }, -- automatically check for plugin updates
performance = {
rtp = {
disabled_plugins = {
"gzip",
"netrwPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
})
hovercraft configuration
return {
'patrickpichler/hovercraft.nvim',
dependencies = {
{ 'nvim-lua/plenary.nvim' },
},
debug = true,
-- this is the default config and can be skipped
opts = {
providers = {
providers = {
{ 'lsp', function() return require('hovercraft.provider.lsp.hover') end },
{ 'man', function() return require('hovercraft.provider.man') end },
{ 'dict', function() return require('hovercraft.provider.dictionary') end },
}
},
window = { border = 'single', },
keys = {
{ '<C-u>', function() require('hovercraft').scroll({ delta = -4 }) end },
{ '<C-d>', function() require('hovercraft').scroll({ delta = 4 }) end },
{ '<C-n>', function() require('hovercraft').hover_next() end },
{ '<C-p>', function() require('hovercraft').hover_next({ step = -1 }) end },
}
},
event = 'VeryLazy',
keys = {
{
"<leader>k", function()
local hovercraft = require("hovercraft")
if hovercraft.is_visible() then
hovercraft.enter_popup()
else
hovercraft.hover()
end
end,
desc = 'Hovercraft keywords'
},
},
}
I don't get anything even when calling :lua require('hovercraft').hover() directly, although the plugin appear as loaded
I managed to reproduce the issue with lazy. I am on vacation this week though and will have a look at it next weekend!
Alright, I found the issue @msoares1979. The config needs to look like this:
return {
'patrickpichler/hovercraft.nvim',
dependencies = {
{ 'nvim-lua/plenary.nvim' },
},
debug = true,
-- this is the default config and can be skipped
opts = function() -- <-- sadly we need to use a function here
return {
providers = {
providers = {
{ 'lsp', require('hovercraft.provider.lsp.hover').new() }, -- <-- we need to use the .new() constructor of the provider, as functions have special meanings (i will rework this part probably)
{ 'man', require('hovercraft.provider.man').new() },
{ 'dict', require('hovercraft.provider.dictionary').new() },
}
},
window = { border = 'single', },
keys = {
{ '<C-u>', function() require('hovercraft').scroll({ delta = -4 }) end },
{ '<C-d>', function() require('hovercraft').scroll({ delta = 4 }) end },
{ '<C-n>', function() require('hovercraft').hover_next() end },
{ '<C-p>', function() require('hovercraft').hover_next({ step = -1 }) end },
}
}
end,
event = 'VeryLazy',
keys = {
{
"<leader>k",
function()
local hovercraft = require("hovercraft")
if hovercraft.is_visible() then
hovercraft.enter_popup()
else
hovercraft.hover()
end
end,
desc = 'Hovercraft keywords'
},
},
}
This brings up a good point though, as this is not best practice on how to configure a plugin via lazy. I need to rethink the configuration a bit. Thanks for raising the issue!
I will close this issue. Feel free to reopen it, if needed.