1 parent
80ec3dfdd3
commit
079cceb554
57 files changed
+4092
-538
No files matched your search
@@ -31,6 +31,19 @@ in
|
||||
];
|
||||
};
|
||||
|
||||
jujutsu = {
|
||||
enable = true;
|
||||
settings = {
|
||||
user = {
|
||||
name = owner.fullName;
|
||||
inherit (owner) email;
|
||||
};
|
||||
ui = {
|
||||
diff.format = "color-words";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Syntax-highlighted diffs as the git pager.
|
||||
delta = {
|
||||
enable = true;
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
# Neovim (nixpkgs, 0.12) with the owner's configuration repository: inputs.nvim
|
||||
# (git.faumaray.ru faumaray/nvim, pinned in flake.lock; `nix flake update nvim`).
|
||||
# Plugins and colours are the repository's business, not Nix's: its init.lua
|
||||
# bootstraps zpack.nvim with Neovim's own vim.pack, which clones the plugins on
|
||||
# the first start (git, network) into ~/.local/share/nvim/site/pack/core/opt at
|
||||
# the revisions of nvim-pack-lock.json. Stylix's neovim target stays off.
|
||||
#
|
||||
# - ~/.config/nvim is a real directory whose files link read-only into the
|
||||
# pinned repository (recursive), so the configuration cannot drift; plugins
|
||||
# may still add files there (cd-project.nvim does).
|
||||
# - Except nvim-pack-lock.json: vim.pack rewrites it whenever it installs,
|
||||
# repairs or updates a plugin and stops with EROFS on a read-only file (the
|
||||
# pinned lockfile lags behind the plugin specs). It is a writable copy, reset
|
||||
# to the pinned one (the old copy kept as .prev) when the pinned one changes;
|
||||
# the switch then says to run :ZRestore in Neovim.
|
||||
# - A new pin also empties vim.loader's bytecode cache: store files all have
|
||||
# mtime 1, so an edit that keeps a file's size would keep running old code.
|
||||
# - The wrapper appends extraPackages to PATH (--suffix), so inside a dev shell
|
||||
# (modules/dev/shells) the shell's compilers, clangd and rust-analyzer come
|
||||
# first. It carries only what the editor needs everywhere.
|
||||
{ inputs, ... }:
|
||||
{
|
||||
flake.modules.homeManager.neovim =
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
lockName = "nvim-pack-lock.json";
|
||||
|
||||
# The repository without its lockfile, linked file by file.
|
||||
nvimConfig = lib.cleanSourceWith {
|
||||
name = "nvim-config";
|
||||
src = "${inputs.nvim}";
|
||||
filter = path: _type: baseNameOf path != lockName;
|
||||
};
|
||||
|
||||
# codelldb, the debug adapter of nvim-dap and rustaceanvim, from the VS Code
|
||||
# extension: that one is in the binary cache, the standalone
|
||||
# vscode-lldb.adapter attribute is not (it would compile on every update).
|
||||
codelldb = pkgs.runCommandLocal "codelldb" { meta.mainProgram = "codelldb"; } ''
|
||||
adapter=${pkgs.vscode-extensions.vadimcn.vscode-lldb}/share/vscode/extensions/vadimcn.vscode-lldb/adapter/codelldb
|
||||
test -x "$adapter" # fail loudly if the extension layout changes
|
||||
mkdir -p $out/bin
|
||||
ln -s "$adapter" $out/bin/codelldb
|
||||
'';
|
||||
in
|
||||
{
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
defaultEditor = true;
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
|
||||
# home-manager always has an init.lua to write (the wrapper's provider
|
||||
# settings); pass it to nvim with --cmd instead, so ~/.config/nvim/init.lua
|
||||
# stays the repository's.
|
||||
sideloadInitLua = true;
|
||||
|
||||
extraPackages = with pkgs; [
|
||||
# vim.pack clones with git; blink.cmp downloads its fuzzy matcher with
|
||||
# curl and asks cc for the libc; tree-sitter-manager compiles parsers
|
||||
# with the tree-sitter CLI and cc; make for build hooks and :make.
|
||||
git
|
||||
curl
|
||||
gnumake
|
||||
gcc
|
||||
tree-sitter
|
||||
# Pickers (telescope, fzf-lua, snacks) and nvim-dap's executable picker.
|
||||
ripgrep
|
||||
fd
|
||||
fzf
|
||||
# Language tools of the configuration that no project toolchain brings.
|
||||
lua-language-server
|
||||
stylua
|
||||
codespell
|
||||
neocmakelsp
|
||||
cmake-format
|
||||
codelldb
|
||||
devcontainer
|
||||
];
|
||||
};
|
||||
|
||||
xdg.configFile.nvim = {
|
||||
source = nvimConfig;
|
||||
recursive = true;
|
||||
};
|
||||
|
||||
home.activation.nvimPackLock = lib.hm.dag.entryAfter [ "linkGeneration" ] ''
|
||||
nvimPin=${inputs.nvim}
|
||||
nvimLock=${config.xdg.configHome}/nvim/${lockName}
|
||||
nvimState=${config.xdg.stateHome}/nvim
|
||||
nvimLuac=${config.xdg.cacheHome}/nvim/luac
|
||||
|
||||
# A new pinned configuration: empty vim.loader's bytecode cache.
|
||||
if [ "$(cat "$nvimState/nix-config" 2>/dev/null)" != "$nvimPin" ]; then
|
||||
if [ -d "$nvimLuac" ]; then
|
||||
run find "$nvimLuac" -mindepth 1 -delete
|
||||
fi
|
||||
run mkdir -p "$nvimState"
|
||||
run sh -c 'printf "%s\n" "$1" > "$2"' sh "$nvimPin" "$nvimState/nix-config"
|
||||
fi
|
||||
|
||||
# A new pinned lockfile, or no writable copy: start again from the pinned one.
|
||||
if [ -f "$nvimPin/${lockName}" ]; then
|
||||
nvimLockHash=$(sha256sum "$nvimPin/${lockName}" | cut -d' ' -f1)
|
||||
if [ -L "$nvimLock" ] || [ ! -f "$nvimLock" ] ||
|
||||
[ "$(cat "$nvimState/nix-lock" 2>/dev/null)" != "$nvimLockHash" ]; then
|
||||
if [ -f "$nvimLock" ] && [ ! -L "$nvimLock" ]; then
|
||||
run cp -f "$nvimLock" "$nvimLock.prev"
|
||||
echo "neovim: pinned plugin lockfile changed; run :ZRestore (zpack 1.x) or :ZPack restore (2.x) in Neovim"
|
||||
fi
|
||||
run rm -f "$nvimLock"
|
||||
run install -m 0644 "$nvimPin/${lockName}" "$nvimLock"
|
||||
run mkdir -p "$nvimState"
|
||||
run sh -c 'printf "%s\n" "$1" > "$2"' sh "$nvimLockHash" "$nvimState/nix-lock"
|
||||
fi
|
||||
fi
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
# Neovim with LSP, completion, fuzzy finding and format-on-save.
|
||||
# The editor config is in init.lua next to this file. It sets the catppuccin
|
||||
# colorscheme itself, so Stylix's neovim target stays off (modules/theme/stylix.nix).
|
||||
{
|
||||
flake.modules.homeManager.neovim =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
defaultEditor = true;
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
|
||||
plugins = with pkgs.vimPlugins; [
|
||||
nvim-treesitter.withAllGrammars
|
||||
nvim-lspconfig
|
||||
blink-cmp
|
||||
telescope-nvim
|
||||
telescope-fzf-native-nvim
|
||||
plenary-nvim
|
||||
lualine-nvim
|
||||
gitsigns-nvim
|
||||
which-key-nvim
|
||||
oil-nvim
|
||||
conform-nvim
|
||||
catppuccin-nvim
|
||||
nvim-web-devicons
|
||||
mini-nvim
|
||||
];
|
||||
|
||||
# Language servers, formatters and search tools, visible to nvim only.
|
||||
extraPackages = with pkgs; [
|
||||
nixd
|
||||
nixfmt
|
||||
lua-language-server
|
||||
stylua
|
||||
bash-language-server
|
||||
shfmt
|
||||
ripgrep
|
||||
fd
|
||||
];
|
||||
|
||||
initLua = builtins.readFile ./init.lua;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
-- Plugins are installed by Nix (see default.nix); this file only configures them.
|
||||
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = " "
|
||||
|
||||
-----------------
|
||||
---- OPTIONS ----
|
||||
-----------------
|
||||
|
||||
local o = vim.opt
|
||||
o.number = true
|
||||
o.relativenumber = true
|
||||
o.signcolumn = "yes"
|
||||
o.cursorline = true
|
||||
o.termguicolors = true
|
||||
o.mouse = "a"
|
||||
o.clipboard = "unnamedplus"
|
||||
o.undofile = true
|
||||
o.ignorecase = true
|
||||
o.smartcase = true
|
||||
o.splitright = true
|
||||
o.splitbelow = true
|
||||
o.scrolloff = 8
|
||||
o.updatetime = 250
|
||||
o.timeoutlen = 400
|
||||
o.expandtab = true
|
||||
o.shiftwidth = 2
|
||||
o.tabstop = 2
|
||||
o.smartindent = true
|
||||
o.wrap = false
|
||||
o.list = true
|
||||
o.listchars = { tab = "» ", trail = "·", nbsp = "␣" }
|
||||
o.inccommand = "split"
|
||||
|
||||
---------------------
|
||||
---- COLORSCHEME ----
|
||||
---------------------
|
||||
|
||||
require("catppuccin").setup({ flavour = "mocha" })
|
||||
vim.cmd.colorscheme("catppuccin")
|
||||
|
||||
require("nvim-web-devicons").setup()
|
||||
require("lualine").setup({ options = { theme = "catppuccin-mocha", globalstatus = true } })
|
||||
require("gitsigns").setup()
|
||||
require("which-key").setup()
|
||||
require("oil").setup()
|
||||
|
||||
-- mini.nvim: only the small editing helpers.
|
||||
require("mini.pairs").setup()
|
||||
require("mini.surround").setup()
|
||||
|
||||
--------------------
|
||||
---- TREESITTER ----
|
||||
--------------------
|
||||
|
||||
-- Parsers come from nvim-treesitter.withAllGrammars. Starting the built-in
|
||||
-- highlighter works with both the old and the rewritten nvim-treesitter.
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
callback = function(args)
|
||||
pcall(vim.treesitter.start, args.buf)
|
||||
end,
|
||||
})
|
||||
|
||||
--------------------
|
||||
---- TELESCOPE ----
|
||||
--------------------
|
||||
|
||||
local telescope = require("telescope")
|
||||
telescope.setup({})
|
||||
pcall(telescope.load_extension, "fzf")
|
||||
|
||||
local builtin = require("telescope.builtin")
|
||||
vim.keymap.set("n", "<leader>ff", builtin.find_files, { desc = "Find files" })
|
||||
vim.keymap.set("n", "<leader>fg", builtin.live_grep, { desc = "Grep" })
|
||||
vim.keymap.set("n", "<leader>fb", builtin.buffers, { desc = "Buffers" })
|
||||
vim.keymap.set("n", "<leader>fh", builtin.help_tags, { desc = "Help" })
|
||||
vim.keymap.set("n", "<leader>fr", builtin.oldfiles, { desc = "Recent files" })
|
||||
|
||||
vim.keymap.set("n", "-", "<cmd>Oil<cr>", { desc = "File explorer" })
|
||||
|
||||
-------------
|
||||
---- LSP ----
|
||||
-------------
|
||||
|
||||
-- Neovim 0.11+ API. nvim-lspconfig supplies the default cmd, filetypes and
|
||||
-- root markers for each server; the language servers are on nvim's PATH
|
||||
-- (extraPackages in default.nix).
|
||||
require("blink.cmp").setup({
|
||||
keymap = { preset = "default" },
|
||||
sources = { default = { "lsp", "path", "snippets", "buffer" } },
|
||||
})
|
||||
|
||||
vim.lsp.config("*", {
|
||||
capabilities = require("blink.cmp").get_lsp_capabilities(),
|
||||
})
|
||||
|
||||
vim.lsp.config("nixd", {
|
||||
settings = {
|
||||
nixd = {
|
||||
formatting = { command = { "nixfmt" } },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
vim.lsp.config("lua_ls", {
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = { version = "LuaJIT" },
|
||||
diagnostics = { globals = { "vim", "hl" } },
|
||||
workspace = { checkThirdParty = false },
|
||||
telemetry = { enable = false },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
vim.lsp.enable({ "nixd", "lua_ls", "bashls" })
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(args)
|
||||
local function map(lhs, rhs, desc)
|
||||
vim.keymap.set("n", lhs, rhs, { buffer = args.buf, desc = desc })
|
||||
end
|
||||
map("gd", vim.lsp.buf.definition, "Go to definition")
|
||||
map("gr", vim.lsp.buf.references, "References")
|
||||
map("K", vim.lsp.buf.hover, "Hover")
|
||||
map("<leader>rn", vim.lsp.buf.rename, "Rename")
|
||||
map("<leader>ca", vim.lsp.buf.code_action, "Code action")
|
||||
map("<leader>e", vim.diagnostic.open_float, "Line diagnostics")
|
||||
end,
|
||||
})
|
||||
|
||||
vim.diagnostic.config({ virtual_text = true, severity_sort = true })
|
||||
|
||||
-----------------------
|
||||
---- FORMAT ON SAVE ----
|
||||
-----------------------
|
||||
|
||||
require("conform").setup({
|
||||
formatters_by_ft = {
|
||||
nix = { "nixfmt" },
|
||||
lua = { "stylua" },
|
||||
sh = { "shfmt" },
|
||||
bash = { "shfmt" },
|
||||
},
|
||||
format_on_save = {
|
||||
timeout_ms = 1000,
|
||||
lsp_format = "fallback",
|
||||
},
|
||||
})
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
shellAliases = {
|
||||
cat = "bat";
|
||||
claude = "claude --dangerously-skip-permissions";
|
||||
".." = "cd ..";
|
||||
g = "git";
|
||||
# nh builds, diffs and activates the flake in one step.
|
||||
|
||||
Reference in new issue
Block a user