neovim: add vale & ltex-lsp

This commit is contained in:
ooks-io 2025-01-24 22:30:45 +11:00
parent aa3af5f0e5
commit 5604745c78
16 changed files with 1442 additions and 18 deletions

View file

@ -5,8 +5,105 @@
...
}: let
inherit (lib) mkOption mkIf boolToString;
inherit (lib.types) bool enum lines;
inherit (lib.nvim.dag) entryAfter;
inherit (lib.types) bool enum lines nullOr str submodule attrsOf;
inherit (lib.nvim.dag) entryBefore;
inherit (lib.nvim.lua) toLuaObject;
# hack to get around nvf's handling of prefixed @ in toLuaObject
wrapHighlights = highlights:
lib.mapAttrs' (
name: value:
if lib.hasPrefix "@" name
then lib.nameValuePair "hl_${name}" value
else lib.nameValuePair name value
)
highlights;
highlightOpts = submodule {
options = {
# https://neovim.io/doc/user/api.html#nvim_set_hl()
fg = mkOption {
type = nullOr str;
default = null;
description = "Foreground color";
};
bg = mkOption {
type = nullOr str;
default = null;
description = "Background color";
};
sp = mkOption {
type = nullOr str;
default = null;
description = "SP color";
};
blend = mkOption {
type = nullOr bool;
default = null;
description = "Blend attribute";
};
bold = mkOption {
type = nullOr bool;
default = null;
description = "Italic attribute";
};
standout = mkOption {
type = nullOr bool;
default = null;
description = "Standout attribute";
};
underline = mkOption {
type = nullOr bool;
default = null;
description = "underline attribute";
};
undercurl = mkOption {
type = nullOr bool;
default = null;
description = "Undercurl attribute";
};
underdouble = mkOption {
type = nullOr bool;
default = null;
description = "Underdouble attribute";
};
underdotted = mkOption {
type = nullOr bool;
default = null;
description = "Underdotted attribute";
};
underdashed = mkOption {
type = nullOr bool;
default = null;
description = "Underdashed attribute";
};
strikethrough = mkOption {
type = nullOr bool;
default = null;
description = "Strikethrough attribute";
};
italic = mkOption {
type = nullOr bool;
default = null;
description = "Bold attribute";
};
reverse = mkOption {
type = nullOr bool;
default = null;
description = "Reverse attribute";
};
nocombine = mkOption {
type = nullOr bool;
default = null;
description = "Nocombine attribute";
};
link = mkOption {
type = nullOr str;
default = null;
description = "Link attribute";
};
};
};
cfg = config.vim.gruvbox-material;
in {
@ -45,13 +142,18 @@ in {
type = lines;
description = "Additional lua configuration after";
};
additionalHighlights = mkOption {
type = attrsOf highlightOpts;
default = {};
description = "Additional highlight groups to be applied after theme setup.";
};
};
config = mkIf cfg.enable {
vim = {
startPlugins = [pkgs.vimPlugins.gruvbox-material-nvim];
luaConfigRC.theme =
entryAfter ["basic"]
entryBefore ["pluginConfigs" "lazyConfigs"]
/*
lua
*/
@ -72,7 +174,14 @@ in {
highlight = ${boolToString cfg.signsHighlight},
},
}
${cfg.extraConfig}
local extra_highlights = ${toLuaObject (wrapHighlights cfg.additionalHighlights)}
for group_name, settings in pairs(extra_highlights) do
-- Unwrap our prefixed names back to @ form
local actual_name = group_name:gsub("^hl_@", "@")
vim.api.nvim_set_hl(0, actual_name, settings)
end
'';
};
};