feat: use elixir-tools.nvim for additional highlighting

This commit is contained in:
NotAShelf 2023-04-15 22:51:13 +03:00
parent 7a20488c05
commit 3071c6bb4b
No known key found for this signature in database
GPG key ID: F0D14CCB5ED5AA22
9 changed files with 112 additions and 3 deletions

View file

@ -337,6 +337,22 @@
"type": "github" "type": "github"
} }
}, },
"elixir-tools": {
"flake": false,
"locked": {
"lastModified": 1681453321,
"narHash": "sha256-7QgWrdq4p5t8WVnFhL5P948JFPR0i2C06kisxl30D2U=",
"owner": "elixir-tools",
"repo": "elixir-tools.nvim",
"rev": "8ccb696c048eca667486ee005f4386c0db8c5e14",
"type": "github"
},
"original": {
"owner": "elixir-tools",
"repo": "elixir-tools.nvim",
"type": "github"
}
},
"fidget-nvim": { "fidget-nvim": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -1336,6 +1352,7 @@
"diffview-nvim": "diffview-nvim", "diffview-nvim": "diffview-nvim",
"dressing-nvim": "dressing-nvim", "dressing-nvim": "dressing-nvim",
"elixir-ls": "elixir-ls", "elixir-ls": "elixir-ls",
"elixir-tools": "elixir-tools",
"fidget-nvim": "fidget-nvim", "fidget-nvim": "fidget-nvim",
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",

View file

@ -153,6 +153,11 @@
flake = false; flake = false;
}; };
elixir-tools = {
url = "github:elixir-tools/elixir-tools.nvim";
flake = false;
};
# Copying/Registers # Copying/Registers
registers = { registers = {
url = "github:tversteeg/registers.nvim"; url = "github:tversteeg/registers.nvim";

View file

@ -80,6 +80,7 @@ with lib; let
"smartcolumn" "smartcolumn"
"project-nvim" "project-nvim"
"elixir-ls" "elixir-ls"
"elixir-tools"
]; ];
# You can either use the name of the plugin or a package. # You can either use the name of the plugin or a package.
pluginsType = with types; pluginsType = with types;

View file

@ -344,7 +344,7 @@ in {
${writeIf cfg.elixir.enable '' ${writeIf cfg.elixir.enable ''
lspconfig.elixirls.setup { lspconfig.elixirls.setup {
cmd = { "${pkgs.elixir-ls}/language_server.sh" }, cmd = { "${lib.getExe pkgs.elixir-ls}" },
on_attach = on_attach on_attach = on_attach
} }
''} ''}

View file

@ -11,7 +11,8 @@
./lsp-signature ./lsp-signature
./lightbulb ./lightbulb
# flutter-tools # language specific modules
./flutter-tools-nvim ./flutter-tools-nvim # dart & flutter
./elixir # elixir
]; ];
} }

View file

@ -0,0 +1,67 @@
{
config,
lib,
pkgs,
...
}:
with lib;
with builtins; let
cfg = config.vim.lsp.elixir;
in {
config = mkIf (cfg.enable) {
vim.startPlugins = [
"elixir-tools"
"plenary-nvim"
];
vim.luaConfigRC.elixir-tools = nvim.dag.entryAnywhere ''
local elixir = require("elixir")
local elixirls = require("elixir.elixirls")
elixir.setup {
elixirls = {
-- alternatively, point to an existing elixir-ls installation (optional)
-- not currently supported by elixirls, but can be a table if you wish to pass other args `{"path/to/elixirls", "--foo"}`
cmd = "${lib.getExe pkgs.elixir-ls}",
-- default settings, use the `settings` function to override settings
settings = elixirls.settings {
dialyzerEnabled = true,
fetchDeps = false,
enableTestLenses = false,
suggestSpecs = false,
},
on_attach = function(client, bufnr)
local map_opts = { buffer = true, noremap = true}
-- run the codelens under the cursor
vim.keymap.set("n", "<space>r", vim.lsp.codelens.run, map_opts)
-- remove the pipe operator
vim.keymap.set("n", "<space>fp", ":ElixirFromPipe<cr>", map_opts)
-- add the pipe operator
vim.keymap.set("n", "<space>tp", ":ElixirToPipe<cr>", map_opts)
vim.keymap.set("v", "<space>em", ":ElixirExpandMacro<cr>", map_opts)
-- bindings for standard LSP functions.
vim.keymap.set("n", "<space>df", "<cmd>lua vim.lsp.buf.format()<cr>", map_opts)
vim.keymap.set("n", "<space>gd", "<cmd>lua vim.diagnostic.open_float()<cr>", map_opts)
vim.keymap.set("n", "<space>dt", "<cmd>lua vim.lsp.buf.definition()<cr>", map_opts)
vim.keymap.set("n", "<space>K", "<cmd>lua vim.lsp.buf.hover()<cr>", map_opts)
vim.keymap.set("n", "<space>gD","<cmd>lua vim.lsp.buf.implementation()<cr>", map_opts)
vim.keymap.set("n", "<space>1gD","<cmd>lua vim.lsp.buf.type_definition()<cr>", map_opts)
-- keybinds for fzf-lsp.nvim: https://github.com/gfanto/fzf-lsp.nvim
-- you could also use telescope.nvim: https://github.com/nvim-telescope/telescope.nvim
-- there are also core vim.lsp functions that put the same data in the loclist
vim.keymap.set("n", "<space>gr", ":References<cr>", map_opts)
vim.keymap.set("n", "<space>g0", ":DocumentSymbols<cr>", map_opts)
vim.keymap.set("n", "<space>gW", ":WorkspaceSymbols<cr>", map_opts)
vim.keymap.set("n", "<leader>d", ":Diagnostics<cr>", map_opts)
end
}
}
'';
};
}

View file

@ -0,0 +1,6 @@
_: {
imports = [
./config.nix
./elixir-tools.nix
];
}

View file

@ -0,0 +1,10 @@
{
config,
lib,
...
}:
with lib;
with builtins; {
options.vim.lsp.elixir = {
};
}

View file

@ -45,6 +45,8 @@ with builtins; {
graphql graphql
json json
zig zig
elixir
heex
] ]
++ (optional config.vim.notes.orgmode.enable org); # add orgmode grammar if enabled ++ (optional config.vim.notes.orgmode.enable org); # add orgmode grammar if enabled
description = '' description = ''