hotpot.nvim
hotpot.nvim copied to clipboard
How to configure fennel-ls
See comment by fennel-ls author: https://github.com/rktjmp/hotpot.nvim/issues/134#issuecomment-2770341836
Guide assumes you're using lspconfig.
By default, fennel-ls does not include fnl/ directories in its module and
macro search paths.
You may either pass updated paths as options to fennel-ls, via
settings.fennel-ls.macro-path|fennel-path or (IMO, the simpler way)
set fnl/ as the root_dir for the lsp server, as shown below.
The root_dir option is a function, which receives the current buffer file path.
vim.fs.find searches from this file path upwards through the tree until it
finds a directory named fnl or .git and returns a list of matching paths
(by default limited to only the first match). By fetching the first element, we
return the path .../fnl/ or nil if there is no match.
We also set "vim" as a valid global variable.
Below is an example configuration to pass to lspconfig.fennel_ls.setup():
{:cmd [(vim.fn.expand "~/your/path/to/fennel-ls")]
:root_dir #(. (vim.fs.find [:fnl :.git] {:upward true :type :directory :path $}) 1)
:settings {:fennel-ls {:extra-globals "vim"}}
Additionally you may want to disable hotpots own diagnostics as fennel-ls should provide the same errors along with additional linting. There should be no negative impact in keeping both enabled, besides the repeated error reporting.
require("hotpot").setup({
enable_hotpot_diagnostics = false,
})
- [ ] Fold into documentation
- [ ] Example autocommand to disable diagnostics on fennel files that the LSP attaches to (vs unnamed buffers with fennel ft?)
With such a config, jump to definition (in another file under the same fnl/ directory) is working?
I have tried to make it work in the past with no success.
I'm not sure if fennel-ls supports jump to definition, but if it does I imagine it will help it work since it could then find the correct files.
Do you know how to add the lua runtime paths to fennel-ls? It would be nice to have completion for plugins and the neovim api.