Feat/neovim #22
@@ -9,6 +9,7 @@ rebuild, never the generated dotfiles.
|
|||||||
| Sway (compositor) | [`sway.nix`](./sway.nix) `config.keybindings` + `config.modes`, plus the home-manager Sway module's built-in defaults |
|
| Sway (compositor) | [`sway.nix`](./sway.nix) `config.keybindings` + `config.modes`, plus the home-manager Sway module's built-in defaults |
|
||||||
| tmux | [`shell.nix`](./shell.nix) `programs.tmux` |
|
| tmux | [`shell.nix`](./shell.nix) `programs.tmux` |
|
||||||
| zsh line editor | [`shell.nix`](./shell.nix) `programs.zsh.historySubstringSearch` |
|
| zsh line editor | [`shell.nix`](./shell.nix) `programs.zsh.historySubstringSearch` |
|
||||||
|
| Neovim | [`editor.nix`](./editor.nix) `programs.nixvim` |
|
||||||
| foot (terminal) | foot package defaults — only colours are themed (in `sway.nix`) |
|
| foot (terminal) | foot package defaults — only colours are themed (in `sway.nix`) |
|
||||||
|
|
||||||
**Conventions**
|
**Conventions**
|
||||||
@@ -167,6 +168,26 @@ Only colours are themed; these are foot's default key bindings.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Neovim
|
||||||
|
|
||||||
|
Leader is **`Space`**. `Ctrl`+`h/j/k/l` is shared with tmux (see above): it moves
|
||||||
|
across vim splits and tmux panes seamlessly. Everything else is stock vim, plus:
|
||||||
|
|
||||||
|
| Shortcut | Action |
|
||||||
|
| ---------------------- | --------------------------------------------------------- |
|
||||||
|
| `,``,` | Toggle the file tree (nvim-tree) — comma pressed twice |
|
||||||
|
| `Ctrl`+`h`/`j`/`k`/`l` | Move between vim splits / tmux panes (vim-tmux-navigator) |
|
||||||
|
| `gd` | Go to definition (LSP) |
|
||||||
|
| `gr` | List references (LSP) |
|
||||||
|
| `K` | Hover documentation (LSP) |
|
||||||
|
| `<leader>rn` | Rename symbol (LSP; `<leader>` is `Space`) |
|
||||||
|
| `<leader>ca` | Code action (LSP) |
|
||||||
|
|
||||||
|
LSP covers Nix, Lua, Python and Terraform (the work box adds C# and Helm);
|
||||||
|
completion (nvim-cmp) appears as you type. `:Git` opens fugitive.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## zsh
|
## zsh
|
||||||
|
|
||||||
| Shortcut | Action |
|
| Shortcut | Action |
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ Keyboard shortcuts have their own reference: [`KEYBINDINGS.md`](./KEYBINDINGS.md
|
|||||||
| ------------------------------------- | ----------------------------------------------------- |
|
| ------------------------------------- | ----------------------------------------------------- |
|
||||||
| zsh, CLI tools, tmux, ssh, auto-tmux | [`shell.nix`](./shell.nix) |
|
| zsh, CLI tools, tmux, ssh, auto-tmux | [`shell.nix`](./shell.nix) |
|
||||||
| git (+ delta, commitizen) | [`git.nix`](./git.nix) |
|
| git (+ delta, commitizen) | [`git.nix`](./git.nix) |
|
||||||
| vim | [`editor.nix`](./editor.nix) |
|
| Neovim (nixvim) + LSP | [`editor.nix`](./editor.nix) |
|
||||||
| GUI apps, GTK/Firefox theming, cursor | [`desktop.nix`](./desktop.nix) (graphical hosts only) |
|
| GUI apps, GTK/Firefox theming, cursor | [`desktop.nix`](./desktop.nix) (graphical hosts only) |
|
||||||
|
|
||||||
Shared by every host via [`default.nix`](./default.nix); the work box also layers
|
Shared by every host via [`default.nix`](./default.nix); the work box also layers
|
||||||
[`../../system/modules/work/default.nix`](../../system/modules/work/default.nix)
|
[`work.nix`](./work.nix) on top (work email, its own ssh config, extra packages,
|
||||||
on top (work email, its own ssh config, extra packages).
|
and the C#/Helm language servers).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -53,8 +53,9 @@ on top (work email, its own ssh config, extra packages).
|
|||||||
driven from the shared `../catppuccin-mocha.nix` palette / the catppuccin/bat
|
driven from the shared `../catppuccin-mocha.nix` palette / the catppuccin/bat
|
||||||
theme.
|
theme.
|
||||||
|
|
||||||
**Env & defaults:** `xdg.enable` on; `PAGER`/`MANPAGER` (bat)/`VISUAL` set in
|
**Env & defaults:** `xdg.enable` on; `PAGER`/`MANPAGER` (bat) set in `default.nix`
|
||||||
`default.nix`; `xdg.mimeApps` maps web→Firefox, directories→nemo (`desktop.nix`).
|
(the editor owns `$EDITOR`/`$VISUAL`); `xdg.mimeApps` maps web→Firefox,
|
||||||
|
directories→nemo (`desktop.nix`).
|
||||||
|
|
||||||
## tmux
|
## tmux
|
||||||
|
|
||||||
@@ -90,6 +91,32 @@ Darwin config). foot uses it as its main font automatically. iTerm2's font is a
|
|||||||
GUI setting — set it to _JetBrainsMono Nerd Font_ (Settings → Profiles → Text →
|
GUI setting — set it to _JetBrainsMono Nerd Font_ (Settings → Profiles → Text →
|
||||||
Font) so the tmux statusline glyphs render instead of `?`.
|
Font) so the tmux statusline glyphs render instead of `?`.
|
||||||
|
|
||||||
|
## Editor (Neovim)
|
||||||
|
|
||||||
|
`nvim` — aliased to `vi`/`vim`, and set as `$EDITOR`/`$VISUAL` — is configured
|
||||||
|
declaratively with **nixvim**, so the same plugins and config are baked in on
|
||||||
|
every host. Migrated from plain vim; the practical gain is a real LSP stack in
|
||||||
|
place of the old (inert) ALE.
|
||||||
|
|
||||||
|
| Feature | Notes |
|
||||||
|
| ------------- | -------------------------------------------------------------------------------------- |
|
||||||
|
| Colorscheme | Catppuccin Mocha (matches the terminal and the rest of the desktop) |
|
||||||
|
| File tree | nvim-tree, toggled with `,,` (comma twice; was nerdtree) |
|
||||||
|
| Indent guides | indent-blankline, on by default (was vim-indent-guides) |
|
||||||
|
| Git | fugitive (`:Git …`) |
|
||||||
|
| Pane nav | vim-tmux-navigator — `Ctrl`+`h/j/k/l` moves across vim splits and tmux panes |
|
||||||
|
| Syntax | tree-sitter (nix, lua, bash, markdown, groovy) — replaces `syntax enable` |
|
||||||
|
| LSP | nvim-cmp completion + servers `nil` (Nix), `lua_ls`, `pyright` (Python), `terraformls` |
|
||||||
|
| Indentation | 2-wide hard tabs (`noexpandtab`, `tabstop`/`shiftwidth` = 2); line numbers on |
|
||||||
|
| Filetypes | `*Jenkinsfile` → groovy |
|
||||||
|
|
||||||
|
Leader is `Space`. LSP keymaps (`gd`, `gr`, `K`, `<leader>rn`, `<leader>ca`) and
|
||||||
|
the file-tree toggle are listed in
|
||||||
|
[`KEYBINDINGS.md`](./KEYBINDINGS.md#neovim). Add a universal language server by
|
||||||
|
enabling it under `programs.nixvim.plugins.lsp.servers` in `editor.nix`;
|
||||||
|
host-specific ones go in that host's module — the work box (`work.nix`) adds
|
||||||
|
`omnisharp` (C#) and `helm_ls` (Helm), kept off the personal machines.
|
||||||
|
|
||||||
## git
|
## git
|
||||||
|
|
||||||
Pager is **delta**. **commitizen** is installed on every host; `cz` defaults to
|
Pager is **delta**. **commitizen** is installed on every host; `cz` defaults to
|
||||||
|
|||||||
@@ -15,11 +15,10 @@
|
|||||||
# defaults match the conventional ~/.config, ~/.cache, ~/.local/share.
|
# defaults match the conventional ~/.config, ~/.cache, ~/.local/share.
|
||||||
xdg.enable = true;
|
xdg.enable = true;
|
||||||
|
|
||||||
# Editor itself comes from vim.defaultEditor (sets $EDITOR). Round out the
|
# Editor ($EDITOR and $VISUAL) comes from nixvim's defaultEditor (editor.nix).
|
||||||
# rest of the standard env. desktop.nix adds its own Wayland session vars;
|
# Round out the rest of the standard env. desktop.nix adds its own Wayland
|
||||||
# home-manager merges the two attrsets, so these do not clash.
|
# session vars; home-manager merges the two attrsets, so these do not clash.
|
||||||
home.sessionVariables = {
|
home.sessionVariables = {
|
||||||
VISUAL = "vim";
|
|
||||||
PAGER = "less -FRX"; # -F quit-if-one-screen, -R raw colour, -X no clear
|
PAGER = "less -FRX"; # -F quit-if-one-screen, -R raw colour, -X no clear
|
||||||
# Render man pages through bat (themed): col strips backspace overstrike,
|
# Render man pages through bat (themed): col strips backspace overstrike,
|
||||||
# bat -l man -p highlights without its own pager decorations.
|
# bat -l man -p highlights without its own pager decorations.
|
||||||
|
|||||||
+100
-20
@@ -1,29 +1,109 @@
|
|||||||
# Editor: vim as the default $EDITOR. Wanted on every host.
|
# Editor: Neovim via nixvim. Migrated from plain vim with feature parity (file
|
||||||
{ pkgs, ... }:
|
# tree, indent guides, fugitive, tmux-navigator, Catppuccin Mocha, 2-space hard
|
||||||
|
# tabs, Jenkinsfile=groovy) plus a real LSP stack in place of the inert ALE.
|
||||||
|
# Wanted on every host; vi/vim/$EDITOR all launch nvim.
|
||||||
|
{ inputs, ... }:
|
||||||
{
|
{
|
||||||
programs.vim = {
|
imports = [ inputs.nixvim.homeModules.nixvim ];
|
||||||
|
|
||||||
|
programs.nixvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
viAlias = true;
|
||||||
|
vimAlias = true;
|
||||||
defaultEditor = true;
|
defaultEditor = true;
|
||||||
plugins = with pkgs.vimPlugins; [
|
|
||||||
nerdtree
|
# Build against our (followed) nixpkgs; set explicitly so the module doesn't
|
||||||
ale
|
# warn that its pinned nixpkgs was overridden by the input `follows`.
|
||||||
vim-fugitive
|
nixpkgs.source = inputs.nixpkgs;
|
||||||
vim-indent-guides
|
|
||||||
catppuccin-vim
|
globals.mapleader = " ";
|
||||||
vim-tmux-navigator # Ctrl-h/j/k/l moves between vim splits and tmux panes
|
|
||||||
];
|
opts = {
|
||||||
settings = {
|
|
||||||
expandtab = false;
|
expandtab = false;
|
||||||
tabstop = 2;
|
tabstop = 2;
|
||||||
shiftwidth = 2;
|
shiftwidth = 2;
|
||||||
|
termguicolors = true;
|
||||||
|
background = "dark";
|
||||||
|
number = true;
|
||||||
};
|
};
|
||||||
extraConfig = ''
|
|
||||||
let g:indent_guides_enable_on_vim_startup = 1
|
colorschemes.catppuccin = {
|
||||||
syntax enable
|
enable = true;
|
||||||
set termguicolors
|
settings.flavour = "mocha";
|
||||||
set background=dark
|
};
|
||||||
colorscheme catppuccin_mocha
|
|
||||||
au BufNewFile,BufRead *Jenkinsfile setf groovy
|
plugins = {
|
||||||
'';
|
nvim-tree.enable = true; # file explorer (was nerdtree)
|
||||||
|
web-devicons.enable = true; # nvim-tree icons (explicit; else auto-enabled with a warning)
|
||||||
|
indent-blankline.enable = true; # indent guides (was vim-indent-guides)
|
||||||
|
fugitive.enable = true; # git (was vim-fugitive)
|
||||||
|
tmux-navigator.enable = true; # Ctrl-h/j/k/l across vim splits and tmux panes
|
||||||
|
|
||||||
|
# Highlighting/indent — the Neovim-native replacement for `syntax enable`.
|
||||||
|
treesitter = {
|
||||||
|
enable = true;
|
||||||
|
settings.ensure_installed = [
|
||||||
|
"nix"
|
||||||
|
"lua"
|
||||||
|
"bash"
|
||||||
|
"markdown"
|
||||||
|
"groovy"
|
||||||
|
"c_sharp" # C#
|
||||||
|
"python"
|
||||||
|
"terraform" # also covers HCL
|
||||||
|
"yaml" # Helm chart templates/values
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# LSP + completion, replacing the (inert) ALE.
|
||||||
|
lsp = {
|
||||||
|
enable = true;
|
||||||
|
# Universal servers. Host-specific ones are enabled in their own module:
|
||||||
|
# C# (omnisharp) and Helm (helm_ls) live in work.nix (EDaaS only).
|
||||||
|
servers = {
|
||||||
|
nil_ls.enable = true; # Nix
|
||||||
|
lua_ls.enable = true; # Lua (editing this config)
|
||||||
|
pyright.enable = true; # Python
|
||||||
|
terraformls.enable = true; # Terraform
|
||||||
|
};
|
||||||
|
keymaps.lspBuf = {
|
||||||
|
gd = "definition";
|
||||||
|
gr = "references";
|
||||||
|
K = "hover";
|
||||||
|
"<leader>rn" = "rename";
|
||||||
|
"<leader>ca" = "code_action";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
cmp = {
|
||||||
|
enable = true;
|
||||||
|
autoEnableSources = true;
|
||||||
|
settings.sources = [
|
||||||
|
{ name = "nvim_lsp"; }
|
||||||
|
{ name = "buffer"; }
|
||||||
|
{ name = "path"; }
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
keymaps = [
|
||||||
|
{
|
||||||
|
mode = "n";
|
||||||
|
key = ",,";
|
||||||
|
action = "<cmd>NvimTreeToggle<cr>";
|
||||||
|
options.desc = "Toggle file tree";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
# au BufNewFile,BufRead *Jenkinsfile setf groovy
|
||||||
|
autoCmd = [
|
||||||
|
{
|
||||||
|
event = [
|
||||||
|
"BufNewFile"
|
||||||
|
"BufRead"
|
||||||
|
];
|
||||||
|
pattern = [ "*Jenkinsfile" ];
|
||||||
|
command = "setf groovy";
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,4 +52,13 @@
|
|||||||
programs.go = {
|
programs.go = {
|
||||||
enable = true;
|
enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# LSP servers only relevant to work: C# (omnisharp) and Helm charts (helm_ls).
|
||||||
|
# The shared editor (lyrathorpe/home/editor.nix) carries the universal ones;
|
||||||
|
# these are gated to this host so the heavy omnisharp closure stays off the
|
||||||
|
# personal machines. Tree-sitter grammars (highlighting) remain global there.
|
||||||
|
programs.nixvim.plugins.lsp.servers = {
|
||||||
|
omnisharp.enable = true;
|
||||||
|
helm_ls.enable = true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user