feat:add_nixvim

This commit is contained in:
dichgrem
2025-09-21 15:54:31 +08:00
parent c36f91562d
commit 8016a1173d
64 changed files with 3608 additions and 30 deletions

View File

@@ -0,0 +1,92 @@
{pkgs, ...}: {
plugins = {
conform-nvim.settings = {
formatters_by_ft = {
cpp = ["clang-format"];
};
formatters = {
clang-format = {
command = "${pkgs.clang-tools}/bin/clang-format";
};
};
};
lsp.servers = {
cmake.enable = true;
clangd = {
enable = true;
cmd = [
"clangd"
"--offset-encoding=utf-16"
"--header-insertion=iwyu"
"--background-index"
"--clang-tidy"
"--all-scopes-completion"
"--completion-style=detailed"
"--function-arg-placeholders"
"--fallback-style=llvm"
"-j=6"
];
onAttach.function = ''
vim.keymap.set('n', 'gh', "<cmd>ClangdSwitchSourceHeader<cr>", { desc = "Switch Source/Header (C/C++)", buffer = bufnr })
require("clangd_extensions.inlay_hints").setup_autocmd()
require("clangd_extensions.inlay_hints").set_inlay_hints()
'';
extraOptions = {
init_options = {
usePlaceholders = true;
completeUnimported = true;
clangdFileStatus = true;
};
};
};
};
clangd-extensions = {
enable = true;
settings = {
inlay_hints.inline = false;
codelens.enable = true;
ast = {
role_icons = {
type = "";
declaration = "";
expression = "";
specifier = "";
statement = "";
templateArgument = "";
};
kind_icons = {
compound = "";
recovery = "";
translationUnit = "";
packExpansion = "";
templateTypeParm = "";
templateTemplateParm = "";
templateParamObject = "";
};
};
};
};
dap = {
adapters.executables.lldb.command = "${pkgs.lldb}/bin/lldb-vscode";
configurations.cpp = [
{
name = "C++";
type = "lldb";
request = "launch";
cwd = "\${workspaceFolder}";
program.__raw = ''
function()
return vim.fn.input('Executable path: ', vim.fn.getcwd() .. '/', 'file')
end
'';
}
];
};
};
}

View File

@@ -0,0 +1,37 @@
{
pkgs,
lib,
...
}: {
plugins = {
conform-nvim.settings = {
formatters_by_ft.css = [
"prettierd"
"prettier"
];
formatters = {
prettierd.command = "${pkgs.prettierd}/bin/prettierd";
prettier.command = "${pkgs.nodePackages.prettier}/bin/prettier";
};
};
lsp.servers = {
cssls = {
enable = true;
cmd = [
"${pkgs.vscode-langservers-extracted}/bin/vscode-css-language-server"
"--stdio"
];
};
tailwindcss = {
enable = true;
cmd = [
(lib.getExe pkgs.tailwindcss-language-server)
"--stdio"
];
};
};
};
}

View File

@@ -0,0 +1,20 @@
{pkgs, ...}: {
plugins = {
lsp.servers = {
dockerls.enable = true;
docker_compose_language_service.enable = true;
};
lint = {
lintersByFt = {
docker = ["hadolint"];
};
linters = {
hadolint = {
cmd = "${pkgs.hadolint}/bin/hadolint";
};
};
};
};
}

View File

@@ -0,0 +1,44 @@
{
pkgs,
lib,
...
}: {
plugins = {
conform-nvim.settings = {
formatters_by_ft.html = [
"prettierd"
"prettier"
];
formatters = {
prettierd.command = "${pkgs.prettierd}/bin/prettierd";
prettier.command = "${pkgs.nodePackages.prettier}/bin/prettier";
};
};
lsp = {
servers = {
html = {
enable = true;
cmd = [
"${pkgs.vscode-langservers-extracted}/bin/vscode-html-language-server"
"--stdio"
];
};
};
enabledServers = [
{
name = "emmet_language_server";
extraOptions = {
cmd = [
(lib.getExe pkgs.emmet-language-server)
"--stdio"
];
filetypes = ["html"];
};
}
];
};
};
}

View File

@@ -0,0 +1,31 @@
{pkgs, ...}: {
plugins = {
conform-nvim.settings = {
formatters_by_ft = {
json = ["jq"];
};
formatters = {
jq = {
command = "${pkgs.jq}/bin/jq";
};
};
};
lint = {
lintersByFt = {
json = ["jsonlint"];
};
linters = {
jsonlint = {
cmd = "${pkgs.nodePackages_latest.jsonlint}/bin/jsonlint";
};
};
};
lsp.servers.jsonls = {
enable = true;
};
};
}

View File

@@ -0,0 +1,22 @@
{pkgs, ...}: {
plugins = {
lsp.servers.lua_ls.enable = true;
conform-nvim.settings = {
formatters_by_ft = {
lua = ["stylua"];
};
formatters = {
stylua = {
command = "${pkgs.stylua}/bin/stylua";
};
};
};
lint = {
lintersByFt.lua = ["luacheck"];
linters.luacheck.cmd = "${pkgs.lua54Packages.luacheck}/bin/luacheck";
};
};
}

View File

@@ -0,0 +1,69 @@
{
lib,
pkgs,
...
}: {
extraPackages = with pkgs; [
marksman
];
plugins = {
clipboard-image = {
enable = true;
clipboardPackage = pkgs.wl-clipboard;
};
image = {
enable = lib.nixvim.enableExceptInTests;
settings.integrations.markdown = {
clearInInsertMode = true;
onlyRenderImageAtCursor = true;
};
};
markdown-preview = {
enable = true;
};
render-markdown = {
enable = true;
};
lsp.servers = {
marksman.enable = true;
ltex = {
enable = true;
filetypes = [
"markdown"
"text"
];
settings.completionEnabled = true;
extraOptions = {
checkFrequency = "save";
language = "en-GB";
};
};
};
# markdownlint-cli2 have problems in build.
# need to try a newer version in future,
# lint = {
# lintersByFt.md = [ "markdownlint-cli2" ];
# linters.markdownlint-cli2.cmd = "${pkgs.markdownlint-cli2}/bin/markdownlint-cli2";
# };
};
keymaps = [
{
mode = "n";
key = "<leader>m";
action = "<cmd>MarkdownPreviewToggle<cr>";
options = {
silent = true;
desc = "Toggle markdown preview";
};
}
];
}

View File

@@ -0,0 +1,49 @@
{pkgs, ...}: let
flake = "/home/atp/System/atpos/";
in {
plugins = {
nix.enable = true;
hmts.enable = true;
nix-develop.enable = true;
conform-nvim.settings = {
formatters_by_ft = {
nix = ["alejandra"];
};
formatters = {
alejandra = {
command = "${pkgs.alejandra}/bin/alejandra";
};
};
};
lint = {
lintersByFt = {
nix = ["statix"];
};
linters = {
statix = {
cmd = "${pkgs.statix}/bin/statix";
};
};
};
lsp.servers.nixd = {
enable = true;
settings = {
nixpkgs.expr = ''import (builtins.getFlake "${flake}").inputs.nixpkgs { }'';
options = {
nixos.expr = ''(builtins.getFlake "${flake}").nixosConfigurations.alfhiem.options'';
home_manager.expr = ''(builtins.getFlake "${flake}").nixosConfigurations.alfhiem.options'';
};
flake_parts.expr = ''let flake = builtins.getFlake ("${flake}"); in flake.debug.options // flake.currentSystem.options'';
};
};
};
extraConfigVim = ''
au BufRead,BufNewFile flake.lock setf json
'';
}

View File

@@ -0,0 +1,44 @@
{pkgs, ...}: {
plugins = {
dap.extensions.dap-python.enable = true;
conform-nvim.settings = {
formatters_by_ft.python = [
"ruff_format"
"ruff_organize_imports"
];
};
lint = {
lintersByFt.python = ["mypy"];
linters.mypy = {
cmd = "${pkgs.mypy}/bin/mypy";
args = ["--ignore-missing-imports"];
};
};
lsp.servers = {
pyright = {
enable = true;
extraOptions.settings = {
# Using Ruff's import organizer
pyright.disableOrganizeImports = true;
python.analysis = {
# Ignore all files for analysis to exclusively use Ruff for linting
ignore.__raw = ''{ '*' }'';
};
};
};
ruff = {
enable = true;
onAttach.function = ''
if client.name == 'ruff' then
-- Disable hover in favor of Pyright
client.server_capabilities.hoverProvider = false
end
'';
};
};
};
}

View File

@@ -0,0 +1,16 @@
{pkgs, ...}: {
plugins = {
conform-nvim.settings = {
formatters_by_ft = {
sh = ["shfmt"];
};
formatters = {
shfmt = {
command = "${pkgs.shfmt}/bin/shfmt";
};
};
};
lsp.servers.bashls.enable = true;
};
}

View File

@@ -0,0 +1,90 @@
{pkgs, ...}: {
plugins = {
conform-nvim.settings = {
formatters_by_ft = {
javascript = ["eslint_d"];
javascriptreact = ["eslint_d"];
typescript = ["eslint_d"];
typescriptreact = ["eslint_d"];
svelte = ["eslint_d"];
};
formatters.eslint_d = {
command = "${pkgs.eslint_d}/bin/eslint_d";
};
};
lsp.servers = {
svelte.enable = true;
eslint = {
enable = true;
filetypes = [
"javascript"
"javascriptreact"
"javascript.jsx"
"typescript"
"typescriptreact"
"typescript.tsx"
"vue"
"html"
"markdown"
"json"
"jsonc"
"yaml"
"toml"
"xml"
"gql"
"graphql"
"svelte"
"css"
"less"
"scss"
"pcss"
"postcss"
];
};
ts_ls = {
enable = true;
filetypes = [
"javascript"
"javascriptreact"
"typescript"
"typescriptreact"
"svelte"
];
settings = {
complete_function_calls = true;
vtsls = {
autoUseWorkspaceTsdk = true;
experimental = {
completion = {
enableServerSideFuzzyMatch = true;
};
};
};
typescript = {
updateImportsOnFileMove.enabled = "always";
suggest = {
completeFunctionCalls = true;
};
inlayHints = {
enumMemberValues.enabled = true;
functionLikeReturnTypes.enabled = true;
parameterNames.enabled = "literals";
parameterTypes.enabled = true;
propertyDeclarationTypes.enabled = true;
variableType.enabled = false;
};
};
};
};
};
ts-autotag.enable = true;
};
}

View File

@@ -0,0 +1,15 @@
{
plugins.lsp.servers.yamlls = {
enable = true;
extraOptions = {
capabilities = {
textDocument = {
foldingRange = {
dynamicRegistration = false;
lineFoldingOnly = true;
};
};
};
};
};
}