A fork of https://git.sr.ht/~xerool/fennel-ls/ for development purposes
Go to file
2022-08-07 18:47:18 -05:00
src find definition is more advanced but more brittle 2022-08-07 18:47:18 -05:00
test find definition is more advanced but more brittle 2022-08-07 18:47:18 -05:00
.gitignore reduce the prevelance of penlight 2022-08-01 18:21:27 -05:00
fennel find definition is more advanced but more brittle 2022-08-07 18:47:18 -05:00
fennel.lua find definition is more advanced but more brittle 2022-08-07 18:47:18 -05:00
file.fnl find definition is more advanced but more brittle 2022-08-07 18:47:18 -05:00
LICENSE More progress 2022-07-30 01:30:01 -05:00
Makefile find definition is more advanced but more brittle 2022-08-07 18:47:18 -05:00
README.md find definition is more advanced but more brittle 2022-08-07 18:47:18 -05:00
test.fnl find definition is more advanced but more brittle 2022-08-07 18:47:18 -05:00

fennel-ls

TO PROSPECTIVE USERS: THIS PROJECT IS NOT IN A USABLE STATE YET. CHECK BACK LATER.

A language server for fennel-ls.

Features / To Do List / Things I would enjoy patches for:

  • Able to connect to a client

  • Support for UTF-8 characters that aren't just plain ASCII. (especially λ)

  • Settings to configure lua / fennel path, allowed globals, etc

  • Builds for anything other than arch linux

  • Go-to-definition

    • directly on require statements
    • for definitions in the same file
    • for definitions in other files
    • follows multisyms through table constructor
    • follows multisyms through mutations (difficult)
    • for methods/metamethods (difficult, in the general case may require type annotations or some insane global type inference logic)
    • into lua files (maybe cheeseable with antifennel if it has --correlate?)
  • Reports compiler errors

    • including in macro files
  • Reports linting issues

  • Completion Suggestions

  • Hover over a symbol for documentation

  • Signature help

  • Go-to-references on definition sites

  • integration with fnlfmt

  • Maybe some sort of type checking??

Setup:

You can match my environment to develop with the following steps.

  1. Install luafilesystem
# On Arch linux, this can be done with pacman:
sudo pacman -S lua-filesystem
  1. Build the binary
make
  1. Configure your editor to use this language server

So far, I've only ever tested it with Neovim using the native language client and lspconfig. If you know what that means, here's the relevant code to help you set up Neovim in the same way:

local lspconfig = require('lspconfig')
-- inform lspconfig about fennel-ls
require("lspconfig.configs")["fennel-ls"] = {
    default_config = {
        cmd = {"/path/to/fennel-ls/fennel-ls"},
        filetypes = {"fennel"},
        root_dir = function(dir) return lspconfig.util.find_git_ancestor(dir) end,
        settings = {}
    }
}
-- setup fennel-ls
-- If you're using a completion system like nvim-cmp, you probably need to modify this line.
lspconfig["fennel-ls"].setup(
    vim.lsp.protocol.make_client_capabilities()
)

Caveats

Until I change this readme, you can assume that this project is incomplete and not meant to be used.

So far, I am only testing this project with Neovim. Since Neovim also uses Lua, there may be instances where fennel-ls encodes JSON incorrectly which may be compatible with Neovim, but not other editors. (ie, a json field that is supposed to be null may be missing, or [] and {} may be conflated). User beware!

If you want to help fix this, ./src/fennel-ls/message.fnl is where messages are being constructed, and ./src/fennel-ls/json-rpc.fnl is where messages are being converted to json. I suspect a different json library will be necessary.

License

fennel-ls is licensed under the MIT license. See LICENSE for more info. However, this project contains files from other projects:

fennel-ls's license does not apply to these files; check those projects for their respective code licenses.