Merge branch 'main' into notashelf/push-qozvyzsvqtmk

This commit is contained in:
raf 2026-02-26 21:14:40 +03:00 committed by GitHub
commit 96535d969d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 602 additions and 68 deletions

View file

@ -4,13 +4,14 @@
lib,
...
}: let
inherit (builtins) length;
inherit (lib.modules) mkIf mkRenamedOptionModule;
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.strings) concatLines concatStringsSep optionalString;
inherit (lib.strings) concatLines concatStringsSep;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.types) listOf str attrsOf;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.dag) entryAfter;
inherit (lib.types) listOf str attrsOf bool;
inherit (lib.lists) optional;
inherit (lib.generators) mkLuaInline;
cfg = config.vim.spellcheck;
in {
@ -86,6 +87,12 @@ in {
'';
};
ignoreTerminal = mkOption {
type = bool;
default = true;
description = "Disable spell checking in terminal.";
};
programmingWordlist.enable = mkEnableOption ''
vim-dirtytalk, a wordlist for programmers containing
common programming terms.
@ -144,20 +151,25 @@ in {
spelllang = concatStringsSep "," cfg.languages;
};
# Register an autocommand to disable spellchecking in buffers with given filetypes.
# If the list is empty, the autocommand does not need to be registered.
luaConfigRC.spellcheck = entryAfter ["basic"] (optionalString (cfg.ignoredFiletypes != []) ''
-- Disable spellchecking for certain filetypes
-- as configured by `vim.spellcheck.ignoredFiletypes`
vim.api.nvim_create_augroup("nvf_autocmds", {clear = false})
vim.api.nvim_create_autocmd({ "FileType" }, {
group = "nvf_autocmds",
pattern = ${toLuaObject cfg.ignoredFiletypes},
callback = function()
vim.opt_local.spell = false
end,
augroups = [{name = "nvf_spellcheck";}];
autocmds =
(optional cfg.ignoreTerminal {
event = ["TermOpen"];
group = "nvf_spellcheck";
callback = mkLuaInline ''
function() vim.opt_local.spell = false end
'';
})
'');
++ (optional (length cfg.ignoredFiletypes > 0) {
event = ["FileType"];
group = "nvf_spellcheck";
pattern = cfg.ignoredFiletypes;
callback = mkLuaInline ''
function()
vim.opt_local.spell = false
end
'';
});
};
};
}

View file

@ -11,21 +11,21 @@
layoutDefined = cfg.layout != [];
in {
config = mkIf cfg.enable {
vim.startPlugins = [
"alpha-nvim"
"nvim-web-devicons"
];
vim = {
startPlugins = ["alpha-nvim"];
visuals.nvim-web-devicons.enable = true;
vim.pluginRC.alpha = let
setupOpts =
if themeDefined
then lib.generators.mkLuaInline "require'alpha.themes.${cfg.theme}'.config"
else {
inherit (cfg) layout opts;
};
in ''
require('alpha').setup(${toLuaObject setupOpts})
'';
pluginRC.alpha = let
setupOpts =
if themeDefined
then lib.generators.mkLuaInline "require'alpha.themes.${cfg.theme}'.config"
else {
inherit (cfg) layout opts;
};
in ''
require('alpha').setup(${toLuaObject setupOpts})
'';
};
assertions = [
{

View file

@ -9,11 +9,8 @@
in {
config = mkIf cfg.enable {
vim = {
startPlugins = [
# dependencies
"nui-nvim" # ui library
"nvim-web-devicons" # glyphs
];
startPlugins = ["nui-nvim"];
visuals.nvim-web-devicons.enable = true;
lazy.plugins = {
"hunk-nvim" = {

View file

@ -0,0 +1,95 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.generators) mkLuaInline;
inherit (lib.meta) getExe getExe';
inherit (lib.modules) mkIf mkMerge;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum listOf str;
inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.arduino;
defaultServers = ["arduino-language-server"];
servers = {
arduino-language-server = {
enable = true;
cmd =
[
(getExe pkgs.arduino-language-server)
"-clangd"
(getExe' pkgs.clang-tools "clangd")
"-cli"
(getExe pkgs.arduino-cli)
"-cli-config"
"$HOME/.arduino15/arduino-cli.yaml"
]
++ cfg.lsp.extraArgs;
filetypes = ["arduino"];
root_dir =
mkLuaInline
/*
lua
*/
''
function(bufnr, on_dir)
local fname = vim.api.nvim_buf_get_name(bufnr)
on_dir(util.root_pattern("*.ino")(fname))
end
'';
capabilities = {
textDocument = {
semanticTokens = mkLuaInline "vim.NIL";
};
workspace = {
semanticTokens = mkLuaInline "vim.NIL";
};
};
};
};
in {
options.vim.languages.arduino = {
enable = mkEnableOption "Arduino support";
treesitter = {
enable = mkEnableOption "Arduino treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "arduino";
};
lsp = {
enable = mkEnableOption "Arduino LSP support" // {default = config.vim.lsp.enable;};
servers = mkOption {
type = listOf (enum (attrNames servers));
default = defaultServers;
description = "Arduino LSP servers to use";
};
extraArgs = mkOption {
type = listOf str;
default = [];
description = "Extra arguments passed to the Arduino LSP";
};
};
};
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 (n: {
name = n;
value = servers.${n};
})
cfg.lsp.servers;
})
]);
}

View file

@ -97,7 +97,7 @@
local function symbol_info()
local bufnr = vim.api.nvim_get_current_buf()
local clangd_client = vim.lsp.get_clients({ bufnr = bufnr, name = "clangd" })[1]
if not clangd_client or not clangd_client.supports_method 'textDocument/symbolInfo' then
if not clangd_client or not clangd_client:supports_method 'textDocument/symbolInfo' then
return vim.notify('Clangd client not found', vim.log.levels.ERROR)
end
local win = vim.api.nvim_get_current_win()

View file

@ -0,0 +1,96 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.meta) getExe;
inherit (lib.types) enum listOf package;
inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.cmake;
defaultServers = ["neocmakelsp"];
servers = {
neocmakelsp = {
enable = true;
cmd = [(getExe pkgs.neocmakelsp) "--stdio"];
filetypes = ["cmake"];
root_markers = [".gersemirc" ".git" "build" "cmake"];
capabilities = {
textDocument.completion.completionItem.snippetSupport = true;
};
};
};
defaultFormat = "gersemi";
formats = {
gersemi = {
package = pkgs.gersemi;
};
};
in {
options.vim.languages.cmake = {
enable = mkEnableOption "CMake language support";
treesitter = {
enable = mkEnableOption "CMake treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "cmake";
};
lsp = {
enable = mkEnableOption "CMake LSP support" // {default = config.vim.lsp.enable;};
servers = mkOption {
type = listOf (enum (attrNames servers));
default = defaultServers;
description = "CMake LSP servers to use";
};
};
format = {
enable = mkEnableOption "CMake formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
description = "CMake formatter to use";
type = enum (attrNames formats);
default = defaultFormat;
};
package = mkOption {
description = "CMake formatter package";
type = package;
default = formats.${cfg.format.type}.package;
};
};
};
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 (n: {
name = n;
value = servers.${n};
})
cfg.lsp.servers;
})
(mkIf cfg.format.enable {
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.cmake = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = {
command = getExe cfg.format.package;
};
};
})
]);
}

View file

@ -3,6 +3,7 @@
inherit (lib.nvim.languages) mkEnable;
in {
imports = [
./arduino.nix
./asm.nix
./astro.nix
./bash.nix
@ -10,10 +11,12 @@ in {
./dart.nix
./clang.nix
./clojure.nix
./cmake.nix
./css.nix
./elixir.nix
./fsharp.nix
./gleam.nix
./glsl.nix
./go.nix
./hcl.nix
./helm.nix

View file

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

View file

@ -20,7 +20,7 @@
servers = {
gopls = {
cmd = [(getExe pkgs.gopls)];
filetypes = ["go" "gomod" "gowork" "gotmpl"];
filetypes = ["go" "gomod" "gosum" "gowork" "gotmpl"];
root_dir = mkLuaInline ''
function(bufnr, on_dir)
local fname = vim.api.nvim_buf_get_name(bufnr)
@ -170,7 +170,11 @@ in {
treesitter = {
enable = mkEnableOption "Go treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "go";
goPackage = mkGrammarOption pkgs "go";
gomodPackage = mkGrammarOption pkgs "gomod";
gosumPackage = mkGrammarOption pkgs "gosum";
goworkPackage = mkGrammarOption pkgs "gowork";
gotmplPackage = mkGrammarOption pkgs "gotmpl";
};
lsp = {
@ -232,7 +236,13 @@ in {
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package];
vim.treesitter.grammars = [
cfg.treesitter.goPackage
cfg.treesitter.gomodPackage
cfg.treesitter.gosumPackage
cfg.treesitter.goworkPackage
cfg.treesitter.gotmplPackage
];
})
(mkIf cfg.lsp.enable {

View file

@ -76,9 +76,14 @@ in {
end
})
local ft = require('Comment.ft')
ft
.set('hcl', '#%s')
${
if config.vim.comments.comment-nvim.enable
then ''
local ft = require('Comment.ft')
ft.set('hcl', '#%s')
''
else ""
}
'';
}
(mkIf cfg.treesitter.enable {

View file

@ -5,7 +5,7 @@
...
}: let
inherit (builtins) attrNames;
inherit (lib.meta) getExe;
inherit (lib.meta) getExe getExe';
inherit (lib.modules) mkIf mkMerge;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) bool enum listOf str nullOr;
@ -55,6 +55,15 @@
prettierd = {
command = getExe pkgs.prettierd;
};
mdformat = {
command = getExe' (pkgs.python313Packages.python.withPackages (p:
with p; [
mdformat
mdformat-gfm
mdformat-frontmatter
mdformat-footnote
])) "mdformat";
};
};
defaultDiagnosticsProvider = ["markdownlint-cli2"];
diagnosticsProviders = {

View file

@ -7,12 +7,15 @@
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) enum;
inherit (lib.types) enum package;
inherit (lib.nvim.dag) entryAfter;
inherit (lib.meta) getExe;
inherit (lib.nvim.types) mkGrammarOption deprecatedSingleOrListOf;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.attrsets) mapListToAttrs;
cfg = config.vim.languages.odin;
defaultServers = ["ols"];
servers = {
ols = {
@ -32,7 +35,19 @@
};
};
cfg = config.vim.languages.odin;
defaultDebugger = "codelldb";
debuggers = {
codelldb = {
package = pkgs.lldb;
dapConfig = ''
dap.adapters.codelldb = {
type = 'executable',
command = '${cfg.dap.package}/bin/lldb-dap',
name = 'codelldb'
}
'';
};
};
in {
options.vim.languages.odin = {
enable = mkEnableOption "Odin language support";
@ -51,6 +66,22 @@ in {
description = "Odin LSP server to use";
};
};
dap = {
enable = mkEnableOption "Enable Odin Debug Adapter" // {default = config.vim.languages.enableDAP;};
debugger = mkOption {
description = "Odin debugger to use";
type = enum (attrNames debuggers);
default = defaultDebugger;
};
package = mkOption {
description = "Odin debugger package.";
type = package;
default = debuggers.${cfg.dap.debugger}.package;
};
};
};
config = mkIf cfg.enable (mkMerge [
@ -67,5 +98,18 @@ in {
})
cfg.lsp.servers;
})
(mkIf cfg.dap.enable {
vim = {
startPlugins = ["nvim-dap-odin"];
debugger.nvim-dap.sources.odin-debugger = debuggers.${cfg.dap.debugger}.dapConfig;
pluginRC.nvim-dap-odin = entryAfter ["nvim-dap"] ''
require('nvim-dap-odin').setup({
notifications = false -- contains no useful information
})
'';
debugger.nvim-dap.enable = true;
};
})
]);
}

View file

@ -11,7 +11,7 @@
inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) enum package bool;
inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (lib.nvim.types) deprecatedSingleOrListOf;
inherit (lib.nvim.types) deprecatedSingleOrListOf diagnostics;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.dag) entryBefore;
inherit (lib.trivial) warn;
@ -278,6 +278,14 @@
'';
};
};
defaultDiagnosticsProvider = ["mypy"];
diagnosticsProviders = {
mypy = {
config = {
cmd = getExe' pkgs.mypy "mypy";
};
};
};
in {
options.vim.languages.python = {
enable = mkEnableOption "Python language support";
@ -335,6 +343,15 @@ in {
'';
};
};
extraDiagnostics = {
enable = mkEnableOption "extra Python diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
types = diagnostics {
langDesc = "Python";
inherit diagnosticsProviders;
inherit defaultDiagnosticsProvider;
};
};
};
config = mkIf cfg.enable (mkMerge [
@ -404,5 +421,15 @@ in {
vim.debugger.nvim-dap.enable = true;
vim.debugger.nvim-dap.sources.python-debugger = debuggers.${cfg.dap.debugger}.dapConfig;
})
(mkIf cfg.extraDiagnostics.enable {
vim.diagnostics.nvim-lint = {
enable = true;
linters_by_ft.python = cfg.extraDiagnostics.types;
linters =
mkMerge (map (name: {${name} = diagnosticsProviders.${name}.config;})
cfg.extraDiagnostics.types);
};
})
]);
}

View file

@ -48,7 +48,7 @@ in {
default_on_attach(client, bufnr)
${optionalString cfg.inlayHints.enable ''
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = bufnr }), { bufnr = bufnr })
end
''}

View file

@ -11,9 +11,47 @@
in {
config = mkIf (cfg.enable && cfg.harper-ls.enable) {
vim.lsp.servers.harper-ls = {
root_markers = [".git"];
root_markers = [".git" ".harper-dictionary.txt"];
cmd = [(getExe pkgs.harper) "--stdio"];
settings = {harper-ls = cfg.harper-ls.settings;};
filetypes =
# <https://writewithharper.com/docs/integrations/language-server#Supported-Languages>
[
"asciidoc"
"c"
"clojure"
"cmake"
"cpp"
"cs"
"daml"
"dart"
"gitcommit"
"go"
"haskell"
"html"
"ink"
"java"
"javascript"
"javascriptreact"
"kotlin"
"lhaskell"
"lua"
"mail"
"markdown"
"nix"
"php"
"python"
"ruby"
"rust"
"scala"
"sh"
"swift"
"text"
"toml"
"typescript"
"typescriptreact"
"typst"
];
};
};
}

View file

@ -80,7 +80,7 @@
mode = mkOption {
description = "Set the display mode";
type = nullOr (enum ["foreground" "background"]);
type = nullOr (enum ["foreground" "background" "virtualtext"]);
default = null;
};

View file

@ -15,7 +15,7 @@ in {
"img-clip"
];
pluginRC.image-nvim = entryAnywhere ''
pluginRC.img-clip = entryAnywhere ''
require("img-clip").setup(${toLuaObject cfg.setupOpts})
'';
};

View file

@ -0,0 +1,9 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {
options.vim.visuals.blink-indent = {
enable = mkEnableOption "indentation guides [blink-indent]";
setupOpts = mkPluginSetupOption "blink-indent" {};
};
}

View file

@ -0,0 +1,19 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
cfg = config.vim.visuals.blink-indent;
in {
config = mkIf cfg.enable {
vim.lazy.plugins.blink-indent = {
package = "blink-indent";
setupModule = "blink.indent";
inherit (cfg) setupOpts;
event = ["BufEnter"];
};
};
}

View file

@ -0,0 +1,6 @@
{
imports = [
./config.nix
./blink-indent.nix
];
}

View file

@ -7,6 +7,7 @@ in {
toggles under individual options.
'')
./blink-indent
./cellular-automaton
./cinnamon-nvim
./fidget-nvim

View file

@ -11,7 +11,8 @@
in {
config = mkIf cfg.enable {
vim = {
startPlugins = ["tiny-devicons-auto-colors-nvim" "nvim-web-devicons"];
startPlugins = ["tiny-devicons-auto-colors-nvim"];
visuals.nvim-web-devicons.enable = true;
pluginRC.tiny-devicons-auto-colors = entryAnywhere ''
require("tiny-devicons-auto-colors").setup(${toLuaObject cfg.setupOpts})

View file

@ -94,7 +94,7 @@
nodeJs.enable = config.vim.withNodeJs;
python3 = {
enable = config.vim.withPython3;
extraPackages = ps: map (flip builtins.getAttr ps) config.vim.python3Packages;
extraPackages = ps: (map (flip builtins.getAttr ps) config.vim.python3Packages) ++ [ps.pynvim];
};
};