lsp/presets/elixir-ls: init

This commit is contained in:
Snoweuph 2026-04-12 14:58:15 +02:00
commit 094d56b7ee
No known key found for this signature in database
GPG key ID: BEFC41DA223CEC55
2 changed files with 35 additions and 0 deletions

View file

@ -6,6 +6,7 @@
./basedpyright.nix
./bash-language-server.nix
./deno.nix
./elixir-ls.nix
./elm-language-server.nix
./emmet-ls.nix
./fsautocomplete.nix

View file

@ -0,0 +1,34 @@
{
config,
lib,
pkgs,
...
}: let
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption;
inherit (lib.generators) mkLuaInline;
cfg = config.vim.lsp.presets.elixir-ls;
in {
options.vim.lsp.presets.elixir-ls = {
enable = mkEnableOption "the Elixir Language Server";
};
config = mkIf cfg.enable {
vim.lsp.servers.elixir-ls = {
enable = true;
cmd = [(getExe pkgs.elixir-ls)];
root_dir = mkLuaInline ''
function(bufnr, on_dir)
local fname = vim.api.nvim_buf_get_name(bufnr)
local matches = vim.fs.find({ 'mix.exs' }, { upward = true, limit = 2, path = fname })
local child_or_root_path, maybe_umbrella_path = unpack(matches)
local root_dir = vim.fs.dirname(maybe_umbrella_path or child_or_root_path)
on_dir(root_dir)
end
'';
};
};
}