mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-05 18:01:32 +00:00
languages/rust: move crates-nvim dependency to extensions attribute; modernize
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I6a6a696490046c3a59d8b9dddd112a6f5120d236
This commit is contained in:
parent
e1ad7f4fb9
commit
f42970ac84
2 changed files with 54 additions and 30 deletions
|
@ -259,6 +259,14 @@ in {
|
||||||
|
|
||||||
(mkRenamedLspServer "zig")
|
(mkRenamedLspServer "zig")
|
||||||
(mkRemovedLspPackage "zig")
|
(mkRemovedLspPackage "zig")
|
||||||
|
|
||||||
|
# 2025-08-21
|
||||||
|
(mkRenamedOptionModule ["vim" "languages" "rust" "crates" "enable"] ["vim" "languages" "rust" "extensions" "crates-nvim" "enable"])
|
||||||
|
(mkRemovedOptionModule ["vim" "languages" "rust" "crates" "codeActions"] ''
|
||||||
|
'vim.languages.rust.crates' option has been moved to 'vim.languages.rust.extensions.crates-nvim' in full and the
|
||||||
|
codeActions option has been removed. To set up code actions again, you may use the the new 'setupOpts' option
|
||||||
|
located under 'vim.languages.rust.extensions.crates-nvim'. Refer to crates.nvim documentation for setup steps.
|
||||||
|
'')
|
||||||
]
|
]
|
||||||
|
|
||||||
# Migrated via batchRenameOptions. Further batch renames must be below this line.
|
# Migrated via batchRenameOptions. Further batch renames must be below this line.
|
||||||
|
|
|
@ -4,16 +4,15 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) attrNames;
|
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.options) mkOption mkEnableOption literalMD;
|
inherit (lib.options) mkOption mkEnableOption literalMD;
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.trivial) boolToString;
|
|
||||||
inherit (lib.lists) isList;
|
inherit (lib.lists) isList;
|
||||||
|
inherit (lib.attrsets) attrNames optionalAttrs;
|
||||||
inherit (lib.types) bool package str listOf either enum;
|
inherit (lib.types) bool package str listOf either enum;
|
||||||
inherit (lib.nvim.types) mkGrammarOption;
|
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption;
|
||||||
inherit (lib.nvim.lua) expToLua;
|
inherit (lib.nvim.lua) expToLua toLuaObject;
|
||||||
inherit (lib.nvim.dag) entryAfter entryAnywhere;
|
inherit (lib.nvim.dag) entryAfter entryAnywhere;
|
||||||
|
|
||||||
cfg = config.vim.languages.rust;
|
cfg = config.vim.languages.rust;
|
||||||
|
@ -33,15 +32,6 @@ in {
|
||||||
package = mkGrammarOption pkgs "rust";
|
package = mkGrammarOption pkgs "rust";
|
||||||
};
|
};
|
||||||
|
|
||||||
crates = {
|
|
||||||
enable = mkEnableOption "crates-nvim, tools for managing dependencies";
|
|
||||||
codeActions = mkOption {
|
|
||||||
description = "Enable code actions through null-ls";
|
|
||||||
type = bool;
|
|
||||||
default = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = mkEnableOption "Rust LSP support (rust-analyzer with extra tools)" // {default = config.vim.lsp.enable;};
|
enable = mkEnableOption "Rust LSP support (rust-analyzer with extra tools)" // {default = config.vim.lsp.enable;};
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
|
@ -103,25 +93,32 @@ in {
|
||||||
default = pkgs.lldb;
|
default = pkgs.lldb;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extensions = {
|
||||||
|
crates-nvim = {
|
||||||
|
enable = mkEnableOption "crates.io dependency management [crates-nvim]";
|
||||||
|
|
||||||
|
setupOpts = mkPluginSetupOption "crates-nvim" {
|
||||||
|
completion.enable = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = config.vim.autocomplete.nvim-cmp.enable;
|
||||||
|
defaultText = "{option}`config.vim.autocomplete.nvim-cmp.enable`";
|
||||||
|
description = ''
|
||||||
|
Whether to add crates.nvim as a source for completion plugins. The following
|
||||||
|
plugins are supported by crates.nvim:
|
||||||
|
|
||||||
|
* nvim-cmp
|
||||||
|
* coq.nvim
|
||||||
|
|
||||||
|
However nvf only supports auto-setup for nvim-cmp.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
(mkIf cfg.crates.enable {
|
|
||||||
vim = {
|
|
||||||
startPlugins = ["crates-nvim"];
|
|
||||||
lsp.null-ls.enable = mkIf cfg.crates.codeActions true;
|
|
||||||
autocomplete.nvim-cmp.sources = {crates = "[Crates]";};
|
|
||||||
pluginRC.rust-crates = entryAnywhere ''
|
|
||||||
require('crates').setup {
|
|
||||||
null_ls = {
|
|
||||||
enabled = ${boolToString cfg.crates.codeActions},
|
|
||||||
name = "crates.nvim",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
||||||
(mkIf cfg.treesitter.enable {
|
(mkIf cfg.treesitter.enable {
|
||||||
vim.treesitter.enable = true;
|
vim.treesitter.enable = true;
|
||||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||||
|
@ -140,7 +137,6 @@ in {
|
||||||
(mkIf (cfg.lsp.enable || cfg.dap.enable) {
|
(mkIf (cfg.lsp.enable || cfg.dap.enable) {
|
||||||
vim = {
|
vim = {
|
||||||
startPlugins = ["rustaceanvim"];
|
startPlugins = ["rustaceanvim"];
|
||||||
|
|
||||||
pluginRC.rustaceanvim = entryAfter ["lsp-setup"] ''
|
pluginRC.rustaceanvim = entryAfter ["lsp-setup"] ''
|
||||||
vim.g.rustaceanvim = {
|
vim.g.rustaceanvim = {
|
||||||
${optionalString cfg.lsp.enable ''
|
${optionalString cfg.lsp.enable ''
|
||||||
|
@ -199,5 +195,25 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.extensions.crates-nvim.enable {
|
||||||
|
vim = let
|
||||||
|
withCompletion = cfg.extensions.crates-nvim.withCmpSource;
|
||||||
|
in
|
||||||
|
mkMerge [
|
||||||
|
{
|
||||||
|
startPlugins = ["crates-nvim"];
|
||||||
|
pluginRC.rust-crates = entryAnywhere ''
|
||||||
|
require("crates").setup(${toLuaObject cfg.extensions.crates-nvim.setupOpts})
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
||||||
|
# FIXME: this will no longer be necessary when a new crates.nvim release is made.
|
||||||
|
# If updating crates.nvim, remember to remove this section.
|
||||||
|
(mkIf withCompletion {
|
||||||
|
autocomplete.nvim-cmp.sources = {crates = "[Crates]";};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue