feat(nvim): add nixCats-backed language options
check / lint (push) Successful in 16s

This commit is contained in:
hektor committed 2026-11-04 23:51:07 +01:00
1 parent 0d5027edb7
commit 3e377ce637
12 files changed
+410 -199

No files matched your search

+1
View File
@@ -31,6 +31,7 @@
desktop.niri.enable = true; desktop.niri.enable = true;
devenv.enable = true; devenv.enable = true;
direnv.enable = true; direnv.enable = true;
docker.enable = true;
gaming.enable = true; gaming.enable = true;
git = { git = {
enable = true; enable = true;
+1
View File
@@ -30,6 +30,7 @@
desktop.niri.enable = true; desktop.niri.enable = true;
devenv.enable = true; devenv.enable = true;
direnv.enable = true; direnv.enable = true;
docker.enable = true;
git = { git = {
enable = true; enable = true;
gitea.enable = true; gitea.enable = true;
+8
View File
@@ -72,6 +72,14 @@
nvim = { nvim = {
enable = true; enable = true;
colorscheme = "vscode"; colorscheme = "vscode";
# note: non-exhaustive (these are the ones that are not inferred from home
# module options atm)
languages = {
css = true;
html = true;
json = true;
tailwind = true;
};
}; };
pandoc.enable = true; pandoc.enable = true;
shell.enable = true; shell.enable = true;
-1
View File
@@ -13,7 +13,6 @@
blender blender
] ]
++ lib.optionals config.modules."3d".modeling.openscad.enable [ ++ lib.optionals config.modules."3d".modeling.openscad.enable [
openscad-lsp
openscad-unstable openscad-unstable
]; ];
}; };
+1 -4
View File
@@ -13,10 +13,7 @@
config = lib.mkIf config.go.enable { config = lib.mkIf config.go.enable {
home = { home = {
sessionVariables.GOPATH = "${config.xdg.dataHome}/go"; sessionVariables.GOPATH = "${config.xdg.dataHome}/go";
packages = with pkgs; [ packages = with pkgs; [ go ];
go
gopls
];
}; };
}; };
} }
@@ -1,29 +1,51 @@
local nixCatsUtils = require("nixCatsUtils")
local formatters = {
general = {
awk = { "awk" },
html = { "prettierd", "prettier", stop_after_first = true },
json = { "prettierd", "prettier", stop_after_first = true },
jsonc = { "prettierd", "prettier", stop_after_first = true },
markdown = { "prettierd", "prettier", stop_after_first = true },
},
c = {
c = { "clang-format" },
cpp = { "clang-format" },
},
css = { css = { "prettierd", "prettier", stop_after_first = true } },
gdscript = { gdscript = { "gdformat" } },
go = { go = { "gofmt" } },
haskell = { haskell = { "ormolu" } },
lua = { lua = { "stylua" } }, -- configured in stylua.toml
nix = { nix = { "nixfmt" } },
python = { python = { "isort", "black" } },
rust = { rust = { "rustfmt", lsp_format = "fallback" } },
shell = { bash = { "shellcheck" } },
svelte = { svelte = { "eslint_d", "prettierd", "prettier", stop_after_first = true } },
typescript = {
javascript = { "eslint_d", "eslint", "prettierd", "prettier", stop_after_first = true },
javascriptreact = { "eslint_d", "eslint", "prettierd", "prettier", stop_after_first = true },
typescript = { "eslint_d", "prettierd", "prettier", stop_after_first = true },
typescriptreact = { "eslint_d", "eslint", "prettierd", "prettier", stop_after_first = true },
},
yaml = {
-- yaml = { "prettierd", "prettier", stop_after_first = true },
},
}
local formatters_by_ft = {}
for language, language_formatters in pairs(formatters) do
if language == "general" or nixCatsUtils.enableForCategory("languages." .. language) then
for ft, ft_formatters in pairs(language_formatters) do
formatters_by_ft[ft] = ft_formatters
end
end
end
require("conform").setup({ require("conform").setup({
format_after_save = { format_after_save = {
lsp_format = "never", lsp_format = "never",
timeout_ms = 500, timeout_ms = 500,
}, },
formatters_by_ft = { formatters_by_ft = formatters_by_ft,
awk = { "awk" },
bash = { "shellcheck" },
c = { "clang-format" },
cpp = { "clang-format" },
css = { "prettierd", "prettier", stop_after_first = true },
gdscript = { "gdformat" },
haskell = { "ormolu" },
html = { "prettierd", "prettier", stop_after_first = true },
javascript = { "eslint_d", "eslint", "prettierd", "prettier", stop_after_first = true },
javascriptreact = { "eslint_d", "eslint", "prettierd", "prettier", stop_after_first = true },
json = { "prettierd", "prettier", stop_after_first = true },
jsonc = { "prettierd", "prettier", stop_after_first = true },
lua = { "stylua" }, -- configured in stylua.toml
markdown = { "prettierd", "prettier", stop_after_first = true },
nix = { "nixfmt" },
python = { "isort", "black" },
rust = { "rustfmt", lsp_format = "fallback" },
svelte = { "eslint_d", "prettierd", "prettier", stop_after_first = true },
typescript = { "eslint_d", "prettierd", "prettier", stop_after_first = true },
typescriptreact = { "eslint_d", "eslint", "prettierd", "prettier", stop_after_first = true },
-- yaml = { "prettierd", "prettier", stop_after_first = true },
},
}) })
@@ -4,159 +4,186 @@ local cmp_nvim_lsp = require("cmp_nvim_lsp")
local capabilities = cmp_nvim_lsp.default_capabilities() local capabilities = cmp_nvim_lsp.default_capabilities()
local servers = { local servers = {
bashls = {}, c = { clangd = {} },
eslint = { css = { cssls = {} },
settings = { docker = { dockerls = {} },
--Assuming prettier/prettierd will handle formatting, we don't need to see these errors gdscript = { gdscript = {} },
rulesCustomizations = { go = { gopls = {} },
{ rule = "prettier/prettier", severity = "off" }, haskell = { hls = { filetypes = { "haskell", "lhaskell", "cabal" } } },
}, helm = {
format = false, helm_ls = {
filetypes = { "helm", "yaml.helm-values" },
}, },
}, },
emmet_language_server = {}, html = {
gdscript = {}, emmet_language_server = {},
helm_ls = { html = {},
filetypes = { "helm", "yaml.helm-values" },
}, },
hls = { filetypes = { "haskell", "lhaskell", "cabal" } }, json = {
html = {}, jsonls = {
jsonls = { settings = {
settings = { json = {
json = { schemas = require("schemastore").json.schemas(),
schemas = require("schemastore").json.schemas(), validate = { enable = true },
validate = { enable = true }, },
}, },
}, },
}, },
lua_ls = { lua = {
on_init = function(client) lua_ls = {
if client.workspace_folders then on_init = function(client)
local path = client.workspace_folders[1].name if client.workspace_folders then
if local path = client.workspace_folders[1].name
path ~= vim.fn.stdpath("config") if
and (vim.uv.fs_stat(path .. "/.luarc.json") or vim.uv.fs_stat(path .. "/.luarc.jsonc")) path ~= vim.fn.stdpath("config")
then and (vim.uv.fs_stat(path .. "/.luarc.json") or vim.uv.fs_stat(path .. "/.luarc.jsonc"))
return then
return
end
end end
end
client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, { client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, {
runtime = { runtime = {
version = "LuaJIT", version = "LuaJIT",
path = { path = {
"lua/?.lua", "lua/?.lua",
"lua/?/init.lua", "lua/?/init.lua",
},
}, },
}, workspace = {
workspace = { checkThirdParty = false,
checkThirdParty = false, library = {
library = { vim.env.VIMRUNTIME,
vim.env.VIMRUNTIME, },
}, },
}, })
}) end,
end, settings = {
settings = { Lua = {},
Lua = {}, },
}, },
}, },
nixd = { nix = {
settings = { nixd = {
nixd = { settings = {
nixpkgs = { nixd = {
expr = "import <nixpkgs> { }", nixpkgs = {
expr = 'import (builtins.getFlake ("git+file://" + toString ../../../../../.)).inputs.nixpkgs { }', expr = "import <nixpkgs> { }",
expr = 'import (builtins.getFlake ("git+file://" + toString ../../../../../.)).inputs.nixpkgs { }',
},
}, },
}, options = {
options = { nixos = {
nixos = { expr = '(builtins.getFlake ("git+file://" + toString ../../../../../.)).nixosConfigurations."'
expr = '(builtins.getFlake ("git+file://" + toString ../../../../../.)).nixosConfigurations."' .. vim.fn.hostname()
.. vim.fn.hostname() .. '".options',
.. '".options', },
}, home_manager = {
home_manager = { expr = '(builtins.getFlake ("git+file://" + toString ../../../../../.)).homeConfigurations."'
expr = '(builtins.getFlake ("git+file://" + toString ../../../../../.)).homeConfigurations."' .. vim.fn.expand("$USER")
.. vim.fn.expand("$USER") .. "@"
.. "@" .. vim.fn.hostname()
.. vim.fn.hostname() .. '".options',
.. '".options', },
}, },
}, },
}, },
}, },
openscad_ls = {}, openscad = { openscad_ls = {} },
pyright = {}, python = { pyright = {} },
shell = { bashls = {} },
svelte = { svelte = {
plugin = { svelte = {
svelte = { plugin = {
defaultScriptLanguage = "ts", svelte = {
defaultScriptLanguage = "ts",
},
}, },
}, },
}, },
tailwindcss = {}, tailwind = { tailwindcss = {} },
ts_ls = {}, typescript = {
vtsls = { eslint = {
filetypes = { settings = {
"javascript", --Assuming prettier/prettierd will handle formatting, we don't need to see these errors
"javascriptreact", rulesCustomizations = {
"javascript.jsx", { rule = "prettier/prettier", severity = "off" },
"typescript", },
"typescriptreact", format = false,
"typescript.tsx", },
}, },
settings = { ts_ls = {},
vtsls = { vtsls = {
enableMoveToFileCodeAction = true, filetypes = {
autoUseWorkspaceTsdk = true, "javascript",
experimental = { "javascriptreact",
completion = { "javascript.jsx",
enableServerSideFuzzyMatch = true, "typescript",
"typescriptreact",
"typescript.tsx",
},
settings = {
vtsls = {
enableMoveToFileCodeAction = true,
autoUseWorkspaceTsdk = true,
experimental = {
completion = {
enableServerSideFuzzyMatch = true,
},
},
},
typescript = {
updateImportsOnFileMove = { enabled = "always" },
tsserver = { maxTsServerMemory = 16384 },
suggest = {
completeFunctionCalls = true,
},
inlayHints = {
enumMemberValues = { enabled = true },
functionLikeReturnTypes = { enabled = true },
parameterNames = { enabled = "literals" },
parameterTypes = { enabled = true },
propertyDeclarationTypes = { enabled = true },
variableTypes = { enabled = false },
}, },
}, },
}, },
typescript = {
updateImportsOnFileMove = { enabled = "always" },
tsserver = { maxTsServerMemory = 16384 },
suggest = {
completeFunctionCalls = true,
},
inlayHints = {
enumMemberValues = { enabled = true },
functionLikeReturnTypes = { enabled = true },
parameterNames = { enabled = "literals" },
parameterTypes = { enabled = true },
propertyDeclarationTypes = { enabled = true },
variableTypes = { enabled = false },
},
},
}, },
}, },
yamlls = { yaml = {
settings = { yamlls = {
yaml = { settings = {
schemaStore = { yaml = {
-- You must disable built-in schemaStore support if you want to use schemaStore = {
-- this plugin and its advanced options like `ignore`. -- You must disable built-in schemaStore support if you want to use
enable = false, -- this plugin and its advanced options like `ignore`.
-- Avoid TypeError: Cannot read properties of undefined (reading 'length') enable = false,
url = "", -- Avoid TypeError: Cannot read properties of undefined (reading 'length')
url = "",
},
schemas = require("schemastore").yaml.schemas(),
}, },
schemas = require("schemastore").yaml.schemas(),
}, },
}, },
}, },
} }
local typescript_server = require("nixCatsUtils").getCatOrDefault("typescriptServer", "ts_ls") local nixCatsUtils = require("nixCatsUtils")
servers[typescript_server == "vtsls" and "ts_ls" or "vtsls"] = nil local typescript_server = nixCatsUtils.getCatOrDefault("typescriptServer", "ts_ls")
servers.typescript[typescript_server == "vtsls" and "ts_ls" or "vtsls"] = nil
for server, config in pairs(servers) do local enabled = {}
config.capabilities = capabilities for language, language_servers in pairs(servers) do
vim.lsp.config(server, config) if nixCatsUtils.enableForCategory("languages." .. language) then
for server, config in pairs(language_servers) do
config.capabilities = capabilities
vim.lsp.config(server, config)
table.insert(enabled, server)
end
end
end end
vim.lsp.enable(vim.tbl_keys(servers)) vim.lsp.enable(enabled)
vim.api.nvim_create_autocmd("LspAttach", { vim.api.nvim_create_autocmd("LspAttach", {
callback = function(e) callback = function(e)
@@ -1,33 +1,60 @@
local nixCatsUtils = require("nixCatsUtils")
vim.env.ESLINT_D_PPID = vim.fn.getpid() vim.env.ESLINT_D_PPID = vim.fn.getpid()
local eslint_linter = "eslint_d" local eslint_linter = "eslint_d"
require("lint").linters_by_ft = { local linters = {
bash = { "shellcheck" }, general = {
c = { "clangtidy", "flawfinder" }, cmake = { "cmakelint" },
cmake = { "cmakelint" }, editorconfig = { "editorconfig-checker" },
cpp = { "clangtidy", "flawfinder" }, -- "cpplint", "cppcheck", "flawfinder" latex = { "chktex" },
css = { "stylelint" }, make = { "checkmake" },
dockerfile = { "hadolint" }, -- pandoc = { "proselint", "woke" },
editorconfig = { "editorconfig-checker" }, systemd = { "systemdlint" },
haskell = { "hlint" }, },
-- html = { "htmlhint" }, c = {
-- javascript = { eslint_linter }, c = { "clangtidy", "flawfinder" },
-- javascriptreact = { eslint_linter }, cpp = { "clangtidy", "flawfinder" }, -- "cpplint", "cppcheck", "flawfinder"
gdscript = { "gdlint" }, },
latex = { "chktex" }, css = { css = { "stylelint" } },
-- lua = { "luacheck", "selene" }, docker = { dockerfile = { "hadolint" } },
make = { "checkmake" }, gdscript = { gdscript = { "gdlint" } },
-- pandoc = { "proselint", "woke" }, haskell = { haskell = { "hlint" } },
-- python = { "pylint" }, html = {
sh = { "shellcheck" }, -- html = { "htmlhint" },
svelte = { eslint_linter }, },
systemd = { "systemdlint" }, lua = {
-- typescript = { eslint_linter }, -- lua = { "luacheck", "selene" },
-- typescriptreact = { eslint_linter }, },
yaml = { "yamllint" }, python = {
-- python = { "pylint" },
},
shell = {
bash = { "shellcheck" },
sh = { "shellcheck" },
},
svelte = { svelte = { eslint_linter } },
typescript = {
-- javascript = { eslint_linter },
-- javascriptreact = { eslint_linter },
-- typescript = { eslint_linter },
-- typescriptreact = { eslint_linter },
},
yaml = { yaml = { "yamllint" } },
} }
local linters_by_ft = {}
for language, language_linters in pairs(linters) do
if language == "general" or nixCatsUtils.enableForCategory("languages." .. language) then
for ft, ft_linters in pairs(language_linters) do
linters_by_ft[ft] = ft_linters
end
end
end
require("lint").linters_by_ft = linters_by_ft
local function has_yamllint_config(buf) local function has_yamllint_config(buf)
return vim.fs.root(buf, { ".yamllint", ".yamllint.yaml", ".yamllint.yml" }) ~= nil return vim.fs.root(buf, { ".yamllint", ".yamllint.yaml", ".yamllint.yml" }) ~= nil
end end
@@ -1 +1,5 @@
if not require("nixCatsUtils").enableForCategory("languages.tailwind") then
return
end
require("tailwind-fold").setup({ ft = { "html", "svelte", "tsx" } }) require("tailwind-fold").setup({ ft = { "html", "svelte", "tsx" } })
+6 -29
View File
@@ -34,6 +34,7 @@
}@inputs: }@inputs:
let let
inherit (nixCats) utils; inherit (nixCats) utils;
inherit (nixpkgs) lib;
luaPath = ./.; luaPath = ./.;
forEachSystem = utils.eachSystem nixpkgs.lib.platforms.all; forEachSystem = utils.eachSystem nixpkgs.lib.platforms.all;
extra_pkg_config = { extra_pkg_config = {
@@ -75,44 +76,23 @@
}: }:
let let
themes = import ./themes.nix pkgs; themes = import ./themes.nix pkgs;
languages = import ./languages.nix { inherit pkgs categories; };
in in
{ {
lspsAndRuntimeDeps = with pkgs; { lspsAndRuntimeDeps = with pkgs; {
general = [ general = [
nodejs_24 nodejs_24
black
clang
clang-tools
curl # → plenary-nvim curl # → plenary-nvim
delta delta
emmet-language-server
eslint_d
fd fd
gawk gawk
gdtoolkit_4
hadolint
helm-ls
inotify-tools inotify-tools
isort
lua-language-server
nixd
nixfmt
prettier prettier
ormolu
prettierd prettierd
rust-analyzer
rustfmt
shellcheck-minimal
stylelint
stylua
tree-sitter tree-sitter
tailwindcss-language-server
(if (categories.typescriptServer or "ts_ls") == "vtsls" then vtsls else typescript-language-server)
vscode-langservers-extracted
yaml-language-server
yamllint
]; ];
github = [ gh ]; github = [ gh ];
languages = lib.mapAttrs (_: language: language.packages) languages;
}; };
startupPlugins = { startupPlugins = {
@@ -137,9 +117,7 @@
# TODO: tidalcycles/vim-tidal # TODO: tidalcycles/vim-tidal
vim-glsl vim-glsl
# TODO: timtro/glslView-nvim # TODO: timtro/glslView-nvim
# TODO: sirtaj/vim-openscad
jupytext-nvim jupytext-nvim
vim-openscad
## paq ## paq
eyeliner-nvim eyeliner-nvim
fzf-lua fzf-lua
@@ -172,21 +150,19 @@
gitsigns-nvim gitsigns-nvim
pkgs.neovimPlugins.atlas-nvim pkgs.neovimPlugins.atlas-nvim
nvim-highlight-colors nvim-highlight-colors
pkgs.neovimPlugins.tailwind-fold-nvim
auto-session auto-session
nvim-dbee nvim-dbee
image-nvim image-nvim
pkgs.neovimPlugins.beancount-nvim pkgs.neovimPlugins.beancount-nvim
codecompanion-nvim codecompanion-nvim
helm-ls-nvim
kitty-scrollback-nvim kitty-scrollback-nvim
fidget-nvim fidget-nvim
rustaceanvim
# pkgs.neovimPlugins.m-taskwarrior-d-nvim # pkgs.neovimPlugins.m-taskwarrior-d-nvim
claudecode-nvim claudecode-nvim
snacks-nvim snacks-nvim
] ]
++ themes.${categories.colorscheme or "zenwritten"}; ++ themes.${categories.colorscheme or "zenwritten"};
languages = lib.mapAttrs (_: language: language.plugins or [ ]) languages;
}; };
optionalPlugins = { optionalPlugins = {
@@ -202,7 +178,7 @@
}; };
packageDefinitions = { packageDefinitions = {
nvim = _: { nvim = { pkgs, ... }: {
settings = { settings = {
suffix-path = true; suffix-path = true;
suffix-LD = true; suffix-LD = true;
@@ -214,6 +190,7 @@
github = false; github = false;
colorscheme = "zenwritten"; colorscheme = "zenwritten";
typescriptServer = "ts_ls"; typescriptServer = "ts_ls";
languages = lib.mapAttrs (_: language: language.enable) (import ./languages.nix { inherit pkgs; });
}; };
}; };
}; };
+133
View File
@@ -0,0 +1,133 @@
{
pkgs,
categories ? { },
}:
with pkgs;
{
c = {
enable = false;
packages = [
clang
clang-tools
];
};
css = {
enable = false;
packages = [
stylelint
vscode-langservers-extracted
];
};
docker = {
enable = false;
packages = [
dockerfile-language-server
hadolint
];
};
gdscript = {
enable = false;
packages = [ gdtoolkit_4 ];
};
go = {
enable = false;
packages = [
go
gopls
];
};
haskell = {
enable = false;
packages = [
haskell-language-server
hlint
ormolu
];
};
helm = {
enable = false;
packages = [ helm-ls ];
plugins = [ vimPlugins.helm-ls-nvim ];
};
html = {
enable = false;
packages = [
emmet-language-server
vscode-langservers-extracted
];
};
json = {
enable = false;
packages = [ vscode-langservers-extracted ];
};
lua = {
enable = true;
packages = [
lua-language-server
stylua
];
};
nix = {
enable = true;
packages = [
nixd
nixfmt
];
};
openscad = {
enable = false;
packages = [ openscad-lsp ];
plugins = [ vimPlugins.vim-openscad ];
};
python = {
enable = false;
packages = [
black
isort
pyright
];
};
rust = {
enable = false;
packages = [
rust-analyzer
rustfmt
];
plugins = [ vimPlugins.rustaceanvim ];
};
shell = {
enable = true;
packages = [
bash-language-server
shellcheck-minimal
];
};
svelte = {
enable = false;
packages = [
eslint_d
svelte-language-server
];
};
tailwind = {
enable = false;
packages = [ tailwindcss-language-server ];
plugins = [ neovimPlugins.tailwind-fold-nvim ];
};
typescript = {
enable = false;
packages = [
eslint_d
(if (categories.typescriptServer or "ts_ls") == "vtsls" then vtsls else typescript-language-server)
vscode-langservers-extracted
];
};
yaml = {
enable = false;
packages = [
yaml-language-server
yamllint
];
};
}
+16 -1
View File
@@ -25,14 +25,29 @@ in
"vtsls" "vtsls"
]; ];
}; };
languages = lib.mapAttrs (
_: language:
lib.mkOption {
default = language.enable;
type = lib.types.bool;
}
) (import "${inputs.nvim}/languages.nix" { inherit pkgs; });
}; };
config = lib.mkIf config.nvim.enable { config = lib.mkIf config.nvim.enable {
nvim.languages = {
docker = lib.mkDefault config.docker.enable;
go = lib.mkDefault config.go.enable;
helm = lib.mkDefault config.k8s.helm.enable;
openscad = lib.mkDefault config.modules."3d".modeling.openscad.enable;
typescript = lib.mkDefault config.nodejs.enable;
};
nvim.packageDefinitions.merge.nvim = _: { nvim.packageDefinitions.merge.nvim = _: {
categories = { categories = {
colorscheme = config.nvim.colorscheme; colorscheme = config.nvim.colorscheme;
github = config.git.github.enable; github = config.git.github.enable;
inherit (config.nvim) typescriptServer; inherit (config.nvim) languages typescriptServer;
}; };
}; };