rktjmp / hotpot.nvim

:stew: Carl Weathers #1 Neovim Plugin.
MIT License
361 stars 10 forks source link

How to configure fennel-ls #134

Open rktjmp opened 8 months ago

rktjmp commented 8 months ago

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,
})
monkoose commented 7 months ago

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.

rktjmp commented 7 months ago

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.

Joao-Queiroga commented 5 months ago

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.