update: removed nixcats and added based neovim config

This commit is contained in:
Michael Thomson
2026-02-07 20:23:36 -05:00
parent 004ccccc35
commit da8683896c
15 changed files with 285 additions and 1082 deletions

View File

@@ -10,14 +10,14 @@
# size = 12;
# };
font = {
# name = "JetBrainsMono Nerd Font";
name = "JetBrainsMono Nerd Font Mono";
size = 12;
# package = pkgs.nerd-fonts.jetbrains-mono;
package = pkgs.nerd-fonts.jetbrains-mono;
};
shellIntegration = {
enableZshIntegration = true;
};
#themeFile = "gruvbox-dark";
themeFile = "Modus_Vivendi";
# darwinLaunchOptions = [
# "--single-instance"
# ];

View File

@@ -0,0 +1,25 @@
{
pkgs,
config,
...
}: {
home.packages = with pkgs; [
#utilities
ripgrep
# language servers
lua-language-server
vtsls
gopls
eslint_d
tailwindcss-language-server
vscode-langservers-extracted
rust-analyzer
yaml-language-server
haskell-language-server
clang
];
home.file = {
".config/nvim/init.lua".source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/dev/personal/nixos/modules/home-manager/neovim/init.lua";
};
}

View File

@@ -0,0 +1,179 @@
-- set leader keys
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- highlight as you search
vim.opt.hlsearch = true
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
-- preview substitutions live in preview window
vim.opt.inccommand = 'split'
-- prevent cursor from hitting top or bottom of screen
vim.opt.scrolloff = 10
-- line numbers
vim.wo.number = true
vim.wo.relativenumber = true
-- Indent stuff
vim.o.expandtab = true
vim.o.smartindent = true
vim.o.autoindent = true
vim.o.tabstop = 2
vim.o.softtabstop = 2
vim.o.shiftwidth = 2
-- wrapped lines are visually indented
vim.o.breakindent = true
-- save undo history
vim.o.undofile = true
-- case insensitive search unless capitalized
vim.o.ignorecase = true
vim.o.smartcase = true
-- keep on signcolumn
vim.wo.signcolumn = 'yes'
-- decrease update time
vim.o.updatetime = 250
vim.o.timeoutlen = 300
-- better completion experience
vim.o.completeopt = 'menu,preview,noselect'
-- better term colors
vim.o.termguicolors = true
-- clean up netrw
vim.g.netrw_liststyle = 0
vim.g.netrw_banner = 0
-- Basic Keymaps
-- improves C-u and C-d by centering on scroll
vim.keymap.set('n', '<C-u>', '<C-u>zz', { desc = 'Scroll Up' })
vim.keymap.set('n', '<C-d>', '<C-d>zz', { desc = 'Scroll Down' })
-- improved search by centering on results
vim.keymap.set('n', 'n', 'nzzzv', { desc = 'Next Search Result' })
vim.keymap.set('n', 'N', 'Nzzzv', { desc = 'Previous Search Result' })
-- diagnostics
vim.keymap.set('n', '<leader>d', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
-- clipboard binds
vim.keymap.set({"v", "x", "n"}, '<leader>y', '"+y', { noremap = true, silent = true, desc = 'Yank to clipboard' })
vim.keymap.set({"n", "v", "x"}, '<leader>Y', '"+yy', { noremap = true, silent = true, desc = 'Yank line to clipboard' })
vim.keymap.set({'n', 'v', 'x'}, '<leader>p', '"+p', { noremap = true, silent = true, desc = 'Paste from clipboard' })
vim.keymap.set('i', '<C-p>', '<C-r><C-p>+', { noremap = true, silent = true, desc = 'Paste from clipboard from within insert mode' })
vim.keymap.set("x", "<leader>P", '"_dP', { noremap = true, silent = true, desc = 'Paste over selection without erasing unnamed register' })
-- Plugins
vim.pack.add({
{ src = 'https://github.com/vague-theme/vague.nvim' },
{ src = 'https://github.com/miikanissi/modus-themes.nvim' },
{ src = 'https://github.com/nvim-treesitter/nvim-treesitter' },
{ src = 'https://github.com/nvim-mini/mini.pick' },
{ src = 'https://github.com/nvim-mini/mini.extra' },
{ src = 'https://github.com/nvim-mini/mini.icons' },
{ src = 'https://github.com/nvim-mini/mini.notify' },
{ src = 'https://github.com/nvim-mini/mini.pairs' },
{ src = 'https://github.com/nvim-mini/mini.surround' },
{ src = 'https://github.com/neovim/nvim-lspconfig' },
{ src = 'https://github.com/stevearc/oil.nvim' },
{ src = 'https://github.com/saghen/blink.cmp', version = vim.version.range('1.*') },
})
-- Theme (vague)
vim.cmd('colorscheme modus')
-- Blink
require('blink.cmp').setup({
signature = { enabled = true }
})
-- Oil
require('oil').setup()
-- Mini
require('mini.icons').setup()
require('mini.pick').setup()
require('mini.extra').setup()
require('mini.notify').setup()
require('mini.pairs').setup()
require('mini.surround').setup()
vim.keymap.set('n', '<leader>ff', MiniPick.builtin.files, { desc = 'Find Files' })
vim.keymap.set('n', '<leader>fg', MiniPick.builtin.grep_live, { desc = 'Grep Files' })
-- Oil
vim.keymap.set('n', '<leader>fe', '<CMD>Oil<CR>', { desc = 'Explore Files' })
-- LSP
-- global on_attach
local function lsp_on_attach(client, bufnr)
-- utility function for LSP keymaps
local nmap = function(keys, func, desc)
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
end
-- if client:supports_method('textDocument/completion') then
-- local chars = {}; for i = 32, 126 do table.insert(chars, string.char(i)) end
-- client.server_capabilities.completionProvider.triggerCharacters = chars
--
-- vim.lsp.completion.enable(true, client.id, bufnr, {autotrigger = true})
-- end
nmap('<leader>rn', vim.lsp.buf.rename, 'Rename')
nmap('<leader>ca', vim.lsp.buf.code_action, 'Code Actions')
nmap('gd', vim.lsp.buf.definition, 'Goto Definition')
nmap('gr', function() MiniExtra.pickers.lsp({ scope = 'references' }) end, 'Goto References')
nmap('gI', function() MiniExtra.pickers.lsp({ scope = 'implementation' }) end, 'Goto Implementation')
nmap('<leader>ds', function() MiniExtra.pickers.lsp({ scope = 'document_symbol' }) end, 'Document Symbols')
nmap('<leader>ws', function() MiniExtra.pickers.lsp({ scope = 'workspace_symbol_live' }) end, 'Workspace Symbols')
nmap('<leader>D', vim.lsp.buf.type_definition, 'Goto Type Definition')
nmap('gD', vim.lsp.buf.declaration, 'Goto Declaration')
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
nmap('<C-K>', vim.lsp.buf.signature_help, 'Signature Documentation')
end
vim.lsp.config('*', {
on_attach = lsp_on_attach
})
-- Langauges
vim.lsp.config('lua_ls', {
settings = {
Lua = {
diagnostics = {
globals = { 'vim' },
},
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
checkThirdParty = false,
},
runtime = {
version = 'LuaJIT',
},
telemetry = {
enable = false,
},
},
},
})
vim.lsp.enable('lua_ls')
vim.lsp.enable('vtsls')
vim.lsp.enable('cssls')
vim.lsp.enable('tailwindcss')
vim.lsp.enable('eslint')
vim.lsp.enable('gopls')
vim.lsp.enable('nixd')
vim.lsp.enable('rust_analyzer')
vim.lsp.enable('yamlls')
vim.lsp.enable('clangd')
vim.lsp.enable('hls')

View File

@@ -1,232 +0,0 @@
{
config,
lib,
inputs,
pkgs,
...
}: let
utils = inputs.nixCats.utils;
kulala-grammer = pkgs.tree-sitter.buildGrammar {
language = "kulala_http";
version = "${pkgs.vimPlugins.kulala-nvim.version}";
src = "${pkgs.vimPlugins.kulala-nvim}/lua/tree-sitter";
generate = true;
};
in {
imports = [
inputs.nixCats.homeModule
../zk.nix
];
config = {
home.sessionVariables = {
EDITOR = "nvim";
};
nixCats = {
enable = true;
packageNames = ["nvim"];
luaPath = ./.;
# for useage of this section, refer to :h nixCats.flake.outputs.categories
categoryDefinitions.replace = {
pkgs,
settings,
categories,
extra,
name,
mkPlugin,
...
} @ packageDef: {
# lspsAndRuntimeDeps:
# this section is for dependencies that should be available
# at RUN TIME for plugins. Will be available to PATH within neovim terminal
# this includes LSPs
lspsAndRuntimeDeps = {
general = with pkgs; [
lazygit
ripgrep
fzf
];
notes = with pkgs; [
zk
tinymist
typst
];
lua = with pkgs; [
lua-language-server
stylua
];
nix = with pkgs; [
nixd
alejandra
];
go = with pkgs; [
gopls
delve
golint
golangci-lint
gotools
go-tools
go
];
typescript = with pkgs; [
vtsls
vscode-langservers-extracted
stylelint-lsp
tailwindcss-language-server
vscode-css-languageserver
];
yaml = with pkgs; [
yaml-language-server
];
c = with pkgs; [
clang
];
csharp = with pkgs; [
omnisharp-roslyn
];
gitlab = with pkgs; [
gitlab-ci-ls
];
http = with pkgs; [
kulala-fmt
];
};
# This is for plugins that will load at startup without using packadd:
startupPlugins = {
general = with pkgs.vimPlugins; [
# lazy loading isnt required with a config this small
# but as a demo, we do it anyway.
lze
lzextras
(nvim-treesitter.withPlugins (
plugins:
nvim-treesitter.allGrammars ++ [kulala-grammer]
))
snacks-nvim
gruvbox-nvim
gruber-darker-nvim
lackluster-nvim
oxocarbon-nvim
vim-sleuth
oil-nvim
plenary-nvim
vim-tmux-navigator
friendly-snippets
vim-ledger
];
};
# not loaded automatically at startup.
# use with packadd and an autocommand in config to achieve lazy loading
optionalPlugins = {
notes = with pkgs.vimPlugins; [
zk-nvim
typst-preview-nvim
];
go = with pkgs.vimPlugins; [
nvim-dap-go
];
lua = with pkgs.vimPlugins; [
lazydev-nvim
];
general = with pkgs.vimPlugins; [
mini-nvim
nvim-lspconfig
blink-cmp
gitsigns-nvim
harpoon2
which-key-nvim
nvim-lint
conform-nvim
nvim-dap
nvim-dap-ui
nvim-dap-virtual-text
];
http = with pkgs.vimPlugins; [
kulala-nvim
];
};
# shared libraries to be added to LD_LIBRARY_PATH
# variable available to nvim runtime
sharedLibraries = {
general = with pkgs; [];
};
# environmentVariables:
# this section is for environmentVariables that should be available
# at RUN TIME for plugins. Will be available to path within neovim terminal
environmentVariables = {
# test = {
# CATTESTVAR = "It worked!";
# };
};
# categories of the function you would have passed to withPackages
python3.libraries = {
# test = [ (_:[]) ];
};
# If you know what these are, you can provide custom ones by category here.
# If you dont, check this link out:
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/setup-hooks/make-wrapper.sh
extraWrapperArgs = {
# test = [
# '' --set CATTESTVAR2 "It worked again!"''
# ];
};
};
# see :help nixCats.flake.outputs.packageDefinitions
packageDefinitions.replace = {
# These are the names of your packages
# you can include as many as you wish.
nvim = {
pkgs,
name,
...
}: {
# they contain a settings set defined above
# see :help nixCats.flake.outputs.settings
settings = {
suffix-path = true;
suffix-LD = true;
wrapRc = true;
# unwrappedCfgPath = "/path/to/here";
# IMPORTANT:
# your alias may not conflict with your other packages.
# aliases = [ "vim" "homeVim" ];
# neovim-unwrapped = inputs.neovim-nightly-overlay.packages.${pkgs.system}.neovim;
hosts.python3.enable = true;
hosts.node.enable = true;
};
# and a set of categories that you want
# (and other information to pass to lua)
# and a set of categories that you want
categories = {
general = true;
notes = true;
lua = true;
nix = true;
go = true;
typescript = true;
yaml = true;
c = true;
csharp = true;
gitlab = true;
http = true;
};
# anything else to pass and grab in lua with `nixCats.extra`
extra = {
nixdExtras.nixpkgs = ''import <nixpkgs> { }'';
};
};
};
};
};
}

View File

@@ -1,820 +0,0 @@
-- NOTE: These 2 need to be set up before any plugins are loaded.
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- [[ Setting options ]]
-- See `:help vim.o`
-- NOTE: You can change these options as you wish!
-- Sets how neovim will display certain whitespace characters in the editor.
-- See `:help 'list'`
-- and `:help 'listchars'`
vim.opt.list = true
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '' }
-- Set highlight on search
vim.opt.hlsearch = true
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
-- Preview substitutions live, as you type!
vim.opt.inccommand = 'split'
-- Minimal number of screen lines to keep above and below the cursor.
vim.opt.scrolloff = 10
-- Make line numbers default
vim.wo.number = true
-- Enable mouse mode
vim.o.mouse = 'a'
vim.o.conceallevel = 2
-- Indent
-- vim.o.smarttab = true
vim.opt.cpoptions:append('I')
vim.o.expandtab = true
vim.o.smartindent = true
vim.o.autoindent = true
vim.o.tabstop = 4
vim.o.softtabstop = 4
vim.o.shiftwidth = 4
-- stops line wrapping from being confusing
vim.o.breakindent = true
-- Save undo history
vim.o.undofile = true
-- Case-insensitive searching UNLESS \C or capital in search
vim.o.ignorecase = true
vim.o.smartcase = true
-- Keep signcolumn on by default
vim.wo.signcolumn = 'yes'
vim.wo.relativenumber = true
-- Decrease update time
vim.o.updatetime = 250
vim.o.timeoutlen = 300
-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menu,preview,noselect'
-- NOTE: You should make sure your terminal supports this
vim.o.termguicolors = true
-- [[ Disable auto comment on enter ]]
-- See :help formatoptions
vim.api.nvim_create_autocmd("FileType", {
desc = "remove formatoptions",
callback = function()
vim.opt.formatoptions:remove({ "c", "r", "o" })
end,
})
-- [[ Highlight on yank ]]
-- See `:help vim.highlight.on_yank()`
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
vim.api.nvim_create_autocmd('TextYankPost', {
callback = function()
vim.highlight.on_yank()
end,
group = highlight_group,
pattern = '*',
})
vim.g.netrw_liststyle=0
vim.g.netrw_banner=0
-- [[ Basic Keymaps ]]
-- Keymaps for better default experience
-- See `:help vim.keymap.set()`
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv", { desc = 'Moves Line Down' })
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv", { desc = 'Moves Line Up' })
vim.keymap.set("n", "<C-d>", "<C-d>zz", { desc = 'Scroll Down' })
vim.keymap.set("n", "<C-u>", "<C-u>zz", { desc = 'Scroll Up' })
vim.keymap.set("n", "n", "nzzzv", { desc = 'Next Search Result' })
vim.keymap.set("n", "N", "Nzzzv", { desc = 'Previous Search Result' })
vim.keymap.set("n", "<leader><leader>[", "<cmd>bprev<CR>", { desc = 'Previous buffer' })
vim.keymap.set("n", "<leader><leader>]", "<cmd>bnext<CR>", { desc = 'Next buffer' })
vim.keymap.set("n", "<leader><leader>l", "<cmd>b#<CR>", { desc = 'Last buffer' })
vim.keymap.set("n", "<leader><leader>d", "<cmd>bdelete<CR>", { desc = 'delete buffer' })
-- Remap for dealing with word wrap
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
-- Diagnostic keymaps
vim.keymap.set('n', '<leader>d', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
-- kickstart.nvim starts you with this.
-- But it constantly clobbers your system clipboard whenever you delete anything.
-- Sync clipboard between OS and Neovim.
-- Remove this option if you want your OS clipboard to remain independent.
-- See `:help 'clipboard'`
-- vim.o.clipboard = 'unnamedplus'
-- You should instead use these keybindings so that they are still easy to use, but dont conflict
vim.keymap.set({"v", "x", "n"}, '<leader>y', '"+y', { noremap = true, silent = true, desc = 'Yank to clipboard' })
vim.keymap.set({"n", "v", "x"}, '<leader>Y', '"+yy', { noremap = true, silent = true, desc = 'Yank line to clipboard' })
vim.keymap.set({'n', 'v', 'x'}, '<leader>p', '"+p', { noremap = true, silent = true, desc = 'Paste from clipboard' })
vim.keymap.set('i', '<C-p>', '<C-r><C-p>+', { noremap = true, silent = true, desc = 'Paste from clipboard from within insert mode' })
vim.keymap.set("x", "<leader>P", '"_dP', { noremap = true, silent = true, desc = 'Paste over selection without erasing unnamed register' })
vim.cmd.colorscheme('gruvbox')
require("oil").setup()
vim.keymap.set("n", "<leader>fe", "<cmd>Oil<CR>", { desc = 'Oil' })
require("snacks").setup({
explorer = {},
picker = {},
bigfile = {},
image = {},
lazygit = {},
rename = {},
notifier = {},
indent = {
enabled = true,
animate = {
enabled = false,
},
},
gitbrowse = {},
scope = {},
})
vim.g.ledger_fuzzy_account_completion = 1
-- LSP Progress indicator
vim.api.nvim_create_autocmd("LspProgress", {
---@param ev {data: {client_id: integer, params: lsp.ProgressParams}}
callback = function(ev)
local spinner = { "", "", "", "", "", "", "", "", "", "" }
vim.notify(vim.lsp.status(), "info", {
id = "lsp_progress",
title = "LSP Progress",
opts = function(notif)
notif.icon = ev.data.params.value.kind == "end" and ""
or spinner[math.floor(vim.uv.hrtime() / (1e6 * 80)) % #spinner + 1]
end,
})
end,
})
vim.keymap.set("n", "<leader>gg", function() Snacks.lazygit.open() end, { desc = 'Snacks LazyGit' })
vim.keymap.set('n', "<leader>sf", function() Snacks.picker.smart() end, { desc = "Smart Find Files" })
vim.keymap.set('n', "<leader><leader>s", function() Snacks.picker.buffers() end, { desc = "Search Buffers" })
-- find
vim.keymap.set('n', "<leader>ff", function() Snacks.picker.files() end, { desc = "Find Files" })
-- Grep
vim.keymap.set('n', "<leader>fg", function() Snacks.picker.grep({ hidden = true }) end, { desc = "Grep" })
-- search
vim.keymap.set('n', "<leader>fd", function() Snacks.picker.diagnostics() end, { desc = "Diagnostics" })
vim.keymap.set('n', "<leader>fh", function() Snacks.picker.help() end, { desc = "Help Pages" })
vim.keymap.set('n', "<leader>fj", function() Snacks.picker.jumps() end, { desc = "Jumps" })
vim.keymap.set('n', "<leader>fk", function() Snacks.picker.keymaps() end, { desc = "Keymaps" })
vim.keymap.set('n', "<leader>fl", function() Snacks.picker.loclist() end, { desc = "Location List" })
vim.keymap.set('n', "<leader>fM", function() Snacks.picker.man() end, { desc = "Man Pages" })
vim.keymap.set('n', "<leader>fq", function() Snacks.picker.qflist() end, { desc = "Quickfix List" })
vim.keymap.set('n', "<leader>fr", function() Snacks.picker.resume() end, { desc = "Resume" })
vim.keymap.set('n', "<leader>fu", function() Snacks.picker.undo() end, { desc = "Undo History" })
require('lze').load {
{
"blink.cmp",
enabled = nixCats('general') or false,
event = "DeferredUIEnter",
on_require = "blink",
after = function (plugin)
require("blink.cmp").setup({
-- 'default' (recommended) for mappings similar to built-in completions (C-y to accept)
-- See :h blink-cmp-config-keymap for configuring keymaps
keymap = { preset = 'default' },
appearance = {
nerd_font_variant = 'mono'
},
signature = { enabled = true, },
sources = {
default = { 'lsp', 'path', 'snippets', 'buffer', 'omni' },
},
})
end,
},
{
"nvim-treesitter",
lazy = false,
after = function(plugin)
---@param buf integer
---@param language string
local function treesitter_try_attach(buf, language)
-- check if parser exists and load it
if not vim.treesitter.language.add(language) then
return
end
-- enables syntax highlighting and other treesitter features
vim.treesitter.start(buf, language)
-- enables treesitter based folds
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
-- enables treesitter based indentation
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end
local available_parsers = require("nvim-treesitter").get_available()
vim.api.nvim_create_autocmd("FileType", {
callback = function(args)
local buf, filetype = args.buf, args.match
local language = vim.treesitter.language.get_lang(filetype)
if not language then
return
end
local installed_parsers = require("nvim-treesitter").get_installed("parsers")
if vim.tbl_contains(installed_parsers, language) then
-- enable the parser if it is installed
treesitter_try_attach(buf, language)
elseif vim.tbl_contains(available_parsers, language) then
-- if a parser is available in `nvim-treesitter` enable it after ensuring it is installed
require("nvim-treesitter").install(language):await(function()
treesitter_try_attach(buf, language)
end)
else
-- try to enable treesitter features in case the parser exists but is not available from `nvim-treesitter`
treesitter_try_attach(buf, language)
end
end,
})
end,
},
{
"mini.nvim",
enabled = nixCats('general') or false,
event = "DeferredUIEnter",
after = function (plugin)
require('mini.pairs').setup()
require('mini.icons').setup()
require('mini.ai').setup()
end,
},
{
"gitsigns.nvim",
enabled = nixCats('general') or false,
event = "DeferredUIEnter",
after = function (plugin)
require('gitsigns').setup({
-- See `:help gitsigns.txt`
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
},
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- Navigation
map({ 'n', 'v' }, ']c', function()
if vim.wo.diff then
return ']c'
end
vim.schedule(function()
gs.next_hunk()
end)
return '<Ignore>'
end, { expr = true, desc = 'Jump to next hunk' })
map({ 'n', 'v' }, '[c', function()
if vim.wo.diff then
return '[c'
end
vim.schedule(function()
gs.prev_hunk()
end)
return '<Ignore>'
end, { expr = true, desc = 'Jump to previous hunk' })
-- Actions
-- visual mode
map('v', '<leader>hs', function()
gs.stage_hunk { vim.fn.line '.', vim.fn.line 'v' }
end, { desc = 'stage git hunk' })
map('v', '<leader>hr', function()
gs.reset_hunk { vim.fn.line '.', vim.fn.line 'v' }
end, { desc = 'reset git hunk' })
-- normal mode
map('n', '<leader>gs', gs.stage_hunk, { desc = 'git stage hunk' })
map('n', '<leader>gr', gs.reset_hunk, { desc = 'git reset hunk' })
map('n', '<leader>gS', gs.stage_buffer, { desc = 'git Stage buffer' })
map('n', '<leader>gu', gs.undo_stage_hunk, { desc = 'undo stage hunk' })
map('n', '<leader>gR', gs.reset_buffer, { desc = 'git Reset buffer' })
map('n', '<leader>gp', gs.preview_hunk, { desc = 'preview git hunk' })
map('n', '<leader>gb', function()
gs.blame_line { full = false }
end, { desc = 'git blame line' })
map('n', '<leader>gd', gs.diffthis, { desc = 'git diff against index' })
map('n', '<leader>gD', function()
gs.diffthis '~'
end, { desc = 'git diff against last commit' })
-- Toggles
map('n', '<leader>gtb', gs.toggle_current_line_blame, { desc = 'toggle git blame line' })
map('n', '<leader>gtd', gs.toggle_deleted, { desc = 'toggle git show deleted' })
-- Text object
map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>', { desc = 'select git hunk' })
end,
})
vim.cmd([[hi GitSignsAdd guifg=#04de21]])
vim.cmd([[hi GitSignsChange guifg=#83fce6]])
vim.cmd([[hi GitSignsDelete guifg=#fa2525]])
end,
},
{
"which-key.nvim",
enabled = nixCats('general') or false,
event = "DeferredUIEnter",
after = function (plugin)
require('which-key').setup({})
require('which-key').add {
{ "<leader>b", group = "buffer commands" },
{ "<leader>c", group = "[c]ode" },
{ "<leader>c_", hidden = true },
{ "<leader>d", group = "[d]ocument" },
{ "<leader>d_", hidden = true },
{ "<leader>g", group = "[g]it" },
{ "<leader>g_", hidden = true },
{ "<leader>r", group = "[r]ename" },
{ "<leader>r_", hidden = true },
{ "<leader>f", group = "[f]ind" },
{ "<leader>f_", hidden = true },
{ "<leader>s", group = "[s]earch" },
{ "<leader>s_", hidden = true },
{ "<leader>t", group = "[t]oggles" },
{ "<leader>t_", hidden = true },
{ "<leader>w", group = "[w]orkspace" },
{ "<leader>w_", hidden = true },
}
end,
},
{
"nvim-lint",
enabled = nixCats('general') or false,
event = "FileType",
after = function (plugin)
require('lint').linters_by_ft = {
-- markdown = {'vale',},
-- javascript = { 'eslint' },
-- typescript = { 'eslint' },
go = nixCats('go') and { 'golangcilint' } or nil,
}
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
callback = function()
require("lint").try_lint()
end,
})
end,
},
{
"conform.nvim",
enabled = nixCats('general') or false,
keys = {
{ "<leader>FF", desc = "[F]ormat [F]ile" },
},
after = function (plugin)
local conform = require("conform")
conform.setup({
formatters_by_ft = {
-- NOTE: download some formatters in lspsAndRuntimeDeps
-- and configure them here
lua = nixCats('lua') and { "stylua" } or nil,
go = nixCats('go') and { "gofmt", "golint" } or nil,
-- templ = { "templ" },
-- Conform will run multiple formatters sequentially
-- python = { "isort", "black" },
-- Use a sub-list to run only the first available formatter
-- javascript = { { "prettierd", "prettier" } },
},
})
vim.keymap.set({ "n", "v" }, "<leader>FF", function()
conform.format({
lsp_fallback = true,
async = false,
timeout_ms = 1000,
})
end, { desc = "[F]ormat [F]ile" })
end,
},
{
"nvim-dap",
enabled = nixCats('general') or false,
keys = {
{ "<F5>", desc = "Debug: Start/Continue" },
{ "<F1>", desc = "Debug: Step Into" },
{ "<F2>", desc = "Debug: Step Over" },
{ "<F3>", desc = "Debug: Step Out" },
{ "<leader>b", desc = "Debug: Toggle Breakpoint" },
{ "<leader>B", desc = "Debug: Set Breakpoint" },
{ "<F7>", desc = "Debug: See last session result." },
},
-- colorscheme = "",
load = function(name)
vim.cmd.packadd(name)
vim.cmd.packadd("nvim-dap-ui")
vim.cmd.packadd("nvim-dap-virtual-text")
end,
after = function (plugin)
local dap = require 'dap'
local dapui = require 'dapui'
-- Basic debugging keymaps, feel free to change to your liking!
vim.keymap.set('n', '<F5>', dap.continue, { desc = 'Debug: Start/Continue' })
vim.keymap.set('n', '<F1>', dap.step_into, { desc = 'Debug: Step Into' })
vim.keymap.set('n', '<F2>', dap.step_over, { desc = 'Debug: Step Over' })
vim.keymap.set('n', '<F3>', dap.step_out, { desc = 'Debug: Step Out' })
vim.keymap.set('n', '<leader>b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' })
vim.keymap.set('n', '<leader>B', function()
dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ')
end, { desc = 'Debug: Set Breakpoint' })
-- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception.
vim.keymap.set('n', '<F7>', dapui.toggle, { desc = 'Debug: See last session result.' })
dap.listeners.after.event_initialized['dapui_config'] = dapui.open
dap.listeners.before.event_terminated['dapui_config'] = dapui.close
dap.listeners.before.event_exited['dapui_config'] = dapui.close
-- Dap UI setup
-- For more information, see |:help nvim-dap-ui|
dapui.setup {
-- Set icons to characters that are more likely to work in every terminal.
-- Feel free to remove or use ones that you like more! :)
-- Don't feel like these are good choices.
icons = { expanded = '', collapsed = '', current_frame = '*' },
controls = {
icons = {
pause = '',
play = '',
step_into = '',
step_over = '',
step_out = '',
step_back = 'b',
run_last = '▶▶',
terminate = '',
disconnect = '',
},
},
}
require("nvim-dap-virtual-text").setup {
enabled = true, -- enable this plugin (the default)
enabled_commands = true, -- create commands DapVirtualTextEnable, DapVirtualTextDisable, DapVirtualTextToggle, (DapVirtualTextForceRefresh for refreshing when debug adapter did not notify its termination)
highlight_changed_variables = true, -- highlight changed values with NvimDapVirtualTextChanged, else always NvimDapVirtualText
highlight_new_as_changed = false, -- highlight new variables in the same way as changed variables (if highlight_changed_variables)
show_stop_reason = true, -- show stop reason when stopped for exceptions
commented = false, -- prefix virtual text with comment string
only_first_definition = true, -- only show virtual text at first definition (if there are multiple)
all_references = false, -- show virtual text on all all references of the variable (not only definitions)
clear_on_continue = false, -- clear virtual text on "continue" (might cause flickering when stepping)
--- A callback that determines how a variable is displayed or whether it should be omitted
--- variable Variable https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable
--- buf number
--- stackframe dap.StackFrame https://microsoft.github.io/debug-adapter-protocol/specification#Types_StackFrame
--- node userdata tree-sitter node identified as variable definition of reference (see `:h tsnode`)
--- options nvim_dap_virtual_text_options Current options for nvim-dap-virtual-text
--- string|nil A text how the virtual text should be displayed or nil, if this variable shouldn't be displayed
display_callback = function(variable, buf, stackframe, node, options)
if options.virt_text_pos == 'inline' then
return ' = ' .. variable.value
else
return variable.name .. ' = ' .. variable.value
end
end,
-- position of virtual text, see `:h nvim_buf_set_extmark()`, default tries to inline the virtual text. Use 'eol' to set to end of line
virt_text_pos = vim.fn.has 'nvim-0.10' == 1 and 'inline' or 'eol',
-- experimental features:
all_frames = false, -- show virtual text for all stack frames not only current. Only works for debugpy on my machine.
virt_lines = false, -- show virtual lines instead of virtual text (will flicker!)
virt_text_win_col = nil -- position the virtual text at a fixed window column (starting from the first text column) ,
-- e.g. 80 to position at column 80, see `:h nvim_buf_set_extmark()`
}
-- NOTE: Install lang specific config
-- either in here, or in a separate plugin spec as demonstrated for go below.
end,
},
{
"nvim-dap-go",
enabled = nixCats('go') or false,
on_plugin = { "nvim-dap", },
after = function(plugin)
require("dap-go").setup()
end,
},
{
-- lazydev makes your lsp way better in your config without needing extra lsp configuration.
"lazydev.nvim",
enabled = nixCats('lua') or false,
cmd = { "LazyDev" },
ft = "lua",
after = function(_)
require('lazydev').setup({
library = {
{ words = { "nixCats" }, path = (nixCats.nixCatsPath or "") .. '/lua' },
},
})
end,
},
{
"harpoon2",
enabled = nixCats('general') or false,
keys = {
{ "<leader>a", desc = "[A]dd harpoon" },
{ "<leader>e", desc = "[E]dit harpoon" },
{ "<leader>k", desc = "Harpoon prev" },
{ "<leader>j", desc = "Harpoon next" },
},
after = function ()
local harpoon = require("harpoon")
require("blink.cmp.sources.lsp.commands")
harpoon:setup()
vim.keymap.set("n", "<leader>a", function() harpoon:list():add() end)
vim.keymap.set("n", "<leader>e", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end)
-- Toggle previous & next buffers stored within Harpoon list
vim.keymap.set("n", "<leader>k", function() harpoon:list():prev() end)
vim.keymap.set("n", "<leader>j", function() harpoon:list():next() end)
end
},
{
"kulala.nvim",
keys = {
{ "<leader>Rs", desc = "Send request" },
{ "<leader>Ra", desc = "Send all requests" },
{ "<leader>Rb", desc = "Open scratchpad" },
},
ft = {"http", "rest"},
after = function ()
require('kulala').setup({
global_keymaps = true,
global_keymaps_prefix = "<leader>R",
})
end
},
{
"obsidian.nvim",
enabled = nixCats('notes') or false,
ft = {"md"},
after = function ()
require("obsidian").setup({
workspaces = {
{
name = "everything",
path = "~/vaults/everything"
},
},
daily_notes = {
folder = "journal"
},
})
end
},
{
"zk-nvim",
enabled = nixCats('notes') or false,
event = "DeferredUIEnter",
after = function ()
require("zk").setup({
picker = "snacks_picker"
})
local opts = { noremap=true, silent=false }
-- Create a new note after asking for its title.
vim.api.nvim_set_keymap("n", "<leader>zn", "<Cmd>ZkNew { title = vim.fn.input('Title: ') }<CR>", opts)
-- Create note from selection
vim.api.nvim_set_keymap("v", "<leader>znt", ":'<,'>ZkNewFromTitleSelection<CR>", opts)
-- Open notes.
vim.api.nvim_set_keymap("n", "<leader>zf", "<Cmd>ZkNotes { sort = { 'modified' } }<CR>", opts)
-- Open notes associated with the selected tags.
vim.api.nvim_set_keymap("n", "<leader>zt", "<Cmd>ZkTags<CR>", opts)
-- show links in note
vim.api.nvim_set_keymap("n", "<leader>zl", "<Cmd>ZkLinks<CR>", opts)
-- Search for the notes matching a given query.
vim.api.nvim_set_keymap("n", "<leader>zg", "<Cmd>ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Search: ') } }<CR>", opts)
-- Search for the notes matching the current visual selection.
vim.api.nvim_set_keymap("v", "<leader>zm", ":'<,'>ZkMatch<CR>", opts)
end
},
{
"typst-preview.nvim",
enabled = nixCats('notes') or false,
after = function ()
require('typst-preview').setup({})
end
}
}
local function lsp_on_attach(_, bufnr)
-- we create a function that lets us more easily define mappings specific
-- for LSP related items. It sets the mode, buffer and description for us each time.
local nmap = function(keys, func, desc)
if desc then
desc = 'LSP: ' .. desc
end
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
end
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
if nixCats('general') then
nmap('gr', function() Snacks.picker.lsp_references() end, '[G]oto [R]eferences')
nmap('gI', function() Snacks.picker.lsp_implementations() end, '[G]oto [I]mplementation')
nmap('<leader>ds', function() Snacks.picker.lsp_symbols() end, '[D]ocument [S]ymbols')
nmap('<leader>ws', function() Snacks.picker.lsp_workspace_symbols() end, '[W]orkspace [S]ymbols')
end
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
-- See `:help K` for why this keymap
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
-- nmap('<C-K>', vim.lsp.buf.signature_help, 'Signature Documentation')
-- Lesser used LSP functionality
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
nmap('<leader>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, '[W]orkspace [L]ist Folders')
-- Create a command `:Format` local to the LSP buffer
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
vim.lsp.buf.format()
end, { desc = 'Format current buffer with LSP' })
end
-- NOTE: Register a handler from lzextras. This one makes it so that
-- you can set up lsps within lze specs,
-- and trigger vim.lsp.enable and the rtp config collection only on the correct filetypes
-- it adds the lsp field used below
-- (and must be registered before any load calls that use it!)
require('lze').register_handlers(require('lzextras').lsp)
-- also replace the fallback filetype list retrieval function with a slightly faster one
require('lze').h.lsp.set_ft_fallback(function(name)
return dofile(nixCats.pawsible({ "allPlugins", "opt", "nvim-lspconfig" }) .. "/lsp/" .. name .. ".lua").filetypes or {}
end)
require('lze').load {
{
"nvim-lspconfig",
enabled = nixCats("general") or false,
-- the on require handler will be needed here if you want to use the
-- fallback method of getting filetypes if you don't provide any
on_require = { "lspconfig" },
-- define a function to run over all type(plugin.lsp) == table
-- when their filetype trigger loads them
lsp = function(plugin)
vim.lsp.config(plugin.name, plugin.lsp or {})
vim.lsp.enable(plugin.name)
end,
before = function(_)
vim.lsp.config('*', {
capabilities = require('blink.cmp').get_lsp_capabilities(),
on_attach = lsp_on_attach,
})
end,
},
{
-- name of the lsp
"lua_ls",
enabled = nixCats('lua') or false,
-- provide a table containing filetypes,
-- and then whatever your functions defined in the function type specs expect.
-- in our case, it just expects the normal lspconfig setup options.
lsp = {
-- if you provide the filetypes it doesn't ask lspconfig for the filetypes
filetypes = { 'lua' },
settings = {
Lua = {
runtime = { version = 'LuaJIT' },
formatters = {
ignoreComments = true,
},
signatureHelp = { enabled = true },
diagnostics = {
globals = { "nixCats", "vim", },
disable = { 'missing-fields' },
},
telemetry = { enabled = false },
},
},
},
-- also these are regular specs and you can use before and after and all the other normal fields
},
{
"vtsls",
enabled = nixCats('typescript') or false,
lsp = {},
},
{
"eslint",
enabled = nixCats('typescript') or false,
lsp = {},
},
{
"stylelint_lsp",
enabled = nixCats('typescript') or false,
lsp = {},
},
{
"tailwindcss",
enabled = false,
lsp = {},
},
{
"cssls",
enabled = nixCats('typescript') or false,
lsp = {},
},
{
"yamlls",
enabled = nixCats('yaml') or false,
lsp = {},
},
{
"clangd",
enabled = nixCats('c') or false,
lsp = {},
},
{
"gopls",
enabled = nixCats("go") or false,
lsp = {
-- filetypes = { "go", "gomod", "gowork", "gotmpl" },
},
},
{
"gitlab_ci_ls",
enabled = nixCats("gitlab") or false,
lsp = {},
},
{
"omnisharp",
enabled = nixCats("csharp") or false,
lsp = {
-- filetypes = { "go", "gomod", "gowork", "gotmpl" },
},
},
{
"tinymist",
enabled = nixCats("notes") or false,
lsp = {},
},
{
"nixd",
enabled = nixCats('nix') or false,
lsp = {
filetypes = { 'nix' },
settings = {
nixd = {
nixpkgs = {
expr = nixCats.extra("nixdExtras.nixpkgs") or [[import <nixpkgs> {}]],
},
formatting = {
command = { "alejandra" }
},
diagnostic = {
suppress = {
"sema-escaping-with"
}
}
}
},
},
},
}