diff options
| author | Martin Fischer <martin@push-f.com> | 2026-10-10 12:25:43 +0200 |
|---|---|---|
| committer | Martin Fischer <martin@push-f.com> | 2026-10-10 19:54:55 +0200 |
| commit | b657343b58adb1d4a8ab7f648c9683c4b1d67128 (patch) | |
| tree | d090705d544c619ba015058b1535d38bc15787ae | |
| parent | d51c60c30e7f67e644db0bc5eadea9f0392481ca (diff) | |
tweak(workstation): use neovim instead of vim
| -rw-r--r-- | nixos/profiles/common/basics.nix | 2 | ||||
| -rw-r--r-- | nixos/profiles/server/default.nix | 4 | ||||
| -rw-r--r-- | nixos/profiles/workstation/default.nix | 5 | ||||
| -rw-r--r-- | nixos/profiles/workstation/doc.nix | 16 | ||||
| -rw-r--r-- | nixos/profiles/workstation/pkgs/nvim.nix | 23 | ||||
| -rw-r--r-- | user/nvim/after/ftplugin/markdown.lua | 5 | ||||
| -rw-r--r-- | user/nvim/after/ftplugin/nix.lua | 7 | ||||
| -rw-r--r-- | user/nvim/after/ftplugin/svelte.lua | 7 | ||||
| -rw-r--r-- | user/nvim/after/ftplugin/typescript.lua | 7 | ||||
| -rw-r--r-- | user/nvim/init.lua | 32 | ||||
| -rw-r--r-- | user/vim/ftdetect/djot.vim | 1 | ||||
| -rw-r--r-- | user/vim/syntax/djot.vim | 85 | ||||
| -rw-r--r-- | user/vim/syntax/jjdescription.vim | 31 | ||||
| -rw-r--r-- | user/vim/vimrc | 26 |
14 files changed, 103 insertions, 148 deletions
diff --git a/nixos/profiles/common/basics.nix b/nixos/profiles/common/basics.nix index 7facee9..afbeb7b 100644 --- a/nixos/profiles/common/basics.nix +++ b/nixos/profiles/common/basics.nix @@ -3,8 +3,6 @@ { environment.systemPackages = with pkgs; [ git - # lowPrio because we use vim-full in the workstation profile - (lib.lowPrio vim) file htop diff --git a/nixos/profiles/server/default.nix b/nixos/profiles/server/default.nix index 6e744a6..fbdb9da 100644 --- a/nixos/profiles/server/default.nix +++ b/nixos/profiles/server/default.nix @@ -6,6 +6,10 @@ ./detect-hostname-change.nix ]; + environment.systemPackages = with pkgs; [ + vim + ]; + services = { openssh = { enable = true; diff --git a/nixos/profiles/workstation/default.nix b/nixos/profiles/workstation/default.nix index d77d67d..cf1f883 100644 --- a/nixos/profiles/workstation/default.nix +++ b/nixos/profiles/workstation/default.nix @@ -4,6 +4,7 @@ let cfg = config.workstation; sources = import <top/npins>; cmd50 = pkgs.callPackage (sources.my-cmd50 { inherit pkgs; }) {}; + nvim = import ./pkgs/nvim.nix { inherit pkgs; }; in { options.workstation = { @@ -19,7 +20,7 @@ in ./firefox.nix ./dev.nix ./create.nix - ./doc.nix + (import ./doc.nix { inherit config pkgs pkgs-unstable nvim; }) ./llm.nix ]; @@ -75,7 +76,7 @@ in (callPackage (sources.my-vdf { inherit pkgs; }) {}) nixfmt - vim-full + nvim cmd50 (writeShellScriptBin "xdg-open" '' diff --git a/nixos/profiles/workstation/doc.nix b/nixos/profiles/workstation/doc.nix index 1c29ed1..b8721a7 100644 --- a/nixos/profiles/workstation/doc.nix +++ b/nixos/profiles/workstation/doc.nix @@ -8,7 +8,7 @@ config, pkgs, pkgs-unstable, - ... + nvim, }: let @@ -18,10 +18,24 @@ let --strip-components=2 --directory $out \ --wildcards '*/Documentation/*.adoc' ''; + + nvimPluginDocs = pkgs.runCommand "nvim-plugin-docs" { } '' + mkdir -p $out + ${pkgs.lib.concatMapStringsSep "\n" (plugin: '' + pluginOut="$out/${pkgs.lib.getName plugin}" + find ${plugin} -path '*/doc/*.txt' -type f | while IFS= read -r file; do + mkdir -p "$pluginOut" + ln -s "$file" "$pluginOut/$(basename "$file")" + done + '') nvim.plugins} + ''; + symlinks = { nix = "${config.nix.package.src}/doc/manual/source"; git = "${gitDocs}"; jj = "${pkgs.jujutsu.src}/docs"; + nvim = "${pkgs.neovim-unwrapped}/share/nvim/runtime/doc"; + nvim-plugins = "${nvimPluginDocs}"; pi = "${pkgs-unstable.pi-coding-agent}/lib/node_modules/pi-monorepo/docs"; }; in diff --git a/nixos/profiles/workstation/pkgs/nvim.nix b/nixos/profiles/workstation/pkgs/nvim.nix new file mode 100644 index 0000000..0961b4d --- /dev/null +++ b/nixos/profiles/workstation/pkgs/nvim.nix @@ -0,0 +1,23 @@ +{ pkgs }: + +# Using the unstable wrapper because it honors `wrapRc = false`, +# which `neovim.override` and `wrapNeovim` disregard (they always set VIMINIT). +pkgs.wrapNeovimUnstable pkgs.neovim-unwrapped { + vimAlias = true; + wrapRc = false; + + plugins = with pkgs.vimPlugins; [ + mini-pick + vscode-nvim + # neovim has no syntax highlighting for Svelte by default + # and nvim-treesitter also provides good auto-indentation. + (nvim-treesitter.withPlugins (p: with p; [ + css + html + javascript + nix + svelte + typescript + ])) + ]; +} diff --git a/user/nvim/after/ftplugin/markdown.lua b/user/nvim/after/ftplugin/markdown.lua new file mode 100644 index 0000000..9909541 --- /dev/null +++ b/user/nvim/after/ftplugin/markdown.lua @@ -0,0 +1,5 @@ +-- Shortcut for Hugo TOML frontmatter. +vim.keymap.set('n', '<C-f>', 'i+++<CR>title = ""<CR>+++<CR><Esc>kk$i', { + buffer = true, + desc = 'Insert Hugo TOML frontmatter', +}) diff --git a/user/nvim/after/ftplugin/nix.lua b/user/nvim/after/ftplugin/nix.lua new file mode 100644 index 0000000..af99d8d --- /dev/null +++ b/user/nvim/after/ftplugin/nix.lua @@ -0,0 +1,7 @@ +vim.opt_local.expandtab = true +vim.opt_local.shiftwidth = 2 +vim.opt_local.softtabstop = 2 +vim.opt_local.tabstop = 2 + +vim.treesitter.start() +vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" diff --git a/user/nvim/after/ftplugin/svelte.lua b/user/nvim/after/ftplugin/svelte.lua new file mode 100644 index 0000000..af99d8d --- /dev/null +++ b/user/nvim/after/ftplugin/svelte.lua @@ -0,0 +1,7 @@ +vim.opt_local.expandtab = true +vim.opt_local.shiftwidth = 2 +vim.opt_local.softtabstop = 2 +vim.opt_local.tabstop = 2 + +vim.treesitter.start() +vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" diff --git a/user/nvim/after/ftplugin/typescript.lua b/user/nvim/after/ftplugin/typescript.lua new file mode 100644 index 0000000..af99d8d --- /dev/null +++ b/user/nvim/after/ftplugin/typescript.lua @@ -0,0 +1,7 @@ +vim.opt_local.expandtab = true +vim.opt_local.shiftwidth = 2 +vim.opt_local.softtabstop = 2 +vim.opt_local.tabstop = 2 + +vim.treesitter.start() +vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" diff --git a/user/nvim/init.lua b/user/nvim/init.lua new file mode 100644 index 0000000..2874c1d --- /dev/null +++ b/user/nvim/init.lua @@ -0,0 +1,32 @@ +-- Don't break words in the middle. +vim.opt.linebreak = true + +-- Use the system clipboard. +vim.opt.clipboard = "unnamedplus" + +-- Ignore case in search unless the pattern contains uppercase. +vim.opt.ignorecase = true +vim.opt.smartcase = true + +-- Color scheme +require('vscode').setup({ + -- Enable transparent background. + transparent = true, +}) +vim.cmd.colorscheme "vscode" + +-- File picker +local pick = require('mini.pick') +-- Disable icons in mini.pick (my font doesn't have them). +pick.setup({ source = { show = pick.default_show } }) +-- Reuse Neovim's popup-menu selection color for mini.pick's selected item. +vim.api.nvim_set_hl(0, 'MiniPickMatchCurrent', { link = 'PmenuSel' }) + +-- Keyboard shortcuts + +-- Clear search highlighting with Escape. +vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>', { desc = 'Clear search highlight' }) + +vim.keymap.set('n', '<C-p>', function() + pick.builtin.files() +end, { desc = 'Pick files' }) diff --git a/user/vim/ftdetect/djot.vim b/user/vim/ftdetect/djot.vim deleted file mode 100644 index bcb5082..0000000 --- a/user/vim/ftdetect/djot.vim +++ /dev/null @@ -1 +0,0 @@ -au BufNewFile,BufRead *.dj set filetype=djot diff --git a/user/vim/syntax/djot.vim b/user/vim/syntax/djot.vim deleted file mode 100644 index 6ec3816..0000000 --- a/user/vim/syntax/djot.vim +++ /dev/null @@ -1,85 +0,0 @@ -" Vim syntax file -" Language: Djot -" Maintainer: John MacFarlane -" Latest Revision: 2022-10-06 - -if exists("b:current_syntax") - finish -endif - -syn match heading '^##* .*$' -syn match blockquote '^\s*>\%(\s\|$\)' - -syn region math matchgroup=delimiter skip='[^`]{1,}' start='[$][$]\?\z(``*\)' end='\z1\|^\s*$' -syn region codespan matchgroup=delimiter skip='[^`]{1,}' start='\z(``*\)' end='\z1\|^\s*$' - -syn region comment matchgroup=delimiter start='%' end='%' contained -syn region string start='"' end='"' skip='\\"' -syn region attributes matchgroup=delimiter start="{[^\[\]_*'\"=\\+-]\@=" end="}" contains=string,comment - -syn region emphasis matchgroup=delimiter start='_[^[:blank:]}]\@=\|{_' end='_}\|[^[:blank:]{]\@=_\|^\s*$' contains=@inline -syn region strong matchgroup=delimiter start='\*[^[:blank:]}]\@=\|{\*' end='[^[:blank:]{]\@=\*\|\*}\|^\s*$' contains=@inline - -syn region superscript matchgroup=delimiter start='\^[^[:blank:]}]\@=\|{\^' end='\^}\|[^[:blank:]{]\@=\^\|^\s*$' contains=@inline -syn region subscript matchgroup=delimiter start='\~[^[:blank:]}]\@=\|{\~' end='\~}\|[^[:blank:]{]\@=\~\|^\s*$' contains=@inline - -syn region highlight matchgroup=delimiter start='{=' end='=}\|^\s*$' contains=@inline -syn match rawattribute "`\@<={=[A-Za-z0-9]*}" - -syn region insert matchgroup=delimiter start='{+' end='+}\|^\s*$' contains=@inline -syn region delete matchgroup=delimiter start='{-' end='-}\|^\s*$' contains=@inline - -syn match inlinelink '\[\%([^\]\\]\|\\[\]\\]\|[\r\n]\)*\](\%([^)\\]\|\\[)\\]\)*)' contains=@inline transparent -syn match linkurl '(\%([^)\\]\|\\[)\\]\)*)'hs=s+1,he=e-1 containedin=inlinelink contained - -syn match referencelink '\[\%([^\]\\]\|\\[\]\\]\|[\r\n]\)*\]\[\%([^]\\]\|\\[]\\]\)*\]' contains=@inline transparent -syn match linklabel '\]\zs\[\%([^]\\]\|\\[]\\]\)*\]'hs=s+1,he=e-1 containedin=referencelink contained - -syn match span '\[\%([^\]\\]\|\\[\]\\]\|[\r\n]\)*\][{]\@=' contains=@inline transparent - -syn match footnoteref '\[\^[^]]*\]' - -syn match openbrace /[{]["']/he=e-1 -syn match closebrace /["'][}]/hs=s+1 - -syn match emoji ':[a-zA-Z0-9_+-]\+:' - -syn match escape '\\[\r\n ~!@#$%^&*(){}`\[\]/=\\?+|\'",<-]'he=e-1 - -syn region djotautolinkurl matchgroup=delimiter start=/</ end=/>/ - -syn cluster inline contains=linkurl,emphasis,strong,codespan,attributes,rawattribute,insert,delete,superscript,subscript,highlight,math,smartquote,openbrace,closebrace,emoji,escape,footnoteref,span - -syn region codeblock matchgroup=delimiter start='^\s*\z(````*\)\s*=\?\w*\s*$' end='^\s*\z1`*\s*$' - -hi emphasis term=italic cterm=italic gui=italic -hi strong term=bold cterm=bold gui=bold -hi def link insert Todo -hi def link delete Error -hi def link superscript Statement -hi def link subscript Statement -hi def link highlight Todo -hi def link heading Label -hi def link codespan Tag -hi def link math Statement -hi def link emoji Statement -hi def link span Statement -hi def link codeblock Tag -hi def link string String -hi def link inlinelink Typedef -hi def link footnoteref Statement -hi def link linkurl Underlined -hi def link djotautolinkurl Underlined -hi def link comment Comment -hi def link linklabel Underlined -hi def link escaped Typedef -hi def link attributes Identifier -hi def link rawattribute Identifier -hi def link delimiter Ignore -hi def link escape Ignore -hi def link openbrace Ignore -hi def link closebrace Ignore -hi def link blockquote Comment - -let b:current_syntax = "djot" - diff --git a/user/vim/syntax/jjdescription.vim b/user/vim/syntax/jjdescription.vim deleted file mode 100644 index ddbdfd5..0000000 --- a/user/vim/syntax/jjdescription.vim +++ /dev/null @@ -1,31 +0,0 @@ -" workaround for https://github.com/vim/vim/commit/86dcb1878cdbd0a8af61664b14f034398e319026 -" FUTURE: delete this file when updating to vim >=v9.2.0341 -" Vim syntax file -" Language: jj description -" Maintainer: Gregory Anders <greg@gpanders.com> -" Last Change: 2024 May 8 -" 2025 Apr 17 by Vim Project (don't require space to start comments, #17130) -" 2026 Apr 09 by Vim Project (anchor status regex to beginning of line, #19879) -" 2026 Apr 09 by Vim Project (detect renames of files, #19879) - -if exists('b:current_syntax') - finish -endif - -syn match jjAdded "^JJ:\s\+\zsA\s.*" contained -syn match jjRemoved "^JJ:\s\+\zsD\s.*" contained -syn match jjChanged "^JJ:\s\+\zsM\s.*" contained -syn match jjRenamed "^JJ:\s\+\zsR\s.*" contained - -syn region jjComment start="^JJ:" end="$" contains=jjAdded,jjRemoved,jjChanged,jjRenamed - -syn include @jjCommitDiff syntax/diff.vim -syn region jjCommitDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^\%(diff --\|$\|@@\@!\|[^[:alnum:]\ +-]\S\@!\)\@=/ fold contains=@jjCommitDiff - -hi def link jjComment Comment -hi def link jjAdded Added -hi def link jjRemoved Removed -hi def link jjChanged Changed -hi def link jjRenamed Changed - -let b:current_syntax = 'jjdescription' diff --git a/user/vim/vimrc b/user/vim/vimrc deleted file mode 100644 index fce7814..0000000 --- a/user/vim/vimrc +++ /dev/null @@ -1,26 +0,0 @@ -syntax on - -" Don't break words in the middle. -set linebreak - -" Enable easy copying between different vim instances. -set clipboard=unnamed - -" Wayland clipboard workaround (see https://github.com/vim/vim/issues/5157). -if !empty($WAYLAND_DISPLAY) && executable('wl-copy') && executable('wl-paste') - " enable focus reporting - let &t_fe = "\<Esc>[?1004h" - let &t_fd = "\<Esc>[?1004l" - - augroup wl-clipboard - autocmd! - autocmd FocusLost * if @" != '' | call system('wl-copy --trim-newline', @") | endif - autocmd FocusGained * let @" = system('wl-paste -n') - augroup END -endif - -" Enable pasting with middle mouse click in insert mode. -set mouse= - -" Shortcut for Hugo TOML frontmatter -autocmd FileType markdown nnoremap <buffer> <C-f> i+++<CR>title = ""<CR>+++<CR><ESC>kk$i |
