mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 02:11:33 +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
|
@ -15,9 +15,5 @@ _: {
|
|||
./lsp-signature
|
||||
./lightbulb
|
||||
./lspkind
|
||||
|
||||
# language specific modules
|
||||
./flutter-tools-nvim # dart & flutter
|
||||
./elixir # elixir
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
_: {
|
||||
imports = [
|
||||
./config.nix
|
||||
./elixir-tools.nix
|
||||
];
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
options.vim.lsp.elixir = {
|
||||
};
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.lsp;
|
||||
ftcfg = cfg.dart.flutter-tools;
|
||||
in {
|
||||
config = mkIf (cfg.enable && ftcfg.enable) {
|
||||
vim.startPlugins = ["flutter-tools"];
|
||||
|
||||
vim.luaConfigRC.flutter-tools = nvim.dag.entryAnywhere ''
|
||||
require('flutter-tools').setup {
|
||||
lsp = {
|
||||
color = { -- show the derived colours for dart variables
|
||||
enabled = ${boolToString ftcfg.color.enable}, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10
|
||||
background = ${boolToString ftcfg.color.highlightBackground}, -- highlight the background
|
||||
foreground = ${boolToString ftcfg.color.highlightForeground}, -- highlight the foreground
|
||||
virtual_text = ${boolToString ftcfg.color.virtualText.enable}, -- show the highlight using virtual text
|
||||
virtual_text_str = ${ftcfg.color.virtualText.character} -- the virtual text character to highlight
|
||||
},
|
||||
|
||||
capabilities = capabilities,
|
||||
on_attach = default_on_attach;
|
||||
flags = lsp_flags,
|
||||
},
|
||||
}
|
||||
|
||||
'';
|
||||
};
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
_: {
|
||||
imports = [
|
||||
./flutter-tools.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
options.vim.lsp.dart.flutter-tools = {
|
||||
enable = mkEnableOption "Enable flutter-tools for flutter support";
|
||||
|
||||
color = {
|
||||
enable = mkEnableOption "Whether or mot to highlight color variables at all";
|
||||
|
||||
highlightBackground = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Highlight the background";
|
||||
};
|
||||
|
||||
highlightForeground = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Highlight the foreground";
|
||||
};
|
||||
|
||||
virtualText = {
|
||||
enable = mkEnableOption "Show the highlight using virtual text";
|
||||
|
||||
character = mkOption {
|
||||
type = types.str;
|
||||
default = "■";
|
||||
description = "Virtual text character to highlight";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue