mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-04-15 00:58:37 +00:00
languages/rust: move crates-nvim setup to languages.rust.extensions
This commit is contained in:
parent
64fbc41f29
commit
205b464a26
1 changed files with 43 additions and 32 deletions
|
@ -4,17 +4,15 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) isList attrNames;
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge mkRenamedOptionModule;
|
||||||
inherit (lib.options) mkOption mkEnableOption;
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.trivial) boolToString;
|
inherit (lib.trivial) boolToString;
|
||||||
inherit (lib.lists) isList;
|
|
||||||
inherit (lib.types) bool package str listOf either enum;
|
inherit (lib.types) bool package str listOf either enum;
|
||||||
inherit (lib.nvim.languages) lspOptions;
|
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption;
|
||||||
inherit (lib.nvim.types) mkGrammarOption;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
inherit (lib.nvim.lua) expToLua;
|
|
||||||
inherit (lib.nvim.dag) entryAfter entryAnywhere;
|
inherit (lib.nvim.dag) entryAfter entryAnywhere;
|
||||||
|
|
||||||
cfg = config.vim.languages.rust;
|
cfg = config.vim.languages.rust;
|
||||||
|
@ -26,6 +24,10 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
imports = [
|
||||||
|
(mkRenamedOptionModule ["vim" "languages" "rust" "crates"] ["vim" "languages" "rust" "extensions" "crates-nvim"])
|
||||||
|
];
|
||||||
|
|
||||||
options.vim.languages.rust = {
|
options.vim.languages.rust = {
|
||||||
enable = mkEnableOption "Rust language support";
|
enable = mkEnableOption "Rust language support";
|
||||||
|
|
||||||
|
@ -34,15 +36,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.languages.enableLSP;};
|
enable = mkEnableOption "Rust LSP support (rust-analyzer with extra tools)" // {default = config.vim.languages.enableLSP;};
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
|
@ -97,25 +90,26 @@ in {
|
||||||
default = pkgs.lldb;
|
default = pkgs.lldb;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extensions = {
|
||||||
|
crates-nvim = {
|
||||||
|
enable =
|
||||||
|
mkEnableOption ""
|
||||||
|
// {
|
||||||
|
default = true;
|
||||||
|
description = ''
|
||||||
|
[crates.nvim]: https://github.com/Saecki/crates.nvim/
|
||||||
|
|
||||||
|
Helper plugin for managing crates.io dependencies [crates.nvim]
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
setupOpts = mkPluginSetupOption "crates-nvim" {};
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [
|
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];
|
||||||
|
@ -147,7 +141,7 @@ in {
|
||||||
server = {
|
server = {
|
||||||
cmd = ${
|
cmd = ${
|
||||||
if isList cfg.lsp.package
|
if isList cfg.lsp.package
|
||||||
then expToLua cfg.lsp.package
|
then toLuaObject cfg.lsp.package
|
||||||
else ''{"${cfg.lsp.package}/bin/rust-analyzer"}''
|
else ''{"${cfg.lsp.package}/bin/rust-analyzer"}''
|
||||||
},
|
},
|
||||||
default_settings = {
|
default_settings = {
|
||||||
|
@ -193,5 +187,22 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# Extensions
|
||||||
|
(mkIf cfg.extensions.crates.enable {
|
||||||
|
vim = {
|
||||||
|
startPlugins = ["crates-nvim"];
|
||||||
|
autocomplete.nvim-cmp.sources = {crates = "[Crates]";};
|
||||||
|
|
||||||
|
pluginRC.rust-crates-nvim = entryAnywhere ''
|
||||||
|
require('crates').setup {
|
||||||
|
null_ls = {
|
||||||
|
enabled = ${boolToString cfg.crates.codeActions},
|
||||||
|
name = "crates.nvim",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue