Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure fennel-ls #134

Open
2 tasks
rktjmp opened this issue Apr 1, 2024 · 3 comments
Open
2 tasks

How to configure fennel-ls #134

rktjmp opened this issue Apr 1, 2024 · 3 comments

Comments

@rktjmp
Copy link
Owner

rktjmp commented Apr 1, 2024

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?)
@rktjmp rktjmp pinned this issue Apr 1, 2024
@rktjmp rktjmp changed the title Hot to configure fennel-ls How to configure fennel-ls Apr 1, 2024
@monkoose
Copy link

monkoose commented Apr 11, 2024

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
Copy link
Owner Author

rktjmp commented Apr 12, 2024

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants