up
This commit is contained in:
47
modules/home-manager/base/editors/neovim/autocmd.nix
Normal file
47
modules/home-manager/base/editors/neovim/autocmd.nix
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
programs.nixvim = {
|
||||
autoGroups = {
|
||||
Christoph = {};
|
||||
};
|
||||
|
||||
autoCmd = [
|
||||
{
|
||||
event = "BufWritePre";
|
||||
group = "Christoph";
|
||||
pattern = "*";
|
||||
command = "%s/\\s\\+$//e";
|
||||
}
|
||||
{
|
||||
event = "BufReadPost";
|
||||
group = "Christoph";
|
||||
pattern = "*";
|
||||
command = "normal zR";
|
||||
}
|
||||
{
|
||||
event = "FileReadPost";
|
||||
group = "Christoph";
|
||||
pattern = "*";
|
||||
command = "normal zR";
|
||||
}
|
||||
{
|
||||
event = "LspAttach";
|
||||
group = "Christoph";
|
||||
callback.__raw = ''
|
||||
function(e)
|
||||
local opts = { buffer = e.buf }
|
||||
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
|
||||
vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
|
||||
vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
|
||||
vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
|
||||
vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
|
||||
vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
|
||||
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
|
||||
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
|
||||
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
|
||||
vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
|
||||
end
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
26
modules/home-manager/base/editors/neovim/default.nix
Normal file
26
modules/home-manager/base/editors/neovim/default.nix
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
imports = [
|
||||
./autocmd.nix
|
||||
./mappings.nix
|
||||
./options.nix
|
||||
./plugins/conform.nix
|
||||
./plugins/grug-far.nix
|
||||
./plugins/lazygit.nix
|
||||
./plugins/lsp.nix
|
||||
./plugins/mini.nix
|
||||
./plugins/treesitter.nix
|
||||
];
|
||||
|
||||
programs.nixvim = {
|
||||
enable = true;
|
||||
defaultEditor = true;
|
||||
luaLoader.enable = true;
|
||||
|
||||
colorschemes.catppuccin = {
|
||||
enable = true;
|
||||
settings = {
|
||||
flavour = "latte";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
165
modules/home-manager/base/editors/neovim/mappings.nix
Normal file
165
modules/home-manager/base/editors/neovim/mappings.nix
Normal file
@@ -0,0 +1,165 @@
|
||||
{
|
||||
programs.nixvim.keymaps = [
|
||||
# e - explore/edit
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>ed";
|
||||
action = ":lua require('mini.files').open()<CR>";
|
||||
options.desc = "Directory";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>ef";
|
||||
action = ":lua require('mini.files').open(vim.api.nvim_buf_get_name(0))<CR>";
|
||||
options.desc = "File directory";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>er";
|
||||
action = ":lua require('grug-far').open()<CR>";
|
||||
options.desc = "Search and replace";
|
||||
}
|
||||
# f - find
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>f/";
|
||||
action = ":Pick history scope='/'<CR>";
|
||||
options.desc = "'/' history";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>f:";
|
||||
action = ":Pick history scope=':'<CR>";
|
||||
options.desc = "':' history";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>fa";
|
||||
action = ":Pick git_hunks scope='staged'<CR>";
|
||||
options.desc = "Added hunks (all)";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>fA";
|
||||
action = ":Pick git_hunks path='%' scope='staged'<CR>";
|
||||
options.desc = "Added hunks (buffer)";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>fb";
|
||||
action = ":Pick buffers<CR>";
|
||||
options.desc = "Buffers";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>fd";
|
||||
action = ":Pick diagnostic scope='all'<CR>";
|
||||
options.desc = "Diagnostic (workspace)";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>fD";
|
||||
action = ":Pick diagnostic scope='current'<CR>";
|
||||
options.desc = "Diagnostic (buffer)";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>ff";
|
||||
action = ":Pick files<CR>";
|
||||
options.desc = "Search files";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>fg";
|
||||
action = ":Pick grep_live<CR>";
|
||||
options.desc = "Grep";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>fr";
|
||||
action = ":Pick lsp scope='references'<CR>";
|
||||
options.desc = "References (LSP)";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>fs";
|
||||
action = ":Pick lsp scope='workspace_symbol'<CR>";
|
||||
options.desc = "Symbols (LSP, workspace)";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>fS";
|
||||
action = ":Pick lsp scope='document_symbol'<CR>";
|
||||
options.desc = "Symbols (LSP, buffer)";
|
||||
}
|
||||
# g - git
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>gg";
|
||||
action = ":LazyGit<CR>";
|
||||
options.desc = "Lazygit";
|
||||
}
|
||||
# l - lsp/formatter
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>la";
|
||||
action = ":lua vim.lsp.buf.code_action()<CR>";
|
||||
options.desc = "Actions";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>ld";
|
||||
action = ":lua vim.diagnostic.open_float()<CR>";
|
||||
options.desc = "Diagnostics popup";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>lf";
|
||||
action = ":lua require('conform').format({ lsp_fallback = true })<CR>";
|
||||
options.desc = "Format";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>li";
|
||||
action = ":lua vim.lsp.buf.hover()<CR>";
|
||||
options.desc = "Information";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>lj";
|
||||
action = ":lua vim.diagnostic.goto_next()<CR>";
|
||||
options.desc = "Next diagnostic";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>lk";
|
||||
action = ":lua vim.diagnostic.goto_prev()<CR>";
|
||||
options.desc = "Prev diagnostic";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>lr";
|
||||
action = ":lua vim.lsp.buf.rename()<CR>";
|
||||
options.desc = "Rename";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>lR";
|
||||
action = ":lua vim.lsp.buf.references()<CR>";
|
||||
options.desc = "References";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>ls";
|
||||
action = ":lua vim.lsp.buf.definition()<CR>";
|
||||
options.desc = "Source definition";
|
||||
}
|
||||
# other
|
||||
{
|
||||
mode = "n";
|
||||
key = "sj";
|
||||
action = ":lua require('mini.jump2d').start(require('mini.jump2d').builtin_opts.query)<CR>";
|
||||
options.desc = "Jump to character";
|
||||
}
|
||||
];
|
||||
}
|
||||
16
modules/home-manager/base/editors/neovim/options.nix
Normal file
16
modules/home-manager/base/editors/neovim/options.nix
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
programs.nixvim = {
|
||||
globals = {
|
||||
# clipboard = "osc52";
|
||||
};
|
||||
opts = {
|
||||
clipboard = "unnamedplus";
|
||||
expandtab = true;
|
||||
ignorecase = true;
|
||||
mouse = "";
|
||||
relativenumber = true;
|
||||
shiftwidth = 2;
|
||||
smartcase = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
14
modules/home-manager/base/editors/neovim/plugins/conform.nix
Normal file
14
modules/home-manager/base/editors/neovim/plugins/conform.nix
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
programs.nixvim.plugins.conform-nvim = {
|
||||
enable = true;
|
||||
settings = {
|
||||
format_on_save = {};
|
||||
formatters_by_ft = {
|
||||
nix = ["alejandra"];
|
||||
javascript = ["prettier"];
|
||||
typescript = ["prettier"];
|
||||
elixir = ["mix"];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
programs.nixvim.plugins = {
|
||||
grug-far = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
programs.nixvim.plugins.lazygit = {
|
||||
enable = true;
|
||||
};
|
||||
}
|
||||
15
modules/home-manager/base/editors/neovim/plugins/lsp.nix
Normal file
15
modules/home-manager/base/editors/neovim/plugins/lsp.nix
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
programs.nixvim.plugins = {
|
||||
lsp = {
|
||||
enable = true;
|
||||
inlayHints = true;
|
||||
servers = {
|
||||
nil_ls.enable = true; # Nix
|
||||
ts_ls.enable = true; # TS/JS
|
||||
cssls.enable = true; # CSS
|
||||
dockerls.enable = true; # Docker
|
||||
elixirls.enable = true; # Elixir
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
158
modules/home-manager/base/editors/neovim/plugins/mini.nix
Normal file
158
modules/home-manager/base/editors/neovim/plugins/mini.nix
Normal file
@@ -0,0 +1,158 @@
|
||||
{
|
||||
programs.nixvim.plugins.mini = {
|
||||
enable = true;
|
||||
modules = {
|
||||
ai = {
|
||||
custom_textobjects = {
|
||||
B.__raw = "require('mini.extra').gen_ai_spec.buffer()";
|
||||
F.__raw = "require('mini.ai').gen_spec.treesitter({ a = '@function.outer', i = '@function.inner' })";
|
||||
};
|
||||
};
|
||||
align = {};
|
||||
basics = {
|
||||
options = {
|
||||
basic = true;
|
||||
extra_ui = true;
|
||||
};
|
||||
mappings = {
|
||||
basic = false;
|
||||
};
|
||||
autocommands = {
|
||||
basic = true;
|
||||
};
|
||||
};
|
||||
bracketed = {};
|
||||
clue = {
|
||||
clues.__raw = ''
|
||||
{
|
||||
{ mode = 'n', keys = '<Leader>e', desc = '+Explore/+Edit' },
|
||||
{ mode = 'n', keys = '<Leader>f', desc = '+Find' },
|
||||
{ mode = 'n', keys = '<Leader>g', desc = '+Git' },
|
||||
{ mode = 'n', keys = '<Leader>l', desc = '+LSP' },
|
||||
{ mode = 'x', keys = '<Leader>l', desc = '+LSP' },
|
||||
require("mini.clue").gen_clues.builtin_completion(),
|
||||
require("mini.clue").gen_clues.g(),
|
||||
require("mini.clue").gen_clues.marks(),
|
||||
require("mini.clue").gen_clues.registers(),
|
||||
require("mini.clue").gen_clues.windows({ submode_resize = true }),
|
||||
require("mini.clue").gen_clues.z(),
|
||||
}
|
||||
'';
|
||||
triggers = [
|
||||
{
|
||||
mode = "n";
|
||||
keys = "<Leader>";
|
||||
}
|
||||
{
|
||||
mode = "x";
|
||||
keys = "<Leader>";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
keys = "[";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
keys = "]";
|
||||
}
|
||||
{
|
||||
mode = "x";
|
||||
keys = "[";
|
||||
}
|
||||
{
|
||||
mode = "x";
|
||||
keys = "]";
|
||||
}
|
||||
{
|
||||
mode = "i";
|
||||
keys = "<C-x>";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
keys = "g";
|
||||
}
|
||||
{
|
||||
mode = "x";
|
||||
keys = "g";
|
||||
}
|
||||
|
||||
{
|
||||
mode = "n";
|
||||
keys = "\"";
|
||||
}
|
||||
{
|
||||
mode = "x";
|
||||
keys = "\"";
|
||||
}
|
||||
{
|
||||
mode = "i";
|
||||
keys = "<C-r>";
|
||||
}
|
||||
{
|
||||
mode = "c";
|
||||
keys = "<C-r>";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
keys = "<C-w>";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
keys = "z";
|
||||
}
|
||||
{
|
||||
mode = "x";
|
||||
keys = "z";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
keys = "'";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
keys = "`";
|
||||
}
|
||||
{
|
||||
mode = "x";
|
||||
keys = "'";
|
||||
}
|
||||
{
|
||||
mode = "x";
|
||||
keys = "`";
|
||||
}
|
||||
];
|
||||
};
|
||||
comment = {};
|
||||
completion = {
|
||||
lsp_completion = {
|
||||
source_func = "omnifunc";
|
||||
};
|
||||
};
|
||||
diff = {};
|
||||
extra = {};
|
||||
files = {};
|
||||
git = {};
|
||||
icons = {};
|
||||
indentscope = {};
|
||||
jump = {};
|
||||
jump2d = {
|
||||
settings = {
|
||||
spotter.__raw = "require('mini.jump2d').gen_spotter.pattern('[^%s%p]+')";
|
||||
labels = "asdfghjkl";
|
||||
view = {
|
||||
dim = true;
|
||||
n_steps_ahead = 2;
|
||||
};
|
||||
};
|
||||
};
|
||||
move = {};
|
||||
pairs = {};
|
||||
pick = {};
|
||||
starter = {};
|
||||
statusline = {};
|
||||
surround = {};
|
||||
trailspace = {};
|
||||
visits = {};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{pkgs, ...}: {
|
||||
programs.nixvim.plugins.treesitter = {
|
||||
enable = true;
|
||||
settings = {
|
||||
highlight.enable = true;
|
||||
indent.enable = true;
|
||||
};
|
||||
grammarPackages = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [
|
||||
bash
|
||||
fish
|
||||
elixir
|
||||
heex
|
||||
json
|
||||
nix
|
||||
toml
|
||||
yaml
|
||||
];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user