mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 10:59:49 +01:00
Merge pull request #49 from NotAShelf/feature/elixir
feat: elixir language support
This commit is contained in:
commit
de36937154
11 changed files with 168 additions and 20 deletions
|
@ -33,6 +33,7 @@ inputs: let
|
|||
nvimCodeActionMenu.enable = true;
|
||||
trouble.enable = true;
|
||||
lspSignature.enable = true;
|
||||
elixir.enable = isMaximal;
|
||||
rust.enable = isMaximal;
|
||||
python = isMaximal;
|
||||
clang.enable = isMaximal;
|
||||
|
|
34
flake.lock
34
flake.lock
|
@ -321,6 +321,38 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"elixir-ls": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1681462421,
|
||||
"narHash": "sha256-pIwZFiCLJ0f7OXi1iTza04KSn7rpFpvUsNYrFh0FoEM=",
|
||||
"owner": "elixir-lsp",
|
||||
"repo": "elixir-ls",
|
||||
"rev": "85cfc5604edeadb0a6a683c41abff60a0c959de7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "elixir-lsp",
|
||||
"repo": "elixir-ls",
|
||||
"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": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
@ -1319,6 +1351,8 @@
|
|||
"dashboard-nvim": "dashboard-nvim",
|
||||
"diffview-nvim": "diffview-nvim",
|
||||
"dressing-nvim": "dressing-nvim",
|
||||
"elixir-ls": "elixir-ls",
|
||||
"elixir-tools": "elixir-tools",
|
||||
"fidget-nvim": "fidget-nvim",
|
||||
"flake-parts": "flake-parts",
|
||||
"flake-utils": "flake-utils",
|
||||
|
|
19
flake.nix
19
flake.nix
|
@ -92,22 +92,27 @@
|
|||
url = "github:neovim/nvim-lspconfig";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
lspsaga = {
|
||||
url = "github:tami5/lspsaga.nvim";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
lspkind = {
|
||||
url = "github:onsails/lspkind-nvim";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
trouble = {
|
||||
url = "github:folke/trouble.nvim";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
nvim-treesitter-context = {
|
||||
url = "github:lewis6991/nvim-treesitter-context";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
nvim-lightbulb = {
|
||||
url = "github:kosayoda/nvim-lightbulb";
|
||||
flake = false;
|
||||
|
@ -117,18 +122,22 @@
|
|||
url = "github:weilbith/nvim-code-action-menu";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
lsp-signature = {
|
||||
url = "github:ray-x/lsp_signature.nvim";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
null-ls = {
|
||||
url = "github:jose-elias-alvarez/null-ls.nvim";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
sqls-nvim = {
|
||||
url = "github:nanotee/sqls.nvim";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
rust-tools = {
|
||||
url = "github:simrat39/rust-tools.nvim";
|
||||
flake = false;
|
||||
|
@ -139,6 +148,16 @@
|
|||
flake = false;
|
||||
};
|
||||
|
||||
elixir-ls = {
|
||||
url = "github:elixir-lsp/elixir-ls";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
elixir-tools = {
|
||||
url = "github:elixir-tools/elixir-tools.nvim";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
# Copying/Registers
|
||||
registers = {
|
||||
url = "github:tversteeg/registers.nvim";
|
||||
|
|
|
@ -79,6 +79,8 @@ with lib; let
|
|||
"vim-repeat"
|
||||
"smartcolumn"
|
||||
"project-nvim"
|
||||
"elixir-ls"
|
||||
"elixir-tools"
|
||||
];
|
||||
# You can either use the name of the plugin or a package.
|
||||
pluginsType = with types;
|
||||
|
|
|
@ -19,25 +19,20 @@ in {
|
|||
[
|
||||
"nvim-lspconfig"
|
||||
"null-ls"
|
||||
(
|
||||
if (config.vim.autocomplete.enable && (config.vim.autocomplete.type == "nvim-cmp"))
|
||||
then "cmp-nvim-lsp"
|
||||
else null
|
||||
)
|
||||
(
|
||||
if cfg.sql
|
||||
then "sqls-nvim"
|
||||
else null
|
||||
)
|
||||
]
|
||||
++ (
|
||||
if cfg.rust.enable
|
||||
then [
|
||||
"crates-nvim"
|
||||
"rust-tools"
|
||||
]
|
||||
else []
|
||||
);
|
||||
++ optionals (cfg.rust.enable) [
|
||||
"crates-nvim"
|
||||
"rust-tools"
|
||||
]
|
||||
++ optionals (cfg.elixir.enable) [
|
||||
"elixir-ls"
|
||||
]
|
||||
++ optionals ((config.vim.autocomplete.enable) && (config.vim.autocomplete.type == "nvim-cmp")) [
|
||||
"cmp-nvim-lsp"
|
||||
]
|
||||
++ optionals (cfg.sql) [
|
||||
"sqls-nvim"
|
||||
];
|
||||
|
||||
vim.configRC.lsp = nvim.dag.entryAnywhere ''
|
||||
${
|
||||
|
@ -346,6 +341,13 @@ in {
|
|||
cmd = { "${pkgs.nodePackages.typescript-language-server}/bin/typescript-language-server", "--stdio" }
|
||||
}
|
||||
''}
|
||||
|
||||
${writeIf cfg.elixir.enable ''
|
||||
lspconfig.elixirls.setup {
|
||||
cmd = { "${lib.getExe pkgs.elixir-ls}" },
|
||||
on_attach = on_attach
|
||||
}
|
||||
''}
|
||||
'';
|
||||
}
|
||||
);
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
./lsp-signature
|
||||
./lightbulb
|
||||
|
||||
# flutter-tools
|
||||
./flutter-tools-nvim
|
||||
# language specific modules
|
||||
./flutter-tools-nvim # dart & flutter
|
||||
./elixir # elixir
|
||||
];
|
||||
}
|
||||
|
|
67
modules/lsp/elixir/config.nix
Normal file
67
modules/lsp/elixir/config.nix
Normal 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
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
6
modules/lsp/elixir/default.nix
Normal file
6
modules/lsp/elixir/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./config.nix
|
||||
./elixir-tools.nix
|
||||
];
|
||||
}
|
10
modules/lsp/elixir/elixir-tools.nix
Normal file
10
modules/lsp/elixir/elixir-tools.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
options.vim.lsp.elixir = {
|
||||
};
|
||||
}
|
|
@ -65,6 +65,10 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
elixir = {
|
||||
enable = mkEnableOption "Elixir LSP";
|
||||
};
|
||||
|
||||
sql = mkEnableOption "SQL Language LSP";
|
||||
go = mkEnableOption "Go language LSP";
|
||||
ts = mkEnableOption "TS language LSP";
|
||||
|
|
|
@ -45,6 +45,8 @@ with builtins; {
|
|||
graphql
|
||||
json
|
||||
zig
|
||||
elixir
|
||||
heex
|
||||
]
|
||||
++ (optional config.vim.notes.orgmode.enable org); # add orgmode grammar if enabled
|
||||
description = ''
|
||||
|
|
Loading…
Reference in a new issue