mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-04-27 11:55:22 +00:00
34 lines
895 B
Nix
34 lines
895 B
Nix
{
|
|
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
|
|
'';
|
|
};
|
|
};
|
|
}
|