mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-02 21:34:33 +02:00
treewide: Reformat with nixfmt
This commit is contained in:
parent
c6281260dc
commit
62f32bfc71
459 changed files with 28139 additions and 26377 deletions
|
@ -5,19 +5,18 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.conform-nvim;
|
||||
in {
|
||||
options.plugins.conform-nvim =
|
||||
helpers.neovim-plugin.extraOptionsOptions
|
||||
// {
|
||||
enable = mkEnableOption "conform-nvim";
|
||||
in
|
||||
{
|
||||
options.plugins.conform-nvim = helpers.neovim-plugin.extraOptionsOptions // {
|
||||
enable = mkEnableOption "conform-nvim";
|
||||
|
||||
package = helpers.mkPackageOption "conform-nvim" pkgs.vimPlugins.conform-nvim;
|
||||
package = helpers.mkPackageOption "conform-nvim" pkgs.vimPlugins.conform-nvim;
|
||||
|
||||
formattersByFt =
|
||||
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything)
|
||||
"see documentation"
|
||||
formattersByFt =
|
||||
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "see documentation"
|
||||
''
|
||||
```nix
|
||||
# Map of filetype to formatters
|
||||
|
@ -37,28 +36,24 @@ in {
|
|||
```
|
||||
'';
|
||||
|
||||
formatOnSave =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
formatOnSave =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(
|
||||
with helpers.nixvimTypes;
|
||||
either
|
||||
strLuaFn
|
||||
(
|
||||
submodule {
|
||||
options = {
|
||||
lspFallback = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "See :help conform.format for details.";
|
||||
};
|
||||
timeoutMs = mkOption {
|
||||
type = types.int;
|
||||
default = 500;
|
||||
description = "See :help conform.format for details.";
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
either strLuaFn (submodule {
|
||||
options = {
|
||||
lspFallback = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "See :help conform.format for details.";
|
||||
};
|
||||
timeoutMs = mkOption {
|
||||
type = types.int;
|
||||
default = 500;
|
||||
description = "See :help conform.format for details.";
|
||||
};
|
||||
};
|
||||
})
|
||||
)
|
||||
"see documentation"
|
||||
''
|
||||
|
@ -68,23 +63,19 @@ in {
|
|||
See :help conform.format for details.
|
||||
'';
|
||||
|
||||
formatAfterSave =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
formatAfterSave =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(
|
||||
with helpers.nixvimTypes;
|
||||
either
|
||||
strLuaFn
|
||||
(
|
||||
submodule {
|
||||
options = {
|
||||
lspFallback = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "See :help conform.format for details.";
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
either strLuaFn (submodule {
|
||||
options = {
|
||||
lspFallback = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "See :help conform.format for details.";
|
||||
};
|
||||
};
|
||||
})
|
||||
)
|
||||
"see documentation"
|
||||
''
|
||||
|
@ -93,45 +84,44 @@ in {
|
|||
This can also be a function that returns the table.
|
||||
'';
|
||||
|
||||
logLevel = helpers.defaultNullOpts.mkLogLevel "error" ''
|
||||
Set the log level. Use `:ConformInfo` to see the location of the log file.
|
||||
'';
|
||||
logLevel = helpers.defaultNullOpts.mkLogLevel "error" ''
|
||||
Set the log level. Use `:ConformInfo` to see the location of the log file.
|
||||
'';
|
||||
|
||||
notifyOnError =
|
||||
helpers.defaultNullOpts.mkBool true
|
||||
"Conform will notify you when a formatter errors";
|
||||
notifyOnError = helpers.defaultNullOpts.mkBool true "Conform will notify you when a formatter errors";
|
||||
|
||||
formatters =
|
||||
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything)
|
||||
"see documentation"
|
||||
formatters =
|
||||
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "see documentation"
|
||||
"Custom formatters and changes to built-in formatters";
|
||||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
setupOptions = with cfg;
|
||||
{
|
||||
formatters_by_ft = formattersByFt;
|
||||
format_on_save =
|
||||
if builtins.isAttrs formatOnSave
|
||||
then {
|
||||
lsp_fallback = formatOnSave.lspFallback;
|
||||
timeout_ms = formatOnSave.timeoutMs;
|
||||
}
|
||||
else helpers.mkRaw formatOnSave;
|
||||
format_after_save =
|
||||
if builtins.isAttrs formatAfterSave
|
||||
then {
|
||||
lsp_fallback = formatOnSave.lspFallback;
|
||||
}
|
||||
else helpers.mkRaw formatAfterSave;
|
||||
log_level = logLevel;
|
||||
notify_on_error = notifyOnError;
|
||||
inherit formatters;
|
||||
}
|
||||
// cfg.extraOptions;
|
||||
in
|
||||
config =
|
||||
let
|
||||
setupOptions =
|
||||
with cfg;
|
||||
{
|
||||
formatters_by_ft = formattersByFt;
|
||||
format_on_save =
|
||||
if builtins.isAttrs formatOnSave then
|
||||
{
|
||||
lsp_fallback = formatOnSave.lspFallback;
|
||||
timeout_ms = formatOnSave.timeoutMs;
|
||||
}
|
||||
else
|
||||
helpers.mkRaw formatOnSave;
|
||||
format_after_save =
|
||||
if builtins.isAttrs formatAfterSave then
|
||||
{ lsp_fallback = formatOnSave.lspFallback; }
|
||||
else
|
||||
helpers.mkRaw formatAfterSave;
|
||||
log_level = logLevel;
|
||||
notify_on_error = notifyOnError;
|
||||
inherit formatters;
|
||||
}
|
||||
// cfg.extraOptions;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [cfg.package];
|
||||
extraPlugins = [ cfg.package ];
|
||||
|
||||
extraConfigLua = ''
|
||||
require("conform").setup(${helpers.toLuaObject setupOptions})
|
||||
|
|
|
@ -5,20 +5,25 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.lsp;
|
||||
in {
|
||||
in
|
||||
{
|
||||
imports =
|
||||
[
|
||||
./language-servers
|
||||
]
|
||||
[ ./language-servers ]
|
||||
# TODO: introduced 2024-02-14, remove on 2024-03-14
|
||||
++ (
|
||||
map
|
||||
++ (map
|
||||
(
|
||||
serverName:
|
||||
mkRemovedOptionModule
|
||||
["plugins" "lsp" "servers" serverName "installLanguageServer"]
|
||||
mkRemovedOptionModule
|
||||
[
|
||||
"plugins"
|
||||
"lsp"
|
||||
"servers"
|
||||
serverName
|
||||
"installLanguageServer"
|
||||
]
|
||||
"If you want to not install the language server package, set `plugins.lsp.servers.${serverName}.package` to `null`."
|
||||
)
|
||||
[
|
||||
|
@ -119,7 +124,7 @@ in {
|
|||
"<leader>k" = "goto_prev";
|
||||
"<leader>j" = "goto_next";
|
||||
};
|
||||
default = {};
|
||||
default = { };
|
||||
};
|
||||
|
||||
lspBuf = mkOption {
|
||||
|
@ -132,7 +137,7 @@ in {
|
|||
"gi" = "implementation";
|
||||
"K" = "hover";
|
||||
};
|
||||
default = {};
|
||||
default = { };
|
||||
};
|
||||
|
||||
extra = mkOption {
|
||||
|
@ -164,12 +169,13 @@ in {
|
|||
action = "<CMD>Lspsaga hover_doc<Enter>";
|
||||
}
|
||||
];
|
||||
default = [];
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
|
||||
enabledServers = mkOption {
|
||||
type = with types;
|
||||
type =
|
||||
with types;
|
||||
listOf (oneOf [
|
||||
str
|
||||
(submodule {
|
||||
|
@ -196,7 +202,7 @@ in {
|
|||
})
|
||||
]);
|
||||
description = "A list of enabled LSP servers. Don't use this directly.";
|
||||
default = [];
|
||||
default = [ ];
|
||||
internal = true;
|
||||
visible = false;
|
||||
};
|
||||
|
@ -216,7 +222,7 @@ in {
|
|||
setupWrappers = mkOption {
|
||||
type = with types; listOf (functionTo str);
|
||||
description = "Code to be run to wrap the setup args. Takes in an argument containing the previous results, and returns a new string of code.";
|
||||
default = [];
|
||||
default = [ ];
|
||||
};
|
||||
|
||||
preConfig = mkOption {
|
||||
|
@ -233,62 +239,54 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
runWrappers = wrappers: s:
|
||||
if wrappers == []
|
||||
then s
|
||||
else (head wrappers) (runWrappers (tail wrappers) s);
|
||||
updateCapabilities = let
|
||||
servers =
|
||||
builtins.filter
|
||||
(server: server.capabilities != null && server.capabilities != {})
|
||||
cfg.enabledServers;
|
||||
in
|
||||
lib.concatMapStringsSep "\n" (
|
||||
server: let
|
||||
updates =
|
||||
lib.concatMapStringsSep "\n"
|
||||
(name: ''
|
||||
config =
|
||||
let
|
||||
runWrappers =
|
||||
wrappers: s: if wrappers == [ ] then s else (head wrappers) (runWrappers (tail wrappers) s);
|
||||
updateCapabilities =
|
||||
let
|
||||
servers = builtins.filter (
|
||||
server: server.capabilities != null && server.capabilities != { }
|
||||
) cfg.enabledServers;
|
||||
in
|
||||
lib.concatMapStringsSep "\n" (
|
||||
server:
|
||||
let
|
||||
updates = lib.concatMapStringsSep "\n" (name: ''
|
||||
client.server_capabilities.${name} = ${helpers.toLuaObject server.capabilities.${name}}
|
||||
'')
|
||||
(builtins.attrNames server.capabilities);
|
||||
in ''
|
||||
if client.name == "${server.name}" then
|
||||
${updates}
|
||||
end
|
||||
''
|
||||
)
|
||||
servers;
|
||||
in
|
||||
'') (builtins.attrNames server.capabilities);
|
||||
in
|
||||
''
|
||||
if client.name == "${server.name}" then
|
||||
${updates}
|
||||
end
|
||||
''
|
||||
) servers;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [pkgs.vimPlugins.nvim-lspconfig];
|
||||
extraPlugins = [ pkgs.vimPlugins.nvim-lspconfig ];
|
||||
|
||||
keymapsOnEvents.LspAttach = let
|
||||
mkMaps = prefix:
|
||||
mapAttrsToList
|
||||
(
|
||||
key: action: let
|
||||
actionStr =
|
||||
if isString action
|
||||
then action
|
||||
else action.action;
|
||||
actionProps =
|
||||
if isString action
|
||||
then {}
|
||||
else filterAttrs (n: v: n != "action") action;
|
||||
in {
|
||||
mode = "n";
|
||||
inherit key;
|
||||
action = helpers.mkRaw (prefix + actionStr);
|
||||
keymapsOnEvents.LspAttach =
|
||||
let
|
||||
mkMaps =
|
||||
prefix:
|
||||
mapAttrsToList (
|
||||
key: action:
|
||||
let
|
||||
actionStr = if isString action then action else action.action;
|
||||
actionProps = if isString action then { } else filterAttrs (n: v: n != "action") action;
|
||||
in
|
||||
{
|
||||
mode = "n";
|
||||
inherit key;
|
||||
action = helpers.mkRaw (prefix + actionStr);
|
||||
|
||||
options =
|
||||
{
|
||||
options = {
|
||||
inherit (cfg.keymaps) silent;
|
||||
}
|
||||
// actionProps;
|
||||
}
|
||||
);
|
||||
in
|
||||
} // actionProps;
|
||||
}
|
||||
);
|
||||
in
|
||||
(mkMaps "vim.diagnostic." cfg.keymaps.diagnostic)
|
||||
++ (mkMaps "vim.lsp.buf." cfg.keymaps.lspBuf)
|
||||
++ cfg.keymaps.extra;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,26 +1,30 @@
|
|||
{pkgs, ...}: {
|
||||
mkLsp = {
|
||||
name,
|
||||
description ? "Enable ${name}.",
|
||||
serverName ? name,
|
||||
package ? pkgs.${name},
|
||||
cmd ? (cfg: null),
|
||||
settings ? (cfg: cfg),
|
||||
settingsOptions ? {},
|
||||
extraConfig ? cfg: {},
|
||||
...
|
||||
}:
|
||||
# returns a module
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
helpers,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
mkLsp =
|
||||
{
|
||||
name,
|
||||
description ? "Enable ${name}.",
|
||||
serverName ? name,
|
||||
package ? pkgs.${name},
|
||||
cmd ? (cfg: null),
|
||||
settings ? (cfg: cfg),
|
||||
settingsOptions ? { },
|
||||
extraConfig ? cfg: { },
|
||||
...
|
||||
}:
|
||||
# returns a module
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
helpers,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.lsp.servers.${name};
|
||||
in {
|
||||
in
|
||||
{
|
||||
options = {
|
||||
plugins.lsp.servers.${name} = {
|
||||
enable = mkEnableOption description;
|
||||
|
@ -33,10 +37,7 @@
|
|||
|
||||
cmd = mkOption {
|
||||
type = with types; nullOr (listOf str);
|
||||
default =
|
||||
if (cfg.package or null) != null
|
||||
then cmd cfg
|
||||
else null;
|
||||
default = if (cfg.package or null) != null then cmd cfg else null;
|
||||
};
|
||||
|
||||
filetypes = helpers.mkNullOrOption (types.listOf types.str) ''
|
||||
|
@ -56,75 +57,72 @@
|
|||
launched server when you open a new buffer matching the filetype of the server.
|
||||
'';
|
||||
|
||||
onAttach =
|
||||
helpers.mkCompositeOption "Server specific on_attach behavior."
|
||||
{
|
||||
override = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Override the global `plugins.lsp.onAttach` function.";
|
||||
};
|
||||
|
||||
function = mkOption {
|
||||
type = types.lines;
|
||||
description = ''
|
||||
Body of the on_attach function.
|
||||
The argument `client` and `bufnr` is provided.
|
||||
'';
|
||||
};
|
||||
onAttach = helpers.mkCompositeOption "Server specific on_attach behavior." {
|
||||
override = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Override the global `plugins.lsp.onAttach` function.";
|
||||
};
|
||||
|
||||
function = mkOption {
|
||||
type = types.lines;
|
||||
description = ''
|
||||
Body of the on_attach function.
|
||||
The argument `client` and `bufnr` is provided.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
settings = helpers.mkSettingsOption {
|
||||
description = "The settings for this LSP.";
|
||||
options = settingsOptions;
|
||||
};
|
||||
|
||||
extraOptions = mkOption {
|
||||
default = {};
|
||||
default = { };
|
||||
type = types.attrsOf types.anything;
|
||||
description = "Extra options for the ${name} language server.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
mkIf cfg.enable
|
||||
{
|
||||
extraPackages = [cfg.package];
|
||||
config = mkIf cfg.enable {
|
||||
extraPackages = [ cfg.package ];
|
||||
|
||||
plugins.lsp.enabledServers = [
|
||||
{
|
||||
name = serverName;
|
||||
extraOptions =
|
||||
{
|
||||
inherit (cfg) cmd filetypes autostart;
|
||||
root_dir = cfg.rootDir;
|
||||
on_attach =
|
||||
helpers.ifNonNull' cfg.onAttach
|
||||
(
|
||||
helpers.mkRaw ''
|
||||
function(client, bufnr)
|
||||
${optionalString (!cfg.onAttach.override) config.plugins.lsp.onAttach}
|
||||
${cfg.onAttach.function}
|
||||
end
|
||||
''
|
||||
);
|
||||
settings = settings cfg.settings;
|
||||
}
|
||||
// cfg.extraOptions;
|
||||
}
|
||||
plugins.lsp.enabledServers = [
|
||||
{
|
||||
name = serverName;
|
||||
extraOptions = {
|
||||
inherit (cfg) cmd filetypes autostart;
|
||||
root_dir = cfg.rootDir;
|
||||
on_attach = helpers.ifNonNull' cfg.onAttach (
|
||||
helpers.mkRaw ''
|
||||
function(client, bufnr)
|
||||
${optionalString (!cfg.onAttach.override) config.plugins.lsp.onAttach}
|
||||
${cfg.onAttach.function}
|
||||
end
|
||||
''
|
||||
);
|
||||
settings = settings cfg.settings;
|
||||
} // cfg.extraOptions;
|
||||
}
|
||||
];
|
||||
};
|
||||
imports =
|
||||
let
|
||||
basePluginPath = [
|
||||
"plugins"
|
||||
"lsp"
|
||||
"servers"
|
||||
name
|
||||
];
|
||||
};
|
||||
imports = let
|
||||
basePluginPath = ["plugins" "lsp" "servers" name];
|
||||
basePluginPathString = concatStringsSep "." basePluginPath;
|
||||
in [
|
||||
(
|
||||
mkRemovedOptionModule
|
||||
(basePluginPath ++ ["extraSettings"])
|
||||
"You can use `${basePluginPathString}.extraOptions.settings` instead."
|
||||
)
|
||||
(extraConfig cfg)
|
||||
];
|
||||
basePluginPathString = concatStringsSep "." basePluginPath;
|
||||
in
|
||||
[
|
||||
(mkRemovedOptionModule (
|
||||
basePluginPath ++ [ "extraSettings" ]
|
||||
) "You can use `${basePluginPathString}.extraOptions.settings` instead.")
|
||||
(extraConfig cfg)
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; {
|
||||
with lib;
|
||||
{
|
||||
options.plugins.inc-rename = {
|
||||
enable = mkEnableOption "inc-rename, a plugin previewing LSP renaming";
|
||||
|
||||
|
@ -13,9 +14,7 @@ with lib; {
|
|||
|
||||
cmdName = helpers.defaultNullOpts.mkStr "IncRename" "the name of the command";
|
||||
|
||||
hlGroup =
|
||||
helpers.defaultNullOpts.mkStr "Substitute"
|
||||
"the highlight group used for highlighting the identifier's new name";
|
||||
hlGroup = helpers.defaultNullOpts.mkStr "Substitute" "the highlight group used for highlighting the identifier's new name";
|
||||
|
||||
previewEmptyName = helpers.defaultNullOpts.mkBool false ''
|
||||
whether an empty new name should be previewed; if false the command preview will be cancelled
|
||||
|
@ -26,7 +25,7 @@ with lib; {
|
|||
whether to display a `Renamed m instances in n files` message after a rename operation
|
||||
'';
|
||||
|
||||
inputBufferType = helpers.defaultNullOpts.mkNullable (types.enum ["dressing"]) "null" ''
|
||||
inputBufferType = helpers.defaultNullOpts.mkNullable (types.enum [ "dressing" ]) "null" ''
|
||||
the type of the external input buffer to use
|
||||
'';
|
||||
|
||||
|
@ -35,19 +34,20 @@ with lib; {
|
|||
'';
|
||||
};
|
||||
|
||||
config = let
|
||||
cfg = config.plugins.inc-rename;
|
||||
setupOptions = {
|
||||
cmd_name = cfg.cmdName;
|
||||
hl_group = cfg.hlGroup;
|
||||
preview_empty_name = cfg.previewEmptyName;
|
||||
show_message = cfg.showMessage;
|
||||
input_buffer_type = cfg.inputBufferType;
|
||||
post_hook = cfg.postHook;
|
||||
};
|
||||
in
|
||||
config =
|
||||
let
|
||||
cfg = config.plugins.inc-rename;
|
||||
setupOptions = {
|
||||
cmd_name = cfg.cmdName;
|
||||
hl_group = cfg.hlGroup;
|
||||
preview_empty_name = cfg.previewEmptyName;
|
||||
show_message = cfg.showMessage;
|
||||
input_buffer_type = cfg.inputBufferType;
|
||||
post_hook = cfg.postHook;
|
||||
};
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [cfg.package];
|
||||
extraPlugins = [ cfg.package ];
|
||||
|
||||
extraConfigLua = ''
|
||||
require("inc_rename").setup(${helpers.toLuaObject setupOptions})
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
config,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.lsp.servers.ccls;
|
||||
in {
|
||||
in
|
||||
{
|
||||
# Options: https://github.com/MaskRay/ccls/wiki/Customization#initialization-options
|
||||
options.plugins.lsp.servers.ccls.initOptions = {
|
||||
cache = {
|
||||
|
@ -42,20 +44,28 @@ in {
|
|||
use a JSON formatter such as `jq . < /tmp/ccls/@tmp@c/a.cc.json` to display it.
|
||||
'';
|
||||
|
||||
retainInMemory = helpers.defaultNullOpts.mkEnum [0 1 2] "1" ''
|
||||
Change to 0 if you want to save memory, but having multiple ccls processes operating in the
|
||||
same directory may corrupt ccls's in-memory representation of the index.
|
||||
retainInMemory =
|
||||
helpers.defaultNullOpts.mkEnum
|
||||
[
|
||||
0
|
||||
1
|
||||
2
|
||||
]
|
||||
"1"
|
||||
''
|
||||
Change to 0 if you want to save memory, but having multiple ccls processes operating in the
|
||||
same directory may corrupt ccls's in-memory representation of the index.
|
||||
|
||||
After this number of loads, keep a copy of file index in memory (which increases memory
|
||||
usage).
|
||||
During incremental updates, the removed file index will be taken from the in-memory copy,
|
||||
instead of the on-disk file.
|
||||
After this number of loads, keep a copy of file index in memory (which increases memory
|
||||
usage).
|
||||
During incremental updates, the removed file index will be taken from the in-memory copy,
|
||||
instead of the on-disk file.
|
||||
|
||||
Every index action is counted: the initial load, a save action.
|
||||
- 0: never retain
|
||||
- 1: retain after initial load
|
||||
- 2: retain after 2 loads (initial load+first save)
|
||||
'';
|
||||
Every index action is counted: the initial load, a save action.
|
||||
- 0: never retain
|
||||
- 1: retain after initial load
|
||||
- 2: retain after 2 loads (initial load+first save)
|
||||
'';
|
||||
};
|
||||
|
||||
clang = {
|
||||
|
@ -189,30 +199,45 @@ in {
|
|||
If you want to reduce peak CPU and memory usage, set it to a small integer.
|
||||
'';
|
||||
|
||||
comments = helpers.defaultNullOpts.mkEnum [0 1 2] "2" ''
|
||||
`ccls` can index the contents of comments associated with functions/types/variables (macros
|
||||
are not handled).
|
||||
This value controls how comments are indexed:
|
||||
- `0`: don't index comments
|
||||
- `1`: index Doxygen comment markers
|
||||
- `2`: use `-fparse-all-comments` and recognize plain `//` `/* */` in addition to Doxygen
|
||||
comment markers
|
||||
'';
|
||||
comments =
|
||||
helpers.defaultNullOpts.mkEnum
|
||||
[
|
||||
0
|
||||
1
|
||||
2
|
||||
]
|
||||
"2"
|
||||
''
|
||||
`ccls` can index the contents of comments associated with functions/types/variables (macros
|
||||
are not handled).
|
||||
This value controls how comments are indexed:
|
||||
- `0`: don't index comments
|
||||
- `1`: index Doxygen comment markers
|
||||
- `2`: use `-fparse-all-comments` and recognize plain `//` `/* */` in addition to Doxygen
|
||||
comment markers
|
||||
'';
|
||||
|
||||
multiVersion = helpers.defaultNullOpts.mkEnum [0 1] "0" ''
|
||||
Index a file only once (`0`), or in each translation unit that includes it (`1`).
|
||||
multiVersion =
|
||||
helpers.defaultNullOpts.mkEnum
|
||||
[
|
||||
0
|
||||
1
|
||||
]
|
||||
"0"
|
||||
''
|
||||
Index a file only once (`0`), or in each translation unit that includes it (`1`).
|
||||
|
||||
The default is sensible for common usage: it reduces memory footprint.
|
||||
If both `a.cc` and `b.cc` include `a.h`, there is only one indexed version of `a.h`.
|
||||
The default is sensible for common usage: it reduces memory footprint.
|
||||
If both `a.cc` and `b.cc` include `a.h`, there is only one indexed version of `a.h`.
|
||||
|
||||
But for dependent name lookup, or references in headers that may change depending on other
|
||||
macros, etc, you may want to index a file multiple times to get every possible cross
|
||||
reference.
|
||||
In that case set the option to `1` but be aware that it may increase index file sizes
|
||||
significantly.
|
||||
But for dependent name lookup, or references in headers that may change depending on other
|
||||
macros, etc, you may want to index a file multiple times to get every possible cross
|
||||
reference.
|
||||
In that case set the option to `1` but be aware that it may increase index file sizes
|
||||
significantly.
|
||||
|
||||
Also consider using `index.multiVersionBlacklist` to exclude system headers.
|
||||
'';
|
||||
Also consider using `index.multiVersionBlacklist` to exclude system headers.
|
||||
'';
|
||||
|
||||
multiVersionBlacklist = helpers.defaultNullOpts.mkNullable (with types; listOf str) "[]" ''
|
||||
A list of regular expressions matching files that should not be indexed via multi-version
|
||||
|
@ -250,24 +275,28 @@ in {
|
|||
cache files to disk.
|
||||
'';
|
||||
|
||||
trackDependency = helpers.defaultNullOpts.mkEnum [0 1 2] "2" ''
|
||||
Determine whether a file should be re-indexed when any of its dependencies changes
|
||||
timestamp.
|
||||
trackDependency =
|
||||
helpers.defaultNullOpts.mkEnum
|
||||
[
|
||||
0
|
||||
1
|
||||
2
|
||||
]
|
||||
"2"
|
||||
''
|
||||
Determine whether a file should be re-indexed when any of its dependencies changes
|
||||
timestamp.
|
||||
|
||||
If `a.h` has been changed, when you open `a.cc` which includes `a.h` then if
|
||||
`trackDependency` is:
|
||||
If `a.h` has been changed, when you open `a.cc` which includes `a.h` then if
|
||||
`trackDependency` is:
|
||||
|
||||
- 0: no re-indexing unless `a.cc` itself changes timestamp.
|
||||
- 2: the index of `a.cc` is considered stale and it should be re-indexed.
|
||||
- 1: before the initial load, the behavior of `2` is used, otherwise the behavior of `0` is
|
||||
used.
|
||||
'';
|
||||
- 0: no re-indexing unless `a.cc` itself changes timestamp.
|
||||
- 2: the index of `a.cc` is considered stale and it should be re-indexed.
|
||||
- 1: before the initial load, the behavior of `2` is used, otherwise the behavior of `0` is
|
||||
used.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
mkIf cfg.enable
|
||||
{
|
||||
plugins.lsp.servers.ccls.extraOptions.init_options = cfg.initOptions;
|
||||
};
|
||||
config = mkIf cfg.enable { plugins.lsp.servers.ccls.extraOptions.init_options = cfg.initOptions; };
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
{ lib, helpers }:
|
||||
with lib;
|
||||
{
|
||||
lib,
|
||||
helpers,
|
||||
}:
|
||||
with lib; {
|
||||
analysisExcludedFolders = helpers.mkNullOrOption (with types; listOf str) ''
|
||||
An array of paths (absolute or relative to each workspace folder) that should be excluded from
|
||||
analysis.
|
||||
|
@ -27,15 +25,21 @@ with lib; {
|
|||
If unspecified, diagnostics will not be generated.
|
||||
'';
|
||||
|
||||
renameFilesWithClasses = helpers.mkNullOrOption (types.enum ["always" "prompt"]) ''
|
||||
When set to "always", will include edits to rename files when classes are renamed if the
|
||||
filename matches the class name (but in snake_form).
|
||||
When set to "prompt", a prompt will be shown on each class rename asking to confirm the file
|
||||
rename.
|
||||
Otherwise, files will not be renamed.
|
||||
Renames are performed using LSP's `ResourceOperation` edits - that means the rename is simply
|
||||
included in the resulting `WorkspaceEdit` and must be handled by the client.
|
||||
'';
|
||||
renameFilesWithClasses =
|
||||
helpers.mkNullOrOption
|
||||
(types.enum [
|
||||
"always"
|
||||
"prompt"
|
||||
])
|
||||
''
|
||||
When set to "always", will include edits to rename files when classes are renamed if the
|
||||
filename matches the class name (but in snake_form).
|
||||
When set to "prompt", a prompt will be shown on each class rename asking to confirm the file
|
||||
rename.
|
||||
Otherwise, files will not be renamed.
|
||||
Renames are performed using LSP's `ResourceOperation` edits - that means the rename is simply
|
||||
included in the resulting `WorkspaceEdit` and must be handled by the client.
|
||||
'';
|
||||
|
||||
enableSnippets = helpers.mkNullOrOption types.bool ''
|
||||
Whether to include code snippets (such as class, stful, switch) in code completion.
|
||||
|
@ -47,11 +51,18 @@ with lib; {
|
|||
When unspecified, imports will be updated if the client supports `willRenameFiles` requests.
|
||||
'';
|
||||
|
||||
documentation = helpers.mkNullOrOption (types.enum ["none" "summary" "full"]) ''
|
||||
The typekind of dartdocs to include in Hovers, Code Completion, Signature Help and other similar
|
||||
requests.
|
||||
If not set, defaults to `"full"`.
|
||||
'';
|
||||
documentation =
|
||||
helpers.mkNullOrOption
|
||||
(types.enum [
|
||||
"none"
|
||||
"summary"
|
||||
"full"
|
||||
])
|
||||
''
|
||||
The typekind of dartdocs to include in Hovers, Code Completion, Signature Help and other similar
|
||||
requests.
|
||||
If not set, defaults to `"full"`.
|
||||
'';
|
||||
|
||||
includeDependenciesInWorkspaceSymbols = helpers.mkNullOrOption types.bool ''
|
||||
Whether to include symbols from dependencies and Dart/Flutter SDKs in Workspace Symbol results.
|
||||
|
|
|
@ -5,15 +5,19 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
lspHelpers = import ../helpers.nix {inherit lib config pkgs;};
|
||||
with lib;
|
||||
let
|
||||
lspHelpers = import ../helpers.nix { inherit lib config pkgs; };
|
||||
|
||||
servers = [
|
||||
{
|
||||
name = "ansiblels";
|
||||
description = "ansiblels for Ansible";
|
||||
package = pkgs.ansible-language-server;
|
||||
cmd = cfg: ["${cfg.package}/bin/ansible-language-server" "--stdio"];
|
||||
cmd = cfg: [
|
||||
"${cfg.package}/bin/ansible-language-server"
|
||||
"--stdio"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "ast-grep";
|
||||
|
@ -27,7 +31,10 @@ with lib; let
|
|||
name = "astro";
|
||||
description = "astrols for Astro";
|
||||
package = pkgs.nodePackages."@astrojs/language-server";
|
||||
cmd = cfg: ["${cfg.package}/bin/astro-ls" "--stdio"];
|
||||
cmd = cfg: [
|
||||
"${cfg.package}/bin/astro-ls"
|
||||
"--stdio"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "bashls";
|
||||
|
@ -73,7 +80,10 @@ with lib; let
|
|||
name = "cssls";
|
||||
description = "cssls for CSS";
|
||||
package = pkgs.vscode-langservers-extracted;
|
||||
cmd = cfg: ["${cfg.package}/bin/vscode-css-language-server" "--stdio"];
|
||||
cmd = cfg: [
|
||||
"${cfg.package}/bin/vscode-css-language-server"
|
||||
"--stdio"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "dagger";
|
||||
|
@ -84,8 +94,8 @@ with lib; let
|
|||
name = "dartls";
|
||||
description = "dart language-server";
|
||||
package = pkgs.dart;
|
||||
settingsOptions = import ./dartls-settings.nix {inherit lib helpers;};
|
||||
settings = cfg: {dart = cfg;};
|
||||
settingsOptions = import ./dartls-settings.nix { inherit lib helpers; };
|
||||
settings = cfg: { dart = cfg; };
|
||||
}
|
||||
{
|
||||
name = "denols";
|
||||
|
@ -112,7 +122,10 @@ with lib; let
|
|||
name = "dockerls";
|
||||
description = "dockerls for Dockerfile";
|
||||
package = pkgs.dockerfile-language-server-nodejs;
|
||||
cmd = cfg: ["${cfg.package}/bin/docker-langserver" "--stdio"];
|
||||
cmd = cfg: [
|
||||
"${cfg.package}/bin/docker-langserver"
|
||||
"--stdio"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "efm";
|
||||
|
@ -132,12 +145,15 @@ with lib; let
|
|||
{
|
||||
name = "eslint";
|
||||
package = pkgs.vscode-langservers-extracted;
|
||||
cmd = cfg: ["${cfg.package}/bin/vscode-eslint-language-server" "--stdio"];
|
||||
cmd = cfg: [
|
||||
"${cfg.package}/bin/vscode-eslint-language-server"
|
||||
"--stdio"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "elixirls";
|
||||
package = pkgs.elixir-ls;
|
||||
cmd = cfg: ["${cfg.package}/bin/elixir-ls"];
|
||||
cmd = cfg: [ "${cfg.package}/bin/elixir-ls" ];
|
||||
}
|
||||
{
|
||||
name = "fortls";
|
||||
|
@ -193,13 +209,19 @@ with lib; let
|
|||
name = "hls";
|
||||
description = "haskell language server";
|
||||
package = pkgs.haskell-language-server;
|
||||
cmd = cfg: ["haskell-language-server-wrapper" "--lsp"];
|
||||
cmd = cfg: [
|
||||
"haskell-language-server-wrapper"
|
||||
"--lsp"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "html";
|
||||
description = "HTML language server from `vscode-langservers-extracted`";
|
||||
package = pkgs.vscode-langservers-extracted;
|
||||
cmd = cfg: ["${cfg.package}/bin/vscode-html-language-server" "--stdio"];
|
||||
cmd = cfg: [
|
||||
"${cfg.package}/bin/vscode-html-language-server"
|
||||
"--stdio"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "htmx";
|
||||
|
@ -215,13 +237,16 @@ with lib; let
|
|||
name = "java-language-server";
|
||||
description = "Java language server";
|
||||
serverName = "java_language_server";
|
||||
cmd = cfg: ["${cfg.package}/bin/java-language-server"];
|
||||
cmd = cfg: [ "${cfg.package}/bin/java-language-server" ];
|
||||
}
|
||||
{
|
||||
name = "jsonls";
|
||||
description = "jsonls for JSON";
|
||||
package = pkgs.vscode-langservers-extracted;
|
||||
cmd = cfg: ["${cfg.package}/bin/vscode-json-language-server" "--stdio"];
|
||||
cmd = cfg: [
|
||||
"${cfg.package}/bin/vscode-json-language-server"
|
||||
"--stdio"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "julials";
|
||||
|
@ -252,8 +277,8 @@ with lib; let
|
|||
name = "ltex";
|
||||
description = "ltex-ls for LanguageTool";
|
||||
package = pkgs.ltex-ls;
|
||||
settingsOptions = import ./ltex-settings.nix {inherit lib helpers;};
|
||||
settings = cfg: {ltex = cfg;};
|
||||
settingsOptions = import ./ltex-settings.nix { inherit lib helpers; };
|
||||
settings = cfg: { ltex = cfg; };
|
||||
}
|
||||
{
|
||||
name = "lua-ls";
|
||||
|
@ -261,9 +286,10 @@ with lib; let
|
|||
# Use the old name of the lua LS if the user is on a stable branch of nixpkgs
|
||||
# Rename occurred here: https://github.com/NixOS/nixpkgs/pull/215057
|
||||
package =
|
||||
if (hasAttr "lua-language-server" pkgs)
|
||||
then pkgs.lua-language-server
|
||||
else pkgs.sumneko-lua-language-server;
|
||||
if (hasAttr "lua-language-server" pkgs) then
|
||||
pkgs.lua-language-server
|
||||
else
|
||||
pkgs.sumneko-lua-language-server;
|
||||
serverName = "lua_ls";
|
||||
|
||||
# All available settings are documented here:
|
||||
|
@ -285,17 +311,12 @@ with lib; let
|
|||
description = ''
|
||||
An array of variable names that will be declared as global.
|
||||
'';
|
||||
default = ["vim"];
|
||||
default = [ "vim" ];
|
||||
};
|
||||
};
|
||||
workspace = {
|
||||
library = mkOption {
|
||||
type = with types;
|
||||
nullOr
|
||||
(
|
||||
listOf
|
||||
(either str helpers.nixvimTypes.rawLua)
|
||||
);
|
||||
type = with types; nullOr (listOf (either str helpers.nixvimTypes.rawLua));
|
||||
description = ''
|
||||
An array of abosolute or workspace-relative paths that will be added to the workspace
|
||||
diagnosis - meaning you will get completion and context from these library files.
|
||||
|
@ -303,7 +324,7 @@ with lib; let
|
|||
Files included here will have some features disabled such as renaming fields to
|
||||
prevent accidentally renaming your library files.
|
||||
'';
|
||||
default = [(helpers.mkRaw "vim.api.nvim_get_runtime_file('', true)")];
|
||||
default = [ (helpers.mkRaw "vim.api.nvim_get_runtime_file('', true)") ];
|
||||
};
|
||||
checkThirdParty = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
|
@ -321,7 +342,7 @@ with lib; let
|
|||
enable = mkEnableOption "telemetry";
|
||||
};
|
||||
};
|
||||
settings = cfg: {Lua = cfg;};
|
||||
settings = cfg: { Lua = cfg; };
|
||||
}
|
||||
{
|
||||
name = "marksman";
|
||||
|
@ -353,7 +374,7 @@ with lib; let
|
|||
diagnostics = {
|
||||
ignored = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
default = [ ];
|
||||
description = ''
|
||||
Ignored diagnostic kinds.
|
||||
The kind identifier is a snake_cased_string usually shown together
|
||||
|
@ -362,7 +383,7 @@ with lib; let
|
|||
};
|
||||
excludedFiles = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
default = [ ];
|
||||
description = ''
|
||||
Files to exclude from showing diagnostics. Useful for generated files.
|
||||
It accepts an array of paths. Relative paths are joint to the workspace root.
|
||||
|
@ -371,7 +392,11 @@ with lib; let
|
|||
};
|
||||
};
|
||||
};
|
||||
settings = cfg: {nil = {inherit (cfg) formatting diagnostics;};};
|
||||
settings = cfg: {
|
||||
nil = {
|
||||
inherit (cfg) formatting diagnostics;
|
||||
};
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "nimls";
|
||||
|
@ -382,12 +407,15 @@ with lib; let
|
|||
name = "nixd";
|
||||
description = "nixd for Nix";
|
||||
package = pkgs.nixd;
|
||||
settings = cfg: {nixd = cfg;};
|
||||
settings = cfg: { nixd = cfg; };
|
||||
}
|
||||
{
|
||||
name = "nushell";
|
||||
description = "Nushell language server";
|
||||
cmd = cfg: ["${cfg.package}/bin/nu" "--lsp"];
|
||||
cmd = cfg: [
|
||||
"${cfg.package}/bin/nu"
|
||||
"--lsp"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "ocamllsp";
|
||||
|
@ -403,8 +431,8 @@ with lib; let
|
|||
name = "omnisharp";
|
||||
description = "OmniSharp language server for C#";
|
||||
package = pkgs.omnisharp-roslyn;
|
||||
cmd = cfg: ["${cfg.package}/bin/OmniSharp"];
|
||||
settings = cfg: {omnisharp = cfg;};
|
||||
cmd = cfg: [ "${cfg.package}/bin/OmniSharp" ];
|
||||
settings = cfg: { omnisharp = cfg; };
|
||||
settingsOptions = {
|
||||
enableEditorConfigSupport = helpers.defaultNullOpts.mkBool true ''
|
||||
Enables support for reading code style, naming convention and analyzer settings from
|
||||
|
@ -488,7 +516,7 @@ with lib; let
|
|||
name = "pylsp";
|
||||
description = "pylsp for Python";
|
||||
package = pkgs.python3Packages.python-lsp-server;
|
||||
settings = cfg: {pylsp = cfg;};
|
||||
settings = cfg: { pylsp = cfg; };
|
||||
}
|
||||
{
|
||||
name = "pylyzer";
|
||||
|
@ -520,7 +548,7 @@ with lib; let
|
|||
serverName = "rust_analyzer";
|
||||
|
||||
settingsOptions = import ./rust-analyzer-config.nix lib pkgs;
|
||||
settings = cfg: {rust-analyzer = cfg;};
|
||||
settings = cfg: { rust-analyzer = cfg; };
|
||||
}
|
||||
{
|
||||
name = "slint-lsp";
|
||||
|
@ -627,16 +655,15 @@ with lib; let
|
|||
description = "zls for Zig";
|
||||
}
|
||||
];
|
||||
in {
|
||||
imports =
|
||||
lib.lists.map lspHelpers.mkLsp servers
|
||||
++ [
|
||||
./ccls.nix
|
||||
./efmls-configs.nix
|
||||
./nixd.nix
|
||||
./pylsp.nix
|
||||
./rust-analyzer.nix
|
||||
./svelte.nix
|
||||
./vls.nix
|
||||
];
|
||||
in
|
||||
{
|
||||
imports = lib.lists.map lspHelpers.mkLsp servers ++ [
|
||||
./ccls.nix
|
||||
./efmls-configs.nix
|
||||
./nixd.nix
|
||||
./pylsp.nix
|
||||
./rust-analyzer.nix
|
||||
./svelte.nix
|
||||
./vls.nix
|
||||
];
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
tools = trivial.importJSON "${pkgs.vimPlugins.efmls-configs-nvim.src}/doc/supported-list.json";
|
||||
|
||||
languages = builtins.attrNames tools;
|
||||
|
@ -71,15 +72,13 @@ with lib; let
|
|||
yamllint
|
||||
yapf
|
||||
;
|
||||
inherit
|
||||
(python3.pkgs)
|
||||
inherit (python3.pkgs)
|
||||
autopep8
|
||||
flake8
|
||||
mdformat
|
||||
vulture
|
||||
;
|
||||
inherit
|
||||
(nodePackages)
|
||||
inherit (nodePackages)
|
||||
eslint
|
||||
eslint_d
|
||||
prettier
|
||||
|
@ -89,20 +88,9 @@ with lib; let
|
|||
textlint
|
||||
write-good
|
||||
;
|
||||
inherit
|
||||
(phpPackages)
|
||||
phan
|
||||
phpstan
|
||||
psalm
|
||||
;
|
||||
inherit
|
||||
(luaPackages)
|
||||
luacheck
|
||||
;
|
||||
inherit
|
||||
(haskellPackages)
|
||||
fourmolu
|
||||
;
|
||||
inherit (phpPackages) phan phpstan psalm;
|
||||
inherit (luaPackages) luacheck;
|
||||
inherit (haskellPackages) fourmolu;
|
||||
ansible_lint = ansible-lint;
|
||||
chktex = texliveMedium;
|
||||
clang_format = clang-tools;
|
||||
|
@ -134,85 +122,86 @@ with lib; let
|
|||
yq = yq-go;
|
||||
};
|
||||
# Filter packages that are not compatible with the current platform
|
||||
toolPkgs =
|
||||
filterAttrs
|
||||
(
|
||||
a: pkg:
|
||||
meta.availableOn
|
||||
pkgs.stdenv.hostPlatform
|
||||
pkg
|
||||
)
|
||||
allToolPkgs;
|
||||
in {
|
||||
toolPkgs = filterAttrs (a: pkg: meta.availableOn pkgs.stdenv.hostPlatform pkg) allToolPkgs;
|
||||
in
|
||||
{
|
||||
options.plugins.efmls-configs = {
|
||||
enable = mkEnableOption "efmls-configs, premade configurations for efm-langserver";
|
||||
|
||||
package = helpers.mkPackageOption "efmls-configs-nvim" pkgs.vimPlugins.efmls-configs-nvim;
|
||||
|
||||
externallyManagedPackages = mkOption {
|
||||
type = types.either (types.enum ["all"]) (types.listOf types.str);
|
||||
type = types.either (types.enum [ "all" ]) (types.listOf types.str);
|
||||
description = ''
|
||||
Linters/Formatters to skip installing with nixvim. Set to `all` to install no packages
|
||||
'';
|
||||
default = [];
|
||||
default = [ ];
|
||||
};
|
||||
|
||||
toolPackages = attrsets.mapAttrs (tool: pkg:
|
||||
toolPackages = attrsets.mapAttrs (
|
||||
tool: pkg:
|
||||
mkOption {
|
||||
type = types.package;
|
||||
default = pkg;
|
||||
description = "Package for ${tool}";
|
||||
})
|
||||
toolPkgs;
|
||||
}
|
||||
) toolPkgs;
|
||||
|
||||
/*
|
||||
Users can set the options as follows:
|
||||
Users can set the options as follows:
|
||||
|
||||
{
|
||||
c = {
|
||||
linter = "cppcheck";
|
||||
formatter = ["clang-format" "uncrustify"];
|
||||
};
|
||||
go = {
|
||||
linter = ["djlint" "golangci_lint"];
|
||||
};
|
||||
}
|
||||
*/
|
||||
setup = let
|
||||
languageTools = lang: kind:
|
||||
builtins.map (v: v.name) (
|
||||
if builtins.hasAttr kind tools.${lang}
|
||||
then tools.${lang}.${kind}
|
||||
else []
|
||||
);
|
||||
|
||||
miscLinters = languageTools "misc" "linters";
|
||||
miscFormatters = languageTools "misc" "formatters";
|
||||
|
||||
mkChooseOption = lang: kind: possible: let
|
||||
toolType = with types; either (enum possible) helpers.nixvimTypes.rawLua;
|
||||
in
|
||||
mkOption {
|
||||
type = with types; either toolType (listOf toolType);
|
||||
default = [];
|
||||
description = "${kind} tools for ${lang}";
|
||||
{
|
||||
c = {
|
||||
linter = "cppcheck";
|
||||
formatter = ["clang-format" "uncrustify"];
|
||||
};
|
||||
in
|
||||
go = {
|
||||
linter = ["djlint" "golangci_lint"];
|
||||
};
|
||||
}
|
||||
*/
|
||||
setup =
|
||||
let
|
||||
languageTools =
|
||||
lang: kind:
|
||||
builtins.map (v: v.name) (
|
||||
if builtins.hasAttr kind tools.${lang} then tools.${lang}.${kind} else [ ]
|
||||
);
|
||||
|
||||
miscLinters = languageTools "misc" "linters";
|
||||
miscFormatters = languageTools "misc" "formatters";
|
||||
|
||||
mkChooseOption =
|
||||
lang: kind: possible:
|
||||
let
|
||||
toolType = with types; either (enum possible) helpers.nixvimTypes.rawLua;
|
||||
in
|
||||
mkOption {
|
||||
type = with types; either toolType (listOf toolType);
|
||||
default = [ ];
|
||||
description = "${kind} tools for ${lang}";
|
||||
};
|
||||
in
|
||||
mkOption {
|
||||
type = types.submodule {
|
||||
freeformType = types.attrs;
|
||||
|
||||
options =
|
||||
(builtins.listToAttrs (builtins.map (lang: let
|
||||
langTools = languageTools lang;
|
||||
in {
|
||||
name = lang;
|
||||
value = {
|
||||
linter = mkChooseOption lang "linter" ((langTools "linters") ++ miscLinters);
|
||||
formatter = mkChooseOption lang "formatter" ((langTools "formatters") ++ miscFormatters);
|
||||
};
|
||||
})
|
||||
languages))
|
||||
(builtins.listToAttrs (
|
||||
builtins.map (
|
||||
lang:
|
||||
let
|
||||
langTools = languageTools lang;
|
||||
in
|
||||
{
|
||||
name = lang;
|
||||
value = {
|
||||
linter = mkChooseOption lang "linter" ((langTools "linters") ++ miscLinters);
|
||||
formatter = mkChooseOption lang "formatter" ((langTools "formatters") ++ miscFormatters);
|
||||
};
|
||||
}
|
||||
) languages
|
||||
))
|
||||
// {
|
||||
all = {
|
||||
linter = mkChooseOption "all languages" "linter" miscLinters;
|
||||
|
@ -221,67 +210,69 @@ in {
|
|||
};
|
||||
};
|
||||
description = "Configuration for each filetype. Use `all` to match any filetype.";
|
||||
default = {};
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
config = let
|
||||
cfg = config.plugins.efmls-configs;
|
||||
toolAsList = tools:
|
||||
if builtins.isList tools
|
||||
then tools
|
||||
else [tools];
|
||||
config =
|
||||
let
|
||||
cfg = config.plugins.efmls-configs;
|
||||
toolAsList = tools: if builtins.isList tools then tools else [ tools ];
|
||||
|
||||
# Tools that have been selected by the user
|
||||
tools = lists.unique (builtins.filter builtins.isString (
|
||||
builtins.concatLists (
|
||||
builtins.map ({
|
||||
linter ? [],
|
||||
formatter ? [],
|
||||
}:
|
||||
(toolAsList linter) ++ (toolAsList formatter))
|
||||
(builtins.attrValues cfg.setup)
|
||||
)
|
||||
));
|
||||
|
||||
pkgsForTools = let
|
||||
partitionFn =
|
||||
if cfg.externallyManagedPackages == "all"
|
||||
then _: false
|
||||
else t: !(builtins.elem t cfg.externallyManagedPackages);
|
||||
partition = lists.partition partitionFn tools;
|
||||
in {
|
||||
nixvim = partition.right;
|
||||
external = partition.wrong;
|
||||
};
|
||||
|
||||
nixvimPkgs = lists.partition (v: builtins.hasAttr v cfg.toolPackages) pkgsForTools.nixvim;
|
||||
|
||||
mkToolOption = kind: opt:
|
||||
builtins.map
|
||||
(tool:
|
||||
if builtins.isString tool
|
||||
then helpers.mkRaw "require 'efmls-configs.${kind}.${tool}'"
|
||||
else tool)
|
||||
(toolAsList opt);
|
||||
|
||||
setupOptions =
|
||||
(builtins.mapAttrs (
|
||||
_: {
|
||||
linter ? [],
|
||||
formatter ? [],
|
||||
}:
|
||||
(mkToolOption "linters" linter)
|
||||
++ (mkToolOption "formatters" formatter)
|
||||
# Tools that have been selected by the user
|
||||
tools = lists.unique (
|
||||
builtins.filter builtins.isString (
|
||||
builtins.concatLists (
|
||||
builtins.map (
|
||||
{
|
||||
linter ? [ ],
|
||||
formatter ? [ ],
|
||||
}:
|
||||
(toolAsList linter) ++ (toolAsList formatter)
|
||||
) (builtins.attrValues cfg.setup)
|
||||
)
|
||||
)
|
||||
(attrsets.filterAttrs (v: _: v != "all") cfg.setup))
|
||||
// {
|
||||
"=" =
|
||||
(mkToolOption "linters" cfg.setup.all.linter)
|
||||
++ (mkToolOption "formatters" cfg.setup.all.formatter);
|
||||
};
|
||||
in
|
||||
);
|
||||
|
||||
pkgsForTools =
|
||||
let
|
||||
partitionFn =
|
||||
if cfg.externallyManagedPackages == "all" then
|
||||
_: false
|
||||
else
|
||||
t: !(builtins.elem t cfg.externallyManagedPackages);
|
||||
partition = lists.partition partitionFn tools;
|
||||
in
|
||||
{
|
||||
nixvim = partition.right;
|
||||
external = partition.wrong;
|
||||
};
|
||||
|
||||
nixvimPkgs = lists.partition (v: builtins.hasAttr v cfg.toolPackages) pkgsForTools.nixvim;
|
||||
|
||||
mkToolOption =
|
||||
kind: opt:
|
||||
builtins.map (
|
||||
tool:
|
||||
if builtins.isString tool then helpers.mkRaw "require 'efmls-configs.${kind}.${tool}'" else tool
|
||||
) (toolAsList opt);
|
||||
|
||||
setupOptions =
|
||||
(builtins.mapAttrs (
|
||||
_:
|
||||
{
|
||||
linter ? [ ],
|
||||
formatter ? [ ],
|
||||
}:
|
||||
(mkToolOption "linters" linter) ++ (mkToolOption "formatters" formatter)
|
||||
) (attrsets.filterAttrs (v: _: v != "all") cfg.setup))
|
||||
// {
|
||||
"=" =
|
||||
(mkToolOption "linters" cfg.setup.all.linter)
|
||||
++ (mkToolOption "formatters" cfg.setup.all.formatter);
|
||||
};
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [cfg.package];
|
||||
extraPlugins = [ cfg.package ];
|
||||
|
||||
warnings = optional ((builtins.length nixvimPkgs.wrong) > 0) ''
|
||||
Nixvim (plugins.efmls-configs): Following tools are not handled by nixvim, please add them to externallyManagedPackages to silence this:
|
||||
|
@ -293,14 +284,8 @@ in {
|
|||
extraOptions.settings.languages = setupOptions;
|
||||
};
|
||||
|
||||
extraPackages =
|
||||
[
|
||||
pkgs.efm-langserver
|
||||
]
|
||||
++ (
|
||||
builtins.map
|
||||
(v: cfg.toolPackages.${v})
|
||||
nixvimPkgs.right
|
||||
);
|
||||
extraPackages = [
|
||||
pkgs.efm-langserver
|
||||
] ++ (builtins.map (v: cfg.toolPackages.${v}) nixvimPkgs.right);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,38 +1,35 @@
|
|||
{ lib, helpers }:
|
||||
with lib;
|
||||
{
|
||||
lib,
|
||||
helpers,
|
||||
}:
|
||||
with lib; {
|
||||
enabled =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with types; either bool (listOf str))
|
||||
''["bibtex" "context" "context.tex" "html" "latex" "markdown" "org" "restructuredtext" "rsweave"]''
|
||||
''
|
||||
Controls whether the extension is enabled.
|
||||
Allows disabling LanguageTool on specific workspaces or for specific code language modes
|
||||
(i.e., file types).
|
||||
helpers.defaultNullOpts.mkNullable (with types; either bool (listOf str))
|
||||
''["bibtex" "context" "context.tex" "html" "latex" "markdown" "org" "restructuredtext" "rsweave"]''
|
||||
''
|
||||
Controls whether the extension is enabled.
|
||||
Allows disabling LanguageTool on specific workspaces or for specific code language modes
|
||||
(i.e., file types).
|
||||
|
||||
Either supply a boolean value stating whether LTEX is enabled for all supported markup languages
|
||||
or disabled for all of them, or supply a list of code language identifiers for which LTEX should
|
||||
be enabled (note that extensions can define additional code language identifiers).
|
||||
Either supply a boolean value stating whether LTEX is enabled for all supported markup languages
|
||||
or disabled for all of them, or supply a list of code language identifiers for which LTEX should
|
||||
be enabled (note that extensions can define additional code language identifiers).
|
||||
|
||||
All supported markup languages are listed in the default value of this setting.
|
||||
In addition, LTEX can check comments in many popular programming languages like C++ or Java, if
|
||||
you add the corresponding code language identifiers to this setting.
|
||||
If you add an unsupported code language mode, LTEX will check corresponding files as plain text
|
||||
without any parsing.
|
||||
All supported markup languages are listed in the default value of this setting.
|
||||
In addition, LTEX can check comments in many popular programming languages like C++ or Java, if
|
||||
you add the corresponding code language identifiers to this setting.
|
||||
If you add an unsupported code language mode, LTEX will check corresponding files as plain text
|
||||
without any parsing.
|
||||
|
||||
The activation events are unaffected by this setting.
|
||||
This means that the extension will be activated whenever a file with a supported code language
|
||||
mode is opened.
|
||||
For unsupported code language modes, you may need to activate the extension explicitly by
|
||||
executing the LTeX: Activate Extension command.
|
||||
The activation events are unaffected by this setting.
|
||||
This means that the extension will be activated whenever a file with a supported code language
|
||||
mode is opened.
|
||||
For unsupported code language modes, you may need to activate the extension explicitly by
|
||||
executing the LTeX: Activate Extension command.
|
||||
|
||||
Examples:
|
||||
- true
|
||||
- false
|
||||
- ["latex" "markdown"]
|
||||
'';
|
||||
Examples:
|
||||
- true
|
||||
- false
|
||||
- ["latex" "markdown"]
|
||||
'';
|
||||
|
||||
language = helpers.defaultNullOpts.mkStr "en-US" ''
|
||||
The language (e.g., "en-US") LanguageTool should check against.
|
||||
|
@ -94,175 +91,159 @@ with lib; {
|
|||
- "zh-CN": Chinese
|
||||
'';
|
||||
|
||||
dictionary =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with types; attrsOf (listOf str))
|
||||
"{}"
|
||||
''
|
||||
Lists of additional words that should not be counted as spelling errors.
|
||||
This setting is language-specific, so use an attrs of the format
|
||||
```nix
|
||||
{
|
||||
"<LANGUAGE1>" = [
|
||||
"<WORD1>"
|
||||
"<WORD2>"
|
||||
...
|
||||
];
|
||||
"<LANGUAGE2>" = [
|
||||
"<WORD1>"
|
||||
"<WORD2>"
|
||||
];
|
||||
...
|
||||
};
|
||||
```
|
||||
where <LANGUAGE> denotes the language code in `settings.language`.
|
||||
|
||||
This setting is a multi-scope setting. See the documentation for details.
|
||||
This setting supports external files. See the documentation for details.
|
||||
By default, no additional spelling errors will be ignored.
|
||||
|
||||
Example:
|
||||
```nix
|
||||
dictionary = helpers.defaultNullOpts.mkNullable (with types; attrsOf (listOf str)) "{}" ''
|
||||
Lists of additional words that should not be counted as spelling errors.
|
||||
This setting is language-specific, so use an attrs of the format
|
||||
```nix
|
||||
{
|
||||
"en-US" = [
|
||||
"adaptivity"
|
||||
"precomputed"
|
||||
"subproblem"
|
||||
"<LANGUAGE1>" = [
|
||||
"<WORD1>"
|
||||
"<WORD2>"
|
||||
...
|
||||
];
|
||||
"de-DE" = [
|
||||
"B-Splines"
|
||||
"<LANGUAGE2>" = [
|
||||
"<WORD1>"
|
||||
"<WORD2>"
|
||||
];
|
||||
...
|
||||
};
|
||||
```
|
||||
where <LANGUAGE> denotes the language code in `settings.language`.
|
||||
|
||||
This setting is a multi-scope setting. See the documentation for details.
|
||||
This setting supports external files. See the documentation for details.
|
||||
By default, no additional spelling errors will be ignored.
|
||||
|
||||
Example:
|
||||
```nix
|
||||
{
|
||||
"en-US" = [
|
||||
"adaptivity"
|
||||
"precomputed"
|
||||
"subproblem"
|
||||
];
|
||||
"de-DE" = [
|
||||
"B-Splines"
|
||||
":/path/to/externalFile.txt"
|
||||
];
|
||||
}
|
||||
```
|
||||
'';
|
||||
|
||||
disabledRules = helpers.defaultNullOpts.mkNullable (with types; attrsOf (listOf str)) "{}" ''
|
||||
Lists of rules that should be disabled (if enabled by default by LanguageTool).
|
||||
This setting is language-specific, so use an attrs of the format
|
||||
```nix
|
||||
{
|
||||
"<LANGUAGE1>" = [
|
||||
"<WORD1>"
|
||||
"<WORD2>"
|
||||
...
|
||||
];
|
||||
"<LANGUAGE2>" = [
|
||||
"<WORD1>"
|
||||
"<WORD2>"
|
||||
];
|
||||
...
|
||||
};
|
||||
```
|
||||
where `<LANGUAGE>` denotes the language code in `settings.language` and `<RULE>` the ID of
|
||||
the LanguageTool rule.
|
||||
|
||||
This setting is a multi-scope setting. See the documentation for details.
|
||||
This setting supports external files. See the documentation for details.
|
||||
By default, no additional rules will be disabled.
|
||||
|
||||
Example:
|
||||
```nix
|
||||
{
|
||||
"en-US" = [
|
||||
"EN_QUOTES"
|
||||
"UPPERCASE_SENTENCE_START"
|
||||
":/path/to/externalFile.txt"
|
||||
];
|
||||
}
|
||||
```
|
||||
'';
|
||||
|
||||
enabledRules = helpers.defaultNullOpts.mkNullable (with types; attrsOf (listOf str)) "{}" ''
|
||||
Lists of rules that should be enabled (if disabled by default by LanguageTool).
|
||||
This setting is language-specific, so use an attrs of the format
|
||||
```nix
|
||||
{
|
||||
"<LANGUAGE1>" = [
|
||||
"<WORD1>"
|
||||
"<WORD2>"
|
||||
...
|
||||
];
|
||||
"<LANGUAGE2>" = [
|
||||
"<WORD1>"
|
||||
"<WORD2>"
|
||||
];
|
||||
...
|
||||
};
|
||||
```
|
||||
where `<LANGUAGE>` denotes the language code in `settings.language` and `<RULE>` the ID of
|
||||
the LanguageTool rule.
|
||||
|
||||
This setting is a multi-scope setting. See the documentation for details.
|
||||
This setting supports external files. See the documentation for details.
|
||||
By default, no additional rules will be enabled.
|
||||
|
||||
Example:
|
||||
```nix
|
||||
{
|
||||
"en-GB" = [
|
||||
"PASSIVE_VOICE"
|
||||
"OXFORD_SPELLING_NOUNS"
|
||||
":/path/to/externalFile.txt"
|
||||
];
|
||||
}
|
||||
```
|
||||
'';
|
||||
```
|
||||
'';
|
||||
|
||||
disabledRules =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with types; attrsOf (listOf str))
|
||||
"{}"
|
||||
''
|
||||
Lists of rules that should be disabled (if enabled by default by LanguageTool).
|
||||
This setting is language-specific, so use an attrs of the format
|
||||
```nix
|
||||
{
|
||||
"<LANGUAGE1>" = [
|
||||
"<WORD1>"
|
||||
"<WORD2>"
|
||||
...
|
||||
];
|
||||
"<LANGUAGE2>" = [
|
||||
"<WORD1>"
|
||||
"<WORD2>"
|
||||
];
|
||||
...
|
||||
};
|
||||
```
|
||||
where `<LANGUAGE>` denotes the language code in `settings.language` and `<RULE>` the ID of
|
||||
the LanguageTool rule.
|
||||
|
||||
This setting is a multi-scope setting. See the documentation for details.
|
||||
This setting supports external files. See the documentation for details.
|
||||
By default, no additional rules will be disabled.
|
||||
|
||||
Example:
|
||||
```nix
|
||||
hiddenFalsePositives = helpers.defaultNullOpts.mkNullable (with types; attrsOf (listOf str)) "{}" ''
|
||||
Lists of false-positive diagnostics to hide (by hiding all diagnostics of a specific rule
|
||||
within a specific sentence).
|
||||
This setting is language-specific, so use an attrs of the format
|
||||
```nix
|
||||
{
|
||||
"en-US" = [
|
||||
"EN_QUOTES"
|
||||
"UPPERCASE_SENTENCE_START"
|
||||
":/path/to/externalFile.txt"
|
||||
"<LANGUAGE1>" = [
|
||||
"<JSON1>"
|
||||
"<JSON2>"
|
||||
...
|
||||
];
|
||||
"<LANGUAGE2>" = [
|
||||
"<JSON1>"
|
||||
"<JSON2>"
|
||||
];
|
||||
...
|
||||
};
|
||||
```
|
||||
where `<LANGUAGE>` denotes the language code in `settings.language` and `<JSON>` is a JSON
|
||||
string containing information about the rule and sentence.
|
||||
|
||||
Although it is possible to manually edit this setting, the intended way is the
|
||||
`Hide false positive` quick fix.
|
||||
|
||||
The JSON string currently has the form `{"rule": "<RULE>", "sentence": "<SENTENCE>"}`, where
|
||||
`<RULE>` is the ID of the LanguageTool rule and `<SENTENCE>` is a Java-compatible regular
|
||||
expression.
|
||||
All occurrences of the given rule are hidden in sentences (as determined by the LanguageTool
|
||||
tokenizer) that match the regular expression.
|
||||
See the documentation for details.
|
||||
|
||||
This setting is a multi-scope setting. See the documentation for details.
|
||||
This setting supports external files. See the documentation for details.
|
||||
If this list is very large, performance may suffer.
|
||||
|
||||
Example:
|
||||
```nix
|
||||
{
|
||||
"en-US" = [ ":/path/to/externalFile.txt" ];
|
||||
}
|
||||
```
|
||||
'';
|
||||
|
||||
enabledRules =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with types; attrsOf (listOf str))
|
||||
"{}"
|
||||
''
|
||||
Lists of rules that should be enabled (if disabled by default by LanguageTool).
|
||||
This setting is language-specific, so use an attrs of the format
|
||||
```nix
|
||||
{
|
||||
"<LANGUAGE1>" = [
|
||||
"<WORD1>"
|
||||
"<WORD2>"
|
||||
...
|
||||
];
|
||||
"<LANGUAGE2>" = [
|
||||
"<WORD1>"
|
||||
"<WORD2>"
|
||||
];
|
||||
...
|
||||
};
|
||||
```
|
||||
where `<LANGUAGE>` denotes the language code in `settings.language` and `<RULE>` the ID of
|
||||
the LanguageTool rule.
|
||||
|
||||
This setting is a multi-scope setting. See the documentation for details.
|
||||
This setting supports external files. See the documentation for details.
|
||||
By default, no additional rules will be enabled.
|
||||
|
||||
Example:
|
||||
```nix
|
||||
{
|
||||
"en-GB" = [
|
||||
"PASSIVE_VOICE"
|
||||
"OXFORD_SPELLING_NOUNS"
|
||||
":/path/to/externalFile.txt"
|
||||
];
|
||||
}
|
||||
```
|
||||
'';
|
||||
|
||||
hiddenFalsePositives =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with types; attrsOf (listOf str))
|
||||
"{}"
|
||||
''
|
||||
Lists of false-positive diagnostics to hide (by hiding all diagnostics of a specific rule
|
||||
within a specific sentence).
|
||||
This setting is language-specific, so use an attrs of the format
|
||||
```nix
|
||||
{
|
||||
"<LANGUAGE1>" = [
|
||||
"<JSON1>"
|
||||
"<JSON2>"
|
||||
...
|
||||
];
|
||||
"<LANGUAGE2>" = [
|
||||
"<JSON1>"
|
||||
"<JSON2>"
|
||||
];
|
||||
...
|
||||
};
|
||||
```
|
||||
where `<LANGUAGE>` denotes the language code in `settings.language` and `<JSON>` is a JSON
|
||||
string containing information about the rule and sentence.
|
||||
|
||||
Although it is possible to manually edit this setting, the intended way is the
|
||||
`Hide false positive` quick fix.
|
||||
|
||||
The JSON string currently has the form `{"rule": "<RULE>", "sentence": "<SENTENCE>"}`, where
|
||||
`<RULE>` is the ID of the LanguageTool rule and `<SENTENCE>` is a Java-compatible regular
|
||||
expression.
|
||||
All occurrences of the given rule are hidden in sentences (as determined by the LanguageTool
|
||||
tokenizer) that match the regular expression.
|
||||
See the documentation for details.
|
||||
|
||||
This setting is a multi-scope setting. See the documentation for details.
|
||||
This setting supports external files. See the documentation for details.
|
||||
If this list is very large, performance may suffer.
|
||||
|
||||
Example:
|
||||
```nix
|
||||
{
|
||||
"en-US" = [ ":/path/to/externalFile.txt" ];
|
||||
}
|
||||
```
|
||||
'';
|
||||
```
|
||||
'';
|
||||
|
||||
fields = helpers.defaultNullOpts.mkNullable (with types; attrsOf bool) "{}" ''
|
||||
List of BibTEX fields whose values are to be checked in BibTEX files.
|
||||
|
@ -351,19 +332,18 @@ with lib; {
|
|||
};
|
||||
|
||||
configurationTarget =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with types; attrsOf str)
|
||||
''
|
||||
{
|
||||
dictionary = "workspaceFolderExternalFile";
|
||||
disabledRules = "workspaceFolderExternalFile";
|
||||
hiddenFalsePositives = "workspaceFolderExternalFile";
|
||||
}
|
||||
''
|
||||
''
|
||||
Controls which `settings.json` or external setting file (see documentation) to update when
|
||||
using one of the quick fixes.
|
||||
'';
|
||||
helpers.defaultNullOpts.mkNullable (with types; attrsOf str)
|
||||
''
|
||||
{
|
||||
dictionary = "workspaceFolderExternalFile";
|
||||
disabledRules = "workspaceFolderExternalFile";
|
||||
hiddenFalsePositives = "workspaceFolderExternalFile";
|
||||
}
|
||||
''
|
||||
''
|
||||
Controls which `settings.json` or external setting file (see documentation) to update when
|
||||
using one of the quick fixes.
|
||||
'';
|
||||
|
||||
additionalRules = {
|
||||
enablePickyRules = helpers.defaultNullOpts.mkBool false ''
|
||||
|
@ -483,34 +463,34 @@ with lib; {
|
|||
|
||||
logLevel =
|
||||
helpers.defaultNullOpts.mkEnum
|
||||
[
|
||||
"severe"
|
||||
"warning"
|
||||
"info"
|
||||
"config"
|
||||
[
|
||||
"severe"
|
||||
"warning"
|
||||
"info"
|
||||
"config"
|
||||
"fine"
|
||||
"finer"
|
||||
"finest"
|
||||
]
|
||||
"fine"
|
||||
"finer"
|
||||
"finest"
|
||||
]
|
||||
"fine"
|
||||
''
|
||||
Logging level (verbosity) of the `ltex-ls` server log.
|
||||
''
|
||||
Logging level (verbosity) of the `ltex-ls` server log.
|
||||
|
||||
The levels in descending order are "severe", "warning", "info", "config", "fine", "finer", and
|
||||
"finest".
|
||||
All messages that have the specified log level or a higher level are logged.
|
||||
The levels in descending order are "severe", "warning", "info", "config", "fine", "finer", and
|
||||
"finest".
|
||||
All messages that have the specified log level or a higher level are logged.
|
||||
|
||||
`ltex-ls` does not use all log levels.
|
||||
`ltex-ls` does not use all log levels.
|
||||
|
||||
Possible values:
|
||||
- "severe": Minimum verbosity. Only log severe errors.
|
||||
- "warning": Very low verbosity. Only log severe errors and warnings.
|
||||
- "info": Low verbosity. Additionally, log startup and shutdown messages.
|
||||
- "config": Medium verbosity. Additionally, log configuration messages.
|
||||
- "fine": Medium to high verbosity (default). Additionally, log when LanguageTool is called or LanguageTool has to be reinitialized due to changed settings.
|
||||
- "finer": High verbosity. Log additional debugging information such as full texts to be checked.
|
||||
- "finest": Maximum verbosity. Log all available debugging information.
|
||||
'';
|
||||
Possible values:
|
||||
- "severe": Minimum verbosity. Only log severe errors.
|
||||
- "warning": Very low verbosity. Only log severe errors and warnings.
|
||||
- "info": Low verbosity. Additionally, log startup and shutdown messages.
|
||||
- "config": Medium verbosity. Additionally, log configuration messages.
|
||||
- "fine": Medium to high verbosity (default). Additionally, log when LanguageTool is called or LanguageTool has to be reinitialized due to changed settings.
|
||||
- "finer": High verbosity. Log additional debugging information such as full texts to be checked.
|
||||
- "finest": Maximum verbosity. Log all available debugging information.
|
||||
'';
|
||||
};
|
||||
|
||||
java = {
|
||||
|
@ -574,40 +554,42 @@ with lib; {
|
|||
'';
|
||||
|
||||
diagnosticSeverity =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with types; either str (attrsOf str))
|
||||
"information"
|
||||
''
|
||||
Severity of the diagnostics corresponding to the grammar and spelling errors.
|
||||
helpers.defaultNullOpts.mkNullable (with types; either str (attrsOf str)) "information"
|
||||
''
|
||||
Severity of the diagnostics corresponding to the grammar and spelling errors.
|
||||
|
||||
Controls how and where the diagnostics appear.
|
||||
The possible severities are "error", "warning", "information", and "hint".
|
||||
Controls how and where the diagnostics appear.
|
||||
The possible severities are "error", "warning", "information", and "hint".
|
||||
|
||||
This setting can either be a string with the severity to use for all diagnostics, or an attrs
|
||||
with rule-dependent severities.
|
||||
If an attrs is used, each key is the ID of a LanguageTool rule and each value is one of the
|
||||
possible severities.
|
||||
In this case, the severity of other rules, which don’t match any of the keys, has to be
|
||||
specified with the special key "default".
|
||||
This setting can either be a string with the severity to use for all diagnostics, or an attrs
|
||||
with rule-dependent severities.
|
||||
If an attrs is used, each key is the ID of a LanguageTool rule and each value is one of the
|
||||
possible severities.
|
||||
In this case, the severity of other rules, which don’t match any of the keys, has to be
|
||||
specified with the special key "default".
|
||||
|
||||
Examples:
|
||||
- `"information"`
|
||||
- `{PASSIVE_VOICE = "hint"; default = "information";}`
|
||||
'';
|
||||
Examples:
|
||||
- `"information"`
|
||||
- `{PASSIVE_VOICE = "hint"; default = "information";}`
|
||||
'';
|
||||
|
||||
checkFrequency =
|
||||
helpers.defaultNullOpts.mkEnumFirstDefault
|
||||
["edit" "save" "manual"]
|
||||
''
|
||||
Controls when documents should be checked.
|
||||
[
|
||||
"edit"
|
||||
"save"
|
||||
"manual"
|
||||
]
|
||||
''
|
||||
Controls when documents should be checked.
|
||||
|
||||
Possible values:
|
||||
- "edit": Documents are checked when they are opened or edited (on every keystroke), or when
|
||||
the settings change.
|
||||
- "save": Documents are checked when they are opened or saved, or when the settings change.
|
||||
- "manual": Documents are not checked automatically, except when the settings change.
|
||||
Use commands such as LTeX: Check Current Document to manually trigger checks.
|
||||
'';
|
||||
Possible values:
|
||||
- "edit": Documents are checked when they are opened or edited (on every keystroke), or when
|
||||
the settings change.
|
||||
- "save": Documents are checked when they are opened or saved, or when the settings change.
|
||||
- "manual": Documents are not checked automatically, except when the settings change.
|
||||
Use commands such as LTeX: Check Current Document to manually trigger checks.
|
||||
'';
|
||||
|
||||
clearDiagnosticsWhenClosingFile = helpers.defaultNullOpts.mkBool true ''
|
||||
If set to true, diagnostics of a file are cleared when the file is closed.
|
||||
|
@ -620,20 +602,24 @@ with lib; {
|
|||
trace = {
|
||||
server =
|
||||
helpers.defaultNullOpts.mkEnumFirstDefault
|
||||
["off" "messages" "verbose"]
|
||||
''
|
||||
Debug setting to log the communication between language client and server.
|
||||
[
|
||||
"off"
|
||||
"messages"
|
||||
"verbose"
|
||||
]
|
||||
''
|
||||
Debug setting to log the communication between language client and server.
|
||||
|
||||
When reporting issues, set this to "verbose".
|
||||
Append the relevant part to the GitHub issue.
|
||||
When reporting issues, set this to "verbose".
|
||||
Append the relevant part to the GitHub issue.
|
||||
|
||||
Changes require restarting LTEX to take effect.
|
||||
Changes require restarting LTEX to take effect.
|
||||
|
||||
Possible values:
|
||||
- "off": Don’t log any of the communication between language client and server.
|
||||
- "messages": Log the type of requests and responses between language client and server.
|
||||
- "verbose": Log the type and contents of requests and responses between language client and
|
||||
server.
|
||||
'';
|
||||
Possible values:
|
||||
- "off": Don’t log any of the communication between language client and server.
|
||||
- "messages": Log the type of requests and responses between language client and server.
|
||||
- "verbose": Log the type and contents of requests and responses between language client and
|
||||
server.
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -5,9 +5,11 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.lsp.servers.nixd;
|
||||
in {
|
||||
in
|
||||
{
|
||||
# Options: https://github.com/nix-community/nixd/blob/main/docs/user-guide.md#configuration
|
||||
options.plugins.lsp.servers.nixd.settings = {
|
||||
# The evaluation section, provide auto completion for dynamic bindings.
|
||||
|
@ -53,12 +55,7 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
config =
|
||||
mkIf cfg.enable
|
||||
{
|
||||
extraPackages =
|
||||
optional
|
||||
(cfg.settings.formatting.command == "nixpkgs-fmt")
|
||||
pkgs.nixpkgs-fmt;
|
||||
};
|
||||
config = mkIf cfg.enable {
|
||||
extraPackages = optional (cfg.settings.formatting.command == "nixpkgs-fmt") pkgs.nixpkgs-fmt;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -5,21 +5,25 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.lsp.servers.pylsp;
|
||||
in {
|
||||
in
|
||||
{
|
||||
# All settings are documented here:
|
||||
# https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md
|
||||
|
||||
options.plugins.lsp.servers.pylsp.settings = {
|
||||
configurationSources = mkOption {
|
||||
type = lib.types.nullOr (types.enum ["pycodestyle" "flake8"]);
|
||||
type = lib.types.nullOr (
|
||||
types.enum [
|
||||
"pycodestyle"
|
||||
"flake8"
|
||||
]
|
||||
);
|
||||
description = "List of configuration sources to use.";
|
||||
default = null;
|
||||
apply = value:
|
||||
if (value != null)
|
||||
then [value]
|
||||
else null;
|
||||
apply = value: if (value != null) then [ value ] else null;
|
||||
};
|
||||
|
||||
plugins = {
|
||||
|
@ -86,10 +90,8 @@ in {
|
|||
|
||||
jedi = {
|
||||
auto_import_modules =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(types.listOf types.str)
|
||||
"[ \"numpy\" ]"
|
||||
"List of module names for `jedi.settings.auto_import_modules`.";
|
||||
helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[ \"numpy\" ]"
|
||||
"List of module names for `jedi.settings.auto_import_modules`.";
|
||||
|
||||
extra_paths = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" ''
|
||||
Define extra paths for jedi.Script.
|
||||
|
@ -128,10 +130,9 @@ in {
|
|||
'';
|
||||
|
||||
cache_for =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(types.listOf types.str)
|
||||
"[ \"pandas\" \"numpy\" \"tensorflow\" \"matplotlib\" ]"
|
||||
"Modules for which labels and snippets should be cached.";
|
||||
helpers.defaultNullOpts.mkNullable (types.listOf types.str)
|
||||
"[ \"pandas\" \"numpy\" \"tensorflow\" \"matplotlib\" ]"
|
||||
"Modules for which labels and snippets should be cached.";
|
||||
};
|
||||
|
||||
jedi_definition = {
|
||||
|
@ -236,15 +237,12 @@ in {
|
|||
(pydocstyle).
|
||||
'';
|
||||
|
||||
convention =
|
||||
helpers.mkNullOrOption
|
||||
(types.enum [
|
||||
"pep257"
|
||||
"numpy"
|
||||
"google"
|
||||
"None"
|
||||
])
|
||||
"Choose the basic list of checked errors by specifying an existing convention.";
|
||||
convention = helpers.mkNullOrOption (types.enum [
|
||||
"pep257"
|
||||
"numpy"
|
||||
"google"
|
||||
"None"
|
||||
]) "Choose the basic list of checked errors by specifying an existing convention.";
|
||||
|
||||
addIgnore = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" ''
|
||||
Ignore errors and warnings in addition to the specified convention.
|
||||
|
@ -356,17 +354,22 @@ in {
|
|||
|
||||
overrides =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(types.listOf
|
||||
(types.oneOf [types.bool types.str helpers.nixvimTypes.rawLua]))
|
||||
"[true]"
|
||||
''
|
||||
Specifies a list of alternate or supplemental command-line options.
|
||||
This modifies the options passed to mypy or the mypy-specific ones passed to dmypy run.
|
||||
When present, the special boolean member true is replaced with the command-line options that
|
||||
would've been passed had overrides not been specified.
|
||||
Later options take precedence, which allows for replacing or negating individual default
|
||||
options (see mypy.main:process_options and mypy --help | grep inverse).
|
||||
'';
|
||||
(types.listOf (
|
||||
types.oneOf [
|
||||
types.bool
|
||||
types.str
|
||||
helpers.nixvimTypes.rawLua
|
||||
]
|
||||
))
|
||||
"[true]"
|
||||
''
|
||||
Specifies a list of alternate or supplemental command-line options.
|
||||
This modifies the options passed to mypy or the mypy-specific ones passed to dmypy run.
|
||||
When present, the special boolean member true is replaced with the command-line options that
|
||||
would've been passed had overrides not been specified.
|
||||
Later options take precedence, which allows for replacing or negating individual default
|
||||
options (see mypy.main:process_options and mypy --help | grep inverse).
|
||||
'';
|
||||
|
||||
dmypy_status_file = helpers.defaultNullOpts.mkStr ".dmypy.json" ''
|
||||
Specifies which status file dmypy should use.
|
||||
|
@ -497,24 +500,21 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
config =
|
||||
mkIf cfg.enable
|
||||
{
|
||||
# WARNING: tricky stuff below:
|
||||
# We need to fix the `python-lsp-server` derivation by adding all of the (user enabled)
|
||||
# plugins to its `propagatedBuildInputs`.
|
||||
# See https://github.com/NixOS/nixpkgs/issues/229337
|
||||
plugins.lsp.servers.pylsp.package = let
|
||||
config = mkIf cfg.enable {
|
||||
# WARNING: tricky stuff below:
|
||||
# We need to fix the `python-lsp-server` derivation by adding all of the (user enabled)
|
||||
# plugins to its `propagatedBuildInputs`.
|
||||
# See https://github.com/NixOS/nixpkgs/issues/229337
|
||||
plugins.lsp.servers.pylsp.package =
|
||||
let
|
||||
isEnabled = x: (x.enabled != null && x.enabled);
|
||||
inherit (cfg.settings) plugins;
|
||||
|
||||
nativePlugins =
|
||||
(map
|
||||
(
|
||||
pluginName: (
|
||||
optionals (isEnabled plugins.${pluginName})
|
||||
cfg.package.optional-dependencies.${pluginName}
|
||||
)
|
||||
pluginName:
|
||||
(optionals (isEnabled plugins.${pluginName}) cfg.package.optional-dependencies.${pluginName})
|
||||
)
|
||||
[
|
||||
"autopep8"
|
||||
|
@ -525,114 +525,95 @@ in {
|
|||
"pyflakes"
|
||||
"pylint"
|
||||
"yapf"
|
||||
])
|
||||
++ (
|
||||
optionals
|
||||
(
|
||||
(isEnabled plugins.rope_autoimport)
|
||||
|| (isEnabled plugins.rope_completion)
|
||||
)
|
||||
cfg.package.optional-dependencies.rope
|
||||
);
|
||||
]
|
||||
)
|
||||
++ (optionals (
|
||||
(isEnabled plugins.rope_autoimport) || (isEnabled plugins.rope_completion)
|
||||
) cfg.package.optional-dependencies.rope);
|
||||
|
||||
# All of those plugins have `python-lsp-server` as a dependency.
|
||||
# We need to get rid of it to add them to the `python-lsp-server` derivation itself.
|
||||
thirdPartyPlugins = lists.flatten (
|
||||
mapAttrsToList
|
||||
(
|
||||
pluginName: nixPackage: (
|
||||
optional
|
||||
(isEnabled plugins.${pluginName})
|
||||
(
|
||||
nixPackage.overridePythonAttrs (
|
||||
old: {
|
||||
# Get rid of the python-lsp-server dependency
|
||||
propagatedBuildInputs =
|
||||
filter
|
||||
(dep: dep.pname != "python-lsp-server")
|
||||
old.propagatedBuildInputs;
|
||||
(
|
||||
pluginName: nixPackage:
|
||||
(optional (isEnabled plugins.${pluginName}) (
|
||||
nixPackage.overridePythonAttrs (old: {
|
||||
# Get rid of the python-lsp-server dependency
|
||||
propagatedBuildInputs = filter (dep: dep.pname != "python-lsp-server") old.propagatedBuildInputs;
|
||||
|
||||
# Skip testing because those naked dependencies will complain about missing pylsp
|
||||
doCheck = false;
|
||||
}
|
||||
)
|
||||
)
|
||||
# Skip testing because those naked dependencies will complain about missing pylsp
|
||||
doCheck = false;
|
||||
})
|
||||
))
|
||||
)
|
||||
)
|
||||
(with pkgs.python3Packages; {
|
||||
pylsp_mypy = pylsp-mypy.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch
|
||||
or ''''
|
||||
+ ''
|
||||
substituteInPlace setup.cfg \
|
||||
--replace-fail "python-lsp-server >=1.7.0" ""
|
||||
'';
|
||||
});
|
||||
isort = pyls-isort.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch
|
||||
or ''''
|
||||
+ ''
|
||||
substituteInPlace setup.py \
|
||||
--replace-fail 'install_requires=["python-lsp-server", "isort"],' 'install_requires=["isort"],'
|
||||
'';
|
||||
});
|
||||
black = python-lsp-black.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch
|
||||
or ''''
|
||||
+ ''
|
||||
substituteInPlace setup.cfg \
|
||||
--replace-fail "python-lsp-server>=1.4.0" ""
|
||||
'';
|
||||
});
|
||||
memestra = pyls-memestra.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch
|
||||
or ''''
|
||||
+ ''
|
||||
sed -i '/python-lsp-server/d' requirements.txt
|
||||
'';
|
||||
});
|
||||
rope = pylsp-rope.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch
|
||||
or ''''
|
||||
+ ''
|
||||
sed -i '/python-lsp-server/d' setup.cfg
|
||||
'';
|
||||
});
|
||||
ruff = python-lsp-ruff.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch
|
||||
or ''''
|
||||
+ ''
|
||||
sed -i '/python-lsp-server/d' pyproject.toml
|
||||
'';
|
||||
(
|
||||
with pkgs.python3Packages;
|
||||
{
|
||||
pylsp_mypy = pylsp-mypy.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch or ''''
|
||||
+ ''
|
||||
substituteInPlace setup.cfg \
|
||||
--replace-fail "python-lsp-server >=1.7.0" ""
|
||||
'';
|
||||
});
|
||||
isort = pyls-isort.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch or ''''
|
||||
+ ''
|
||||
substituteInPlace setup.py \
|
||||
--replace-fail 'install_requires=["python-lsp-server", "isort"],' 'install_requires=["isort"],'
|
||||
'';
|
||||
});
|
||||
black = python-lsp-black.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch or ''''
|
||||
+ ''
|
||||
substituteInPlace setup.cfg \
|
||||
--replace-fail "python-lsp-server>=1.4.0" ""
|
||||
'';
|
||||
});
|
||||
memestra = pyls-memestra.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch or ''''
|
||||
+ ''
|
||||
sed -i '/python-lsp-server/d' requirements.txt
|
||||
'';
|
||||
});
|
||||
rope = pylsp-rope.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch or ''''
|
||||
+ ''
|
||||
sed -i '/python-lsp-server/d' setup.cfg
|
||||
'';
|
||||
});
|
||||
ruff = python-lsp-ruff.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch or ''''
|
||||
+ ''
|
||||
sed -i '/python-lsp-server/d' pyproject.toml
|
||||
'';
|
||||
|
||||
build-system = [setuptools] ++ (old.build-system or []);
|
||||
});
|
||||
})
|
||||
build-system = [ setuptools ] ++ (old.build-system or [ ]);
|
||||
});
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
# Final list of pylsp plugins to install
|
||||
pylspPlugins = nativePlugins ++ thirdPartyPlugins;
|
||||
in
|
||||
mkDefault (
|
||||
# This is the final default package for pylsp
|
||||
pkgs.python3Packages.python-lsp-server.overridePythonAttrs (
|
||||
old: {
|
||||
propagatedBuildInputs = pylspPlugins ++ old.dependencies;
|
||||
disabledTests =
|
||||
(old.disabledTests or [])
|
||||
++ [
|
||||
# Those tests fail when third-party plugins are loaded
|
||||
"test_notebook_document__did_open"
|
||||
"test_notebook_document__did_change"
|
||||
];
|
||||
}
|
||||
)
|
||||
);
|
||||
};
|
||||
mkDefault (
|
||||
# This is the final default package for pylsp
|
||||
pkgs.python3Packages.python-lsp-server.overridePythonAttrs (old: {
|
||||
propagatedBuildInputs = pylspPlugins ++ old.dependencies;
|
||||
disabledTests = (old.disabledTests or [ ]) ++ [
|
||||
# Those tests fail when third-party plugins are loaded
|
||||
"test_notebook_document__did_open"
|
||||
"test_notebook_document__did_change"
|
||||
];
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,34 +1,32 @@
|
|||
lib: pkgs:
|
||||
# Future improvements:
|
||||
# - extra documentation from anyOf types, they can have `enumDescriptions` that are valuable
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
packageJson = "${pkgs.rust-analyzer.src}/editors/code/package.json";
|
||||
|
||||
options =
|
||||
(trivial.importJSON packageJson)
|
||||
.contributes
|
||||
.configuration
|
||||
.properties;
|
||||
options = (trivial.importJSON packageJson).contributes.configuration.properties;
|
||||
|
||||
packageJsonTxt = strings.splitString "\n" (builtins.readFile packageJson);
|
||||
vscodeStart =
|
||||
lists.findFirstIndex (x: x == " \"configuration\": {")
|
||||
(throw "no configuration")
|
||||
packageJsonTxt;
|
||||
vscodeStart = lists.findFirstIndex (
|
||||
x: x == " \"configuration\": {"
|
||||
) (throw "no configuration") packageJsonTxt;
|
||||
vscodeEnd =
|
||||
lists.findFirstIndex (strings.hasInfix "generated-start") (throw "no generated start")
|
||||
packageJsonTxt;
|
||||
packageJsonTxt;
|
||||
vscodeOptions = lists.sublist vscodeStart (vscodeEnd - vscodeStart) packageJsonTxt;
|
||||
|
||||
vscodeOptionNames =
|
||||
builtins.map
|
||||
(x: strings.removeSuffix "\": {" (strings.removePrefix " \"" x))
|
||||
(lists.filter (strings.hasPrefix " \"rust-analyzer.")
|
||||
vscodeOptions);
|
||||
vscodeOptionNames = builtins.map (
|
||||
x: strings.removeSuffix "\": {" (strings.removePrefix " \"" x)
|
||||
) (lists.filter (strings.hasPrefix " \"rust-analyzer.") vscodeOptions);
|
||||
|
||||
rustAnalyzerOptions =
|
||||
builtins.removeAttrs options
|
||||
(vscodeOptionNames ++ ["\$generated-start" "\$generated-end"]);
|
||||
rustAnalyzerOptions = builtins.removeAttrs options (
|
||||
vscodeOptionNames
|
||||
++ [
|
||||
"\$generated-start"
|
||||
"\$generated-end"
|
||||
]
|
||||
);
|
||||
|
||||
nullType = mkOptionType {
|
||||
name = "nullType";
|
||||
|
@ -38,126 +36,132 @@ with lib; let
|
|||
check = e: e == null;
|
||||
};
|
||||
|
||||
mkRustAnalyzerType = opt: {
|
||||
type,
|
||||
enum ? null,
|
||||
minimum ? null,
|
||||
maximum ? null,
|
||||
items ? null,
|
||||
anyOf ? null,
|
||||
uniqueItems ? null,
|
||||
# unused, but for exhaustivness
|
||||
enumDescriptions ? null,
|
||||
} @ def:
|
||||
if enum != null
|
||||
then types.enum enum
|
||||
else if anyOf != null
|
||||
then types.oneOf (builtins.map (mkRustAnalyzerType opt) anyOf)
|
||||
else if builtins.isList type
|
||||
then
|
||||
if builtins.length type == 2 && builtins.head type == "null"
|
||||
then types.nullOr (mkRustAnalyzerType opt (def // {type = builtins.elemAt type 1;}))
|
||||
else types.oneOf (builtins.map (t: mkRustAnalyzerType opt (def // {type = t;})) type)
|
||||
else if type == "boolean"
|
||||
then types.bool
|
||||
else if type == "object"
|
||||
then types.attrsOf types.anything
|
||||
else if type == "string"
|
||||
then types.str
|
||||
else if type == "null"
|
||||
then nullType
|
||||
else if type == "array"
|
||||
then
|
||||
mkRustAnalyzerType =
|
||||
opt:
|
||||
{
|
||||
type,
|
||||
enum ? null,
|
||||
minimum ? null,
|
||||
maximum ? null,
|
||||
items ? null,
|
||||
anyOf ? null,
|
||||
uniqueItems ? null,
|
||||
# unused, but for exhaustivness
|
||||
enumDescriptions ? null,
|
||||
}@def:
|
||||
if enum != null then
|
||||
types.enum enum
|
||||
else if anyOf != null then
|
||||
types.oneOf (builtins.map (mkRustAnalyzerType opt) anyOf)
|
||||
else if builtins.isList type then
|
||||
if builtins.length type == 2 && builtins.head type == "null" then
|
||||
types.nullOr (mkRustAnalyzerType opt (def // { type = builtins.elemAt type 1; }))
|
||||
else
|
||||
types.oneOf (builtins.map (t: mkRustAnalyzerType opt (def // { type = t; })) type)
|
||||
else if type == "boolean" then
|
||||
types.bool
|
||||
else if type == "object" then
|
||||
types.attrsOf types.anything
|
||||
else if type == "string" then
|
||||
types.str
|
||||
else if type == "null" then
|
||||
nullType
|
||||
else if type == "array" then
|
||||
types.listOf (
|
||||
mkRustAnalyzerType "${opt}-items"
|
||||
(
|
||||
if items == null
|
||||
then throw "null items with array type (in ${opt})"
|
||||
else items
|
||||
mkRustAnalyzerType "${opt}-items" (
|
||||
if items == null then throw "null items with array type (in ${opt})" else items
|
||||
)
|
||||
)
|
||||
else if type == "number"
|
||||
then
|
||||
if minimum != null && maximum != null
|
||||
then types.numbers.between minimum maximum
|
||||
else if minimum != null
|
||||
then types.addCheck types.number (x: x >= minimum)
|
||||
else if maximum != null
|
||||
then types.addCheck types.number (x: x <= maximum)
|
||||
else types.number
|
||||
else if type == "integer"
|
||||
then
|
||||
if minimum != null && maximum != null
|
||||
then types.ints.between minimum maximum
|
||||
else if minimum != null
|
||||
then types.addCheck types.int (x: x >= minimum)
|
||||
else if maximum != null
|
||||
then types.addCheck types.int (x: x <= maximum)
|
||||
else types.int
|
||||
else throw "unhandled type `${builtins.toJSON type}` (in ${opt})";
|
||||
else if type == "number" then
|
||||
if minimum != null && maximum != null then
|
||||
types.numbers.between minimum maximum
|
||||
else if minimum != null then
|
||||
types.addCheck types.number (x: x >= minimum)
|
||||
else if maximum != null then
|
||||
types.addCheck types.number (x: x <= maximum)
|
||||
else
|
||||
types.number
|
||||
else if type == "integer" then
|
||||
if minimum != null && maximum != null then
|
||||
types.ints.between minimum maximum
|
||||
else if minimum != null then
|
||||
types.addCheck types.int (x: x >= minimum)
|
||||
else if maximum != null then
|
||||
types.addCheck types.int (x: x <= maximum)
|
||||
else
|
||||
types.int
|
||||
else
|
||||
throw "unhandled type `${builtins.toJSON type}` (in ${opt})";
|
||||
|
||||
mkRustAnalyzerOption = opt: {
|
||||
default,
|
||||
markdownDescription,
|
||||
type ? null,
|
||||
anyOf ? null,
|
||||
# Enum types
|
||||
enum ? null,
|
||||
enumDescriptions ? null,
|
||||
# Int types
|
||||
minimum ? null,
|
||||
maximum ? null,
|
||||
# List types
|
||||
items ? null,
|
||||
uniqueItems ? false,
|
||||
}:
|
||||
mkRustAnalyzerOption =
|
||||
opt:
|
||||
{
|
||||
default,
|
||||
markdownDescription,
|
||||
type ? null,
|
||||
anyOf ? null,
|
||||
# Enum types
|
||||
enum ? null,
|
||||
enumDescriptions ? null,
|
||||
# Int types
|
||||
minimum ? null,
|
||||
maximum ? null,
|
||||
# List types
|
||||
items ? null,
|
||||
uniqueItems ? false,
|
||||
}:
|
||||
mkOption {
|
||||
type = types.nullOr (mkRustAnalyzerType opt {
|
||||
inherit
|
||||
type
|
||||
enum
|
||||
minimum
|
||||
maximum
|
||||
items
|
||||
anyOf
|
||||
uniqueItems
|
||||
;
|
||||
});
|
||||
type = types.nullOr (
|
||||
mkRustAnalyzerType opt {
|
||||
inherit
|
||||
type
|
||||
enum
|
||||
minimum
|
||||
maximum
|
||||
items
|
||||
anyOf
|
||||
uniqueItems
|
||||
;
|
||||
}
|
||||
);
|
||||
default = null;
|
||||
description =
|
||||
if enum != null
|
||||
then let
|
||||
valueDesc = builtins.map ({
|
||||
fst,
|
||||
snd,
|
||||
}: ''- ${fst}: ${snd}'') (lists.zipLists enum enumDescriptions);
|
||||
in ''
|
||||
${markdownDescription}
|
||||
if enum != null then
|
||||
let
|
||||
valueDesc = builtins.map ({ fst, snd }: ''- ${fst}: ${snd}'') (
|
||||
lists.zipLists enum enumDescriptions
|
||||
);
|
||||
in
|
||||
''
|
||||
${markdownDescription}
|
||||
|
||||
Values:
|
||||
${builtins.concatStringsSep "\n" valueDesc}
|
||||
Values:
|
||||
${builtins.concatStringsSep "\n" valueDesc}
|
||||
|
||||
```nix
|
||||
${generators.toPretty {} default}
|
||||
```
|
||||
''
|
||||
else ''
|
||||
${markdownDescription}
|
||||
```nix
|
||||
${generators.toPretty { } default}
|
||||
```
|
||||
''
|
||||
else
|
||||
''
|
||||
${markdownDescription}
|
||||
|
||||
default:
|
||||
```nix
|
||||
${generators.toPretty {} default}
|
||||
```
|
||||
'';
|
||||
default:
|
||||
```nix
|
||||
${generators.toPretty { } default}
|
||||
```
|
||||
'';
|
||||
};
|
||||
|
||||
nixOptions = builtins.mapAttrs mkRustAnalyzerOption rustAnalyzerOptions;
|
||||
|
||||
nestOpt = opt: value: let
|
||||
parts = strings.splitString "." opt;
|
||||
in
|
||||
builtins.foldl' (current: segment: {${segment} = current;}) value (lists.reverseList parts);
|
||||
nestOpt =
|
||||
opt: value:
|
||||
let
|
||||
parts = strings.splitString "." opt;
|
||||
in
|
||||
builtins.foldl' (current: segment: { ${segment} = current; }) value (lists.reverseList parts);
|
||||
|
||||
nestedNixOptions = attrsets.mapAttrsToList nestOpt nixOptions;
|
||||
in
|
||||
(builtins.foldl' attrsets.recursiveUpdate {} nestedNixOptions).rust-analyzer
|
||||
(builtins.foldl' attrsets.recursiveUpdate { } nestedNixOptions).rust-analyzer
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.lsp.servers.rust-analyzer;
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.plugins.lsp.servers.rust-analyzer = {
|
||||
# https://github.com/nix-community/nixvim/issues/674
|
||||
installCargo = mkOption {
|
||||
|
@ -37,45 +39,30 @@ in {
|
|||
};
|
||||
config = mkIf cfg.enable {
|
||||
warnings =
|
||||
(
|
||||
optional
|
||||
(cfg.installCargo == null)
|
||||
''
|
||||
`rust_analyzer` relies on `cargo`.
|
||||
- Set `plugins.lsp.servers.rust-analyzer.installCargo = true` to install it automatically
|
||||
with Nixvim.
|
||||
You can customize which package to install by changing
|
||||
`plugins.lsp.servers.rust-analyzer.cargoPackage`.
|
||||
- Set `plugins.lsp.servers.rust-analyzer.installCargo = false` to not have it install
|
||||
through Nixvim.
|
||||
By doing so, you will dismiss this warning.
|
||||
''
|
||||
)
|
||||
++ (
|
||||
optional
|
||||
(cfg.installRustc == null)
|
||||
''
|
||||
`rust_analyzer` relies on `rustc`.
|
||||
- Set `plugins.lsp.servers.rust-analyzer.installRustc = true` to install it automatically
|
||||
with Nixvim.
|
||||
You can customize which package to install by changing
|
||||
`plugins.lsp.servers.rust-analyzer.rustcPackage`.
|
||||
- Set `plugins.lsp.servers.rust-analyzer.installRustc = false` to not have it install
|
||||
through Nixvim.
|
||||
By doing so, you will dismiss this warning.
|
||||
''
|
||||
);
|
||||
(optional (cfg.installCargo == null) ''
|
||||
`rust_analyzer` relies on `cargo`.
|
||||
- Set `plugins.lsp.servers.rust-analyzer.installCargo = true` to install it automatically
|
||||
with Nixvim.
|
||||
You can customize which package to install by changing
|
||||
`plugins.lsp.servers.rust-analyzer.cargoPackage`.
|
||||
- Set `plugins.lsp.servers.rust-analyzer.installCargo = false` to not have it install
|
||||
through Nixvim.
|
||||
By doing so, you will dismiss this warning.
|
||||
'')
|
||||
++ (optional (cfg.installRustc == null) ''
|
||||
`rust_analyzer` relies on `rustc`.
|
||||
- Set `plugins.lsp.servers.rust-analyzer.installRustc = true` to install it automatically
|
||||
with Nixvim.
|
||||
You can customize which package to install by changing
|
||||
`plugins.lsp.servers.rust-analyzer.rustcPackage`.
|
||||
- Set `plugins.lsp.servers.rust-analyzer.installRustc = false` to not have it install
|
||||
through Nixvim.
|
||||
By doing so, you will dismiss this warning.
|
||||
'');
|
||||
|
||||
extraPackages = with pkgs;
|
||||
(
|
||||
optional
|
||||
((isBool cfg.installCargo) && cfg.installCargo)
|
||||
cfg.cargoPackage
|
||||
)
|
||||
++ (
|
||||
optional
|
||||
((isBool cfg.installRustc) && cfg.installRustc)
|
||||
cfg.rustcPackage
|
||||
);
|
||||
extraPackages =
|
||||
with pkgs;
|
||||
(optional ((isBool cfg.installCargo) && cfg.installCargo) cfg.cargoPackage)
|
||||
++ (optional ((isBool cfg.installRustc) && cfg.installRustc) cfg.rustcPackage);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
config,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.lsp.servers.svelte;
|
||||
in {
|
||||
in
|
||||
{
|
||||
# Options: https://github.com/sveltejs/language-tools/tree/master/packages/language-server#settings
|
||||
options.plugins.lsp.servers.svelte.initOptions = {
|
||||
svelte = {
|
||||
|
@ -283,11 +285,9 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
config =
|
||||
mkIf cfg.enable
|
||||
{
|
||||
plugins.lsp.servers.svelte.extraOptions.init_options = {
|
||||
configuration = cfg.initOptions;
|
||||
};
|
||||
config = mkIf cfg.enable {
|
||||
plugins.lsp.servers.svelte.extraOptions.init_options = {
|
||||
configuration = cfg.initOptions;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
{ lib, config, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.lsp.servers.vls;
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.plugins.lsp.servers.vls = {
|
||||
autoSetFiletype = mkOption {
|
||||
type = types.bool;
|
||||
|
@ -18,11 +16,5 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
config =
|
||||
mkIf cfg.enable
|
||||
{
|
||||
filetype.extension =
|
||||
mkIf cfg.autoSetFiletype
|
||||
{v = "vlang";};
|
||||
};
|
||||
config = mkIf cfg.enable { filetype.extension = mkIf cfg.autoSetFiletype { v = "vlang"; }; };
|
||||
}
|
||||
|
|
|
@ -5,90 +5,95 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.lsp-format;
|
||||
in {
|
||||
options.plugins.lsp-format =
|
||||
helpers.neovim-plugin.extraOptionsOptions
|
||||
// {
|
||||
enable = mkEnableOption "lsp-format.nvim";
|
||||
in
|
||||
{
|
||||
options.plugins.lsp-format = helpers.neovim-plugin.extraOptionsOptions // {
|
||||
enable = mkEnableOption "lsp-format.nvim";
|
||||
|
||||
package = helpers.mkPackageOption "lsp-format.nvim" pkgs.vimPlugins.lsp-format-nvim;
|
||||
package = helpers.mkPackageOption "lsp-format.nvim" pkgs.vimPlugins.lsp-format-nvim;
|
||||
|
||||
setup = mkOption {
|
||||
type = with types;
|
||||
attrsOf
|
||||
(submodule {
|
||||
# Allow the user to provide other options
|
||||
freeformType = types.attrs;
|
||||
setup = mkOption {
|
||||
type =
|
||||
with types;
|
||||
attrsOf (submodule {
|
||||
# Allow the user to provide other options
|
||||
freeformType = types.attrs;
|
||||
|
||||
options = {
|
||||
exclude =
|
||||
helpers.mkNullOrOption (listOf str)
|
||||
"List of client names to exclude from formatting.";
|
||||
options = {
|
||||
exclude = helpers.mkNullOrOption (listOf str) "List of client names to exclude from formatting.";
|
||||
|
||||
order =
|
||||
helpers.mkNullOrOption (listOf str)
|
||||
''
|
||||
List of client names. Formatting is requested from clients in the following
|
||||
order: first all clients that are not in the `order` table, then the remaining
|
||||
clients in the order as they occur in the `order` table.
|
||||
(same logic as |vim.lsp.buf.formatting_seq_sync()|).
|
||||
'';
|
||||
order = helpers.mkNullOrOption (listOf str) ''
|
||||
List of client names. Formatting is requested from clients in the following
|
||||
order: first all clients that are not in the `order` table, then the remaining
|
||||
clients in the order as they occur in the `order` table.
|
||||
(same logic as |vim.lsp.buf.formatting_seq_sync()|).
|
||||
'';
|
||||
|
||||
sync = helpers.defaultNullOpts.mkBool false ''
|
||||
Whether to turn on synchronous formatting.
|
||||
The editor will block until formatting is done.
|
||||
'';
|
||||
sync = helpers.defaultNullOpts.mkBool false ''
|
||||
Whether to turn on synchronous formatting.
|
||||
The editor will block until formatting is done.
|
||||
'';
|
||||
|
||||
force = helpers.defaultNullOpts.mkBool false ''
|
||||
If true, the format result will always be written to the buffer, even if the
|
||||
buffer changed.
|
||||
'';
|
||||
};
|
||||
});
|
||||
description = "The setup option maps |filetypes| to format options.";
|
||||
example = {
|
||||
gopls = {
|
||||
exclude = ["gopls"];
|
||||
order = ["gopls" "efm"];
|
||||
sync = true;
|
||||
force = true;
|
||||
force = helpers.defaultNullOpts.mkBool false ''
|
||||
If true, the format result will always be written to the buffer, even if the
|
||||
buffer changed.
|
||||
'';
|
||||
};
|
||||
});
|
||||
description = "The setup option maps |filetypes| to format options.";
|
||||
example = {
|
||||
gopls = {
|
||||
exclude = [ "gopls" ];
|
||||
order = [
|
||||
"gopls"
|
||||
"efm"
|
||||
];
|
||||
sync = true;
|
||||
force = true;
|
||||
};
|
||||
default = {};
|
||||
};
|
||||
|
||||
lspServersToEnable = mkOption {
|
||||
type = with types; either (enum ["none" "all"]) (listOf str);
|
||||
default = "all";
|
||||
description = ''
|
||||
Choose the LSP servers for which lsp-format should be enabled.
|
||||
|
||||
Possible values:
|
||||
- "all" (default): Enable formatting for all language servers
|
||||
- "none": Do not enable formatting on any language server.
|
||||
You might choose this if for some reason you want to manually call
|
||||
`require("lsp-format").on_attach(client)` in the `onAttach` function of your language
|
||||
servers.
|
||||
- list of LS names: Manually choose the servers by name
|
||||
'';
|
||||
example = [
|
||||
"efm"
|
||||
"gopls"
|
||||
];
|
||||
};
|
||||
default = { };
|
||||
};
|
||||
|
||||
config = let
|
||||
setupOptions = cfg.setup // cfg.extraOptions;
|
||||
in
|
||||
lspServersToEnable = mkOption {
|
||||
type =
|
||||
with types;
|
||||
either (enum [
|
||||
"none"
|
||||
"all"
|
||||
]) (listOf str);
|
||||
default = "all";
|
||||
description = ''
|
||||
Choose the LSP servers for which lsp-format should be enabled.
|
||||
|
||||
Possible values:
|
||||
- "all" (default): Enable formatting for all language servers
|
||||
- "none": Do not enable formatting on any language server.
|
||||
You might choose this if for some reason you want to manually call
|
||||
`require("lsp-format").on_attach(client)` in the `onAttach` function of your language
|
||||
servers.
|
||||
- list of LS names: Manually choose the servers by name
|
||||
'';
|
||||
example = [
|
||||
"efm"
|
||||
"gopls"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
setupOptions = cfg.setup // cfg.extraOptions;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
warnings = mkIf (!config.plugins.lsp.enable) [
|
||||
"You have enabled `plugins.lsp-format` but have `plugins.lsp` disabled."
|
||||
];
|
||||
|
||||
extraPlugins = [cfg.package];
|
||||
extraPlugins = [ cfg.package ];
|
||||
|
||||
plugins.lsp = {
|
||||
onAttach = mkIf (cfg.lspServersToEnable == "all") ''
|
||||
|
@ -96,18 +101,14 @@ in {
|
|||
'';
|
||||
|
||||
servers =
|
||||
if (isList cfg.lspServersToEnable)
|
||||
then
|
||||
genAttrs
|
||||
cfg.lspServersToEnable
|
||||
(
|
||||
serverName: {
|
||||
onAttach.function = ''
|
||||
require("lsp-format").on_attach(client)
|
||||
'';
|
||||
}
|
||||
)
|
||||
else {};
|
||||
if (isList cfg.lspServersToEnable) then
|
||||
genAttrs cfg.lspServersToEnable (serverName: {
|
||||
onAttach.function = ''
|
||||
require("lsp-format").on_attach(client)
|
||||
'';
|
||||
})
|
||||
else
|
||||
{ };
|
||||
};
|
||||
|
||||
extraConfigLua = ''
|
||||
|
|
|
@ -5,9 +5,11 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.lsp-lines;
|
||||
in {
|
||||
in
|
||||
{
|
||||
options = {
|
||||
plugins.lsp-lines = {
|
||||
enable = mkEnableOption "lsp_lines.nvim";
|
||||
|
@ -22,19 +24,15 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
diagnosticConfig = {
|
||||
virtual_text = false;
|
||||
virtual_lines =
|
||||
if cfg.currentLine
|
||||
then {
|
||||
only_current_line = true;
|
||||
}
|
||||
else true;
|
||||
};
|
||||
in
|
||||
config =
|
||||
let
|
||||
diagnosticConfig = {
|
||||
virtual_text = false;
|
||||
virtual_lines = if cfg.currentLine then { only_current_line = true; } else true;
|
||||
};
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [cfg.package];
|
||||
extraPlugins = [ cfg.package ];
|
||||
|
||||
extraConfigLua = ''
|
||||
do
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -6,20 +6,22 @@
|
|||
...
|
||||
}:
|
||||
with lib;
|
||||
helpers.neovim-plugin.mkNeovimPlugin config {
|
||||
name = "nvim-lightbulb";
|
||||
defaultPackage = pkgs.vimPlugins.nvim-lightbulb;
|
||||
helpers.neovim-plugin.mkNeovimPlugin config {
|
||||
name = "nvim-lightbulb";
|
||||
defaultPackage = pkgs.vimPlugins.nvim-lightbulb;
|
||||
|
||||
maintainers = [maintainers.GaetanLepage];
|
||||
maintainers = [ maintainers.GaetanLepage ];
|
||||
|
||||
# TODO introduced 2024-02-15. Remove on 2024-03-15
|
||||
imports =
|
||||
map
|
||||
# TODO introduced 2024-02-15. Remove on 2024-03-15
|
||||
imports =
|
||||
map
|
||||
(
|
||||
optionName:
|
||||
mkRemovedOptionModule
|
||||
["plugins" "nvim-lightbulb" optionName]
|
||||
"Please use `plugins.nvim-lightbulb.settings` instead."
|
||||
mkRemovedOptionModule [
|
||||
"plugins"
|
||||
"nvim-lightbulb"
|
||||
optionName
|
||||
] "Please use `plugins.nvim-lightbulb.settings` instead."
|
||||
)
|
||||
[
|
||||
"ignore"
|
||||
|
@ -30,196 +32,203 @@ with lib;
|
|||
"autocmd"
|
||||
];
|
||||
|
||||
settingsOptions = {
|
||||
priority = helpers.defaultNullOpts.mkUnsignedInt 10 ''
|
||||
Priority of the lightbulb for all handlers except float.
|
||||
settingsOptions = {
|
||||
priority = helpers.defaultNullOpts.mkUnsignedInt 10 ''
|
||||
Priority of the lightbulb for all handlers except float.
|
||||
'';
|
||||
|
||||
hide_in_unfocused_buffer = helpers.defaultNullOpts.mkBool true ''
|
||||
Whether or not to hide the lightbulb when the buffer is not focused.
|
||||
Only works if configured during `NvimLightbulb.setup`.
|
||||
'';
|
||||
|
||||
link_highlights = helpers.defaultNullOpts.mkBool true ''
|
||||
Whether or not to link the highlight groups automatically.
|
||||
Default highlight group links:
|
||||
- `LightBulbSign` -> `DiagnosticSignInfo`
|
||||
- `LightBulbFloatWin` -> `DiagnosticFloatingInfo`
|
||||
- `LightBulbVirtualText` -> `DiagnosticVirtualTextInfo`
|
||||
- `LightBulbNumber` -> `DiagnosticSignInfo`
|
||||
- `LightBulbLine` -> `CursorLine`
|
||||
|
||||
Only works if configured during `NvimLightbulb.setup`.
|
||||
'';
|
||||
|
||||
validate_config =
|
||||
helpers.defaultNullOpts.mkEnumFirstDefault
|
||||
[
|
||||
"auto"
|
||||
"always"
|
||||
"never"
|
||||
]
|
||||
''
|
||||
Perform full validation of configuration.
|
||||
|
||||
- "auto" only performs full validation in `NvimLightbulb.setup`.
|
||||
- "always" performs full validation in `NvimLightbulb.update_lightbulb` as well.
|
||||
- "never" disables config validation.
|
||||
'';
|
||||
|
||||
action_kinds = helpers.mkNullOrOption (with types; listOf str) ''
|
||||
Code action kinds to observe.
|
||||
To match all code actions, set to `null`.
|
||||
Otherwise, set to a list of kinds.
|
||||
|
||||
Example:
|
||||
```nix
|
||||
[
|
||||
"quickfix"
|
||||
"refactor.rewrite"
|
||||
]
|
||||
```
|
||||
See: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind
|
||||
'';
|
||||
|
||||
sign = {
|
||||
enabled = helpers.defaultNullOpts.mkBool true "Sign column.";
|
||||
|
||||
text = helpers.defaultNullOpts.mkStr "💡" ''
|
||||
Text to show in the sign column.
|
||||
Must be between 1-2 characters.
|
||||
'';
|
||||
|
||||
hide_in_unfocused_buffer = helpers.defaultNullOpts.mkBool true ''
|
||||
Whether or not to hide the lightbulb when the buffer is not focused.
|
||||
hl = helpers.defaultNullOpts.mkStr "LightBulbSign" ''
|
||||
Highlight group to highlight the sign column text.
|
||||
'';
|
||||
};
|
||||
|
||||
virtual_text = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false "Virtual text.";
|
||||
|
||||
text = helpers.defaultNullOpts.mkStr "💡" "Text to show in the virt_text.";
|
||||
|
||||
pos = helpers.defaultNullOpts.mkStr "eol" ''
|
||||
Position of virtual text given to |nvim_buf_set_extmark|.
|
||||
Can be a number representing a fixed column (see `virt_text_pos`).
|
||||
Can be a string representing a position (see `virt_text_win_col`).
|
||||
'';
|
||||
|
||||
hl = helpers.defaultNullOpts.mkStr "LightBulbVirtualText" ''
|
||||
Highlight group to highlight the virtual text.
|
||||
'';
|
||||
|
||||
hl_mode = helpers.defaultNullOpts.mkStr "combine" ''
|
||||
How to combine other highlights with text highlight.
|
||||
See `hl_mode` of |nvim_buf_set_extmark|.
|
||||
'';
|
||||
};
|
||||
|
||||
float = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false "Floating window.";
|
||||
|
||||
text = helpers.defaultNullOpts.mkStr "💡" "Text to show in the floating window.";
|
||||
|
||||
hl = helpers.defaultNullOpts.mkStr "LightBulbFloatWin" ''
|
||||
Highlight group to highlight the floating window.
|
||||
'';
|
||||
|
||||
win_opts = helpers.defaultNullOpts.mkAttrsOf types.anything "{}" ''
|
||||
Window options.
|
||||
See |vim.lsp.util.open_floating_preview| and |nvim_open_win|.
|
||||
Note that some options may be overridden by |open_floating_preview|.
|
||||
'';
|
||||
};
|
||||
|
||||
status_text = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false ''
|
||||
Status text.
|
||||
When enabled, will allow using |NvimLightbulb.get_status_text| to retrieve the configured text.
|
||||
'';
|
||||
|
||||
text = helpers.defaultNullOpts.mkStr "💡" "Text to set if a lightbulb is available.";
|
||||
|
||||
text_unavailable = helpers.defaultNullOpts.mkStr "" ''
|
||||
Text to set if a lightbulb is unavailable.
|
||||
'';
|
||||
};
|
||||
|
||||
number = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false "Number column.";
|
||||
|
||||
hl = helpers.defaultNullOpts.mkStr "LightBulbNumber" ''
|
||||
Highlight group to highlight the number column if there is a lightbulb.
|
||||
'';
|
||||
};
|
||||
|
||||
line = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false "Content line.";
|
||||
|
||||
hl = helpers.defaultNullOpts.mkStr "LightBulbLine" ''
|
||||
Highlight group to highlight the line if there is a lightbulb.
|
||||
'';
|
||||
};
|
||||
|
||||
autocmd = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false ''
|
||||
Autocmd configuration.
|
||||
If enabled, automatically defines an autocmd to show the lightbulb.
|
||||
If disabled, you will have to manually call |NvimLightbulb.update_lightbulb|.
|
||||
Only works if configured during `NvimLightbulb.setup`.
|
||||
'';
|
||||
|
||||
link_highlights = helpers.defaultNullOpts.mkBool true ''
|
||||
Whether or not to link the highlight groups automatically.
|
||||
Default highlight group links:
|
||||
- `LightBulbSign` -> `DiagnosticSignInfo`
|
||||
- `LightBulbFloatWin` -> `DiagnosticFloatingInfo`
|
||||
- `LightBulbVirtualText` -> `DiagnosticVirtualTextInfo`
|
||||
- `LightBulbNumber` -> `DiagnosticSignInfo`
|
||||
- `LightBulbLine` -> `CursorLine`
|
||||
|
||||
Only works if configured during `NvimLightbulb.setup`.
|
||||
updatetime = helpers.defaultNullOpts.mkInt 200 ''
|
||||
See |updatetime|.
|
||||
Set to a negative value to avoid setting the updatetime.
|
||||
'';
|
||||
|
||||
validate_config = helpers.defaultNullOpts.mkEnumFirstDefault ["auto" "always" "never"] ''
|
||||
Perform full validation of configuration.
|
||||
|
||||
- "auto" only performs full validation in `NvimLightbulb.setup`.
|
||||
- "always" performs full validation in `NvimLightbulb.update_lightbulb` as well.
|
||||
- "never" disables config validation.
|
||||
pattern = helpers.defaultNullOpts.mkListOf types.str ''["*"]'' ''
|
||||
See |nvim_create_autocmd| and |autocmd-pattern|.
|
||||
'';
|
||||
|
||||
action_kinds = helpers.mkNullOrOption (with types; listOf str) ''
|
||||
Code action kinds to observe.
|
||||
To match all code actions, set to `null`.
|
||||
Otherwise, set to a list of kinds.
|
||||
|
||||
Example:
|
||||
```nix
|
||||
[
|
||||
"quickfix"
|
||||
"refactor.rewrite"
|
||||
]
|
||||
```
|
||||
See: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind
|
||||
events = helpers.defaultNullOpts.mkListOf types.str ''["CursorHold" "CursorHoldI"]'' ''
|
||||
See |nvim_create_autocmd|.
|
||||
'';
|
||||
|
||||
sign = {
|
||||
enabled = helpers.defaultNullOpts.mkBool true "Sign column.";
|
||||
|
||||
text = helpers.defaultNullOpts.mkStr "💡" ''
|
||||
Text to show in the sign column.
|
||||
Must be between 1-2 characters.
|
||||
'';
|
||||
|
||||
hl = helpers.defaultNullOpts.mkStr "LightBulbSign" ''
|
||||
Highlight group to highlight the sign column text.
|
||||
'';
|
||||
};
|
||||
|
||||
virtual_text = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false "Virtual text.";
|
||||
|
||||
text = helpers.defaultNullOpts.mkStr "💡" "Text to show in the virt_text.";
|
||||
|
||||
pos = helpers.defaultNullOpts.mkStr "eol" ''
|
||||
Position of virtual text given to |nvim_buf_set_extmark|.
|
||||
Can be a number representing a fixed column (see `virt_text_pos`).
|
||||
Can be a string representing a position (see `virt_text_win_col`).
|
||||
'';
|
||||
|
||||
hl = helpers.defaultNullOpts.mkStr "LightBulbVirtualText" ''
|
||||
Highlight group to highlight the virtual text.
|
||||
'';
|
||||
|
||||
hl_mode = helpers.defaultNullOpts.mkStr "combine" ''
|
||||
How to combine other highlights with text highlight.
|
||||
See `hl_mode` of |nvim_buf_set_extmark|.
|
||||
'';
|
||||
};
|
||||
|
||||
float = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false "Floating window.";
|
||||
|
||||
text = helpers.defaultNullOpts.mkStr "💡" "Text to show in the floating window.";
|
||||
|
||||
hl = helpers.defaultNullOpts.mkStr "LightBulbFloatWin" ''
|
||||
Highlight group to highlight the floating window.
|
||||
'';
|
||||
|
||||
win_opts = helpers.defaultNullOpts.mkAttrsOf types.anything "{}" ''
|
||||
Window options.
|
||||
See |vim.lsp.util.open_floating_preview| and |nvim_open_win|.
|
||||
Note that some options may be overridden by |open_floating_preview|.
|
||||
'';
|
||||
};
|
||||
|
||||
status_text = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false ''
|
||||
Status text.
|
||||
When enabled, will allow using |NvimLightbulb.get_status_text| to retrieve the configured text.
|
||||
'';
|
||||
|
||||
text = helpers.defaultNullOpts.mkStr "💡" "Text to set if a lightbulb is available.";
|
||||
|
||||
text_unavailable = helpers.defaultNullOpts.mkStr "" ''
|
||||
Text to set if a lightbulb is unavailable.
|
||||
'';
|
||||
};
|
||||
|
||||
number = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false "Number column.";
|
||||
|
||||
hl = helpers.defaultNullOpts.mkStr "LightBulbNumber" ''
|
||||
Highlight group to highlight the number column if there is a lightbulb.
|
||||
'';
|
||||
};
|
||||
|
||||
line = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false "Content line.";
|
||||
|
||||
hl = helpers.defaultNullOpts.mkStr "LightBulbLine" ''
|
||||
Highlight group to highlight the line if there is a lightbulb.
|
||||
'';
|
||||
};
|
||||
|
||||
autocmd = {
|
||||
enabled = helpers.defaultNullOpts.mkBool false ''
|
||||
Autocmd configuration.
|
||||
If enabled, automatically defines an autocmd to show the lightbulb.
|
||||
If disabled, you will have to manually call |NvimLightbulb.update_lightbulb|.
|
||||
Only works if configured during `NvimLightbulb.setup`.
|
||||
'';
|
||||
|
||||
updatetime = helpers.defaultNullOpts.mkInt 200 ''
|
||||
See |updatetime|.
|
||||
Set to a negative value to avoid setting the updatetime.
|
||||
'';
|
||||
|
||||
pattern = helpers.defaultNullOpts.mkListOf types.str ''["*"]'' ''
|
||||
See |nvim_create_autocmd| and |autocmd-pattern|.
|
||||
'';
|
||||
|
||||
events = helpers.defaultNullOpts.mkListOf types.str ''["CursorHold" "CursorHoldI"]'' ''
|
||||
See |nvim_create_autocmd|.
|
||||
'';
|
||||
};
|
||||
|
||||
ignore = {
|
||||
clients = helpers.defaultNullOpts.mkListOf types.str "[]" ''
|
||||
LSP client names to ignore.
|
||||
Example: {"null-ls", "lua_ls"}
|
||||
'';
|
||||
|
||||
ft = helpers.defaultNullOpts.mkListOf types.str "[]" ''
|
||||
Filetypes to ignore.
|
||||
Example: {"neo-tree", "lua"}
|
||||
'';
|
||||
|
||||
actions_without_kind = helpers.defaultNullOpts.mkBool false ''
|
||||
Ignore code actions without a `kind` like `refactor.rewrite`, quickfix.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
settingsExample = {
|
||||
sign = {
|
||||
enabled = false;
|
||||
text = "";
|
||||
};
|
||||
virtual_text = {
|
||||
enabled = true;
|
||||
text = "";
|
||||
};
|
||||
float = {
|
||||
enabled = false;
|
||||
text = " ";
|
||||
win_opts.border = "rounded";
|
||||
};
|
||||
status_text = {
|
||||
enabled = false;
|
||||
text = " ";
|
||||
};
|
||||
number = {
|
||||
enabled = false;
|
||||
};
|
||||
line = {
|
||||
enabled = false;
|
||||
};
|
||||
autocmd = {
|
||||
enabled = true;
|
||||
updatetime = 200;
|
||||
};
|
||||
ignore = {
|
||||
clients = helpers.defaultNullOpts.mkListOf types.str "[]" ''
|
||||
LSP client names to ignore.
|
||||
Example: {"null-ls", "lua_ls"}
|
||||
'';
|
||||
|
||||
ft = helpers.defaultNullOpts.mkListOf types.str "[]" ''
|
||||
Filetypes to ignore.
|
||||
Example: {"neo-tree", "lua"}
|
||||
'';
|
||||
|
||||
actions_without_kind = helpers.defaultNullOpts.mkBool false ''
|
||||
Ignore code actions without a `kind` like `refactor.rewrite`, quickfix.
|
||||
'';
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
settingsExample = {
|
||||
sign = {
|
||||
enabled = false;
|
||||
text = "";
|
||||
};
|
||||
virtual_text = {
|
||||
enabled = true;
|
||||
text = "";
|
||||
};
|
||||
float = {
|
||||
enabled = false;
|
||||
text = " ";
|
||||
win_opts.border = "rounded";
|
||||
};
|
||||
status_text = {
|
||||
enabled = false;
|
||||
text = " ";
|
||||
};
|
||||
number = {
|
||||
enabled = false;
|
||||
};
|
||||
line = {
|
||||
enabled = false;
|
||||
};
|
||||
autocmd = {
|
||||
enabled = true;
|
||||
updatetime = 200;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -6,103 +6,165 @@
|
|||
...
|
||||
}:
|
||||
with lib;
|
||||
helpers.neovim-plugin.mkNeovimPlugin config {
|
||||
name = "trouble";
|
||||
originalName = "trouble-nvim";
|
||||
defaultPackage = pkgs.vimPlugins.trouble-nvim;
|
||||
helpers.neovim-plugin.mkNeovimPlugin config {
|
||||
name = "trouble";
|
||||
originalName = "trouble-nvim";
|
||||
defaultPackage = pkgs.vimPlugins.trouble-nvim;
|
||||
|
||||
extraPlugins = with pkgs.vimPlugins; [
|
||||
nvim-web-devicons
|
||||
];
|
||||
extraPlugins = with pkgs.vimPlugins; [ nvim-web-devicons ];
|
||||
|
||||
maintainers = [maintainers.loicreynier];
|
||||
maintainers = [ maintainers.loicreynier ];
|
||||
|
||||
# TODO introduced 2024-03-15: remove 2024-05-15
|
||||
optionsRenamedToSettings = [
|
||||
"autoClose"
|
||||
"autoFold"
|
||||
"autoOpen"
|
||||
"autoJump"
|
||||
"autoPreview"
|
||||
"foldClosed"
|
||||
"foldOpen"
|
||||
"group"
|
||||
"height"
|
||||
"icons"
|
||||
"indentLines"
|
||||
"mode"
|
||||
"padding"
|
||||
"position"
|
||||
"width"
|
||||
"useDiagnosticSigns"
|
||||
# TODO introduced 2024-03-15: remove 2024-05-15
|
||||
optionsRenamedToSettings = [
|
||||
"autoClose"
|
||||
"autoFold"
|
||||
"autoOpen"
|
||||
"autoJump"
|
||||
"autoPreview"
|
||||
"foldClosed"
|
||||
"foldOpen"
|
||||
"group"
|
||||
"height"
|
||||
"icons"
|
||||
"indentLines"
|
||||
"mode"
|
||||
"padding"
|
||||
"position"
|
||||
"width"
|
||||
"useDiagnosticSigns"
|
||||
|
||||
["actionKeys" "cancel"]
|
||||
["actionKeys" "close"]
|
||||
["actionKeys" "closeFolds"]
|
||||
["actionKeys" "hover"]
|
||||
["actionKeys" "jump"]
|
||||
["actionKeys" "jumpClose"]
|
||||
["actionKeys" "next"]
|
||||
["actionKeys" "openFolds"]
|
||||
["actionKeys" "openSplit"]
|
||||
["actionKeys" "openTab"]
|
||||
["actionKeys" "openVsplit"]
|
||||
["actionKeys" "previous"]
|
||||
["actionKeys" "refresh"]
|
||||
["actionKeys" "toggleFold"]
|
||||
["actionKeys" "toggleMode"]
|
||||
["actionKeys" "togglePreview"]
|
||||
["signs" "error"]
|
||||
["signs" "hint"]
|
||||
["signs" "other"]
|
||||
["signs" "warning"]
|
||||
];
|
||||
[
|
||||
"actionKeys"
|
||||
"cancel"
|
||||
]
|
||||
[
|
||||
"actionKeys"
|
||||
"close"
|
||||
]
|
||||
[
|
||||
"actionKeys"
|
||||
"closeFolds"
|
||||
]
|
||||
[
|
||||
"actionKeys"
|
||||
"hover"
|
||||
]
|
||||
[
|
||||
"actionKeys"
|
||||
"jump"
|
||||
]
|
||||
[
|
||||
"actionKeys"
|
||||
"jumpClose"
|
||||
]
|
||||
[
|
||||
"actionKeys"
|
||||
"next"
|
||||
]
|
||||
[
|
||||
"actionKeys"
|
||||
"openFolds"
|
||||
]
|
||||
[
|
||||
"actionKeys"
|
||||
"openSplit"
|
||||
]
|
||||
[
|
||||
"actionKeys"
|
||||
"openTab"
|
||||
]
|
||||
[
|
||||
"actionKeys"
|
||||
"openVsplit"
|
||||
]
|
||||
[
|
||||
"actionKeys"
|
||||
"previous"
|
||||
]
|
||||
[
|
||||
"actionKeys"
|
||||
"refresh"
|
||||
]
|
||||
[
|
||||
"actionKeys"
|
||||
"toggleFold"
|
||||
]
|
||||
[
|
||||
"actionKeys"
|
||||
"toggleMode"
|
||||
]
|
||||
[
|
||||
"actionKeys"
|
||||
"togglePreview"
|
||||
]
|
||||
[
|
||||
"signs"
|
||||
"error"
|
||||
]
|
||||
[
|
||||
"signs"
|
||||
"hint"
|
||||
]
|
||||
[
|
||||
"signs"
|
||||
"other"
|
||||
]
|
||||
[
|
||||
"signs"
|
||||
"warning"
|
||||
]
|
||||
];
|
||||
|
||||
settingsOptions = {
|
||||
position = helpers.defaultNullOpts.mkEnum ["top" "left" "right" "bottom"] "bottom" ''
|
||||
Position of the list.
|
||||
'';
|
||||
|
||||
height = helpers.defaultNullOpts.mkInt 10 ''
|
||||
Height of the trouble list when position is top or bottom.
|
||||
'';
|
||||
|
||||
width = helpers.defaultNullOpts.mkInt 50 ''
|
||||
Width of the list when position is left or right.
|
||||
'';
|
||||
|
||||
icons = helpers.defaultNullOpts.mkBool true "Use devicons for filenames";
|
||||
|
||||
mode =
|
||||
helpers.defaultNullOpts.mkEnum
|
||||
settingsOptions = {
|
||||
position =
|
||||
helpers.defaultNullOpts.mkEnum
|
||||
[
|
||||
"workspace_diagnostics"
|
||||
"document_diagnostics"
|
||||
"quickfix"
|
||||
"lsp_references"
|
||||
"loclist"
|
||||
"top"
|
||||
"left"
|
||||
"right"
|
||||
"bottom"
|
||||
]
|
||||
"workspace_diagnostics"
|
||||
"Mode for default list";
|
||||
"bottom"
|
||||
''
|
||||
Position of the list.
|
||||
'';
|
||||
|
||||
fold_open = helpers.defaultNullOpts.mkStr "" "Icon used for open folds";
|
||||
height = helpers.defaultNullOpts.mkInt 10 ''
|
||||
Height of the trouble list when position is top or bottom.
|
||||
'';
|
||||
|
||||
fold_closed = helpers.defaultNullOpts.mkStr "" "Icon used for closed folds";
|
||||
width = helpers.defaultNullOpts.mkInt 50 ''
|
||||
Width of the list when position is left or right.
|
||||
'';
|
||||
|
||||
group = helpers.defaultNullOpts.mkBool true "Group results by file";
|
||||
icons = helpers.defaultNullOpts.mkBool true "Use devicons for filenames";
|
||||
|
||||
padding = helpers.defaultNullOpts.mkBool true "Add an extra new line on top of the list";
|
||||
mode = helpers.defaultNullOpts.mkEnum [
|
||||
"workspace_diagnostics"
|
||||
"document_diagnostics"
|
||||
"quickfix"
|
||||
"lsp_references"
|
||||
"loclist"
|
||||
] "workspace_diagnostics" "Mode for default list";
|
||||
|
||||
cycle_results = helpers.defaultNullOpts.mkBool true "Whether to cycle item list when reaching beginning or end of list";
|
||||
fold_open = helpers.defaultNullOpts.mkStr "" "Icon used for open folds";
|
||||
|
||||
action_keys =
|
||||
mapAttrs
|
||||
fold_closed = helpers.defaultNullOpts.mkStr "" "Icon used for closed folds";
|
||||
|
||||
group = helpers.defaultNullOpts.mkBool true "Group results by file";
|
||||
|
||||
padding = helpers.defaultNullOpts.mkBool true "Add an extra new line on top of the list";
|
||||
|
||||
cycle_results = helpers.defaultNullOpts.mkBool true "Whether to cycle item list when reaching beginning or end of list";
|
||||
|
||||
action_keys =
|
||||
mapAttrs
|
||||
(
|
||||
action: config:
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with types; either str (listOf str))
|
||||
config.default
|
||||
config.description
|
||||
helpers.defaultNullOpts.mkNullable (
|
||||
with types; either str (listOf str)
|
||||
) config.default config.description
|
||||
)
|
||||
{
|
||||
close = {
|
||||
|
@ -175,50 +237,47 @@ with lib;
|
|||
};
|
||||
};
|
||||
|
||||
indent_lines = helpers.defaultNullOpts.mkBool true ''
|
||||
Add an indent guide below the fold icons.
|
||||
'';
|
||||
indent_lines = helpers.defaultNullOpts.mkBool true ''
|
||||
Add an indent guide below the fold icons.
|
||||
'';
|
||||
|
||||
win_config =
|
||||
helpers.defaultNullOpts.mkAttrsOf types.anything
|
||||
''
|
||||
{
|
||||
border = "single";
|
||||
}
|
||||
''
|
||||
"Configuration for floating windows. See `|nvim_open_win()|`.";
|
||||
win_config = helpers.defaultNullOpts.mkAttrsOf types.anything ''
|
||||
{
|
||||
border = "single";
|
||||
}
|
||||
'' "Configuration for floating windows. See `|nvim_open_win()|`.";
|
||||
|
||||
auto_open = helpers.defaultNullOpts.mkBool false ''
|
||||
Automatically open the list when you have diagnostics.
|
||||
'';
|
||||
auto_open = helpers.defaultNullOpts.mkBool false ''
|
||||
Automatically open the list when you have diagnostics.
|
||||
'';
|
||||
|
||||
auto_close = helpers.defaultNullOpts.mkBool false ''
|
||||
Automatically close the list when you have no diagnostics.
|
||||
'';
|
||||
auto_close = helpers.defaultNullOpts.mkBool false ''
|
||||
Automatically close the list when you have no diagnostics.
|
||||
'';
|
||||
|
||||
auto_preview = helpers.defaultNullOpts.mkBool true ''
|
||||
Automatically preview the location of the diagnostic.
|
||||
<esc> to close preview and go back to last window.
|
||||
'';
|
||||
auto_preview = helpers.defaultNullOpts.mkBool true ''
|
||||
Automatically preview the location of the diagnostic.
|
||||
<esc> to close preview and go back to last window.
|
||||
'';
|
||||
|
||||
auto_fold = helpers.defaultNullOpts.mkBool false ''
|
||||
Automatically fold a file trouble list at creation.
|
||||
'';
|
||||
auto_fold = helpers.defaultNullOpts.mkBool false ''
|
||||
Automatically fold a file trouble list at creation.
|
||||
'';
|
||||
|
||||
auto_jump = helpers.defaultNullOpts.mkListOf types.str ''["lsp_definitions"]'' ''
|
||||
For the given modes, automatically jump if there is only a single result.
|
||||
'';
|
||||
auto_jump = helpers.defaultNullOpts.mkListOf types.str ''["lsp_definitions"]'' ''
|
||||
For the given modes, automatically jump if there is only a single result.
|
||||
'';
|
||||
|
||||
include_declaration =
|
||||
helpers.defaultNullOpts.mkListOf types.str
|
||||
include_declaration =
|
||||
helpers.defaultNullOpts.mkListOf types.str
|
||||
''["lsp_references" "lsp_implementations" "lsp_definitions"]''
|
||||
"For the given modes, include the declaration of the current symbol in the results.";
|
||||
|
||||
signs =
|
||||
mapAttrs
|
||||
signs =
|
||||
mapAttrs
|
||||
(
|
||||
diagnostic: default:
|
||||
helpers.defaultNullOpts.mkStr default "Icon/text for ${diagnostic} diagnostics."
|
||||
helpers.defaultNullOpts.mkStr default "Icon/text for ${diagnostic} diagnostics."
|
||||
)
|
||||
{
|
||||
error = "";
|
||||
|
@ -228,8 +287,8 @@ with lib;
|
|||
other = "";
|
||||
};
|
||||
|
||||
use_diagnostic_signs = helpers.defaultNullOpts.mkBool false ''
|
||||
Enabling this will use the signs defined in your lsp client
|
||||
'';
|
||||
};
|
||||
}
|
||||
use_diagnostic_signs = helpers.defaultNullOpts.mkBool false ''
|
||||
Enabling this will use the signs defined in your lsp client
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -5,13 +5,17 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.wtf;
|
||||
|
||||
defaultKeymaps = {
|
||||
ai = {
|
||||
key = "gw";
|
||||
mode = ["n" "x"];
|
||||
mode = [
|
||||
"n"
|
||||
"x"
|
||||
];
|
||||
action.__raw = "require('wtf').ai";
|
||||
};
|
||||
|
||||
|
@ -21,98 +25,92 @@ with lib; let
|
|||
action.__raw = "require('wtf').search";
|
||||
};
|
||||
};
|
||||
in {
|
||||
in
|
||||
{
|
||||
options = {
|
||||
plugins.wtf =
|
||||
helpers.neovim-plugin.extraOptionsOptions
|
||||
// {
|
||||
enable = mkEnableOption "wtf.nvim";
|
||||
plugins.wtf = helpers.neovim-plugin.extraOptionsOptions // {
|
||||
enable = mkEnableOption "wtf.nvim";
|
||||
|
||||
package = helpers.mkPackageOption "wtf.nvim" pkgs.vimPlugins.wtf-nvim;
|
||||
package = helpers.mkPackageOption "wtf.nvim" pkgs.vimPlugins.wtf-nvim;
|
||||
|
||||
keymaps =
|
||||
mapAttrs
|
||||
(
|
||||
action: defaults:
|
||||
helpers.mkNullOrOption
|
||||
(
|
||||
with types;
|
||||
either
|
||||
str
|
||||
(helpers.keymaps.mkMapOptionSubmodule defaults)
|
||||
)
|
||||
"Keymap for the ${action} action."
|
||||
)
|
||||
defaultKeymaps;
|
||||
keymaps = mapAttrs (
|
||||
action: defaults:
|
||||
helpers.mkNullOrOption (
|
||||
with types; either str (helpers.keymaps.mkMapOptionSubmodule defaults)
|
||||
) "Keymap for the ${action} action."
|
||||
) defaultKeymaps;
|
||||
|
||||
popupType = helpers.defaultNullOpts.mkEnum ["popup" "horizontal" "vertical"] "popup" ''
|
||||
Default AI popup type.
|
||||
'';
|
||||
popupType =
|
||||
helpers.defaultNullOpts.mkEnum
|
||||
[
|
||||
"popup"
|
||||
"horizontal"
|
||||
"vertical"
|
||||
]
|
||||
"popup"
|
||||
''
|
||||
Default AI popup type.
|
||||
'';
|
||||
|
||||
openaiApiKey = helpers.mkNullOrOption (with types; either str helpers.nixvimTypes.rawLua) ''
|
||||
An alternative way to set your API key.
|
||||
'';
|
||||
openaiApiKey = helpers.mkNullOrOption (with types; either str helpers.nixvimTypes.rawLua) ''
|
||||
An alternative way to set your API key.
|
||||
'';
|
||||
|
||||
openaiModelId = helpers.defaultNullOpts.mkStr "gpt-3.5-turbo" "ChatGPT Model.";
|
||||
openaiModelId = helpers.defaultNullOpts.mkStr "gpt-3.5-turbo" "ChatGPT Model.";
|
||||
|
||||
context = helpers.defaultNullOpts.mkBool true "Send code as well as diagnostics.";
|
||||
context = helpers.defaultNullOpts.mkBool true "Send code as well as diagnostics.";
|
||||
|
||||
language = helpers.defaultNullOpts.mkStr "english" ''
|
||||
Set your preferred language for the response.
|
||||
'';
|
||||
language = helpers.defaultNullOpts.mkStr "english" ''
|
||||
Set your preferred language for the response.
|
||||
'';
|
||||
|
||||
additionalInstructions = helpers.mkNullOrOption types.str "Any additional instructions.";
|
||||
additionalInstructions = helpers.mkNullOrOption types.str "Any additional instructions.";
|
||||
|
||||
searchEngine =
|
||||
helpers.defaultNullOpts.mkEnum
|
||||
["google" "duck_duck_go" "stack_overflow" "github"]
|
||||
"google"
|
||||
"Default search engine.";
|
||||
searchEngine = helpers.defaultNullOpts.mkEnum [
|
||||
"google"
|
||||
"duck_duck_go"
|
||||
"stack_overflow"
|
||||
"github"
|
||||
] "google" "Default search engine.";
|
||||
|
||||
hooks = {
|
||||
requestStarted = helpers.defaultNullOpts.mkLuaFn "nil" "Callback for request start.";
|
||||
hooks = {
|
||||
requestStarted = helpers.defaultNullOpts.mkLuaFn "nil" "Callback for request start.";
|
||||
|
||||
requestFinished = helpers.defaultNullOpts.mkLuaFn "nil" "Callback for request finished.";
|
||||
};
|
||||
|
||||
winhighlight = helpers.defaultNullOpts.mkStr "Normal:Normal,FloatBorder:FloatBorder" ''
|
||||
Add custom colours.
|
||||
'';
|
||||
requestFinished = helpers.defaultNullOpts.mkLuaFn "nil" "Callback for request finished.";
|
||||
};
|
||||
|
||||
winhighlight = helpers.defaultNullOpts.mkStr "Normal:Normal,FloatBorder:FloatBorder" ''
|
||||
Add custom colours.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
setupOptions = with cfg;
|
||||
{
|
||||
popup_type = popupType;
|
||||
openai_api_key = openaiApiKey;
|
||||
openai_model_id = openaiModelId;
|
||||
inherit
|
||||
context
|
||||
language
|
||||
;
|
||||
additional_instructions = additionalInstructions;
|
||||
search_engine = searchEngine;
|
||||
hooks = {
|
||||
request_started = hooks.requestStarted;
|
||||
request_finished = hooks.requestFinished;
|
||||
};
|
||||
inherit winhighlight;
|
||||
}
|
||||
// cfg.extraOptions;
|
||||
in
|
||||
config =
|
||||
let
|
||||
setupOptions =
|
||||
with cfg;
|
||||
{
|
||||
popup_type = popupType;
|
||||
openai_api_key = openaiApiKey;
|
||||
openai_model_id = openaiModelId;
|
||||
inherit context language;
|
||||
additional_instructions = additionalInstructions;
|
||||
search_engine = searchEngine;
|
||||
hooks = {
|
||||
request_started = hooks.requestStarted;
|
||||
request_finished = hooks.requestFinished;
|
||||
};
|
||||
inherit winhighlight;
|
||||
}
|
||||
// cfg.extraOptions;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [cfg.package];
|
||||
extraPlugins = [ cfg.package ];
|
||||
|
||||
keymaps = filter (keymap: keymap != null) (
|
||||
mapAttrsToList
|
||||
(
|
||||
action: value:
|
||||
if isString value
|
||||
then defaultKeymaps.${action} // {key = value;}
|
||||
else value
|
||||
)
|
||||
cfg.keymaps
|
||||
mapAttrsToList (
|
||||
action: value: if isString value then defaultKeymaps.${action} // { key = value; } else value
|
||||
) cfg.keymaps
|
||||
);
|
||||
|
||||
extraConfigLua = ''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue