Compare commits

..

2 commits

Author SHA1 Message Date
raf
3e4e92ec9f
Merge 41830a79b8 into efd8b44ce1 2024-05-06 20:43:48 +00:00
41830a79b8
languages/clang: set default clang LSP encoding as utf-16 2024-05-06 23:43:36 +03:00
12 changed files with 123 additions and 199 deletions

View file

@ -54,6 +54,7 @@ inputs: let
enableTreesitter = true;
enableExtraDiagnostics = true;
nim.enable = false;
nix.enable = true;
markdown.enable = true;
@ -64,14 +65,12 @@ inputs: let
ts.enable = isMaximal;
svelte.enable = isMaximal;
go.enable = isMaximal;
elixir.enable = isMaximal;
zig.enable = isMaximal;
python.enable = isMaximal;
dart.enable = isMaximal;
bash.enable = isMaximal;
tailwind.enable = isMaximal;
typst.enable = isMaximal;
nim.enable = isMaximal;
clang = {
enable = isMaximal;
lsp.server = "clangd";

View file

@ -12,10 +12,9 @@ Release notes for release 0.7
[frothymarrow](https://github.com/frothymarrow):
- Modified type for [](#opt-vim.visuals.fidget-nvim.setupOpts.progress.display.overrides)
from `anything` to a `submodule` for better type checking.
- Fix null `vim.lsp.mappings` generating an error and not being filtered out.
from `anything` to a `submodule` for better type checking
[horriblename](https://github.com/horriblename):
[horriblename](https://github.com/horriblename)
- Fix broken treesitter-context keybinds in visual mode
@ -25,9 +24,9 @@ Release notes for release 0.7
automatically if you have autoformatting enabled, but can be disabled manually
if you choose to.
- Refactor `programs.languages.elixir` to use lspconfig and none-ls for LSP and
formatter setups respectively. Diagnostics support is considered, and may be
added once the [credo](https://github.com/rrrene/credo) linter has been added
to nixpkgs. A pull request is currently open.
- Remove vim-tidal and friends
- Remove unmaintained Elixir language module. This has been long broken, and was
unmaintained due to my disinterest in using Elixir. If you depend on Elixir
language support, please create an issue. Do keep in mind that elixirls **does
not exist in nixpkgs**.

View file

@ -546,22 +546,6 @@
"type": "github"
}
},
"plugin-elixir-tools": {
"flake": false,
"locked": {
"lastModified": 1714657398,
"narHash": "sha256-U6db1n/RIpT7Dd54e9iI/PjO1BhDpMyNPfaph+dUk7k=",
"owner": "elixir-tools",
"repo": "elixir-tools.nvim",
"rev": "51eddb03a7a8c9f00d6415b356a4d3b75d8e75b6",
"type": "github"
},
"original": {
"owner": "elixir-tools",
"repo": "elixir-tools.nvim",
"type": "github"
}
},
"plugin-fidget-nvim": {
"flake": false,
"locked": {
@ -1780,7 +1764,6 @@
"plugin-diffview-nvim": "plugin-diffview-nvim",
"plugin-dracula": "plugin-dracula",
"plugin-dressing-nvim": "plugin-dressing-nvim",
"plugin-elixir-tools": "plugin-elixir-tools",
"plugin-fidget-nvim": "plugin-fidget-nvim",
"plugin-flutter-tools": "plugin-flutter-tools",
"plugin-gesture-nvim": "plugin-gesture-nvim",

View file

@ -178,8 +178,13 @@
flake = false;
};
plugin-elixir-tools = {
url = "github:elixir-tools/elixir-tools.nvim";
plugin-glow-nvim = {
url = "github:ellisonleao/glow.nvim";
flake = false;
};
plugin-image-nvim = {
url = "github:3rd/image.nvim";
flake = false;
};
@ -482,16 +487,6 @@
flake = false;
};
plugin-glow-nvim = {
url = "github:ellisonleao/glow.nvim";
flake = false;
};
plugin-image-nvim = {
url = "github:3rd/image.nvim";
flake = false;
};
# Note-taking
plugin-obsidian-nvim = {
url = "github:epwalsh/obsidian.nvim";

View file

@ -3,6 +3,11 @@
in {
imports = [
# 2024-06-06
(mkRemovedOptionModule ["vim" "languages" "elixir"] ''
Elixir language support has been removed as of 2024-06-06 as it was long unmaintained. If
you dependend on this language support, please consider contributing to its maintenance.
'')
(mkRemovedOptionModule ["vim" "tidal"] ''
Tidalcycles language support has been removed as of 2024-06-06 as it was long unmaintained. If
you depended on this functionality, please open an issue.

View file

@ -26,10 +26,10 @@
ccls = {
package = pkgs.ccls;
lspConfig = ''
lspconfig.ccls.setup{
capabilities = capabilities;
on_attach=default_on_attach;
cmd = ${packageToCmd cfg.lsp.package "ccls"};
lspconfig.ccls.setup {
capabilities = capabilities,
on_attach=default_on_attach,
cmd = ${packageToCmd cfg.lsp.package "ccls"},
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.opts}"}
}
'';
@ -40,10 +40,10 @@
local clangd_cap = capabilities
-- use same offsetEncoding as null-ls
clangd_cap.offsetEncoding = {"utf-16"}
lspconfig.clangd.setup{
capabilities = clangd_cap;
on_attach=default_on_attach;
cmd = ${packageToCmd cfg.lsp.package "clangd"};
lspconfig.clangd.setup {
capabilities = clangd_cap,
on_attach=default_on_attach,
cmd = ${packageToCmd cfg.lsp.package "clangd"},
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.opts}"}
}
'';
@ -83,12 +83,16 @@ in {
enable = mkEnableOption "C/C++ language support";
cHeader = mkOption {
description = ''
C syntax for headers. Can fix treesitter errors, see:
https://www.reddit.com/r/neovim/comments/orfpcd/question_does_the_c_parser_from_nvimtreesitter/
'';
type = bool;
default = false;
description = ''
Enable C syntax for headers.
::: {.note}
This can potentially fix Treesitter errors for headers. See [this reddit
post] https://www.reddit.com/r/neovim/comments/orfpcd/question_does_the_c_parser_from_nvimtreesitter/
:::
'';
};
treesitter = {
@ -107,16 +111,16 @@ in {
};
package = mkOption {
description = "clang LSP server package, or the command to run as a list of strings";
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
description = "clang LSP server package, or the command to run as a list of strings";
};
opts = mkOption {
description = "Options to pass to clang LSP server";
default = "--offset-encoding=utf-16";
type = nullOr str;
default = null;
description = "Options to pass to clang LSP server";
};
};
@ -126,11 +130,13 @@ in {
type = bool;
default = config.vim.languages.enableDAP;
};
debugger = mkOption {
description = "clang debugger to use";
type = enum (attrNames debuggers);
default = defaultDebugger;
};
package = mkOption {
description = "clang debugger package.";
type = package;
@ -151,7 +157,6 @@ in {
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.clang-lsp = servers.${cfg.lsp.server}.lspConfig;
})

View file

@ -6,7 +6,6 @@ in {
./dart.nix
./clang.nix
./css.nix
./elixir.nix
./go.nix
./html.nix
./java.nix

View file

@ -1,138 +0,0 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.languages.elixir;
defaultServer = "elixirls";
servers = {
elixirls = {
package = pkgs.elixir-ls;
lspConfig = ''
-- elixirls setup
lspconfig.elixirls.setup {
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/elixir-ls"}''
}
}
'';
};
};
defaultFormat = "mix";
formats = {
mix = {
package = pkgs.elixir;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.mix.with({
command = "${cfg.format.package}/bin/mix",
})
)
'';
};
};
in {
options.vim.languages.elixir = {
enable = mkEnableOption "Elixir language support";
treesitter = {
enable = mkEnableOption "Elixir treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "elixir";
};
lsp = {
enable = mkEnableOption "Elixir LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "Elixir LSP server to use";
type = enum (attrNames servers);
default = defaultServer;
};
package = mkOption {
description = "Elixir LSP server package, or the command to run as a list of strings";
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
};
};
format = {
enable = mkEnableOption "Elixir formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
description = "Elixir formatter to use";
type = enum (attrNames formats);
default = defaultFormat;
};
package = mkOption {
description = "Elixir formatter package";
type = package;
default = formats.${cfg.format.type}.package;
};
};
elixir-tools = {
enable = mkEnableOption "Elixir tools";
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package];
})
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.elixir-lsp = servers.${cfg.lsp.server}.lspConfig;
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.elixir-format = formats.${cfg.format.type}.nullConfig;
})
(mkIf cfg.elixir-tools.enable {
vim.startPlugins = ["elixir-tools"];
vim.luaConfigRC.elixir-tools = entryAnywhere ''
local elixir-tools = require("elixir")
local elixirls = require("elixir-tools.elixirls")
-- disable imperative insstallations of various
-- elixir related tools installed by elixir-tools
elixir-tools.setup {
nextls = {
enable = false -- defaults to false
},
credo = {
enable = false -- defaults to true
},
elixirls = {
enable = false, -- defaults to true
}
}
'';
})
]);
}

View file

@ -0,0 +1,67 @@
{
config,
lib,
pkgs,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.meta) getExe;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.languages.elixir;
in {
config = mkIf (cfg.enable) {
vim.startPlugins = [
"elixir-tools"
];
vim.luaConfigRC.elixir-tools = 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 = "${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,7 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption;
in {
options.vim.languages.elixir = {
enable = mkEnableOption "Elixir language support";
};
}

View file

@ -16,10 +16,7 @@
mappingDefinitions = self.options.vim.lsp.mappings;
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
mkBinding = binding: action:
if binding.value != null
then "vim.api.nvim_buf_set_keymap(bufnr, 'n', '${binding.value}', '<cmd>lua ${action}<CR>', {noremap=true, silent=true, desc='${binding.description}'})"
else "";
mkBinding = binding: action: "vim.api.nvim_buf_set_keymap(bufnr, 'n', '${binding.value}', '<cmd>lua ${action}<CR>', {noremap=true, silent=true, desc='${binding.description}'})";
in {
config = mkIf cfg.enable {
vim = {