Merge branch 'main' into notashelf/push-qozvyzsvqtmk

This commit is contained in:
raf 2026-02-01 18:14:14 +03:00 committed by GitHub
commit 09bd743ad6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 317 additions and 37 deletions

View file

@ -4,17 +4,14 @@
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.autopairs.nvim-autopairs;
in {
config = mkIf cfg.enable {
vim = {
startPlugins = ["nvim-autopairs"];
pluginRC.autopairs = entryAnywhere ''
require('nvim-autopairs').setup(${toLuaObject cfg.setupOpts})
'';
vim.lazy.plugins.nvim-autopairs = {
package = "nvim-autopairs";
setupModule = "nvim-autopairs";
setupOpts = cfg.setupOpts;
event = ["InsertEnter"];
};
};
}

View file

@ -19,8 +19,10 @@ in {
./helm.nix
./kotlin.nix
./html.nix
./tera.nix
./haskell.nix
./java.nix
./jinja.nix
./json.nix
./lua.nix
./markdown.nix
@ -50,6 +52,7 @@ in {
./yaml.nix
./ruby.nix
./just.nix
./xml.nix
# This is now a hard deprecation.
(mkRenamedOptionModule ["vim" "languages" "enableLSP"] ["vim" "lsp" "enable"])

View file

@ -10,7 +10,7 @@
inherit (lib.meta) getExe;
inherit (lib.generators) mkLuaInline;
inherit (lib.types) bool enum package;
inherit (lib.nvim.types) mkGrammarOption deprecatedSingleOrListOf;
inherit (lib.nvim.types) mkGrammarOption diagnostics deprecatedSingleOrListOf;
inherit (lib.nvim.dag) entryAfter;
inherit (lib.nvim.attrsets) mapListToAttrs;
@ -78,6 +78,91 @@
package = pkgs.delve;
};
};
defaultDiagnosticsProvider = ["golangci-lint"];
diagnosticsProviders = {
golangci-lint = let
pkg = pkgs.golangci-lint;
in {
package = pkg;
config = {
cmd = getExe pkg;
args = [
"run"
"--output.json.path=stdout"
"--issues-exit-code=0"
"--show-stats=false"
"--fix=false"
"--path-mode=abs"
# Overwrite values that could be configured and result in unwanted writes
"--output.text.path="
"--output.tab.path="
"--output.html.path="
"--output.checkstyle.path="
"--output.code-climate.path="
"--output.junit-xml.path="
"--output.teamcity.path="
"--output.sarif.path="
];
parser = mkLuaInline ''
function(output, bufnr)
local SOURCE = "golangci-lint";
local function display_tool_error(msg)
return{
{
bufnr = bufnr,
lnum = 0,
col = 0,
message = string.format("[%s] %s", SOURCE, msg),
severity = vim.diagnostic.severity.ERROR,
source = SOURCE,
},
}
end
if output == "" then
return display_tool_error("no output provided")
end
local ok, decoded = pcall(vim.json.decode, output)
if not ok then
return display_tool_error("failed to parse JSON output")
end
if not decoded or not decoded.Issues then
return display_tool_error("unexpected output format")
end
local severity_map = {
error = vim.diagnostic.severity.ERROR,
warning = vim.diagnostic.severity.WARN,
info = vim.diagnostic.severity.INFO,
hint = vim.diagnostic.severity.HINT,
}
local diagnostics = {}
for _, issue in ipairs(decoded.Issues) do
local sev = vim.diagnostic.severity.ERROR
if issue.Severity and issue.Severity ~= "" then
local normalized = issue.Severity:lower()
sev = severity_map[normalized] or vim.diagnostic.severity.ERROR
end
table.insert(diagnostics, {
bufnr = bufnr,
lnum = issue.Pos.Line - 1,
col = issue.Pos.Column - 1,
message = issue.Text,
code = issue.FromLinter,
severity = sev,
source = SOURCE,
})
end
return diagnostics
end
'';
};
};
};
in {
options.vim.languages.go = {
enable = mkEnableOption "Go language support";
@ -134,6 +219,14 @@ in {
default = debuggers.${cfg.dap.debugger}.package;
};
};
extraDiagnostics = {
enable = mkEnableOption "extra Go diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
types = diagnostics {
langDesc = "Go";
inherit diagnosticsProviders;
inherit defaultDiagnosticsProvider;
};
};
};
config = mkIf cfg.enable (mkMerge [
@ -179,5 +272,15 @@ in {
debugger.nvim-dap.enable = true;
};
})
(mkIf cfg.extraDiagnostics.enable {
vim.diagnostics.nvim-lint = {
enable = true;
linters_by_ft.go = cfg.extraDiagnostics.types;
linters =
mkMerge (map (name: {${name} = diagnosticsProviders.${name}.config;})
cfg.extraDiagnostics.types);
};
})
]);
}

View file

@ -0,0 +1,65 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum listOf;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.attrsets) mapListToAttrs;
cfg = config.vim.languages.jinja;
defaultServers = ["jinja-lsp"];
servers = {
jinja-lsp = {
enable = true;
cmd = [(getExe pkgs.jinja-lsp)];
filetypes = ["jinja"];
root_markers = [
".git"
];
};
};
in {
options.vim.languages.jinja = {
enable = mkEnableOption "Jinja template language support";
treesitter = {
enable = mkEnableOption "Jinja treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "jinja";
inlinePackage = mkGrammarOption pkgs "jinja_inline";
};
lsp = {
enable = mkEnableOption "Jinja LSP support" // {default = config.vim.lsp.enable;};
servers = mkOption {
description = "Jinja LSP server to use";
type = listOf (enum (attrNames servers));
default = defaultServers;
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [
cfg.treesitter.package
cfg.treesitter.inlinePackage
];
})
(mkIf cfg.lsp.enable {
vim.lsp.servers =
mapListToAttrs (n: {
name = n;
value = servers.${n};
})
cfg.lsp.servers;
})
]);
}

View file

@ -228,10 +228,17 @@ in {
(mkIf cfg.extensions.crates-nvim.enable {
vim = mkMerge [
{
startPlugins = ["crates-nvim"];
pluginRC.rust-crates = entryAnywhere ''
require("crates").setup(${toLuaObject cfg.extensions.crates-nvim.setupOpts})
'';
lazy.plugins.crates-nvim = {
package = "crates-nvim";
setupModule = "crates";
setupOpts = cfg.extensions.crates-nvim.setupOpts;
event = [
{
event = "BufRead";
pattern = "Cargo.toml";
}
];
};
}
];
})

View file

@ -0,0 +1,28 @@
{
config,
pkgs,
lib,
...
}: let
inherit (lib.options) mkEnableOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.tera;
in {
options.vim.languages.tera = {
enable = mkEnableOption "Tera templating language support";
treesitter = {
enable = mkEnableOption "Tera treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "tera";
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package];
})
]);
}

View file

@ -0,0 +1,62 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) enum listOf;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.attrsets) mapListToAttrs;
cfg = config.vim.languages.xml;
defaultServers = ["lemminx"];
servers = {
lemminx = {
enable = true;
cmd = [
(getExe pkgs.lemminx)
];
filetypes = ["xml"];
root_markers = [".git"];
};
};
in {
options.vim.languages.xml = {
enable = mkEnableOption "XML language support";
treesitter = {
enable = mkEnableOption "XML treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "xml";
};
lsp = {
enable = mkEnableOption "XML LSP support" // {default = config.vim.lsp.enable;};
servers = mkOption {
type = listOf (enum (attrNames servers));
default = defaultServers;
description = "XML LSP server to use";
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package];
})
(mkIf cfg.lsp.enable {
vim.lsp.servers =
mapListToAttrs (name: {
inherit name;
value = servers.${name};
})
cfg.lsp.servers;
})
]);
}

View file

@ -1,6 +1,7 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {
options.vim.minimap.codewindow = {
enable = mkEnableOption "codewindow plugin for minimap view";
@ -11,5 +12,7 @@ in {
toggle = mkMappingOption "Toggle minimap [codewindow]" "<leader>mm";
toggleFocus = mkMappingOption "Toggle minimap focus [codewindow]" "<leader>mf";
};
setupOpts = mkPluginSetupOption "codewindow" {};
};
}

View file

@ -6,6 +6,7 @@
}: let
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding pushDownDefault;
cfg = config.vim.minimap.codewindow;
@ -32,9 +33,7 @@ in {
pluginRC.codewindow = entryAnywhere ''
local codewindow = require('codewindow')
codewindow.setup({
exclude_filetypes = { 'NvimTree', 'orgagenda', 'Alpha'},
})
codewindow.setup(${toLuaObject cfg.setupOpts})
'';
};
};

View file

@ -21,18 +21,9 @@ in {
treesitter.grammars = optionals cfg.addDefaultGrammars cfg.defaultGrammars;
# Define the autogroup for treesitter here rather than in the Lua snippet
# to allow overriding more easily. Should be highly unlikely that a user
# wants to override, but not impossible.
augroups = [
{
enable = true;
name = "nvf_treesitter";
clear = true;
}
];
pluginRC.treesitter-autocommands = entryAfter ["basic"] ''
vim.api.nvim_create_augroup("nvf_treesitter", { clear = true })
${lib.optionalString cfg.highlight.enable ''
-- Enable treesitter highlighting for all filetypes
vim.api.nvim_create_autocmd("FileType", {
@ -63,7 +54,6 @@ in {
callback = function()
vim.wo[0][0].foldmethod = "expr"
vim.wo[0][0].foldexpr = "v:lua.vim.treesitter.foldexpr()"
-- This is optional, but is set rather as a sane default.
-- If unset, opened files will be folded by automatically as
-- the files are opened