A fork of https://git.sr.ht/~xerool/fennel-ls/ for development purposes
Go to file
2022-08-20 16:07:14 -05:00
src refactoring and README update 2022-08-20 16:07:14 -05:00
test Refactor 2022-08-19 09:43:58 -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
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 refactoring and README update 2022-08-20 16:07:14 -05:00

fennel-ls

A language server for fennel-ls. Uses static analysis, and doesn't actually run your code, which makes it perfect for analyzing your (os.execute "rm -rf") code. If you want live analysis of your code as it runs, consider using a REPL.

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 understands:
    • literal table constructor
    • table destructuring
    • require
    • multisyms
    • . builtin (when called with constants)
    • macros (a little bit)
    • lua files
    • setmetatable
    • function arguments / function calls
  • Reports compiler errors
    • including in macro files
  • Reports linting issues
  • Completion Suggestions
  • Hover over a symbol for documentation
  • Signature help
  • Go-to-references
  • rename
  • formatting with fnlfmt
  • Maybe some sort of type checking???

{field: {}}

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.