Merge branch 'main' into main

This commit is contained in:
Nikita 2025-05-09 22:22:16 +03:00 committed by GitHub
commit b6486a2aba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
176 changed files with 4155 additions and 1832 deletions

View file

@ -20,7 +20,7 @@ in {
};
lsp = {
enable = mkEnableOption "Assembly LSP support (asm-lsp)" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Assembly LSP support (asm-lsp)" // {default = config.vim.lsp.enable;};
package = mkOption {
type = package;

View file

@ -10,8 +10,8 @@
inherit (lib.lists) isList;
inherit (lib.meta) getExe;
inherit (lib.types) enum either listOf package str;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.languages) diagnosticsToLua;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
cfg = config.vim.languages.astro;
@ -22,7 +22,7 @@
package = pkgs.astro-language-server;
lspConfig = ''
lspconfig.astro.setup {
capabilities = capabilities;
capabilities = capabilities,
on_attach = attach_keymaps,
cmd = ${
if isList cfg.lsp.package
@ -39,42 +39,35 @@
formats = {
prettier = {
package = pkgs.nodePackages.prettier;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.prettier.with({
command = "${cfg.format.package}/bin/prettier",
})
)
'';
};
prettierd = {
package = pkgs.prettierd;
};
biome = {
package = pkgs.biome;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.biome.with({
command = "${cfg.format.package}/bin/biome",
})
)
'';
};
};
# TODO: specify packages
defaultDiagnosticsProvider = ["eslint_d"];
diagnosticsProviders = {
eslint_d = {
package = pkgs.eslint_d;
nullConfig = pkg: ''
table.insert(
ls_sources,
null_ls.builtins.diagnostics.eslint_d.with({
command = "${getExe pkg}",
})
)
'';
eslint_d = let
pkg = pkgs.eslint_d;
in {
package = pkg;
config = {
cmd = getExe pkg;
required_files = [
"eslint.config.js"
"eslint.config.mjs"
".eslintrc"
".eslintrc.json"
".eslintrc.js"
".eslintrc.yml"
];
};
};
};
in {
@ -88,19 +81,19 @@ in {
};
lsp = {
enable = mkEnableOption "Astro LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Astro LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Astro LSP server to use";
type = enum (attrNames servers);
default = defaultServer;
description = "Astro LSP server to use";
};
package = mkOption {
description = "Astro LSP server package, or the command to run as a list of strings";
example = ''[lib.getExe pkgs.astro-language-server "--minify" "--stdio"]'';
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
example = ''[lib.getExe pkgs.astro-language-server "--minify" "--stdio"]'';
description = "Astro LSP server package, or the command to run as a list of strings";
};
};
@ -143,16 +136,22 @@ in {
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.astro-format = formats.${cfg.format.type}.nullConfig;
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.astro = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = {
command = getExe cfg.format.package;
};
};
})
(mkIf cfg.extraDiagnostics.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources = diagnosticsToLua {
lang = "astro";
config = cfg.extraDiagnostics.types;
inherit diagnosticsProviders;
vim.diagnostics.nvim-lint = {
enable = true;
linters_by_ft.astro = cfg.extraDiagnostics.types;
linters =
mkMerge (map (name: {${name} = diagnosticsProviders.${name}.config;})
cfg.extraDiagnostics.types);
};
})
]);

View file

@ -6,10 +6,10 @@
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.types) enum either package listOf str bool;
inherit (lib.nvim.languages) diagnosticsToLua;
inherit (lib.nvim.types) diagnostics mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
@ -37,14 +37,6 @@
formats = {
shfmt = {
package = pkgs.shfmt;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.shfmt.with({
command = "${pkgs.shfmt}/bin/shfmt",
})
)
'';
};
};
@ -52,15 +44,6 @@
diagnosticsProviders = {
shellcheck = {
package = pkgs.shellcheck;
nullConfig = pkg: ''
table.insert(
ls_sources,
null_ls.builtins.diagnostics.shellcheck.with({
command = "${pkg}/bin/shellcheck",
diagnostics_format = "#{m} [#{c}]"
})
)
'';
};
};
in {
@ -73,7 +56,7 @@ in {
};
lsp = {
enable = mkEnableOption "Enable Bash LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Enable Bash LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Bash LSP server to use";
@ -130,16 +113,23 @@ in {
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.bash-format = formats.${cfg.format.type}.nullConfig;
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.sh = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = {
command = getExe cfg.format.package;
};
};
})
(mkIf cfg.extraDiagnostics.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources = diagnosticsToLua {
lang = "bash";
config = cfg.extraDiagnostics.types;
inherit diagnosticsProviders;
vim.diagnostics.nvim-lint = {
enable = true;
linters_by_ft.sh = cfg.extraDiagnostics.types;
linters = mkMerge (map (name: {
${name}.cmd = getExe diagnosticsProviders.${name}.package;
})
cfg.extraDiagnostics.types);
};
})
]);

View file

@ -98,7 +98,7 @@ in {
};
lsp = {
enable = mkEnableOption "clang LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "clang LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "The clang LSP server to use";

View file

@ -91,7 +91,7 @@ in {
};
lsp = {
enable = mkEnableOption "C# LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "C# LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "C# LSP server to use";
type = enum (attrNames servers);

View file

@ -6,6 +6,7 @@
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.types) enum either listOf package str;
@ -42,14 +43,6 @@
formats = {
prettier = {
package = pkgs.nodePackages.prettier;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.prettier.with({
command = "${cfg.format.package}/bin/prettier",
})
)
'';
};
prettierd = {
@ -87,7 +80,7 @@ in {
};
lsp = {
enable = mkEnableOption "CSS LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "CSS LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "CSS LSP server to use";
@ -132,8 +125,13 @@ in {
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.css-format = formats.${cfg.format.type}.nullConfig;
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.css = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = {
command = getExe cfg.format.package;
};
};
})
]);
}

View file

@ -0,0 +1,51 @@
{
pkgs,
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) package;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.cue;
in {
options.vim.languages.cue = {
enable = mkEnableOption "CUE language support";
treesitter = {
enable = mkEnableOption "CUE treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "cue";
};
lsp = {
enable = mkEnableOption "CUE LSP support" // {default = config.vim.lsp.enable;};
package = mkOption {
type = package;
default = pkgs.cue;
description = "cue lsp implementation";
};
};
};
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.cue-lsp = ''
lspconfig.cue.setup {
capabilities = capabilities,
on_attach = default_on_attach,
cmd = {"${cfg.lsp.package}/bin/cue", "lsp"},
}
'';
})
]);
}

View file

@ -13,7 +13,7 @@
inherit (lib.strings) optionalString;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.dag) entryAfter;
cfg = config.vim.languages.dart;
ftcfg = cfg.flutter-tools;
@ -77,20 +77,29 @@ in {
flutter-tools = {
enable = mkOption {
type = bool;
default = config.vim.languages.enableLSP;
default = config.vim.lsp.enable;
description = "Enable flutter-tools for flutter support";
};
flutterPackage = mkOption {
type = nullOr package;
default = pkgs.flutter;
description = "Flutter package, or null to detect the flutter path at runtime instead.";
};
enableNoResolvePatch = mkOption {
type = bool;
default = true;
default = false;
description = ''
Whether to patch flutter-tools so that it doesn't resolve
symlinks when detecting flutter path.
This is required if you want to use a flutter package built with nix.
If you are using a flutter SDK installed from a different source
and encounter the error "`dart` missing from PATH", disable this option.
::: {.note}
This is required if `flutterPackage` is set to null and the flutter
package in your `PATH` was built with Nix. If you are using a flutter
SDK installed from a different source and encounter the error "`dart`
missing from `PATH`", leave this option disabled.
:::
'';
};
@ -122,25 +131,30 @@ in {
};
};
config = mkIf cfg.enable (mkMerge [
config.vim = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package];
treesitter.enable = true;
treesitter.grammars = [cfg.treesitter.package];
})
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.dart-lsp = servers.${cfg.lsp.server}.lspConfig;
lsp.lspconfig.enable = true;
lsp.lspconfig.sources.dart-lsp = servers.${cfg.lsp.server}.lspConfig;
})
(mkIf ftcfg.enable {
vim.startPlugins =
if ftcfg.enableNoResolvePatch
then ["flutter-tools-patched"]
else ["flutter-tools-nvim"];
startPlugins = [
(
if ftcfg.enableNoResolvePatch
then "flutter-tools-patched"
else "flutter-tools-nvim"
)
"plenary-nvim"
];
vim.pluginRC.flutter-tools = entryAnywhere ''
pluginRC.flutter-tools = entryAfter ["lsp-setup"] ''
require('flutter-tools').setup {
${optionalString (ftcfg.flutterPackage != null) "flutter_path = \"${ftcfg.flutterPackage}/bin/flutter\","}
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
@ -152,7 +166,6 @@ in {
capabilities = capabilities,
on_attach = default_on_attach;
flags = lsp_flags,
},
${optionalString cfg.dap.enable ''
debugger = {

View file

@ -1,17 +1,21 @@
{lib, ...}: let
inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.nvim.languages) mkEnable;
in {
imports = [
./asm.nix
./astro.nix
./bash.nix
./cue.nix
./dart.nix
./clang.nix
./css.nix
./elixir.nix
./fsharp.nix
./gleam.nix
./go.nix
./hcl.nix
./helm.nix
./kotlin.nix
./html.nix
./haskell.nix
@ -41,10 +45,13 @@ in {
./wgsl.nix
./yaml.nix
./ruby.nix
# This is now a hard deprecation.
(mkRenamedOptionModule ["vim" "languages" "enableLSP"] ["vim" "lsp" "enable"])
];
options.vim.languages = {
enableLSP = mkEnable "LSP";
# Those are still managed by plugins, and should be enabled here.
enableDAP = mkEnable "Debug Adapter";
enableTreesitter = mkEnable "Treesitter";
enableFormat = mkEnable "Formatting";

View file

@ -38,14 +38,9 @@
formats = {
mix = {
package = pkgs.elixir;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.mix.with({
command = "${cfg.format.package}/bin/mix",
})
)
'';
config = {
command = "${cfg.format.package}/bin/mix";
};
};
};
in {
@ -58,7 +53,7 @@ in {
};
lsp = {
enable = mkEnableOption "Elixir LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Elixir LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Elixir LSP server to use";
@ -107,8 +102,12 @@ in {
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.elixir-format = formats.${cfg.format.type}.nullConfig;
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.elixir = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} =
formats.${cfg.format.type}.config;
};
})
(mkIf cfg.elixir-tools.enable {

View file

@ -0,0 +1,107 @@
{
lib,
pkgs,
config,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) either listOf package str enum;
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
defaultServer = "fsautocomplete";
servers = {
fsautocomplete = {
package = pkgs.fsautocomplete;
internalFormatter = false;
lspConfig = ''
lspconfig.fsautocomplete.setup {
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else "{'${cfg.lsp.package}/bin/fsautocomplete'}"
},
}
'';
};
};
defaultFormat = "fantomas";
formats = {
fantomas = {
package = pkgs.fantomas;
};
};
cfg = config.vim.languages.fsharp;
in {
options = {
vim.languages.fsharp = {
enable = mkEnableOption "F# language support";
treesitter = {
enable = mkEnableOption "F# treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "fsharp";
};
lsp = {
enable = mkEnableOption "F# LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
type = enum (attrNames servers);
default = defaultServer;
description = "F# LSP server to use";
};
package = mkOption {
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
example = ''[lib.getExe pkgs.fsautocomplete "--state-directory" "~/.cache/fsautocomplete"]'';
description = "F# LSP server package, or the command to run as a list of strings";
};
};
format = {
enable = mkEnableOption "F# formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
type = enum (attrNames formats);
default = defaultFormat;
description = "F# formatter to use";
};
package = mkOption {
type = package;
default = formats.${cfg.format.type}.package;
description = "F# formatter package";
};
};
};
};
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.fsharp-lsp = servers.${cfg.lsp.server}.lspConfig;
})
(mkIf cfg.format.enable {
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.fsharp = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = {
command = getExe cfg.format.package;
};
};
})
]);
}

View file

@ -41,7 +41,7 @@ in {
};
lsp = {
enable = mkEnableOption "Gleam LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Gleam LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
type = enum (attrNames servers);

View file

@ -5,7 +5,7 @@
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.options) mkEnableOption mkOption literalMD;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.meta) getExe;
inherit (lib.lists) isList;
@ -38,36 +38,15 @@
formats = {
gofmt = {
package = pkgs.go;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.gofmt.with({
command = "${cfg.format.package}/bin/gofmt",
})
)
'';
config.command = "${cfg.format.package}/bin/gofmt";
};
gofumpt = {
package = pkgs.gofumpt;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.gofumpt.with({
command = "${cfg.format.package}/bin/gofumpt",
})
)
'';
config.command = getExe cfg.format.package;
};
golines = {
package = pkgs.golines;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.golines.with({
command = "${cfg.format.package}/bin/golines",
})
)
'';
config.command = "${cfg.format.package}/bin/golines";
};
};
@ -88,7 +67,7 @@ in {
};
lsp = {
enable = mkEnableOption "Go LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Go LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Go LSP server to use";
@ -105,7 +84,14 @@ in {
};
format = {
enable = mkEnableOption "Go formatting" // {default = config.vim.languages.enableFormat;};
enable =
mkEnableOption "Go formatting"
// {
default = !cfg.lsp.enable && config.vim.languages.enableFormat;
defaultText = literalMD ''
disabled if Go LSP is enabled, otherwise follows {option}`vim.languages.enableFormat`
'';
};
type = mkOption {
description = "Go formatter to use";
@ -153,8 +139,11 @@ in {
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.go-format = formats.${cfg.format.type}.nullConfig;
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.go = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = formats.${cfg.format.type}.config;
};
})
(mkIf cfg.dap.enable {

View file

@ -25,7 +25,7 @@ in {
};
lsp = {
enable = mkEnableOption "LSP support for Haskell" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "LSP support for Haskell" // {default = config.vim.lsp.enable;};
package = mkOption {
description = "Haskell LSP package or command to run the Haskell LSP";
example = ''[ (lib.getExe pkgs.haskellPackages.haskell-language-server) "--debug" ]'';

View file

@ -6,6 +6,7 @@
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) package bool enum;
inherit (lib.nvim.types) mkGrammarOption;
@ -30,14 +31,6 @@
formats = {
hclfmt = {
package = pkgs.hclfmt;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.hclfmt.with({
command = "${lib.getExe cfg.format.package}",
})
)
'';
};
};
in {
@ -50,7 +43,7 @@ in {
};
lsp = {
enable = mkEnableOption "HCL LSP support (terraform-ls)" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "HCL LSP support (terraform-ls)" // {default = config.vim.lsp.enable;};
# TODO: (maybe, is it better?) it would be cooler to use vscode-extensions.hashicorp.hcl probably, shouldn't be too hard
package = mkOption {
type = package;
@ -110,8 +103,13 @@ in {
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.hcl-format = formats.${cfg.format.type}.nullConfig;
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.hcl = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = {
command = getExe cfg.format.package;
};
};
})
]);
}

View file

@ -0,0 +1,89 @@
{
pkgs,
config,
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;
cfg = config.vim.languages.helm;
yamlCfg = config.vim.languages.yaml;
helmCmd =
if isList cfg.lsp.package
then cfg.lsp.package
else ["${cfg.lsp.package}/bin/helm_ls" "serve"];
yamlCmd =
if isList yamlCfg.lsp.package
then builtins.elemAt yamlCfg.lsp.package 0
else "${yamlCfg.lsp.package}/bin/yaml-language-server";
defaultServer = "helm-ls";
servers = {
helm-ls = {
package = pkgs.helm-ls;
lspConfig = ''
lspconfig.helm_ls.setup {
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${expToLua helmCmd},
settings = {
['helm-ls'] = {
yamlls = {
path = "${yamlCmd}"
}
}
}
}
'';
};
};
in {
options.vim.languages.helm = {
enable = mkEnableOption "Helm language support";
treesitter = {
enable = mkEnableOption "Helm treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "helm";
};
lsp = {
enable = mkEnableOption "Helm LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Helm LSP server to use";
type = enum (attrNames servers);
default = defaultServer;
};
package = mkOption {
description = "Helm LSP server package";
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
};
};
};
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.helm-lsp = servers.${cfg.lsp.server}.lspConfig;
})
{
# Enables filetype detection
vim.startPlugins = [pkgs.vimPlugins.vim-helm];
}
]);
}

View file

@ -23,7 +23,7 @@ in {
};
lsp = {
enable = mkEnableOption "Java LSP support (java-language-server)" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Java LSP support (java-language-server)" // {default = config.vim.lsp.enable;};
package = mkOption {
description = "java language server package, or the command to run as a list of strings";
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';

View file

@ -78,7 +78,7 @@ in {
lsp = {
enable = mkOption {
type = bool;
default = config.vim.languages.enableLSP;
default = config.vim.lsp.enable;
description = ''
Whether to enable Julia LSP support.

View file

@ -7,7 +7,6 @@
inherit (lib.options) mkEnableOption mkOption literalExpression;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.meta) getExe;
inherit (lib.nvim.languages) diagnosticsToLua;
inherit (lib.types) either package listOf str;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
inherit (lib.lists) isList;
@ -19,14 +18,6 @@
diagnosticsProviders = {
ktlint = {
package = pkgs.ktlint;
nullConfig = pkg: ''
table.insert(
ls_sources,
null_ls.builtins.diagnostics.ktlint.with({
command = "${getExe pkg}",
})
)
'';
};
};
in {
@ -39,7 +30,7 @@ in {
};
lsp = {
enable = mkEnableOption "Kotlin LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Kotlin LSP support" // {default = config.vim.lsp.enable;};
package = mkOption {
description = "kotlin_language_server package with Kotlin runtime";
@ -76,11 +67,13 @@ in {
})
(mkIf cfg.extraDiagnostics.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources = diagnosticsToLua {
lang = "kotlin";
config = cfg.extraDiagnostics.types;
inherit diagnosticsProviders;
vim.diagnostics.nvim-lint = {
enable = true;
linters_by_ft.kotlin = cfg.extraDiagnostics.types;
linters = mkMerge (map (name: {
${name}.cmd = getExe diagnosticsProviders.${name}.package;
})
cfg.extraDiagnostics.types);
};
})

View file

@ -4,16 +4,30 @@
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.meta) getExe;
inherit (lib.lists) isList;
inherit (lib.types) either listOf package str;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.types) bool either enum listOf package str;
inherit (lib.nvim.types) diagnostics mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.dag) entryBefore;
cfg = config.vim.languages.lua;
defaultFormat = "stylua";
formats = {
stylua = {
package = pkgs.stylua;
};
};
defaultDiagnosticsProvider = ["luacheck"];
diagnosticsProviders = {
luacheck = {
package = pkgs.luajitPackages.luacheck;
};
};
in {
imports = [
(lib.mkRemovedOptionModule ["vim" "languages" "lua" "lsp" "neodev"] ''
@ -29,7 +43,7 @@ in {
};
lsp = {
enable = mkEnableOption "Lua LSP support via LuaLS" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Lua LSP support via LuaLS" // {default = config.vim.lsp.enable;};
package = mkOption {
description = "LuaLS package, or the command to run as a list of strings";
@ -39,6 +53,34 @@ in {
lazydev.enable = mkEnableOption "lazydev.nvim integration, useful for neovim plugin developers";
};
format = {
enable = mkOption {
type = bool;
default = config.vim.languages.enableFormat;
description = "Enable Lua formatting";
};
type = mkOption {
type = enum (attrNames formats);
default = defaultFormat;
description = "Lua formatter to use";
};
package = mkOption {
type = package;
default = formats.${cfg.format.type}.package;
description = "Lua formatter package";
};
};
extraDiagnostics = {
enable = mkEnableOption "extra Lua diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
types = diagnostics {
langDesc = "Lua";
inherit diagnosticsProviders;
inherit defaultDiagnosticsProvider;
};
};
};
config = mkMerge [
@ -74,6 +116,27 @@ in {
})
'';
})
(mkIf cfg.format.enable {
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.lua = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = {
command = getExe cfg.format.package;
};
};
})
(mkIf cfg.extraDiagnostics.enable {
vim.diagnostics.nvim-lint = {
enable = true;
linters_by_ft.lua = cfg.extraDiagnostics.types;
linters = mkMerge (map (name: {
${name}.cmd = getExe diagnosticsProviders.${name}.package;
})
cfg.extraDiagnostics.types);
};
})
]))
];
}

View file

@ -5,12 +5,13 @@
...
}: let
inherit (builtins) attrNames;
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.lists) isList concatLists;
inherit (lib.types) bool enum either package listOf str;
inherit (lib.lists) isList;
inherit (lib.types) bool enum either package listOf str nullOr;
inherit (lib.nvim.lua) expToLua toLuaObject;
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption;
inherit (lib.nvim.types) diagnostics mkGrammarOption mkPluginSetupOption;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.languages.markdown;
@ -32,31 +33,23 @@
};
};
defaultFormat = "denofmt";
defaultFormat = "deno_fmt";
formats = {
# for backwards compatibility
denofmt = {
package = pkgs.deno;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.deno_fmt.with({
filetypes = ${expToLua (concatLists [cfg.format.extraFiletypes ["markdown"]])},
command = "${cfg.format.package}/bin/deno",
})
)
'';
};
deno_fmt = {
package = pkgs.deno;
};
prettierd = {
package = pkgs.prettierd;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.prettierd.with({
filetypes = ${expToLua (concatLists [cfg.format.extraFiletypes ["markdown"]])},
command = "${cfg.format.package}/bin/prettierd",
})
)
'';
};
};
defaultDiagnosticsProvider = ["markdownlint-cli2"];
diagnosticsProviders = {
markdownlint-cli2 = {
package = pkgs.markdownlint-cli2;
};
};
in {
@ -74,7 +67,7 @@ in {
};
lsp = {
enable = mkEnableOption "Enable Markdown LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Enable Markdown LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
type = enum (attrNames servers);
@ -96,7 +89,7 @@ in {
type = mkOption {
type = enum (attrNames formats);
default = defaultFormat;
description = "Markdown formatter to use";
description = "Markdown formatter to use. `denofmt` is deprecated and currently aliased to deno_fmt.";
};
package = mkOption {
@ -121,15 +114,19 @@ in {
[render-markdown.nvim]: https://github.com/MeanderingProgrammer/render-markdown.nvim
Inline Markdown rendering with [render-markdown.nvim]
'';
};
setupOpts = mkPluginSetupOption "render-markdown" {
auto_override_publish_diagnostics = mkOption {
description = "Automatically override the publish_diagnostics handler";
type = bool;
default = true;
file_types = lib.mkOption {
type = nullOr (listOf str);
default = null;
description = ''
List of buffer filetypes to enable this plugin in.
This will cause the plugin to attach to new buffers who
have any of these filetypes.
'';
};
};
};
@ -146,6 +143,15 @@ in {
setupOpts = mkPluginSetupOption "markview-nvim" {};
};
};
extraDiagnostics = {
enable = mkEnableOption "extra Markdown diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
types = diagnostics {
langDesc = "Markdown";
inherit diagnosticsProviders;
inherit defaultDiagnosticsProvider;
};
};
};
config = mkIf cfg.enable (mkMerge [
@ -160,8 +166,17 @@ in {
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.markdown-format = formats.${cfg.format.type}.nullConfig;
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.markdown = [cfg.format.type];
setupOpts.formatters.${
if cfg.format.type == "denofmt"
then "deno_fmt"
else cfg.format.type
} = {
command = getExe cfg.format.package;
};
};
})
# Extensions
@ -178,5 +193,16 @@ in {
require("markview").setup(${toLuaObject cfg.extensions.markview-nvim.setupOpts})
'';
})
(mkIf cfg.extraDiagnostics.enable {
vim.diagnostics.nvim-lint = {
enable = true;
linters_by_ft.markdown = cfg.extraDiagnostics.types;
linters = mkMerge (map (name: {
${name}.cmd = getExe diagnosticsProviders.${name}.package;
})
cfg.extraDiagnostics.types);
};
})
]);
}

View file

@ -6,6 +6,7 @@
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.types) enum either listOf package str;
@ -38,14 +39,9 @@
formats = {
nimpretty = {
package = pkgs.nim;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.nimpretty.with({
command = "${pkgs.nim}/bin/nimpretty",
})
)
'';
config = {
command = "${cfg.format.package}/bin/nimpretty";
};
};
};
in {
@ -58,7 +54,7 @@ in {
};
lsp = {
enable = mkEnableOption "Nim LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Nim LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Nim LSP server to use";
type = str;
@ -110,8 +106,11 @@ in {
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.nim-format = formats.${cfg.format.type}.nullConfig;
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.nim = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = formats.${cfg.format.type}.config;
};
})
]);
}

View file

@ -2,10 +2,12 @@
config,
pkgs,
lib,
inputs,
...
}: let
inherit (builtins) attrNames;
inherit (lib) concatStringsSep;
inherit (lib.meta) getExe;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
@ -13,7 +15,6 @@
inherit (lib.types) anything attrsOf enum either listOf nullOr package str;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
inherit (lib.nvim.lua) expToLua toLuaObject;
inherit (lib.nvim.languages) diagnosticsToLua;
cfg = config.vim.languages.nix;
@ -27,7 +28,7 @@
else ''{"${package}/bin/${defaultCmd}"}'';
servers = {
nil = {
package = pkgs.nil;
package = inputs.nil.packages.${pkgs.stdenv.system}.nil;
internalFormatter = true;
lspConfig = ''
lspconfig.nil_ls.setup{
@ -100,26 +101,10 @@
formats = {
alejandra = {
package = pkgs.alejandra;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.alejandra.with({
command = "${cfg.format.package}/bin/alejandra"
})
)
'';
};
nixfmt = {
package = pkgs.nixfmt-rfc-style;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.nixfmt.with({
command = "${cfg.format.package}/bin/nixfmt"
})
)
'';
};
};
@ -159,7 +144,7 @@ in {
};
lsp = {
enable = mkEnableOption "Nix LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Nix LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Nix LSP server to use";
type = enum (attrNames servers);
@ -237,17 +222,24 @@ in {
vim.lsp.lspconfig.sources.nix-lsp = servers.${cfg.lsp.server}.lspConfig;
})
(mkIf (cfg.format.enable && !servers.${cfg.lsp.server}.internalFormatter) {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.nix-format = formats.${cfg.format.type}.nullConfig;
(mkIf (cfg.format.enable && (!cfg.lsp.enable || !servers.${cfg.lsp.server}.internalFormatter)) {
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.nix = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = {
command = getExe cfg.format.package;
};
};
})
(mkIf cfg.extraDiagnostics.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources = diagnosticsToLua {
lang = "nix";
config = cfg.extraDiagnostics.types;
inherit diagnosticsProviders;
vim.diagnostics.nvim-lint = {
enable = true;
linters_by_ft.nix = cfg.extraDiagnostics.types;
linters = mkMerge (map (name: {
${name}.cmd = getExe diagnosticsProviders.${name}.package;
})
cfg.extraDiagnostics.types);
};
})
]);

View file

@ -40,7 +40,7 @@ in {
};
lsp = {
enable = mkEnableOption "Nu LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Nu LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
type = str;
default = defaultServer;

View file

@ -37,14 +37,6 @@
formats = {
ocamlformat = {
package = pkgs.ocamlPackages.ocamlformat;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.ocamlformat.with({
command = "${cfg.format.package}/bin/ocamlformat",
})
)
'';
};
};
in {
@ -57,7 +49,7 @@ in {
};
lsp = {
enable = mkEnableOption "OCaml LSP support (ocaml-lsp)" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "OCaml LSP support (ocaml-lsp)" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "OCaml LSP server to user";
type = enum (attrNames servers);
@ -97,9 +89,13 @@ in {
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.ocamlformat = formats.${cfg.format.type}.nullConfig;
vim.extraPackages = [formats.${cfg.format.type}.package];
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.ocaml = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = {
command = getExe cfg.format.package;
};
};
})
]);
}

View file

@ -41,7 +41,7 @@ in {
};
lsp = {
enable = mkEnableOption "Odin LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Odin LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
type = enum (attrNames servers);

View file

@ -64,6 +64,26 @@
}
'';
};
intelephense = {
package = pkgs.intelephense;
lspConfig = ''
lspconfig.intelephense.setup{
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''
{
"${getExe cfg.lsp.package}",
"--stdio"
},
''
}
}
'';
};
};
in {
options.vim.languages.php = {
@ -75,7 +95,7 @@ in {
};
lsp = {
enable = mkEnableOption "PHP LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "PHP LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "PHP LSP server to use";

View file

@ -47,7 +47,7 @@
};
python-lsp-server = {
package = pkgs.python-lsp-server;
package = pkgs.python3Packages.python-lsp-server;
lspConfig = ''
lspconfig.pylsp.setup{
capabilities = capabilities;
@ -66,26 +66,10 @@
formats = {
black = {
package = pkgs.black;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.black.with({
command = "${cfg.format.package}/bin/black",
})
)
'';
};
isort = {
package = pkgs.isort;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.isort.with({
command = "${cfg.format.package}/bin/isort",
})
)
'';
};
black-and-isort = {
@ -96,15 +80,6 @@
black --quiet - "$@" | isort --profile black -
'';
};
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.black.with({
command = "${cfg.format.package}/bin/black",
})
)
'';
};
ruff = {
@ -115,14 +90,6 @@
ruff format -
'';
};
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.ruff.with({
command = "${cfg.format.package}/bin/ruff",
})
)
'';
};
};
@ -132,7 +99,7 @@
# idk if this is the best way to install/run debugpy
package = pkgs.python3.withPackages (ps: with ps; [debugpy]);
dapConfig = ''
dap.adapters.python = function(cb, config)
dap.adapters.debugpy = function(cb, config)
if config.request == 'attach' then
---@diagnostic disable-next-line: undefined-field
local port = (config.connect or config).port
@ -161,7 +128,7 @@
dap.configurations.python = {
{
-- The first three options are required by nvim-dap
type = 'python'; -- the type here established the link to the adapter definition: `dap.adapters.python`
type = 'debugpy'; -- the type here established the link to the adapter definition: `dap.adapters.debugpy`
request = 'launch';
name = "Launch file";
@ -202,7 +169,7 @@ in {
};
lsp = {
enable = mkEnableOption "Python LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Python LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Python LSP server to use";
@ -272,8 +239,22 @@ in {
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.python-format = formats.${cfg.format.type}.nullConfig;
vim.formatter.conform-nvim = {
enable = true;
# HACK: I'm planning to remove these soon so I just took the easiest way out
setupOpts.formatters_by_ft.python =
if cfg.format.type == "black-and-isort"
then ["black"]
else [cfg.format.type];
setupOpts.formatters =
if (cfg.format.type == "black-and-isort")
then {
black.command = "${cfg.format.package}/bin/black";
}
else {
${cfg.format.type}.command = getExe cfg.format.package;
};
};
})
(mkIf cfg.dap.enable {

View file

@ -24,28 +24,29 @@
package = pkgs.rWrapper.override {
packages = [pkgs.rPackages.styler];
};
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.styler.with({
command = "${cfg.format.package}/bin/R",
})
)
'';
config = {
command = "${cfg.format.package}/bin/R";
};
};
format_r = {
package = pkgs.rWrapper.override {
packages = [pkgs.rPackages.formatR];
};
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.format_r.with({
command = "${cfg.format.package}/bin/R",
})
)
'';
config = {
command = "${cfg.format.package}/bin/R";
stdin = true;
args = [
"--slave"
"--no-restore"
"--no-save"
"-s"
"-e"
''formatR::tidy_source(source="stdin")''
];
# TODO: range_args seem to be possible
# https://github.com/nvimtools/none-ls.nvim/blob/main/lua/null-ls/builtins/formatting/format_r.lua
};
};
};
@ -78,7 +79,7 @@ in {
};
lsp = {
enable = mkEnableOption "R LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "R LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "R LSP server to use";
@ -118,8 +119,11 @@ in {
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.r-format = formats.${cfg.format.type}.nullConfig;
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.r = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = formats.${cfg.format.type}.config;
};
})
(mkIf cfg.lsp.enable {

View file

@ -6,10 +6,10 @@
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
inherit (lib.types) either listOf package str enum;
inherit (lib.nvim.languages) diagnosticsToLua;
cfg = config.vim.languages.ruby;
@ -35,24 +35,8 @@
defaultFormat = "rubocop";
formats = {
rubocop = {
# TODO: is this right?
package = pkgs.rubyPackages.rubocop;
nullConfig = ''
local conditional = function(fn)
local utils = require("null-ls.utils").make_conditional_utils()
return fn(utils)
end
table.insert(
ls_sources,
null_ls.builtins.formatting.rubocop.with({
command="${pkgs.bundler}/bin/bundle",
args = vim.list_extend(
{"exec", "rubocop", "-a" },
null_ls.builtins.formatting.rubocop._opts.args
),
})
)
'';
};
};
@ -60,14 +44,7 @@
diagnosticsProviders = {
rubocop = {
package = pkgs.rubyPackages.rubocop;
nullConfig = pkg: ''
table.insert(
ls_sources,
null_ls.builtins.diagnostics.rubocop.with({
command = "${lib.getExe pkg}",
})
)
'';
config.command = getExe cfg.format.package;
};
};
in {
@ -80,7 +57,7 @@ in {
};
lsp = {
enable = mkEnableOption "Ruby LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Ruby LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
type = enum (attrNames servers);
@ -136,16 +113,23 @@ in {
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.ruby-format = formats.${cfg.format.type}.nullConfig;
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.ruby = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = {
command = getExe cfg.format.package;
};
};
})
(mkIf cfg.extraDiagnostics.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources = diagnosticsToLua {
lang = "ruby";
config = cfg.extraDiagnostics.types;
inherit diagnosticsProviders;
vim.diagnostics.nvim-lint = {
enable = true;
linters_by_ft.ruby = cfg.extraDiagnostics.types;
linters = mkMerge (map (name: {
${name}.cmd = getExe diagnosticsProviders.${name}.package;
})
cfg.extraDiagnostics.types);
};
})
]);

View file

@ -5,6 +5,7 @@
...
}: let
inherit (builtins) attrNames;
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.strings) optionalString;
@ -21,14 +22,6 @@
formats = {
rustfmt = {
package = pkgs.rustfmt;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.rustfmt.with({
command = "${cfg.format.package}/bin/rustfmt",
})
)
'';
};
};
in {
@ -50,7 +43,7 @@ in {
};
lsp = {
enable = mkEnableOption "Rust LSP support (rust-analyzer with extra tools)" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Rust LSP support (rust-analyzer with extra tools)" // {default = config.vim.lsp.enable;};
package = mkOption {
description = "rust-analyzer package, or the command to run as a list of strings";
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
@ -128,8 +121,13 @@ in {
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.rust-format = formats.${cfg.format.type}.nullConfig;
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.rust = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = {
command = getExe cfg.format.package;
};
};
})
(mkIf (cfg.lsp.enable || cfg.dap.enable) {

View file

@ -33,7 +33,7 @@ in {
};
lsp = {
enable = mkEnableOption "Scala LSP support (metals)" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Scala LSP support (metals)" // {default = config.vim.lsp.enable;};
package = mkPackageOption pkgs "metals" {
default = ["metals"];
};

View file

@ -6,11 +6,11 @@
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.languages) diagnosticsToLua;
inherit (lib.nvim.types) diagnostics;
cfg = config.vim.languages.sql;
@ -41,15 +41,10 @@
formats = {
sqlfluff = {
package = sqlfluffDefault;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.sqlfluff.with({
command = "${cfg.format.package}/bin/sqlfluff",
extra_args = {"--dialect", "${cfg.dialect}"}
})
)
'';
config = {
command = getExe cfg.format.package;
append_args = ["--dialect=${cfg.dialect}"];
};
};
};
@ -57,15 +52,10 @@
diagnosticsProviders = {
sqlfluff = {
package = sqlfluffDefault;
nullConfig = pkg: ''
table.insert(
ls_sources,
null_ls.builtins.diagnostics.sqlfluff.with({
command = "${pkg}/bin/sqlfluff",
extra_args = {"--dialect", "${cfg.dialect}"}
})
)
'';
config = {
cmd = getExe sqlfluffDefault;
args = ["lint" "--format=json" "--dialect=${cfg.dialect}"];
};
};
};
in {
@ -89,7 +79,7 @@ in {
};
lsp = {
enable = mkEnableOption "SQL LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "SQL LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "SQL LSP server to use";
@ -150,16 +140,20 @@ in {
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources."sql-format" = formats.${cfg.format.type}.nullConfig;
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.sql = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = formats.${cfg.format.type}.config;
};
})
(mkIf cfg.extraDiagnostics.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources = diagnosticsToLua {
lang = "sql";
config = cfg.extraDiagnostics.types;
inherit diagnosticsProviders;
vim.diagnostics.nvim-lint = {
enable = true;
linters_by_ft.sql = cfg.extraDiagnostics.types;
linters =
mkMerge (map (name: {${name} = diagnosticsProviders.${name}.config;})
cfg.extraDiagnostics.types);
};
})
]);

View file

@ -9,9 +9,9 @@
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.meta) getExe;
inherit (lib.generators) mkLuaInline;
inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.languages) diagnosticsToLua;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
cfg = config.vim.languages.svelte;
@ -39,42 +39,31 @@
formats = {
prettier = {
package = pkgs.nodePackages.prettier;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.prettier.with({
command = "${cfg.format.package}/bin/prettier",
})
)
'';
};
biome = {
package = pkgs.biome;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.biome.with({
command = "${cfg.format.package}/bin/biome",
})
)
'';
};
};
# TODO: specify packages
defaultDiagnosticsProvider = ["eslint_d"];
diagnosticsProviders = {
eslint_d = {
package = pkgs.eslint_d;
nullConfig = pkg: ''
table.insert(
ls_sources,
null_ls.builtins.diagnostics.eslint_d.with({
command = "${getExe pkg}",
})
)
'';
eslint_d = let
pkg = pkgs.eslint_d;
in {
package = pkg;
config = {
cmd = getExe pkg;
required_files = [
"eslint.config.js"
"eslint.config.mjs"
".eslintrc"
".eslintrc.json"
".eslintrc.js"
".eslintrc.yml"
];
};
};
};
in {
@ -88,7 +77,7 @@ in {
};
lsp = {
enable = mkEnableOption "Svelte LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Svelte LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Svelte LSP server to use";
@ -143,16 +132,22 @@ in {
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.svelte-format = formats.${cfg.format.type}.nullConfig;
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.svelte = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = {
command = getExe cfg.format.package;
};
};
})
(mkIf cfg.extraDiagnostics.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources = diagnosticsToLua {
lang = "svelte";
config = cfg.extraDiagnostics.types;
inherit diagnosticsProviders;
vim.diagnostics.nvim-lint = {
enable = true;
linters_by_ft.svelte = cfg.extraDiagnostics.types;
linters =
mkMerge (map (name: {${name} = diagnosticsProviders.${name}.config;})
cfg.extraDiagnostics.types);
};
})
]);

View file

@ -35,7 +35,7 @@ in {
enable = mkEnableOption "Tailwindcss language support";
lsp = {
enable = mkEnableOption "Tailwindcss LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Tailwindcss LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Tailwindcss LSP server to use";

View file

@ -20,7 +20,7 @@ in {
};
lsp = {
enable = mkEnableOption "Terraform LSP support (terraform-ls)" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Terraform LSP support (terraform-ls)" // {default = config.vim.lsp.enable;};
package = mkOption {
description = "terraform-ls package";

View file

@ -9,10 +9,10 @@
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.meta) getExe;
inherit (lib.generators) mkLuaInline;
inherit (lib.types) enum either listOf package str bool;
inherit (lib.nvim.lua) expToLua toLuaObject;
inherit (lib.nvim.types) mkGrammarOption diagnostics mkPluginSetupOption;
inherit (lib.nvim.languages) diagnosticsToLua;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.languages.ts;
@ -77,55 +77,36 @@
formats = {
prettier = {
package = pkgs.nodePackages.prettier;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.prettier.with({
command = "${cfg.format.package}/bin/prettier",
filetypes = { "typescript", "javascript" },
})
)
'';
};
prettierd = {
package = pkgs.prettierd;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.prettier.with({
command = "${cfg.format.package}/bin/prettierd",
})
)
'';
};
biome = {
package = pkgs.biome;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.biome.with({
command = "${cfg.format.package}/bin/biome",
})
)
'';
};
};
# TODO: specify packages
defaultDiagnosticsProvider = ["eslint_d"];
diagnosticsProviders = {
eslint_d = {
package = pkgs.eslint_d;
nullConfig = pkg: ''
table.insert(
ls_sources,
null_ls.builtins.diagnostics.eslint_d.with({
command = "${getExe pkg}",
})
)
'';
eslint_d = let
pkg = pkgs.eslint_d;
in {
package = pkg;
config = {
cmd = getExe pkg;
required_files = [
"eslint.config.js"
"eslint.config.mjs"
".eslintrc"
".eslintrc.cjs"
".eslintrc.json"
".eslintrc.js"
".eslintrc.yml"
];
};
};
};
in {
@ -140,7 +121,7 @@ in {
};
lsp = {
enable = mkEnableOption "Typescript/Javascript LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Typescript/Javascript LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Typescript/Javascript LSP server to use";
@ -215,16 +196,28 @@ in {
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.ts-format = formats.${cfg.format.type}.nullConfig;
vim.formatter.conform-nvim = {
enable = true;
setupOpts = {
formatters_by_ft.typescript = [cfg.format.type];
# .tsx files
formatters_by_ft.typescriptreact = [cfg.format.type];
formatters.${cfg.format.type} = {
command = getExe cfg.format.package;
};
};
};
})
(mkIf cfg.extraDiagnostics.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources = diagnosticsToLua {
lang = "ts";
config = cfg.extraDiagnostics.types;
inherit diagnosticsProviders;
vim.diagnostics.nvim-lint = {
enable = true;
linters_by_ft.typescript = cfg.extraDiagnostics.types;
linters_by_ft.typescriptreact = cfg.extraDiagnostics.types;
linters =
mkMerge (map (name: {${name} = diagnosticsProviders.${name}.config;})
cfg.extraDiagnostics.types);
};
})

View file

@ -9,7 +9,6 @@
inherit (lib.lists) isList;
inherit (lib.types) nullOr enum either attrsOf listOf package str;
inherit (lib.attrsets) attrNames;
inherit (lib.generators) mkLuaInline;
inherit (lib.meta) getExe;
inherit (lib.nvim.lua) expToLua toLuaObject;
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption;
@ -61,26 +60,10 @@
formats = {
typstfmt = {
package = pkgs.typstfmt;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.typstfmt.with({
command = "${cfg.format.package}/bin/typstfmt",
})
)
'';
};
# https://github.com/Enter-tainer/typstyle
typstyle = {
package = pkgs.typstyle;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.typstfmt.with({
command = "${cfg.format.package}/bin/typstyle",
})
)
'';
};
};
in {
@ -93,7 +76,7 @@ in {
};
lsp = {
enable = mkEnableOption "Typst LSP support (typst-lsp)" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Typst LSP support (typst-lsp)" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Typst LSP server to use";
@ -176,8 +159,13 @@ in {
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.typst-format = formats.${cfg.format.type}.nullConfig;
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.typst = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = {
command = getExe cfg.format.package;
};
};
})
(mkIf cfg.lsp.enable {

View file

@ -50,7 +50,7 @@ in {
};
lsp = {
enable = mkEnableOption "Vala LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Vala LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Vala LSP server to use";
type = enum (attrNames servers);

View file

@ -42,7 +42,7 @@ in {
};
lsp = {
enable = mkEnableOption "WGSL LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "WGSL LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
type = enum (attrNames servers);

View file

@ -14,14 +14,27 @@
cfg = config.vim.languages.yaml;
onAttach =
if config.vim.languages.helm.lsp.enable
then ''
on_attach = function(client, bufnr)
local filetype = vim.bo[bufnr].filetype
if filetype == "helm" then
client.stop()
end
end''
else "on_attach = default_on_attach";
defaultServer = "yaml-language-server";
servers = {
yaml-language-server = {
package = pkgs.nodePackages.yaml-language-server;
lspConfig = ''
lspconfig.yamlls.setup {
capabilities = capabilities;
on_attach = default_on_attach;
capabilities = capabilities,
${onAttach},
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
@ -42,7 +55,7 @@ in {
};
lsp = {
enable = mkEnableOption "YAML LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "YAML LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
type = enum (attrNames servers);

View file

@ -72,7 +72,7 @@ in {
};
lsp = {
enable = mkEnableOption "Zig LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Zig LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
type = enum (attrNames servers);