mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2025-01-10 01:59:49 +01:00
Compare commits
4 commits
2759b9caae
...
35c7327f81
Author | SHA1 | Date | |
---|---|---|---|
35c7327f81 | |||
|
8a0cddd9bb | ||
923481640e | |||
|
d6cd853520 |
3 changed files with 50 additions and 5 deletions
|
@ -49,3 +49,9 @@ Release notes for release 0.7
|
|||
- Add [ocaml-lsp](https://github.com/ocaml/ocaml-lsp) support.
|
||||
|
||||
- Fix Emac typo
|
||||
|
||||
[diniamo](https://github.com/diniamo):
|
||||
|
||||
- Move the `theme` dag entry to before `luaScript`.
|
||||
|
||||
- Add rustfmt as the default formatter for Rust
|
||||
|
|
|
@ -4,17 +4,33 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.trivial) boolToString;
|
||||
inherit (lib.lists) isList optionals;
|
||||
inherit (lib.types) bool package str listOf either;
|
||||
inherit (lib.types) bool package str listOf either enum;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
|
||||
cfg = config.vim.languages.rust;
|
||||
|
||||
defaultFormat = "rustfmt";
|
||||
formats = {
|
||||
rustfmt = {
|
||||
package = pkgs.rustfmt;
|
||||
nullConfig = ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.formatting.rustfmt.with({
|
||||
command = "${cfg.format.package}/bin/rustfmt",
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.rust = {
|
||||
enable = mkEnableOption "Rust language support";
|
||||
|
@ -49,6 +65,22 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
format = {
|
||||
enable = mkEnableOption "Rust formatting" // {default = config.vim.languages.enableFormat;};
|
||||
|
||||
type = mkOption {
|
||||
description = "Rust formatter to use";
|
||||
type = enum (attrNames formats);
|
||||
default = defaultFormat;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Rust formatter package";
|
||||
type = package;
|
||||
default = formats.${cfg.format.type}.package;
|
||||
};
|
||||
};
|
||||
|
||||
dap = {
|
||||
enable = mkOption {
|
||||
description = "Rust Debug Adapter support";
|
||||
|
@ -86,6 +118,11 @@ in {
|
|||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
|
||||
(mkIf cfg.format.enable {
|
||||
vim.lsp.null-ls.enable = true;
|
||||
vim.lsp.null-ls.sources.rust-format = formats.${cfg.format.type}.nullConfig;
|
||||
})
|
||||
|
||||
(mkIf (cfg.lsp.enable || cfg.dap.enable) {
|
||||
vim = {
|
||||
startPlugins = ["rust-tools"] ++ optionals cfg.dap.enable [cfg.dap.package];
|
||||
|
|
|
@ -45,10 +45,12 @@ in {
|
|||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = [cfg.name];
|
||||
luaConfigRC = {
|
||||
themeSetup = entryBefore ["theme"] cfg.extraConfig;
|
||||
theme = supported_themes.${cfg.name}.setup (with cfg; {inherit style transparent;});
|
||||
};
|
||||
configRC.theme = entryBefore ["luaScript"] ''
|
||||
lua << EOF
|
||||
${cfg.extraConfig}
|
||||
${supported_themes.${cfg.name}.setup (with cfg; {inherit style transparent;})}
|
||||
EOF
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue