Problems with adding fennel-ls #333
Replies: 2 comments 1 reply
-
This is actually not making a ton of sense to me yet with the info I have right now. The spec you showed (which, in isolation looks correct, it should load the lsp, the configuration for the lsp for fennel is handled in a separate file or by nfnl or aniseed) {
"fennel_ls",
for_cat = "fennel",
lsp = {
filetypes = { "fennel" },
},
},The lsp field comes from the lsp handler from lzextras It is added to the example configuration here: The thing which is confusing to me, is that the lsp handler disables the default load hook for specs with the lsp field. So that error shouldn't be possible given the spec you showed if the handler is registered prior to that call to lze.load? What the lsp handler does is allows you to easily use lze to lazily setup your lsps on that specific filetype (or other trigger). Calling vim.lsp.enable on a bunch of lsps at startup can be heavy because each call has to search the rtp for lsp/*.lua files, so this allows you to easily delay that until they are needed, without needing to put each one in their own ftplugin file and/or set up your own autocommand system for them You define a spec with lsp field as a function, and the lsp function fields get ran for all specs where lsp field is a table. require('lze').register_handlers(require('lzextras').lsp)
require('lze').load {
{
"nvim-lspconfig",
lsp = function(plugin) -- <- this gets ran for all specs with an lsp field of a non-function type
vim.lsp.config(plugin.name, plugin.lsp or {})
vim.lsp.enable(plugin.name)
end,
before = function(_) -- <- the rest of the spec is only ran when loading nvim-lspconfig spec as normal
vim.lsp.config('*', {
on_attach = require('LSPs.on_attach'),
})
end,
},
{
"bashls",
lsp = { -- <-- this will cause the lsp handler to modify the spec, removing the default load field and instead running the lsp function fields.
filetypes = { "bash", "sh" },
},
},
{
"fennel_ls",
lsp = {
filetypes = { "fennel" },
},
},
}This should work as long as it is added to your path, which, if you put it in lspsAndRuntimeDeps and then made sure the category was enabled, then it should be. Also if you wanted to see how to set up lsps without the lsp handler https://github.com/BirdeeHub/nixCats-nvim/blob/main/templates/simple/plugin/lsp.lua There's an example of that also As long as the lsp is in the path for that instance, either via nixCats or some other way, both of the ways should work |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for your help! fennel-ls works when im loading it with load. I still don't understand why... |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi
I'm trying to add fennel-ls to the starter nixcats template. Now i always get the error:
E5108: Error executing lua ...ck-dir/pack/myNeovimPackages/start/lze/lua/lze/h/cmd.lua:19:
Invalid command name: 'fennel-ls'
In flake.nix i added:
and in lua/myLuaConf/LSPs/init.lua:
{
"fennel-ls",
-- enabled = true;
cmd = { "fennel-ls" },
for_cat = "fennel",
-- if you don't provide the filetypes it asks lspconfig for them
lsp = {
filetypes = { "fennel" },
},
},
What do i miss? If i leave the cmd empty i get a: Failed to run 'load' hook for fennel-ls: Vim:E919: Di
rectory not found in 'packpath': "pack/*/opt/fennel-ls".
Beta Was this translation helpful? Give feedback.
All reactions