mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
plugins/rust-tools: remove with lib and helpers
This commit is contained in:
parent
32969847d3
commit
876ca32451
4 changed files with 41 additions and 39 deletions
|
@ -1,17 +1,15 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
helpers,
|
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib;
|
|
||||||
let
|
let
|
||||||
cfg = config.plugins.rust-tools;
|
cfg = config.plugins.rust-tools;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.plugins.rust-tools = helpers.neovim-plugin.extraOptionsOptions // {
|
options.plugins.rust-tools = lib.nixvim.neovim-plugin.extraOptionsOptions // {
|
||||||
enable = mkEnableOption "rust tools plugins";
|
enable = lib.mkEnableOption "rust tools plugins";
|
||||||
package = lib.mkPackageOption pkgs "rust-tools" {
|
package = lib.mkPackageOption pkgs "rust-tools" {
|
||||||
default = [
|
default = [
|
||||||
"vimPlugins"
|
"vimPlugins"
|
||||||
|
@ -22,47 +20,49 @@ in
|
||||||
nullable = true;
|
nullable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
executor = helpers.defaultNullOpts.mkEnumFirstDefault [
|
executor = lib.nixvim.defaultNullOpts.mkEnumFirstDefault [
|
||||||
"termopen"
|
"termopen"
|
||||||
"quickfix"
|
"quickfix"
|
||||||
] "how to execute terminal commands";
|
] "how to execute terminal commands";
|
||||||
|
|
||||||
onInitialized = helpers.defaultNullOpts.mkLuaFn null ''
|
onInitialized = lib.nixvim.defaultNullOpts.mkLuaFn null ''
|
||||||
Callback to execute once rust-analyzer is done initializing the workspace
|
Callback to execute once rust-analyzer is done initializing the workspace
|
||||||
The callback receives one parameter indicating the `health` of the server:
|
The callback receives one parameter indicating the `health` of the server:
|
||||||
"ok" | "warning" | "error"
|
"ok" | "warning" | "error"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
reloadWorkspaceFromCargoToml = helpers.defaultNullOpts.mkBool true ''
|
reloadWorkspaceFromCargoToml = lib.nixvim.defaultNullOpts.mkBool true ''
|
||||||
Automatically call RustReloadWorkspace when writing to a Cargo.toml file.
|
Automatically call RustReloadWorkspace when writing to a Cargo.toml file.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
inlayHints = {
|
inlayHints = {
|
||||||
auto = helpers.defaultNullOpts.mkBool true "automatically set inlay hints (type hints)";
|
auto = lib.nixvim.defaultNullOpts.mkBool true "automatically set inlay hints (type hints)";
|
||||||
|
|
||||||
onlyCurrentLine = helpers.defaultNullOpts.mkBool false "Only show for current line";
|
onlyCurrentLine = lib.nixvim.defaultNullOpts.mkBool false "Only show for current line";
|
||||||
|
|
||||||
showParameterHints = helpers.defaultNullOpts.mkBool true "whether to show parameter hints with the inlay hints or not";
|
showParameterHints = lib.nixvim.defaultNullOpts.mkBool true "whether to show parameter hints with the inlay hints or not";
|
||||||
|
|
||||||
parameterHintsPrefix = helpers.defaultNullOpts.mkStr "<- " "prefix for parameter hints";
|
parameterHintsPrefix = lib.nixvim.defaultNullOpts.mkStr "<- " "prefix for parameter hints";
|
||||||
|
|
||||||
otherHintsPrefix = helpers.defaultNullOpts.mkStr "=> " "prefix for all the other hints (type, chaining)";
|
otherHintsPrefix = lib.nixvim.defaultNullOpts.mkStr "=> " "prefix for all the other hints (type, chaining)";
|
||||||
|
|
||||||
maxLenAlign = helpers.defaultNullOpts.mkBool false "whether to align to the length of the longest line in the file";
|
maxLenAlign = lib.nixvim.defaultNullOpts.mkBool false "whether to align to the length of the longest line in the file";
|
||||||
|
|
||||||
maxLenAlignPadding =
|
maxLenAlignPadding =
|
||||||
helpers.defaultNullOpts.mkUnsignedInt 1
|
lib.nixvim.defaultNullOpts.mkUnsignedInt 1
|
||||||
"padding from the left if max_len_align is true";
|
"padding from the left if max_len_align is true";
|
||||||
|
|
||||||
rightAlign = helpers.defaultNullOpts.mkBool false "whether to align to the extreme right or not";
|
rightAlign = lib.nixvim.defaultNullOpts.mkBool false "whether to align to the extreme right or not";
|
||||||
|
|
||||||
rightAlignPadding = helpers.defaultNullOpts.mkInt 7 "padding from the right if right_align is true";
|
rightAlignPadding =
|
||||||
|
lib.nixvim.defaultNullOpts.mkInt 7
|
||||||
|
"padding from the right if right_align is true";
|
||||||
|
|
||||||
highlight = helpers.defaultNullOpts.mkStr "Comment" "The color of the hints";
|
highlight = lib.nixvim.defaultNullOpts.mkStr "Comment" "The color of the hints";
|
||||||
};
|
};
|
||||||
|
|
||||||
hoverActions = {
|
hoverActions = {
|
||||||
border = helpers.defaultNullOpts.mkBorder [
|
border = lib.nixvim.defaultNullOpts.mkBorder [
|
||||||
[
|
[
|
||||||
"╭"
|
"╭"
|
||||||
"FloatBorder"
|
"FloatBorder"
|
||||||
|
@ -97,39 +97,41 @@ in
|
||||||
]
|
]
|
||||||
] "rust-tools hover window" "";
|
] "rust-tools hover window" "";
|
||||||
|
|
||||||
maxWidth = helpers.defaultNullOpts.mkUnsignedInt null "Maximal width of the hover window. null means no max.";
|
maxWidth = lib.nixvim.defaultNullOpts.mkUnsignedInt null "Maximal width of the hover window. null means no max.";
|
||||||
|
|
||||||
maxHeight = helpers.defaultNullOpts.mkUnsignedInt null "Maximal height of the hover window. null means no max.";
|
maxHeight = lib.nixvim.defaultNullOpts.mkUnsignedInt null "Maximal height of the hover window. null means no max.";
|
||||||
|
|
||||||
autoFocus = helpers.defaultNullOpts.mkBool false "whether the hover action window gets automatically focused";
|
autoFocus = lib.nixvim.defaultNullOpts.mkBool false "whether the hover action window gets automatically focused";
|
||||||
};
|
};
|
||||||
|
|
||||||
crateGraph = {
|
crateGraph = {
|
||||||
backend = helpers.defaultNullOpts.mkStr "x11" ''
|
backend = lib.nixvim.defaultNullOpts.mkStr "x11" ''
|
||||||
Backend used for displaying the graph
|
Backend used for displaying the graph
|
||||||
see: https://graphviz.org/docs/outputs/
|
see: https://graphviz.org/docs/outputs/
|
||||||
'';
|
'';
|
||||||
|
|
||||||
output = helpers.defaultNullOpts.mkStr null "where to store the output, nil for no output stored";
|
output = lib.nixvim.defaultNullOpts.mkStr null "where to store the output, nil for no output stored";
|
||||||
|
|
||||||
full = helpers.defaultNullOpts.mkBool true ''
|
full = lib.nixvim.defaultNullOpts.mkBool true ''
|
||||||
true for all crates.io and external crates, false only the local crates
|
true for all crates.io and external crates, false only the local crates
|
||||||
'';
|
'';
|
||||||
|
|
||||||
enabledGraphvizBackends = helpers.defaultNullOpts.mkNullable (types.listOf types.str) null ''
|
enabledGraphvizBackends =
|
||||||
List of backends found on: https://graphviz.org/docs/outputs/
|
lib.nixvim.defaultNullOpts.mkNullable (lib.types.listOf lib.types.str) null
|
||||||
Is used for input validation and autocompletion
|
''
|
||||||
'';
|
List of backends found on: https://graphviz.org/docs/outputs/
|
||||||
|
Is used for input validation and autocompletion
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
server = {
|
server = {
|
||||||
standalone = helpers.defaultNullOpts.mkBool true ''
|
standalone = lib.nixvim.defaultNullOpts.mkBool true ''
|
||||||
standalone file support
|
standalone file support
|
||||||
setting it to false may improve startup time
|
setting it to false may improve startup time
|
||||||
'';
|
'';
|
||||||
} // (import ../../lsp/language-servers/rust-analyzer-config.nix lib helpers);
|
} // import ../../lsp/language-servers/rust-analyzer-config.nix lib;
|
||||||
};
|
};
|
||||||
config = mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
extraPlugins = [
|
extraPlugins = [
|
||||||
config.plugins.lsp.package
|
config.plugins.lsp.package
|
||||||
cfg.package
|
cfg.package
|
||||||
|
@ -140,8 +142,8 @@ in
|
||||||
let
|
let
|
||||||
options = {
|
options = {
|
||||||
tools = {
|
tools = {
|
||||||
executor = helpers.ifNonNull' cfg.executor (
|
executor = lib.nixvim.ifNonNull' cfg.executor (
|
||||||
helpers.mkRaw "require(${rust-tools.executors}).${cfg.executor}"
|
lib.nixvim.mkRaw "require(${lib.rust-tools.executors}).${cfg.executor}"
|
||||||
);
|
);
|
||||||
|
|
||||||
on_initialized = cfg.onInitialized;
|
on_initialized = cfg.onInitialized;
|
||||||
|
@ -175,12 +177,12 @@ in
|
||||||
server = {
|
server = {
|
||||||
inherit (cfg.server) standalone;
|
inherit (cfg.server) standalone;
|
||||||
settings.rust-analyzer = lib.filterAttrs (n: v: n != "standalone") cfg.server;
|
settings.rust-analyzer = lib.filterAttrs (n: v: n != "standalone") cfg.server;
|
||||||
on_attach = helpers.mkRaw "__lspOnAttach";
|
on_attach = lib.nixvim.mkRaw "__lspOnAttach";
|
||||||
};
|
};
|
||||||
} // cfg.extraOptions;
|
} // cfg.extraOptions;
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
require('rust-tools').setup(${helpers.toLuaObject options})
|
require('rust-tools').setup(${lib.nixvim.toLuaObject options})
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,7 +257,7 @@ with lib;
|
||||||
default_settings =
|
default_settings =
|
||||||
helpers.mkNullOrStrLuaFnOr
|
helpers.mkNullOrStrLuaFnOr
|
||||||
(types.submodule {
|
(types.submodule {
|
||||||
options.rust-analyzer = import ../../lsp/language-servers/rust-analyzer-config.nix lib helpers;
|
options.rust-analyzer = import ../../lsp/language-servers/rust-analyzer-config.nix lib;
|
||||||
freeformType = with types; attrsOf anything;
|
freeformType = with types; attrsOf anything;
|
||||||
})
|
})
|
||||||
''
|
''
|
||||||
|
|
|
@ -109,7 +109,7 @@ let
|
||||||
settings = cfg: { pylsp = cfg; };
|
settings = cfg: { pylsp = cfg; };
|
||||||
};
|
};
|
||||||
rust_analyzer = {
|
rust_analyzer = {
|
||||||
settingsOptions = import ./rust-analyzer-config.nix lib helpers;
|
settingsOptions = import ./rust-analyzer-config.nix lib;
|
||||||
settings = cfg: { rust-analyzer = cfg; };
|
settings = cfg: { rust-analyzer = cfg; };
|
||||||
};
|
};
|
||||||
ts_ls = {
|
ts_ls = {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# TODO: make all the types support raw lua
|
# TODO: make all the types support raw lua
|
||||||
lib: helpers:
|
lib:
|
||||||
let
|
let
|
||||||
rustAnalyzerOptions = import ../../../generated/rust-analyzer.nix;
|
rustAnalyzerOptions = import ../../../generated/rust-analyzer.nix;
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ let
|
||||||
pluginDefault,
|
pluginDefault,
|
||||||
type,
|
type,
|
||||||
}:
|
}:
|
||||||
helpers.defaultNullOpts.mkNullable' {
|
lib.nixvim.defaultNullOpts.mkNullable' {
|
||||||
inherit description pluginDefault;
|
inherit description pluginDefault;
|
||||||
type = mkRustAnalyzerType type;
|
type = mkRustAnalyzerType type;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue