languages: convert language modules M-Z

This commit is contained in:
raf 2025-04-06 02:19:29 +03:00
parent dade4b6ed6
commit 64fbc41f29
No known key found for this signature in database
GPG key ID: 29D95B64378DB4BF
22 changed files with 341 additions and 445 deletions

View file

@ -4,14 +4,14 @@
lib,
...
}: let
inherit (builtins) attrNames;
inherit (builtins) attrNames isList;
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.lists) isList;
inherit (lib.types) bool enum either package listOf str;
inherit (lib.nvim.lua) expToLua toLuaObject;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.types) diagnostics mkGrammarOption mkPluginSetupOption;
inherit (lib.nvim.languages) lspOptions;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.languages.markdown;
@ -19,33 +19,23 @@
servers = {
marksman = {
package = pkgs.marksman;
lspConfig = ''
lspconfig.marksman.setup{
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${
options = {
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/marksman", "server"}''
},
}
'';
then toLuaObject cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/marksman", "server"}'';
};
};
};
defaultFormat = "deno_fmt";
formats = {
# for backwards compatibility
denofmt = {
package = pkgs.deno;
};
deno_fmt = {
package = pkgs.deno;
};
prettierd = {
package = pkgs.prettierd;
};
denofmt.package = pkgs.deno;
deno_fmt.package = pkgs.deno;
prettierd.package = pkgs.prettierd;
};
defaultDiagnosticsProvider = ["markdownlint-cli2"];
diagnosticsProviders = {
markdownlint-cli2 = {
@ -57,35 +47,29 @@ in {
enable = mkEnableOption "Markdown markup language support";
treesitter = {
enable = mkOption {
type = bool;
default = config.vim.languages.enableTreesitter;
description = "Enable Markdown treesitter";
};
enable = mkEnableOption "Markdown treesitter" // {default = config.vim.languages.enableTreesitter;};
mdPackage = mkGrammarOption pkgs "markdown";
mdInlinePackage = mkGrammarOption pkgs "markdown-inline";
};
lsp = {
enable = mkEnableOption "Enable Markdown LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Markdown LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
type = enum (attrNames servers);
default = defaultServer;
type = listOf (enum (attrNames servers));
default = [defaultServer];
description = "Markdown LSP server to use";
};
package = mkOption {
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
example = ''["marksman"]'';
description = "Markdown LSP server package, or the command to run as a list of strings";
};
};
format = {
enable = mkEnableOption "Markdown formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
type = enum (attrNames formats);
default = defaultFormat;

View file

@ -12,6 +12,7 @@
inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.languages) lspOptions;
cfg = config.vim.languages.nim;
@ -19,19 +20,14 @@
servers = {
nimlsp = {
package = pkgs.nimlsp;
lspConfig = ''
lspconfig.nimls.setup{
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${
options = {
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''
{"${cfg.lsp.package}/bin/nimlsp"}
''
};
}
'';
'';
};
};
};
@ -56,31 +52,31 @@ in {
lsp = {
enable = mkEnableOption "Nim LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
type = listOf (enum (attrNames servers));
default = [defaultServer];
description = "Nim LSP server to use";
type = str;
default = defaultServer;
};
package = mkOption {
description = "Nim LSP server package, or the command to run as a list of strings";
example = ''[lib.getExe pkgs.nimlsp]'';
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
example = ''[lib.getExe pkgs.nimlsp]'';
description = "Nim LSP server package, or the command to run as a list of strings";
};
};
format = {
enable = mkEnableOption "Nim formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
description = "Nim formatter to use";
type = enum (attrNames formats);
default = defaultFormat;
description = "Nim formatter to use";
};
package = mkOption {
description = "Nim formatter package";
type = package;
default = formats.${cfg.format.type}.package;
description = "Nim formatter package";
};
};
};

View file

@ -12,6 +12,7 @@
inherit (lib.lists) isList;
inherit (lib.strings) optionalString;
inherit (lib.types) anything attrsOf enum either listOf nullOr package str;
inherit (lib.nvim.languages) lspOptions;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
inherit (lib.nvim.lua) expToLua toLuaObject;
@ -20,11 +21,12 @@
useFormat = "on_attach = default_on_attach";
noFormat = "on_attach = attach_keymaps";
defaultServer = "nil";
packageToCmd = package: defaultCmd:
if isList package
then expToLua package
else ''{"${package}/bin/${defaultCmd}"}'';
defaultServer = "nil";
servers = {
nil = {
package = pkgs.nil;
@ -145,9 +147,9 @@ in {
lsp = {
enable = mkEnableOption "Nix LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
type = listOf (enum (attrNames servers));
default = [defaultServer];
description = "Nix LSP server to use";
type = enum (attrNames servers);
default = defaultServer;
};
package = mkOption {
@ -156,12 +158,6 @@ in {
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
};
options = mkOption {
type = nullOr (attrsOf anything);
default = null;
description = "Options to pass to nixd LSP server";
};
};
format = {

View file

@ -4,28 +4,25 @@
config,
...
}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) str either package listOf;
inherit (builtins) isList attrNames;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.lua) expToLua;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) str either package listOf enum;
inherit (lib.meta) getExe;
inherit (lib.nvim.languages) lspOptions;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.types) mkGrammarOption;
inherit (builtins) isList;
defaultServer = "nushell";
servers = {
nushell = {
package = pkgs.nushell;
lspConfig = ''
lspconfig.nushell.setup{
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
options = {
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/nu", "--no-config-file", "--lsp"}''
}
}
'';
then toLuaObject cfg.lsp.package
else ''{"${getExe cfg.lsp.package}", "--no-config-file", "--lsp"}'';
};
};
};
@ -42,8 +39,8 @@ in {
lsp = {
enable = mkEnableOption "Nu LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
type = str;
default = defaultServer;
type = listOf (enum (attrNames servers));
default = [defaultServer];
description = "Nu LSP server to use";
};

View file

@ -4,12 +4,12 @@
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (builtins) isList attrNames;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.meta) getExe;
inherit (lib.lists) isList;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) either enum listOf package str;
inherit (lib.meta) getExe;
inherit (lib.nvim.languages) lspOptions;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
@ -19,17 +19,12 @@
servers = {
ocaml-lsp = {
package = pkgs.ocamlPackages.ocaml-lsp;
lspConfig = ''
lspconfig.ocamllsp.setup {
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
options = {
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${getExe cfg.lsp.package}"}''
};
}
'';
else ''{"${getExe cfg.lsp.package}"}'';
};
};
};
@ -49,30 +44,31 @@ in {
};
lsp = {
enable = mkEnableOption "OCaml LSP support (ocaml-lsp)" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "OCaml LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "OCaml LSP server to user";
type = enum (attrNames servers);
type = listOf (enum (attrNames servers));
default = defaultServer;
description = "OCaml LSP server to user";
};
package = mkOption {
description = "OCaml language server package, or the command to run as a list of strings";
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
description = "OCaml language server package, or the command to run as a list of strings";
};
};
format = {
enable = mkEnableOption "OCaml formatting support (ocamlformat)" // {default = config.vim.languages.enableFormat;};
enable = mkEnableOption "OCaml formatting support" // {default = config.vim.languages.enableFormat;};
type = mkOption {
description = "OCaml formatter to use";
type = enum (attrNames formats);
default = defaultFormat;
description = "OCaml formatter to use";
};
package = mkOption {
description = "OCaml formatter package";
type = package;
default = formats.${cfg.format.type}.package;
description = "OCaml formatter package";
};
};
};

View file

@ -4,11 +4,12 @@
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (builtins) isList attrNames;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) either listOf package str enum;
inherit (lib.meta) getExe;
inherit (lib.nvim.languages) lspOptions;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
@ -16,17 +17,12 @@
servers = {
ols = {
package = pkgs.ols;
lspConfig = ''
lspconfig.ols.setup {
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
options = {
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else "{'${cfg.lsp.package}/bin/ols'}"
}
}
'';
else "{'${getExe cfg.lsp.package}'}";
};
};
};
@ -42,7 +38,6 @@ in {
lsp = {
enable = mkEnableOption "Odin LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
type = enum (attrNames servers);
default = defaultServer;
@ -50,9 +45,9 @@ in {
};
package = mkOption {
description = "Ols package, or the command to run as a list of strings";
type = either package (listOf str);
default = pkgs.ols;
description = "Ols package, or the command to run as a list of strings";
};
};
};

View file

@ -4,12 +4,13 @@
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.meta) getExe;
inherit (builtins) isList attrNames;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) enum either listOf package str;
inherit (lib.meta) getExe;
inherit (lib.nvim.languages) lspOptions;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
@ -19,31 +20,18 @@
servers = {
phpactor = {
package = pkgs.phpactor;
lspConfig = ''
lspconfig.phpactor.setup{
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
options = {
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''
{
"${getExe cfg.lsp.package}",
"language-server"
},
''
}
}
'';
else ''{"${getExe cfg.lsp.package}", "language-server"}'';
};
};
phan = {
package = pkgs.php81Packages.phan;
lspConfig = ''
lspconfig.phan.setup{
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
package = pkgs.php83Packages.phan;
options = {
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''
@ -59,30 +47,18 @@
"--language-server-on-stdin",
"--allow-polyfill-parser"
},
''
}
}
'';
'';
};
};
intelephense = {
package = pkgs.intelephense;
lspConfig = ''
lspconfig.intelephense.setup{
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
options = {
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''
{
"${getExe cfg.lsp.package}",
"--stdio"
},
''
}
}
'';
else ''{"${getExe cfg.lsp.package}", "--stdio"'';
};
};
};
in {
@ -98,16 +74,16 @@ in {
enable = mkEnableOption "PHP LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "PHP LSP server to use";
type = enum (attrNames servers);
type = listOf (enum (attrNames servers));
default = defaultServer;
description = "PHP LSP server to use";
};
package = mkOption {
description = "PHP 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 = "PHP LSP server package, or the command to run as a list of strings";
};
};
};
@ -117,6 +93,7 @@ in {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package];
})
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig = {
enable = true;

View file

@ -4,12 +4,13 @@
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption literalExpression;
inherit (lib.meta) getExe;
inherit (builtins) isList attrNames;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) enum either listOf package str bool;
inherit (lib.meta) getExe;
inherit (lib.nvim.languages) lspOptions;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
cfg = config.vim.languages.python;
@ -18,47 +19,32 @@
servers = {
pyright = {
package = pkgs.pyright;
lspConfig = ''
lspconfig.pyright.setup{
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${
options = {
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/pyright-langserver", "--stdio"}''
}
}
'';
else ''{"${cfg.lsp.package}/bin/pyright-langserver", "--stdio"}'';
};
};
basedpyright = {
package = pkgs.basedpyright;
lspConfig = ''
lspconfig.basedpyright.setup{
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${
options = {
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/basedpyright-langserver", "--stdio"}''
}
}
'';
else ''{"${cfg.lsp.package}/bin/basedpyright-langserver", "--stdio"}'';
};
};
python-lsp-server = {
package = pkgs.python3Packages.python-lsp-server;
lspConfig = ''
lspconfig.pylsp.setup{
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${
options = {
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/pylsp"}''
}
}
'';
else ''{"${cfg.lsp.package}/bin/pylsp"}'';
};
};
};
@ -161,27 +147,22 @@ in {
treesitter = {
enable = mkEnableOption "Python treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkOption {
description = "Python treesitter grammar to use";
type = package;
default = pkgs.vimPlugins.nvim-treesitter.builtGrammars.python;
};
package = mkGrammarOption pkgs "python";
};
lsp = {
enable = mkEnableOption "Python LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "Python LSP server to use";
type = enum (attrNames servers);
type = listOf (enum (attrNames servers));
default = defaultServer;
description = "Python LSP server to use";
};
package = mkOption {
description = "python 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 = "Python LSP server package, or the command to run as a list of strings";
};
};

View file

@ -4,12 +4,13 @@
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption literalExpression;
inherit (builtins) isList attrNames;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.lua) expToLua;
inherit (lib.meta) getExe;
inherit (lib.nvim.languages) lspOptions;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.r;
@ -56,17 +57,12 @@
package = pkgs.writeShellScriptBin "r_lsp" ''
${r-with-languageserver}/bin/R --slave -e "languageserver::run()"
'';
lspConfig = ''
lspconfig.r_language_server.setup{
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${
options = {
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${lib.getExe cfg.lsp.package}"}''
}
}
'';
then toLuaObject cfg.lsp.package
else ''{"${getExe cfg.lsp.package}"}'';
};
};
};
in {
@ -82,16 +78,16 @@ in {
enable = mkEnableOption "R LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "R LSP server to use";
type = enum (attrNames servers);
type = listOf (enum (attrNames servers));
default = defaultServer;
description = "R LSP server to use";
};
package = mkOption {
description = "R LSP server package, or the command to run as a list of strings";
example = literalExpression "[ (lib.getExe pkgs.jdt-language-server) \"-data\" \"~/.cache/jdtls/workspace\" ]";
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
example = literalExpression "[ (lib.getExe pkgs.jdt-language-server) \"-data\" \"~/.cache/jdtls/workspace\" ]";
description = "R LSP server package, or the command to run as a list of strings";
};
};
@ -118,6 +114,11 @@ in {
vim.treesitter.grammars = [cfg.treesitter.package];
})
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.r-lsp = servers.${cfg.lsp.server}.lspConfig;
})
(mkIf cfg.format.enable {
vim.formatter.conform-nvim = {
enable = true;
@ -125,10 +126,5 @@ in {
setupOpts.formatters.${cfg.format.type} = formats.${cfg.format.type}.config;
};
})
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.r-lsp = servers.${cfg.lsp.server}.lspConfig;
})
]);
}

View file

@ -4,34 +4,35 @@
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.meta) getExe;
inherit (builtins) isList attrNames;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) either listOf package str enum;
inherit (lib.meta) getExe;
inherit (lib.nvim.languages) lspOptions;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.languages.ruby;
defaultServer = "rubyserver";
defaultServer = "solargraph";
servers = {
rubyserver = {
solargraph = {
package = pkgs.rubyPackages.solargraph;
lspConfig = ''
lspconfig.solargraph.setup {
capabilities = capabilities,
on_attach = attach_keymaps,
flags = {
debounce_text_changes = 150,
},
cmd = { "${pkgs.solargraph}/bin/solargraph", "stdio" }
}
'';
options = {
cmd =
if isList cfg.lsp.package
then toLuaObject cfg.lsp.package
else ''{"${getExe cfg.lsp.package}", "stdio"}'';
flags = {
debounce_text_changes = 150;
};
};
};
};
# testing
defaultFormat = "rubocop";
formats = {
rubocop = {
@ -58,9 +59,8 @@ in {
lsp = {
enable = mkEnableOption "Ruby LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
type = enum (attrNames servers);
type = listOf (enum (attrNames servers));
default = defaultServer;
description = "Ruby LSP server to use";
};
@ -74,7 +74,6 @@ in {
format = {
enable = mkEnableOption "Ruby formatter support" // {default = config.vim.languages.enableFormat;};
type = mkOption {
type = enum (attrNames formats);
default = defaultFormat;
@ -89,10 +88,7 @@ in {
};
extraDiagnostics = {
enable =
mkEnableOption "Ruby extra diagnostics support"
// {default = config.vim.languages.enableExtraDiagnostics;};
enable = mkEnableOption "extra Ruby diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
types = diagnostics {
langDesc = "Ruby";
inherit diagnosticsProviders;

View file

@ -12,6 +12,7 @@
inherit (lib.trivial) boolToString;
inherit (lib.lists) isList;
inherit (lib.types) bool package str listOf either enum;
inherit (lib.nvim.languages) lspOptions;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.dag) entryAfter entryAnywhere;

View file

@ -6,13 +6,15 @@
}: let
inherit (lib.generators) mkLuaInline;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.options) mkOption mkEnableOption mkPackageOption;
inherit (lib.strings) optionalString;
inherit (lib.types) attrsOf anything bool;
inherit (lib.nvim.languages) lspOptions;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.dag) entryAfter;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.types) mkGrammarOption luaInline;
inherit (lib.options) mkOption mkEnableOption mkPackageOption;
inherit (lib.strings) optionalString;
inherit (lib.types) attrsOf anything bool;
listCommandsAction =
if config.vim.telescope.enable

View file

@ -4,14 +4,15 @@
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.meta) getExe;
inherit (builtins) isList attrNames;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) diagnostics;
inherit (lib.meta) getExe;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.languages) lspOptions;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.types) diagnostics mkGrammarOption;
cfg = config.vim.languages.sql;
sqlfluffDefault = pkgs.sqlfluff;
@ -20,20 +21,20 @@
servers = {
sqls = {
package = pkgs.sqls;
lspConfig = ''
lspconfig.sqls.setup {
on_attach = function(client)
client.server_capabilities.execute_command = true
options = {
on_attach = mkLuaInline ''
function(client)
on_attach_keymaps(client, bufnr)
require'sqls'.setup{}
client.server_capabilities.execute_command = true
require('sqls').setup()
end,
cmd = ${
'';
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{ "${cfg.lsp.package}/bin/sqls", "-config", string.format("%s/config.yml", vim.fn.getcwd()) }''
}
}
'';
then toLuaObject cfg.lsp.package
else ''{ "${cfg.lsp.package}/bin/sqls", "-config", string.format("%s/config.yml", vim.fn.getcwd()) }'';
};
};
};
@ -70,50 +71,42 @@ in {
treesitter = {
enable = mkEnableOption "SQL treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkOption {
description = "SQL treesitter grammar to use";
type = package;
default = pkgs.vimPlugins.nvim-treesitter.builtGrammars.sql;
};
package = mkGrammarOption "sql";
};
lsp = {
enable = mkEnableOption "SQL LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "SQL LSP server to use";
type = enum (attrNames servers);
type = listOf (enum (attrNames servers));
default = defaultServer;
description = "SQL LSP server to use";
};
package = mkOption {
description = "SQL 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);
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
default = servers.${cfg.lsp.server}.package;
description = "SQL LSP server package, or the command to run as a list of strings";
};
};
format = {
enable = mkEnableOption "SQL formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
description = "SQL formatter to use";
type = enum (attrNames formats);
default = defaultFormat;
description = "SQL formatter to use";
};
package = mkOption {
description = "SQL formatter package";
type = package;
default = formats.${cfg.format.type}.package;
description = "SQL formatter package";
};
};
extraDiagnostics = {
enable = mkEnableOption "extra SQL diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
types = diagnostics {
langDesc = "SQL";
inherit diagnosticsProviders;

View file

@ -4,14 +4,15 @@
lib,
...
}: let
inherit (builtins) attrNames;
inherit (builtins) isList 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.meta) getExe;
inherit (lib.generators) mkLuaInline;
inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.languages) lspOptions;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
cfg = config.vim.languages.svelte;
@ -20,17 +21,12 @@
servers = {
svelte = {
package = pkgs.nodePackages.svelte-language-server;
lspConfig = ''
lspconfig.svelte.setup {
capabilities = capabilities;
on_attach = attach_keymaps,
cmd = ${
options = {
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/svelteserver", "--stdio"}''
}
}
'';
then toLuaObject cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/svelteserver", "--stdio"}'';
};
};
};
@ -79,7 +75,6 @@ in {
treesitter = {
enable = mkEnableOption "Svelte treesitter" // {default = config.vim.languages.enableTreesitter;};
sveltePackage = mkGrammarOption pkgs "svelte";
};
@ -88,15 +83,15 @@ in {
server = mkOption {
description = "Svelte LSP server to use";
type = enum (attrNames servers);
type = listOf (enum (attrNames servers));
default = defaultServer;
};
package = mkOption {
description = "Svelte 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 = "Svelte LSP server package, or the command to run as a list of strings";
};
};

View file

@ -9,7 +9,8 @@
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) lspOptions;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.languages.tailwind;
@ -17,17 +18,12 @@
servers = {
tailwindcss-language-server = {
package = pkgs.tailwindcss-language-server;
lspConfig = ''
lspconfig.tailwindcss.setup {
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${
options = {
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/tailwindcss-language-server", "--stdio"}''
}
}
'';
then toLuaObject cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/tailwindcss-language-server", "--stdio"}'';
};
};
};
in {
@ -36,11 +32,10 @@ in {
lsp = {
enable = mkEnableOption "Tailwindcss LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "Tailwindcss LSP server to use";
type = enum (attrNames servers);
type = listOf (enum (attrNames servers));
default = defaultServer;
description = "Tailwindcss LSP server to use";
};
package = mkOption {

View file

@ -4,12 +4,28 @@
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (builtins) isList attrNames;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) package;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) either package enum listOf str;
inherit (lib.meta) getExe;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.languages) lspOptions;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.terraform;
defaultServer = "terraform-ls";
servers = {
terraform-ls = {
package = pkgs.terraform-ls;
options = {
cmd =
if isList cfg.lsp.package
then toLuaObject cfg.lsp.package
else ''{"${getExe cfg.lsp.package}", "serve"}'';
};
};
};
in {
options.vim.languages.terraform = {
enable = mkEnableOption "Terraform/HCL support";
@ -20,12 +36,18 @@ in {
};
lsp = {
enable = mkEnableOption "Terraform LSP support (terraform-ls)" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Terraform LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
type = listOf (enum (attrNames servers));
default = defaultServer;
description = "Terraform LSP server to use";
};
package = mkOption {
description = "terraform-ls package";
type = package;
default = pkgs.terraform-ls;
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
description = "Terraform LSP server package, or the command to run as a list of strings";
};
};
};

View file

@ -4,14 +4,14 @@
lib,
...
}: let
inherit (builtins) attrNames;
inherit (builtins) isList attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.types) enum either listOf package str bool;
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.languages) lspOptions;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.types) mkGrammarOption diagnostics mkPluginSetupOption;
inherit (lib.nvim.dag) entryAnywhere;
@ -21,36 +21,29 @@
servers = {
ts_ls = {
package = pkgs.typescript-language-server;
lspConfig = ''
lspconfig.ts_ls.setup {
capabilities = capabilities,
on_attach = function(client, bufnr)
options = {
on_attach = mkLuaInline ''
function(client, bufnr)
attach_keymaps(client, bufnr);
client.server_capabilities.documentFormattingProvider = false;
end,
cmd = ${
'';
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/typescript-language-server", "--stdio"}''
}
}
'';
then toLuaObject cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/typescript-language-server", "--stdio"}'';
};
};
denols = {
package = pkgs.deno;
lspConfig = ''
vim.g.markdown_fenced_languages = { "ts=typescript" }
lspconfig.denols.setup {
capabilities = capabilities;
on_attach = attach_keymaps,
cmd = ${
options = {
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/deno", "lsp"}''
}
}
'';
then toLuaObject cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/deno", "lsp"}'';
};
};
# Here for backwards compatibility. Still consider tsserver a valid
@ -58,17 +51,12 @@
# redirect the user to the correct server.
tsserver = {
package = pkgs.typescript-language-server;
lspConfig = ''
lspconfig.ts_ls.setup {
capabilities = capabilities;
on_attach = attach_keymaps,
cmd = ${
options = {
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/typescript-language-server", "--stdio"}''
}
}
'';
then toLuaObject cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/typescript-language-server", "--stdio"}'';
};
};
};
@ -128,40 +116,37 @@ in {
lsp = {
enable = mkEnableOption "Typescript/Javascript LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "Typescript/Javascript LSP server to use";
type = enum (attrNames servers);
type = listOf (enum (attrNames servers));
default = defaultServer;
description = "Typescript/Javascript LSP server to use";
};
package = mkOption {
description = "Typescript/Javascript 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 = "Typescript/Javascript LSP server package, or the command to run as a list of strings";
};
};
format = {
enable = mkEnableOption "Typescript/Javascript formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
description = "Typescript/Javascript formatter to use";
type = enum (attrNames formats);
default = defaultFormat;
description = "Typescript/Javascript formatter to use";
};
package = mkOption {
description = "Typescript/Javascript formatter package";
type = package;
default = formats.${cfg.format.type}.package;
description = "Typescript/Javascript formatter package";
};
};
extraDiagnostics = {
enable = mkEnableOption "extra Typescript/Javascript diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
types = diagnostics {
langDesc = "Typescript/Javascript";
inherit diagnosticsProviders;
@ -175,15 +160,14 @@ in {
[ts-error-translator.nvim]: https://github.com/dmmulroy/ts-error-translator.nvim
Typescript error translation with [ts-error-translator.nvim]
'';
setupOpts = mkPluginSetupOption "ts-error-translator" {
# This is the default configuration behaviour.
auto_override_publish_diagnostics = mkOption {
description = "Automatically override the publish_diagnostics handler";
type = bool;
default = true;
description = "Automatically override the publish_diagnostics handler";
};
};
};

View file

@ -4,12 +4,14 @@
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (builtins) isList attrNames;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) nullOr enum either attrsOf listOf package str;
inherit (lib.attrsets) attrNames;
inherit (lib.meta) getExe;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.languages) lspOptions;
inherit (lib.nvim.lua) expToLua toLuaObject;
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption;
inherit (lib.nvim.dag) entryAnywhere;
@ -20,39 +22,38 @@
servers = {
typst-lsp = {
package = pkgs.typst-lsp;
lspConfig = ''
lspconfig.typst_lsp.setup {
capabilities = capabilities,
on_attach = function(client, bufnr)
-- Disable semantic tokens as a workaround for a semantic token error when using non-english characters
options = {
on_attach = mkLuaInline ''
function(client, bufnr)
-- Disable semantic tokens as a workaround for a semantic token error
-- when using non-english characters
client.server_capabilities.semanticTokensProvider = nil
end,
cmd = ${
'';
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/typst-lsp"}''
},
}
'';
else ''{"${getExe cfg.lsp.package}'';
};
};
tinymist = {
package = pkgs.tinymist;
lspConfig = ''
lspconfig.tinymist.setup {
capabilities = capabilities,
single_file_support = true,
on_attach = function(client, bufnr)
-- Disable semantic tokens as a workaround for a semantic token error when using non-english characters
options = {
on_attach = mkLuaInline ''
function(client, bufnr)
-- Disable semantic tokens as a workaround for a semantic token error
-- when using non-english characters
client.server_capabilities.semanticTokensProvider = nil
end,
cmd = ${
'';
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/tinymist"}''
},
}
'';
else ''{"${cfg.lsp.package}/bin/tinymist"}'';
};
};
};
@ -79,44 +80,46 @@ in {
enable = mkEnableOption "Typst LSP support (typst-lsp)" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "Typst LSP server to use";
type = enum (attrNames servers);
type = listOf (enum (attrNames servers));
default = defaultServer;
description = "Typst LSP server to use";
};
package = mkOption {
description = "typst-lsp 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 = "typst-lsp package, or the command to run as a list of strings";
};
};
format = {
enable = mkEnableOption "Typst document formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
description = "Typst formatter to use";
type = enum (attrNames formats);
default = defaultFormat;
description = "Typst formatter to use";
};
package = mkOption {
description = "Typst formatter package";
type = package;
default = formats.${cfg.format.type}.package;
description = "Typst formatter package";
};
};
extensions = {
typst-preview-nvim = {
enable =
mkEnableOption ''
[typst-preview.nvim]: https://github.com/chomosuke/typst-preview.nvim
mkEnableOption ""
// {
default = true;
description = ''
[typst-preview.nvim]: https://github.com/chomosuke/typst-preview.nvim
Low latency typst preview for Neovim via [typst-preview.nvim]
''
// {default = true;};
Low latency typst preview for Neovim via [typst-preview.nvim]
'';
};
setupOpts = mkPluginSetupOption "typst-preview-nvim" {
open_cmd = mkOption {

View file

@ -9,6 +9,8 @@
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.languages) lspOptions;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
@ -26,18 +28,13 @@
--prefix PATH : ${pkgs.uncrustify}/bin
'';
};
internalFormatter = true;
lspConfig = ''
lspconfig.vala_ls.setup {
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${
options = {
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/vala-language-server"}''
},
}
'';
else ''{"${cfg.lsp.package}/bin/vala-language-server"}'';
};
};
};
in {
@ -52,15 +49,15 @@ in {
lsp = {
enable = mkEnableOption "Vala LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "Vala LSP server to use";
type = enum (attrNames servers);
type = listOf (enum (attrNames servers));
default = defaultServer;
description = "Vala LSP server to use";
};
package = mkOption {
description = "Vala LSP server package, or the command to run as a list of strings";
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
description = "Vala LSP server package, or the command to run as a list of strings";
};
};
};

View file

@ -7,10 +7,11 @@
inherit (builtins) attrNames;
inherit (lib.lists) isList;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.options) literalExpression mkEnableOption mkOption;
inherit (lib.types) either enum listOf package str;
inherit (lib.nvim.languages) lspOptions;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.wgsl;
@ -19,17 +20,12 @@
wgsl-analyzer = {
package = pkgs.wgsl-analyzer;
internalFormatter = true;
lspConfig = ''
lspconfig.wgsl_analyzer.setup {
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
options = {
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else "{'${cfg.lsp.package}/bin/wgsl_analyzer'}"
}
}
'';
else "{'${cfg.lsp.package}/bin/wgsl_analyzer'}";
};
};
};
in {
@ -43,18 +39,17 @@ in {
lsp = {
enable = mkEnableOption "WGSL LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
type = enum (attrNames servers);
type = listOf (enum (attrNames servers));
default = defaultServer;
description = "WGSL LSP server to use";
};
package = mkOption {
description = "wgsl-analyzer package, or the command to run as a list of strings";
example = literalExpression "[(lib.getExe pkgs.wgsl-analyzer)]";
type = either package (listOf str);
default = pkgs.wgsl-analyzer;
example = literalExpression "[(lib.getExe pkgs.wgsl-analyzer)]";
description = "wgsl-analyzer package, or the command to run as a list of strings";
};
};
};

View file

@ -4,44 +4,39 @@
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (builtins) isList attrNames;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) enum either listOf package str;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.languages) lspOptions;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
cfg = config.vim.languages.yaml;
onAttach =
yamlOnAttach =
if config.vim.languages.helm.lsp.enable
then ''
on_attach = function(client, bufnr)
function(client, bufnr)
local filetype = vim.bo[bufnr].filetype
if filetype == "helm" then
client.stop()
end
end''
else "on_attach = default_on_attach";
else "default_on_attach";
defaultServer = "yaml-language-server";
servers = {
yaml-language-server = {
package = pkgs.nodePackages.yaml-language-server;
lspConfig = ''
lspconfig.yamlls.setup {
capabilities = capabilities,
${onAttach},
cmd = ${
options = {
on_attach = mkLuaInline yamlOnAttach;
cmd =
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/yaml-language-server", "--stdio"}''
},
}
'';
else ''{"${cfg.lsp.package}/bin/yaml-language-server", "--stdio"}'';
};
};
};
in {
@ -58,7 +53,7 @@ in {
enable = mkEnableOption "YAML LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
type = enum (attrNames servers);
type = listOf (enum (attrNames servers));
default = defaultServer;
description = "YAML LSP server to use";
};

View file

@ -9,6 +9,7 @@
inherit (lib.modules) mkIf mkMerge mkDefault;
inherit (lib.lists) isList;
inherit (lib.types) bool either listOf package str enum;
inherit (lib.nvim.languages) lspOptions;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
@ -73,7 +74,6 @@ in {
lsp = {
enable = mkEnableOption "Zig LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
type = enum (attrNames servers);
default = defaultServer;
@ -81,9 +81,9 @@ in {
};
package = mkOption {
description = "ZLS package, or the command to run as a list of strings";
type = either package (listOf str);
default = pkgs.zls;
description = "ZLS package, or the command to run as a list of strings";
};
};