nix-community.nixvim/plugins/by-name/rust-tools/default.nix
github-actions[bot] 6395b9c013
flake.lock: Update
Flake lock file updates:

• Updated input 'flake-parts':
    'github:hercules-ci/flake-parts/506278e768c2a08bec68eb62932193e341f55c90?narHash=sha256-hgmguH29K2fvs9szpq2r3pz2/8cJd2LPS%2Bb4tfNFCwE%3D' (2024-11-01)
  → 'github:hercules-ci/flake-parts/205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9?narHash=sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c%3D' (2024-12-04)
• Updated input 'git-hooks':
    'github:cachix/git-hooks.nix/3308484d1a443fc5bc92012435d79e80458fe43c?narHash=sha256-mnTbjpdqF0luOkou8ZFi2asa1N3AA2CchR/RqCNmsGE%3D' (2024-11-19)
  → 'github:cachix/git-hooks.nix/6f4e2a2112050951a314d2733a994fbab94864c6?narHash=sha256-SVQVsbafSM1dJ4fpgyBqLZ%2BLft%2BjcQuMtEL3lQWx2Sk%3D' (2024-12-04)
• Updated input 'home-manager':
    'github:nix-community/home-manager/62d536255879be574ebfe9b87c4ac194febf47c5?narHash=sha256-lYnT%2BEYE47f5yY3KS/Kd4pJ6CO9fhCqumkYYkQ3TK20%3D' (2024-12-01)
  → 'github:nix-community/home-manager/c7ffc9727d115e433fd884a62dc164b587ff651d?narHash=sha256-zjO6m5BqxXIyjrnUziAzk4%2BT4VleqjstNudSqWcpsHI%3D' (2024-12-07)
• Updated input 'nix-darwin':
    'github:lnl7/nix-darwin/c6b65d946097baf3915dd51373251de98199280d?narHash=sha256-Qs3YmoLYUJ8g4RkFj2rMrzrP91e4ShAioC9s%2BvG6ENM%3D' (2024-12-02)
  → 'github:lnl7/nix-darwin/a35b08d09efda83625bef267eb24347b446c80b8?narHash=sha256-sQJAxY1TYWD1UyibN/FnN97paTFuwBw3Vp3DNCyKsMk%3D' (2024-12-07)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/f9f0d5c5380be0a599b1fb54641fa99af8281539?narHash=sha256-En%2BgSoVJ3iQKPDU1FHrR6zIxSLXKjzKY%2Bpnh9tt%2BYts%3D' (2024-12-02)
  → 'github:NixOS/nixpkgs/4dc2fc4e62dbf62b84132fe526356fbac7b03541?narHash=sha256-FillH0qdWDt/nlO6ED7h4cmN%2BG9uXwGjwmCnHs0QVYM%3D' (2024-12-05)
• Updated input 'nuschtosSearch':
    'github:NuschtOS/search/16307548b7a1247291c84ae6a12c0aacb07dfba2?narHash=sha256-BC1CecAQISV5Q4LZK72Gx0%2BfaemOwaChiD9rMVfDPoA%3D' (2024-11-30)
  → 'github:NuschtOS/search/68e9fad70d95d08156cf10a030bd39487bed8ffe?narHash=sha256-315rJ7O9cOllPDaFscnJhcMleORHbxon0Kq9LAKJ5p4%3D' (2024-12-05)
• Updated input 'treefmt-nix':
    'github:numtide/treefmt-nix/6209c381904cab55796c5d7350e89681d3b2a8ef?narHash=sha256-2qbdorpq0TXHBWbVXaTqKoikN4bqAtAplTwGuII%2BoAc%3D' (2024-11-29)
  → 'github:numtide/treefmt-nix/50862ba6a8a0255b87377b9d2d4565e96f29b410?narHash=sha256-qKL3vjO%2BIXFQ0nTinFDqNq/sbbnnS5bMI1y0xX215fU%3D' (2024-12-05)
2024-12-08 05:56:53 +00:00

184 lines
5.8 KiB
Nix

{
lib,
config,
pkgs,
...
}:
let
cfg = config.plugins.rust-tools;
in
{
options.plugins.rust-tools = lib.nixvim.neovim-plugin.extraOptionsOptions // {
enable = lib.mkEnableOption "rust tools plugins";
package = lib.mkPackageOption pkgs "rust-tools" {
default = [
"vimPlugins"
"rust-tools-nvim"
];
};
serverPackage = lib.mkPackageOption pkgs "rust-analyzer" {
nullable = true;
};
executor = lib.nixvim.defaultNullOpts.mkEnumFirstDefault [
"termopen"
"quickfix"
] "how to execute terminal commands";
onInitialized = lib.nixvim.defaultNullOpts.mkLuaFn null ''
Callback to execute once rust-analyzer is done initializing the workspace
The callback receives one parameter indicating the `health` of the server:
"ok" | "warning" | "error"
'';
reloadWorkspaceFromCargoToml = lib.nixvim.defaultNullOpts.mkBool true ''
Automatically call RustReloadWorkspace when writing to a Cargo.toml file.
'';
inlayHints = {
auto = lib.nixvim.defaultNullOpts.mkBool true "automatically set inlay hints (type hints)";
onlyCurrentLine = lib.nixvim.defaultNullOpts.mkBool false "Only show for current line";
showParameterHints = lib.nixvim.defaultNullOpts.mkBool true "whether to show parameter hints with the inlay hints or not";
parameterHintsPrefix = lib.nixvim.defaultNullOpts.mkStr "<- " "prefix for parameter hints";
otherHintsPrefix = lib.nixvim.defaultNullOpts.mkStr "=> " "prefix for all the other hints (type, chaining)";
maxLenAlign = lib.nixvim.defaultNullOpts.mkBool false "whether to align to the length of the longest line in the file";
maxLenAlignPadding = lib.nixvim.defaultNullOpts.mkUnsignedInt 1 "padding from the left if max_len_align is true";
rightAlign = lib.nixvim.defaultNullOpts.mkBool false "whether to align to the extreme right or not";
rightAlignPadding = lib.nixvim.defaultNullOpts.mkInt 7 "padding from the right if right_align is true";
highlight = lib.nixvim.defaultNullOpts.mkStr "Comment" "The color of the hints";
};
hoverActions = {
border = lib.nixvim.defaultNullOpts.mkBorder [
[
""
"FloatBorder"
]
[
""
"FloatBorder"
]
[
""
"FloatBorder"
]
[
""
"FloatBorder"
]
[
""
"FloatBorder"
]
[
""
"FloatBorder"
]
[
""
"FloatBorder"
]
[
""
"FloatBorder"
]
] "rust-tools hover window" "";
maxWidth = lib.nixvim.defaultNullOpts.mkUnsignedInt null "Maximal width 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 = lib.nixvim.defaultNullOpts.mkBool false "whether the hover action window gets automatically focused";
};
crateGraph = {
backend = lib.nixvim.defaultNullOpts.mkStr "x11" ''
Backend used for displaying the graph
see: https://graphviz.org/docs/outputs/
'';
output = lib.nixvim.defaultNullOpts.mkStr null "where to store the output, nil for no output stored";
full = lib.nixvim.defaultNullOpts.mkBool true ''
true for all crates.io and external crates, false only the local crates
'';
enabledGraphvizBackends =
lib.nixvim.defaultNullOpts.mkNullable (lib.types.listOf lib.types.str) null
''
List of backends found on: https://graphviz.org/docs/outputs/
Is used for input validation and autocompletion
'';
};
server = {
standalone = lib.nixvim.defaultNullOpts.mkBool true ''
standalone file support
setting it to false may improve startup time
'';
} // import ../../lsp/language-servers/rust-analyzer-config.nix lib;
};
config = lib.mkIf cfg.enable {
extraPlugins = [
config.plugins.lsp.package
cfg.package
];
extraPackages = [ cfg.serverPackage ];
plugins.lsp.postConfig =
let
options = {
tools = {
executor = lib.nixvim.ifNonNull' cfg.executor (
lib.nixvim.mkRaw "require(${lib.rust-tools.executors}).${cfg.executor}"
);
on_initialized = cfg.onInitialized;
reload_workspace_from_cargo_toml = cfg.reloadWorkspaceFromCargoToml;
inlay_hints = with cfg.inlayHints; {
inherit auto;
only_current_line = onlyCurrentLine;
show_parameter_hints = showParameterHints;
parameter_hints_prefix = parameterHintsPrefix;
other_hints_prefix = otherHintsPrefix;
max_len_align = maxLenAlign;
max_len_align_padding = maxLenAlignPadding;
right_align = rightAlign;
right_align_padding = rightAlignPadding;
inherit highlight;
};
hover_actions = with cfg.hoverActions; {
inherit border;
max_width = maxWidth;
max_height = maxHeight;
auto_focus = autoFocus;
};
crate_graph = with cfg.crateGraph; {
inherit backend output full;
enabled_graphviz_backends = enabledGraphvizBackends;
};
};
server = {
inherit (cfg.server) standalone;
settings.rust-analyzer = lib.filterAttrs (n: v: n != "standalone") cfg.server;
on_attach = lib.nixvim.mkRaw "__lspOnAttach";
};
} // cfg.extraOptions;
in
''
require('rust-tools').setup(${lib.nixvim.toLuaObject options})
'';
};
}