mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-04-13 16:18:36 +00:00
Merge b2f6c60221
into ed31499ad6
This commit is contained in:
commit
dbb35afead
26 changed files with 495 additions and 517 deletions
|
@ -1,10 +1,11 @@
|
|||
# From home-manager: https://github.com/nix-community/home-manager/blob/master/modules/lib/booleans.nix
|
||||
{lib}: let
|
||||
inherit (builtins) isString getAttr;
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.types) bool;
|
||||
inherit (lib.types) listOf bool str submodule attrsOf anything either nullOr;
|
||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||
inherit (lib.nvim.types) luaInline;
|
||||
in {
|
||||
# TODO: remove
|
||||
diagnosticsToLua = {
|
||||
lang,
|
||||
config,
|
||||
|
@ -32,4 +33,48 @@ in {
|
|||
type = bool;
|
||||
description = "Turn on ${desc} for enabled languages by default";
|
||||
};
|
||||
|
||||
lspOptions = submodule {
|
||||
freeformType = attrsOf anything;
|
||||
options = {
|
||||
enable = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "Whether to enable this LSP server.";
|
||||
};
|
||||
|
||||
capabilities = mkOption {
|
||||
type = nullOr (either luaInline (attrsOf anything));
|
||||
default = null;
|
||||
description = "LSP capabilitiess to pass to lspconfig";
|
||||
};
|
||||
|
||||
on_attach = mkOption {
|
||||
type = nullOr luaInline;
|
||||
default = null;
|
||||
description = "Function to execute when an LSP server attaches to a buffer";
|
||||
};
|
||||
|
||||
filetypes = mkOption {
|
||||
type = nullOr (listOf str);
|
||||
default = null;
|
||||
description = "Filetypes to auto-attach LSP in";
|
||||
};
|
||||
|
||||
cmd = mkOption {
|
||||
type = nullOr (listOf str);
|
||||
default = null;
|
||||
description = "Command used to start the LSP server";
|
||||
};
|
||||
|
||||
root_markers = mkOption {
|
||||
type = nullOr (listOf str);
|
||||
default = null;
|
||||
description = ''
|
||||
"root markers" used to determine the root directory of the workspace, and
|
||||
the filetypes associated with this LSP server.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
48
lib/lua.nix
48
lib/lua.nix
|
@ -1,8 +1,8 @@
|
|||
# Helpers for converting values to lua
|
||||
{lib}: let
|
||||
inherit (builtins) hasAttr head throw typeOf isList isAttrs isBool isInt isString isPath isFloat toJSON;
|
||||
inherit (lib.attrsets) mapAttrsToList filterAttrs;
|
||||
inherit (lib.strings) concatStringsSep concatMapStringsSep stringToCharacters concatLines;
|
||||
inherit (builtins) head throw typeOf isList isAttrs isBool isInt isString isPath isFloat toJSON;
|
||||
inherit (lib.attrsets) mapAttrsToList filterAttrs hasAttr;
|
||||
inherit (lib.strings) concatStringsSep concatMapStringsSep stringToCharacters;
|
||||
inherit (lib.trivial) boolToString warn;
|
||||
in rec {
|
||||
# Convert a null value to lua's nil
|
||||
|
@ -11,43 +11,13 @@ in rec {
|
|||
then "nil"
|
||||
else "'${value}'";
|
||||
|
||||
# convert an expression to lua
|
||||
expToLua = exp:
|
||||
if isList exp
|
||||
then listToLuaTable exp # if list, convert to lua table
|
||||
else if isAttrs exp
|
||||
then attrsetToLuaTable exp # if attrs, convert to table
|
||||
else if isBool exp
|
||||
then boolToString exp # if bool, convert to string
|
||||
else if isInt exp
|
||||
then toString exp # if int, convert to string
|
||||
else if exp == null
|
||||
then "nil"
|
||||
else (toJSON exp); # otherwise jsonify the value and print as is
|
||||
|
||||
# convert list to a lua table
|
||||
listToLuaTable = list:
|
||||
"{ " + (concatStringsSep ", " (map expToLua list)) + " }";
|
||||
|
||||
# convert attrset to a lua table
|
||||
attrsetToLuaTable = attrset:
|
||||
"{ "
|
||||
+ (
|
||||
concatStringsSep ", "
|
||||
(
|
||||
mapAttrsToList (
|
||||
name: value:
|
||||
name
|
||||
+ " = "
|
||||
+ (expToLua value)
|
||||
)
|
||||
attrset
|
||||
)
|
||||
)
|
||||
+ " }";
|
||||
# Convert a list of lua expressions to a lua table. The difference to listToLuaTable is that the elements here are expected to be lua expressions already, whereas listToLuaTable converts from nix types to lua first
|
||||
luaTable = items: ''{${concatStringsSep "," items}}'';
|
||||
expToLua = exp: builtins.warn "expToLua is deprecated, please use toLuaObject instead" (toLuaObject exp);
|
||||
listToLuaTable = exp: builtins.warn "listToLuaTable is deprecated, please use toLuaObject instead" (toLuaObject exp);
|
||||
attrsetToLuaTable = exp: builtins.warn "attrsetToLuaTable is deprecated, please use toLuaObject instead" (toLuaObject exp);
|
||||
luaTable = exp: builtins.warn "luaTable is deprecated, please use toLuaObject instead" (toLuaObject exp);
|
||||
|
||||
# Check if the given object is a Lua inline object.
|
||||
# isLuaInline :: AttrSet -> Bool
|
||||
isLuaInline = object: (object._type or null) == "lua-inline";
|
||||
|
||||
toLuaObject = args:
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
./debug.nix
|
||||
./diagnostics.nix
|
||||
./highlight.nix
|
||||
./lsp.nix
|
||||
./spellcheck.nix
|
||||
];
|
||||
}
|
||||
|
|
55
modules/neovim/init/lsp.nix
Normal file
55
modules/neovim/init/lsp.nix
Normal file
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) filter;
|
||||
inherit (lib.modules) mkIf mkMerge mkDefault;
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.types) attrsOf;
|
||||
inherit (lib.strings) concatLines;
|
||||
inherit (lib.attrsets) mapAttrsToList attrNames filterAttrs;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.nvim.languages) lspOptions;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
|
||||
lspConfigurations =
|
||||
mapAttrsToList (
|
||||
name: value: ''
|
||||
vim.lsp.config["${name}"] = ${toLuaObject value}
|
||||
''
|
||||
)
|
||||
cfg.servers;
|
||||
|
||||
enabledServers = filterAttrs (_: u: u.enable) cfg.servers;
|
||||
in {
|
||||
options = {
|
||||
vim.lsp.servers = mkOption {
|
||||
type = attrsOf lspOptions;
|
||||
default = {};
|
||||
description = "";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkMerge [
|
||||
{
|
||||
vim.lsp.servers."*" = {
|
||||
capabilities = mkDefault (mkLuaInline "capabilities");
|
||||
on_attach = mkDefault (mkLuaInline "default_on_attach");
|
||||
};
|
||||
}
|
||||
|
||||
(mkIf (cfg.servers != {}) {
|
||||
vim.luaConfigRC.lsp-servers = entryAnywhere ''
|
||||
-- Individual LSP configurations managed by nvf.
|
||||
${(concatLines lspConfigurations)}
|
||||
|
||||
-- Enable configured LSPs explicitly
|
||||
vim.lsp.enable(${toLuaObject (filter (name: name != "*") (attrNames enabledServers))})
|
||||
'';
|
||||
})
|
||||
];
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -4,16 +4,15 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (builtins) isList attrNames;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.modules) mkIf mkMerge mkRenamedOptionModule;
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.trivial) boolToString;
|
||||
inherit (lib.lists) isList;
|
||||
inherit (lib.types) bool package str listOf either enum;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.dag) entryAfter entryAnywhere;
|
||||
|
||||
cfg = config.vim.languages.rust;
|
||||
|
@ -25,6 +24,10 @@
|
|||
};
|
||||
};
|
||||
in {
|
||||
imports = [
|
||||
(mkRenamedOptionModule ["vim" "languages" "rust" "crates"] ["vim" "languages" "rust" "extensions" "crates-nvim"])
|
||||
];
|
||||
|
||||
options.vim.languages.rust = {
|
||||
enable = mkEnableOption "Rust language support";
|
||||
|
||||
|
@ -33,15 +36,6 @@ in {
|
|||
package = mkGrammarOption pkgs "rust";
|
||||
};
|
||||
|
||||
crates = {
|
||||
enable = mkEnableOption "crates-nvim, tools for managing dependencies";
|
||||
codeActions = mkOption {
|
||||
description = "Enable code actions through null-ls";
|
||||
type = bool;
|
||||
default = true;
|
||||
};
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "Rust LSP support (rust-analyzer with extra tools)" // {default = config.vim.languages.enableLSP;};
|
||||
package = mkOption {
|
||||
|
@ -96,25 +90,26 @@ in {
|
|||
default = pkgs.lldb;
|
||||
};
|
||||
};
|
||||
|
||||
extensions = {
|
||||
crates-nvim = {
|
||||
enable =
|
||||
mkEnableOption ""
|
||||
// {
|
||||
default = true;
|
||||
description = ''
|
||||
[crates.nvim]: https://github.com/Saecki/crates.nvim/
|
||||
|
||||
Helper plugin for managing crates.io dependencies [crates.nvim]
|
||||
'';
|
||||
};
|
||||
|
||||
setupOpts = mkPluginSetupOption "crates-nvim" {};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.crates.enable {
|
||||
vim = {
|
||||
startPlugins = ["crates-nvim"];
|
||||
lsp.null-ls.enable = mkIf cfg.crates.codeActions true;
|
||||
autocomplete.nvim-cmp.sources = {crates = "[Crates]";};
|
||||
pluginRC.rust-crates = entryAnywhere ''
|
||||
require('crates').setup {
|
||||
null_ls = {
|
||||
enabled = ${boolToString cfg.crates.codeActions},
|
||||
name = "crates.nvim",
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
|
@ -146,7 +141,7 @@ in {
|
|||
server = {
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then expToLua cfg.lsp.package
|
||||
then toLuaObject cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/rust-analyzer"}''
|
||||
},
|
||||
default_settings = {
|
||||
|
@ -192,5 +187,22 @@ in {
|
|||
'';
|
||||
};
|
||||
})
|
||||
|
||||
# Extensions
|
||||
(mkIf cfg.extensions.crates.enable {
|
||||
vim = {
|
||||
startPlugins = ["crates-nvim"];
|
||||
autocomplete.nvim-cmp.sources = {crates = "[Crates]";};
|
||||
|
||||
pluginRC.rust-crates-nvim = entryAnywhere ''
|
||||
require('crates').setup {
|
||||
null_ls = {
|
||||
enabled = ${boolToString cfg.crates.codeActions},
|
||||
name = "crates.nvim",
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue