mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 10:21:31 +00:00
feat: refactor dart and elixir LSPs according to the new structure
This commit is contained in:
parent
07d5aee29c
commit
824c852ec1
12 changed files with 167 additions and 87 deletions
66
modules/languages/elixir/config.nix
Normal file
66
modules/languages/elixir/config.nix
Normal file
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.languages.elixir;
|
||||
in {
|
||||
config = mkIf (cfg.enable) {
|
||||
vim.startPlugins = [
|
||||
"elixir-tools"
|
||||
];
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
6
modules/languages/elixir/default.nix
Normal file
6
modules/languages/elixir/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./config.nix
|
||||
./elixir-tools.nix
|
||||
];
|
||||
}
|
11
modules/languages/elixir/elixir-tools.nix
Normal file
11
modules/languages/elixir/elixir-tools.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
options.vim.languages.elixir = {
|
||||
enable = mkEnableOption "elixir support";
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue