Move neovim/nixvim configuration

This commit is contained in:
Oliver Davies 2025-07-26 02:35:57 +01:00
parent 32e28379e2
commit 6c1b494e82
56 changed files with 438 additions and 404 deletions

View file

@ -0,0 +1,6 @@
{
flake.modules.nixvim.custom = {
viAlias = true;
vimAlias = true;
};
}

View file

@ -0,0 +1,6 @@
{
flake.modules.nixvim.custom.colorschemes.catppuccin = {
enable = true;
settings.flavour = "mocha";
};
}

View file

@ -0,0 +1,12 @@
{
flake.modules.nixvim.custom.diagnostic.settings = {
signs = true;
underline = false;
update_in_insert = false;
virtual_text = {
enable = true;
spacing = 2;
};
};
}

View file

@ -0,0 +1,10 @@
{
flake.modules.nixvim.custom =
{ pkgs, ... }:
{
extraPackages = with pkgs; [
nixfmt-rfc-style
stylua
];
};
}

View file

@ -0,0 +1,17 @@
{
flake.modules.nixvim.custom.filetype = {
extension = {
"neon.dist" = "yaml";
inc = "php";
install = "php";
module = "php";
neon = "yaml";
pcss = "scss";
theme = "php";
};
filename = {
"composer.lock" = "json";
};
};
}

View file

@ -0,0 +1,13 @@
{ config, ... }:
{
perSystem =
{ inputs', pkgs, ... }:
{
packages.nixvim = inputs'.nixvim.legacyPackages.makeNixvimWithModule {
inherit pkgs;
module = config.flake.modules.nixvim.custom;
};
};
}

View file

@ -0,0 +1,86 @@
{
flake.modules.nixvim.custom.keymaps = [
{
action = "<Esc>A,<Esc>";
key = ",,";
mode = "i";
}
{
action = "<Esc>A;<Esc>";
key = ";;";
mode = "i";
}
{
action = "<cmd>!drush cache-rebuild<CR>";
key = "<leader>dcr";
}
{
action = "<cmd>:edit todo.txt<CR>";
key = "<leader>et";
}
{
action = "<cmd>lua vim.lsp.buf.format()<CR>";
key = "<leader>f";
options.silent = true;
}
{
action = "\"+y";
key = "<leader>y";
mode = [
"n"
"x"
];
}
{
action = "@q";
key = "Q";
}
{
action = "<cmd>silent !tmux new-window tmux-sessionizer<CR>";
key = "<C-f>";
options.silent = true;
}
{
action = "<Esc>:w<CR>";
key = "<C-s>";
mode = [
"i"
"n"
];
}
{
action = "<cmd>tabnew<CR>";
key = "<C-t>";
}
{
action = "<cmd>!composer install<CR>";
key = "<leader>ci";
}
{
action = "<cmd>edit composer.json<CR>";
key = "<leader>ec";
}
{
action = "<cmd>edit flake.nix<CR>";
key = "<leader>ef";
}
{
action = "<Esc>";
key = "jk";
mode = "i";
}
];
}

View file

@ -0,0 +1,6 @@
{
flake.modules.nixvim.custom.globals = {
mapleader = " ";
maplocalleader = " ";
};
}

View file

@ -0,0 +1,11 @@
{
flake.modules.nixvim.custom.plugins.lualine = {
enable = true;
settings.options = {
component_separators = "";
icons_enabled = false;
section_separators = "";
};
};
}

View file

@ -0,0 +1,27 @@
{
flake.modules.nixvim.custom.opts = {
expandtab = true;
exrc = true;
foldlevel = 1;
foldlevelstart = 99;
foldmethod = "indent";
inccommand = "split";
laststatus = 3;
list = true;
number = true;
relativenumber = true;
scrolloff = 5;
shiftwidth = 2;
signcolumn = "yes:1";
smartindent = true;
softtabstop = 2;
splitbelow = true;
splitright = true;
swapfile = false;
syntax = "on";
tabstop = 2;
termguicolors = true;
updatetime = 1000;
wrap = false;
};
}

View file

@ -0,0 +1,24 @@
{
flake.modules.nixvim.custom.plugins.auto-save = {
enable = true;
settings.condition = ''
function(buf)
local excluded_filetypes = {
"harpoon",
"oil",
}
local excluded_filenames = {}
if vim.tbl_contains(excluded_filetypes, vim.fn.getbufvar(buf, "&filetype"))
or vim.tbl_contains(excluded_filenames, vim.fn.expand("%:t"))
then
return false
end
return true
end
'';
};
}

View file

@ -0,0 +1,58 @@
{
flake.modules.nixvim.custom.plugins.cmp = {
enable = true;
autoEnableSources = true;
settings = {
mapping = {
"<C-e>" = "cmp.mapping.close()";
"<C-h>" = ''
cmp.mapping(function()
if ls.locally_jumpable(-1) then
ls.jump(-1)
end
end)
'';
"<C-l>" = ''
cmp.mapping(function()
if ls.expand_or_locally_jumpable() then
ls.expand_or_jump()
end
end)
'';
"<C-n>" = "cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select })";
"<C-p>" = "cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select })";
"<C-y>" = "cmp.mapping.confirm({ select = true })";
"<CR>" = "nil";
"<S-Tab>" = "nil";
"<Tab>" = "nil";
};
snippet.expand = ''
function(args)
require('luasnip').lsp_expand(args.body)
end
'';
sources = [
{ name = "nvim_lsp"; }
{ name = "nvim_lua"; }
{
name = "luasnip";
keyword_length = 2;
}
{
name = "buffer";
keyword_length = 3;
}
{ name = "calc"; }
];
};
};
}

View file

@ -0,0 +1,3 @@
{
flake.modules.nixvim.custom.plugins.conform-nvim.enable = true;
}

View file

@ -0,0 +1,3 @@
{
flake.modules.nixvim.custom.plugins.fidget.enable = true;
}

View file

@ -0,0 +1,18 @@
{
flake.modules.nixvim.custom = {
plugins.fugitive.enable = true;
keymaps = [
{
key = "<leader>gc";
action = "<cmd>Git commit<CR><C-w>K";
}
{
# Open the ":Git" window in its own buffer, not a split.
key = "<leader>gs";
action = "<cmd>0Git<CR>";
}
];
};
}

View file

@ -0,0 +1,48 @@
{
flake.modules.nixvim.custom = {
plugins.gitsigns.enable = true;
keymaps = [
{
action = "<cmd>Gitsigns prev_hunk<CR>";
key = "[h";
}
{
action = "<cmd>Gitsigns next_hunk<CR>";
key = "]h";
}
{
action = "<cmd>Gitsigns reset_hunk<CR>";
key = "<leader>hr";
}
{
action = "<cmd>Gitsigns reset_buffer<CR>";
key = "<leader>hR";
}
{
action = "<cmd>Gitsigns stage_hunk<CR>";
key = "<leader>hs";
mode = [
"n"
"v"
];
}
{
action = "<cmd>Gitsigns stage_buffer<CR>";
key = "<leader>hS";
mode = "n";
}
{
action = "<cmd>Gitsigns undo_stage_hunk<CR>";
key = "<leader>hu";
mode = "x";
}
];
};
}

View file

@ -0,0 +1,45 @@
let
leaderBinding = key: command: {
key = "<leader>${key}";
action = "<cmd>${command}<CR>";
options.silent = true;
};
in
{
flake.modules.nixvim.custom = {
plugins.harpoon = {
enable = true;
enableTelescope = true;
};
keymaps = [
{
key = "<leader>a";
action.__raw = "function() require'harpoon':list():add() end";
}
{
key = "<C-e>";
action.__raw = ''
function()
require 'harpoon'.ui:toggle_quick_menu(require'harpoon':list())
end
'';
}
]
++ (map
(num: leaderBinding "${toString num}" "lua require(\"harpoon\"):list():select(${toString num})")
[
1
2
3
4
5
6
7
8
9
]
);
};
}

View file

@ -0,0 +1,3 @@
{
flake.modules.nixvim.custom.plugins.lint.enable = true;
}

View file

@ -0,0 +1,23 @@
{
flake.modules.nixvim.custom.plugins.lsp = {
enable = true;
keymaps = {
diagnostic = {
"<leader>dl" = "setqflist";
};
lspBuf = {
"<leader>ca" = "code_action";
"<leader>cr" = "rename";
K = "hover";
gD = "declaration";
gT = "type_definition";
gd = "definition";
gr = "references";
};
};
servers.phpactor.enable = true;
};
}

View file

@ -0,0 +1,3 @@
{
flake.modules.nixvim.custom.plugins.luasnip.enable = true;
}

View file

@ -0,0 +1,15 @@
{
flake.modules.nixvim.custom.plugins.mini = {
enable = true;
modules = {
ai = { };
align = { };
bracketed = { };
move = { };
operators = { };
splitjoin = { };
surround = { };
};
};
}

View file

@ -0,0 +1,23 @@
{
flake.modules.nixvim.custom = {
plugins.oil = {
enable = true;
settings = {
delete_to_trash = true;
keymaps."-" = "actions.parent";
skip_confirm_for_simple_edits = true;
view_options.show_hidden = true;
};
};
keymaps = [
{
action = "<cmd>Oil<CR>";
key = "-";
}
];
};
}

View file

@ -0,0 +1,19 @@
{
flake.modules.nixvim.custom =
{ pkgs, ... }:
{
extraPlugins = with pkgs.vimPlugins; [ phpactor ];
keymaps = [
{
key = "<leader>pm";
action = "<cmd>PhpactorContextMenu<CR>";
}
{
key = "<leader>pn";
action = "<cmd>PhpactorClassNew<CR>";
}
];
};
}

View file

@ -0,0 +1,54 @@
{ config, lib, ... }:
{
flake.modules.nixvim.custom = {
plugins.refactoring = {
enable = true;
enableTelescope = true;
};
keymaps = [
{
key = "<leader>ri";
action = "<cmd>Refactor inline_var<CR>";
mode = "n";
}
{
key = "<leader>re";
action = "<cmd>Refactor extract<CR>";
mode = "x";
}
{
key = "<leader>ri";
action = "<cmd>Refactor inline_var<CR>";
mode = "x";
}
{
key = "<leader>rv";
action = "<cmd>Refactor extract_var<CR>";
mode = "x";
}
];
# ++
# lib.optionals
# (
# config.flake.modules.nixvim.custom.plugins.refactoring.enable
# && config.flake.modules.nixvim.custom.plugins.refactoring.enableTelescope
# )
# [
# {
# mode = "n";
# key = "<leader>rR";
# action.__raw = ''
# function()
# require('telescope').extensions.refactoring.refactors()
# end
# '';
# options.silent = true;
# }
# ];
};
}

View file

@ -0,0 +1,31 @@
{
flake.modules.nixvim.custom.plugins.telescope = {
enable = true;
extensions = {
live-grep-args.enable = true;
fzf-native.enable = true;
ui-select.enable = true;
};
keymaps = {
"<leader>/" = "current_buffer_fuzzy_find";
"<leader>fb" = "buffers";
"<leader>fd" = "find_files";
"<leader>fg" = "live_grep";
"<leader>gw" = {
action = "grep_string";
mode = [
"n"
"v"
];
};
};
settings.defaults.layout_config.prompt_position = "top";
settings.defaults.sorting_strategy = "ascending";
settings.pickers.find_files.hidden = true;
};
}

View file

@ -0,0 +1,50 @@
{
flake.modules.nixvim.custom =
{ pkgs, ... }:
{
plugins = {
treesitter = {
enable = true;
grammarPackages = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [
bash
comment
css
csv
dockerfile
gitattributes
gitignore
go
html
javascript
json
kdl
lua
luadoc
make
markdown
markdown_inline
nix
php
phpdoc
query
rst
scss
sql
terraform
twig
typescript
vim
vimdoc
vue
xml
yaml
];
settings.highlight.enable = true;
};
treesitter-textobjects.enable = true;
};
};
}

View file

@ -0,0 +1,12 @@
{
flake.modules.nixvim.custom = {
plugins.undotree.enable = true;
keymaps = [
{
action = "<cmd>UndotreeToggle<CR>";
key = "<leader>u";
}
];
};
}

View file

@ -0,0 +1,7 @@
{
flake.modules.nixvim.custom =
{ pkgs, ... }:
{
extraPlugins = [ pkgs.vimPlugins.vim-cool ];
};
}

View file

@ -0,0 +1,7 @@
{
flake.modules.nixvim.custom.plugins = {
vim-dadbod.enable = true;
vim-dadbod-completion.enable = true;
vim-dadbod-ui.enable = true;
};
}

View file

@ -0,0 +1,11 @@
{
flake.modules.nixvim.custom =
{ pkgs, ... }:
{
extraPlugins = [ pkgs.vimPlugins.vim-highlightedyank ];
extraConfigVim = ''
let g:highlightedyank_highlight_duration = 100
'';
};
}

View file

@ -0,0 +1,20 @@
{
flake.modules.nixvim.custom = {
plugins.vim-test.enable = true;
keymaps = [
{
key = "<leader>tf";
action = "<cmd>TestFile<CR>";
}
{
key = "<leader>tl";
action = "<cmd>TestLast<CR>";
}
{
key = "<leader>tn";
action = "<cmd>TestNearest<CR>";
}
];
};
}

View file

@ -0,0 +1,3 @@
{
flake.modules.nixvim.custom.plugins.web-devicons.enable = false;
}

View file

@ -0,0 +1,24 @@
{ config, inputs, lib, ... }:
{
flake.modules.homeManager.base =
hmArgs@{ pkgs, ... }:
let
# Ideally:
# nixvim = self.packages.${pkgs.system}.nixvim;
# but https://github.com/danth/stylix/pull/415#issuecomment-2832398958
nixvim = inputs.nixvim.legacyPackages.${pkgs.system}.makeNixvimWithModule {
inherit pkgs;
extraSpecialArgs.homeConfig = hmArgs.config;
module = config.flake.modules.nixvim.custom;
};
in
{
home = {
packages = [ nixvim ];
sessionVariables.EDITOR = lib.mkForce (lib.getExe nixvim);
};
};
}

View file

@ -1,4 +1,4 @@
{ self, ... }:
{ config, ... }:
{
perSystem =
@ -10,7 +10,7 @@
neovim = inputs'.nixvim.legacyPackages.makeNixvimWithModule {
inherit pkgs;
module = import "${self}/modules/home-manager/neovim/config";
module = config.flake.modules.nixvim.custom;
};
};
};