Replaced several plugins with snacks.nvim.

Added zk keybinds.
This commit is contained in:
Gabe Venberg 2025-07-04 18:58:40 +02:00
parent 3bd72ab98f
commit 132d57fc3f
11 changed files with 216 additions and 525 deletions

View file

@ -1,43 +1,4 @@
# Example `nixCats` Configuration
# Gabes `nixCats` Configuration
This directory contains an example of the suggested, idiomatic way to manage a neovim configuration using `nixCats`. It leverages [`lze`](https://github.com/BirdeeHub/lze) for lazy loading, although [`lz.n`](https://github.com/nvim-neorocks/lz.n) can be used instead to similar effect. It also includes a fallback mechanism using `paq` and `mason`, allowing you to load the directory without `nix` if needed.
This setup serves as a strong starting point for a `Neovim` configuration—think of it as `kickstart.nvim`, but using `nixCats` **instead of** `lazy.nvim` and `mason`, rather than in addition to them. It also follows a modular approach, spreading the configuration across multiple files rather than consolidating everything into one.
While this is not a "perfect" configuration, nor does it claim to be, it is **a well-structured, recommended way to use `nixCats`**. You are encouraged to customize it to fit your needs. `nixCats` itself is just the `nix`-based package manager, along with its associated [Lua plugin](https://nixcats.org/nixCats_plugin.html).
## Why Use This Approach?
Using `nixCats` in this way provides a **simpler, more transparent** experience compared to solutions like `lazy.nvim`, which hijack normal plugin loading.
It leverages the normal packpath methods of loading plugins both at startup and lazily, allowing you to know what is going on behind the scenes.
It avoids duplicating functionality between nix and other nvim based download managers, avoiding compatibility issues.
You can still have a config that works without nix using this method if desired without undue difficulty.
## Directory Structure
This configuration primarily uses the following directory structure:
- The `lua/` directory for core configurations.
- The `after/plugin/` directory to demonstrate compatibility.
While this structure works well, you are encouraged to further modularize your setup by utilizing any of the runtime directories checked by Neovim:
- `ftplugin/` for file-type-specific configurations.
- `plugin/` for global plugin configurations.
- Even `pack/*/{start,opt}/` work if you want to make a plugin inside your configuration.
- And so on...
If you are unfamiliar with the above, refer to the [Neovim runtime path documentation](https://neovim.io/doc/user/options.html#'rtp').
---
> "Idiomatic" here means:
>
> - This configuration does **not** use `lazy.nvim`, and does not use `mason.nvim` when nix is involved.
> - `nixCats` is responsible for downloading all plugins.
> - Plugins are only loaded if their respective category is enabled.
> - The [Lua utilities template](https://github.com/BirdeeHub/nixCats-nvim/tree/main/templates/luaUtils/lua/nixCatsUtils) is used (see [`:h nixCats.luaUtils`](https://nixcats.org/nixCats_luaUtils.html)).
> - [`lze`](https://github.com/BirdeeHub/lze) or [`lz.n`](https://github.com/nvim-neorocks/lz.n) is used for lazy loading.
My preferred way of setting up neovim. This configuration has organically grown since 2016,
originally as a vimscript config, then as a lua config, then as a nixvim config, and finally a nix/lua hybrid.

View file

@ -55,7 +55,15 @@
name,
mkPlugin,
...
} @ packageDef: {
} @ packageDef: let
colorschemes = with pkgs.vimPlugins; {
"onedark" = onedark-nvim;
"catppuccin" = catppuccin-nvim;
"tokyonight" = tokyonight-nvim;
"nord" = nord-nvim;
"gruvbox" = gruvbox-nvim;
};
in {
# to define and use a new category, simply add a new list to a set here,
# and later, you will include categoryname = true; in the set you
# provide when you build the package using this builder function.
@ -72,15 +80,13 @@
ripgrep
fd
fzf
];
telescope = [
lazygit
zoxide
];
lsp = {
rust = [
rust-analyzer
cargo
];
lua = [
lua-language-server
@ -117,7 +123,7 @@
todo-comments-nvim
marks-nvim
];
lsp={
lsp = {
rust = [
rustaceanvim
];
@ -132,20 +138,11 @@
nvim-treesitter.withAllGrammars
treesj
];
allcolorschemes = colorschemes;
# You can retreive information from the
# packageDefinitions of the package this was packaged with.
# :help nixCats.flake.outputs.categoryDefinitions.scheme
themer = with pkgs.vimPlugins; (
builtins.getAttr (categories.colorscheme or "gruvbox") {
# Theme switcher without creating a new category
"onedark" = onedark-nvim;
"catppuccin" = catppuccin-nvim;
"tokyonight" = tokyonight-nvim;
"nord" = nord-nvim;
"gruvbox" = gruvbox-nvim;
"solarized" = solarized-nvim;
}
);
themer = builtins.getAttr (categories.colorscheme or "gruvbox") colorschemes;
# This is obviously a fairly basic usecase for this, but still nice.
};
@ -160,7 +157,6 @@
nvim-dap
nvim-dap-ui
nvim-dap-virtual-text
telescope-dap-nvim
];
};
lint = [
@ -189,11 +185,6 @@
gitsigns-nvim
nvim-surround
leap-nvim
toggleterm-nvim
];
tree = [
nvim-tree-lua
fidget-nvim
];
completion = [
luasnip
@ -203,12 +194,6 @@
blink-compat
colorful-menu-nvim
];
telescope = [
telescope-ui-select-nvim
telescope-nvim
telescope-zoxide
telescope-file-browser-nvim
];
extra = [
vim-startuptime
];
@ -244,11 +229,9 @@
extraCats = {
debug = [
["debug" "default"]
["telescope"]
];
lsp = [
["lsp" "default"]
["telescope"]
];
};
};
@ -289,11 +272,9 @@
markdown = true;
lsp = true;
completion = true;
telescope = true;
tree = true;
debug = true;
lspDebugMode = false;
themer = true;
allcolorschemes = true;
colorscheme = "gruvbox";
};
extra = {
@ -317,8 +298,6 @@
always = true;
treesitter = true;
completion = true;
telescope = true;
tree = true;
lspDebugMode = false;
themer = true;
colorscheme = "gruvbox";
@ -369,6 +348,8 @@
# and additionally output the original as default.
packages = utils.mkAllWithDefault defaultPackage;
formatter = pkgs.alejandra;
# choose your package for devShell
# and add whatever else you want in it.
devShells = {

View file

@ -2,47 +2,71 @@ local catUtils = require('nixCatsUtils')
if (catUtils.isNixCats and nixCats('lspDebugMode')) then
vim.lsp.set_log_level("debug")
end
-- 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 lspmap = function(keys, func, desc)
if desc then
desc = 'LSP: ' .. desc
end
local Snacks = require("snacks")
-- all of our LSP keybindings will be namespaced under <leader>l
keys = '<leader>l' .. keys
vim.keymap.set("n", "<leader>lI", Snacks.picker.lsp_implementations, { desc = "Goto [I]mplementation" })
vim.keymap.set("n", "<leader>lR", Snacks.picker.lsp_references, { desc = "Goto [R]eferences" })
vim.keymap.set("n", "<leader>li", Snacks.picker.diagnostics, { desc = "D[i]agnostics" })
vim.keymap.set("n", "<leader>ls", Snacks.picker.lsp_symbols, { desc = "Document [S]ymbols" })
vim.keymap.set("n", "<leader>lws", Snacks.picker.lsp_workspace_symbols, { desc = "[W]orkspace [S]ymbols" })
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
end
vim.keymap.set("n", "<leader>lD", vim.lsp.buf.declaration, { desc = "Goto [D]eclaration" })
vim.keymap.set("n", "<leader>lD", vim.lsp.buf.type_definition, { desc = "Type [D]efinition" })
vim.keymap.set("n", "<leader>la", vim.lsp.buf.code_action, { desc = "[C]ode Action" })
vim.keymap.set("n", "<leader>ld", vim.lsp.buf.definition, { desc = "Goto [D]efinition" })
vim.keymap.set("n", "<leader>lf", vim.lsp.buf.format, { desc = "Format buffer" })
vim.keymap.set("n", "<leader>lh", vim.lsp.buf.hover, { desc = "Hover Documentation" })
vim.keymap.set("n", "<leader>lr", vim.lsp.buf.rename, { desc = "[R]ename" })
vim.keymap.set("n", "<leader>ls", vim.lsp.buf.signature_help, { desc = "Signature Documentation" })
vim.keymap.set("n", "<leader>lwa", vim.lsp.buf.add_workspace_folder, { desc = "[W]orkspace [A]dd Folder" })
vim.keymap.set("n", "<leader>lwl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end,
{ desc = "[W]orkspace [L]ist Folders" })
vim.keymap.set("n", "<leader>lwr", vim.lsp.buf.remove_workspace_folder, { desc = "[W]orkspace [R]emove Folder" })
lspmap('r', vim.lsp.buf.rename, '[R]ename')
lspmap('a', vim.lsp.buf.code_action, '[C]ode Action')
-- setup lsp progress notifications
local progress = vim.defaulttable()
vim.api.nvim_create_autocmd("LspProgress", {
callback = function(ev)
local client = vim.lsp.get_client_by_id(ev.data.client_id)
local value = ev.data.params
.value --[[@as {percentage?: number, title?: string, message?: string, kind: "begin" | "report" | "end"}]]
if not client or type(value) ~= "table" then
return
end
local p = progress[client.id]
lspmap('d', vim.lsp.buf.definition, 'Goto [D]efinition')
for i = 1, #p + 1 do
if i == #p + 1 or p[i].token == ev.data.params.token then
p[i] = {
token = ev.data.params.token,
msg = ("[%3d%%] %s%s"):format(
value.kind == "end" and 100 or value.percentage or 100,
value.title or "",
value.message and (" **%s**"):format(value.message) or ""
),
done = value.kind == "end",
}
break
end
end
-- NOTE: why are these functions that call the telescope builtin?
-- because otherwise they would load telescope eagerly when this is defined.
-- due to us using the on_require handler to make sure it is available.
if nixCats('telescope') then
lspmap('R', function() require('telescope.builtin').lsp_references() end, 'Goto [R]eferences')
lspmap('I', function() require('telescope.builtin').lsp_implementations() end, 'Goto [I]mplementation')
lspmap('s', function() require('telescope.builtin').lsp_document_symbols() end, 'Document [S]ymbols')
lspmap('ws', function() require('telescope.builtin').lsp_dynamic_workspace_symbols() end, '[W]orkspace [S]ymbols')
end -- TODO: Investigate whether I can replace these with snacsk.nvim.
local msg = {} ---@type string[]
progress[client.id] = vim.tbl_filter(function(v)
return table.insert(msg, v.msg) or not v.done
end, p)
lspmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition')
lspmap('h', vim.lsp.buf.hover, 'Hover Documentation')
lspmap('s', vim.lsp.buf.signature_help, 'Signature Documentation')
lspmap('f', vim.lsp.buf.format, 'Format buffer')
-- Lesser used LSP functionality
lspmap('D', vim.lsp.buf.declaration, 'Goto [D]eclaration')
lspmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
lspmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
lspmap('wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, '[W]orkspace [L]ist Folders')
local spinner = { "", "", "", "", "", "", "", "", "", "" }
vim.notify(table.concat(msg, "\n"), "info", {
id = "lsp_progress",
title = client.name,
opts = function(notif)
notif.icon = #progress[client.id] == 0 and ""
or spinner[math.floor(vim.uv.hrtime() / (1e6 * 80)) % #spinner + 1]
end,
})
end,
})
-- NOTE: This file uses lzextras.lsp handler https://github.com/BirdeeHub/lzextras?tab=readme-ov-file#lsp-handler
-- This is a slightly more performant fallback function
@ -67,6 +91,8 @@ require('lze').load {
"nvim-lspconfig",
for_cat = "lsp",
on_require = { "lspconfig" },
-- rustaceanvim and zk-nvim dont require("lspconfig")
ft = { "markdown", "rust" },
-- NOTE: define a function for lsp,
-- and it will run for all specs with type(plugin.lsp) == table
-- when their filetype trigger loads them
@ -180,4 +206,21 @@ require('lze').load {
"rustaceanvim",
for_cat = "lsp.rust",
},
{
"zk-nvim",
for_cat = "lsp.zk",
ft = "markdown",
after = function()
require("zk").setup({ picker = "snacks_picker" })
vim.api.nvim_set_keymap("n", "<leader>zb", "<Cmd>ZkBackLinks<CR>", {desc="Show [B]acklinkgs"})
vim.api.nvim_set_keymap("n", "<leader>zl", "<Cmd>ZkLinks<CR>", {desc="Show [L]inks"})
vim.api.nvim_set_keymap("n", "<leader>zi", ":'<,'>ZkInsertLink<CR>", {desc="[I]nsert link"})
vim.api.nvim_set_keymap("n", "<leader>zn", "<Cmd>ZkNew { title = vim.fn.input('Title: ') }<CR>", {desc="[N]ew note"})
vim.api.nvim_set_keymap("n", "<leader>zo", "<Cmd>ZkNotes { sort = { 'modified' } }<CR>", {desc="[O]pen notes"})
vim.api.nvim_set_keymap("n", "<leader>zt", "<Cmd>ZkTags<CR>", {desc="Search [T]ags"})
vim.api.nvim_set_keymap("v", "<leader>zf", ":'<,'>ZkMatch<CR>", {desc="[F]ind note from selection"})
vim.api.nvim_set_keymap("v", "<leader>zn", ":'<,'>ZkNewFromTitleSelection<CR>", {desc="[N]ew note from selection"})
end
},
}

View file

@ -1,111 +0,0 @@
require('lze').load {
{
"nvim-dap",
-- NOTE: I dont want to figure out mason tools installer for this, so I only enabled debug if nix loaded config
for_cat = { cat = 'debug', default = false },
-- cmd = { "" },
-- event = "",
-- ft = "",
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." },
},
load = (require('nixCatsUtils').isNixCats and function(name)
vim.cmd.packadd(name)
vim.cmd.packadd("nvim-dap-ui")
vim.cmd.packadd("nvim-dap-virtual-text")
end) or function(name)
vim.cmd.packadd(name)
vim.cmd.packadd("nvim-dap-ui")
vim.cmd.packadd("nvim-dap-virtual-text")
vim.cmd.packadd("mason-nvim-dap.nvim")
end,
after = function(plugin)
local dap = require 'dap'
local dapui = require 'dapui'
require('telescope').load_extension('dap')
-- 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,
},
}

View file

@ -1,38 +0,0 @@
require('lze').load {
{
"conform.nvim",
for_cat = 'format',
-- cmd = { "" },
-- event = "",
-- ft = "",
keys = {
{ "<leader>FF", desc = "[F]ormat [F]ile" },
},
-- colorscheme = "",
after = function (plugin)
local conform = require("conform")
conform.setup({
formatters_by_ft = {
-- NOTE: download some formatters in lspsAndRuntimeDeps
-- and configure them here
-- lua = { "stylua" },
-- go = { "gofmt", "golint" },
-- 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,
},
}

View file

@ -1,4 +1,5 @@
-- TODO: split up the plugins a bit.
-- NOTE: various, non-plugin config
require('myLuaConf.opts_and_keys')
@ -16,21 +17,4 @@ require('lze').register_handlers(require('lzextras').lsp)
require("myLuaConf.plugins")
-- NOTE: obviously, more plugins, but more organized by what they do below
require("myLuaConf.LSPs")
-- NOTE: we even ask nixCats if we included our debug stuff in this setup! (we didnt)
-- But we have a good base setup here as an example anyway!
if nixCats('debug') then
require('myLuaConf.debug')
end
-- NOTE: we included these though! Or, at least, the category is enabled.
-- these contain nvim-lint and conform setups.
if nixCats('lint') then
require('myLuaConf.lint')
end
if nixCats('format') then
require('myLuaConf.format')
end
-- NOTE: I didnt actually include any linters or formatters in this configuration,
-- but it is enough to serve as an example.

View file

@ -1,20 +0,0 @@
require('lze').load {
{
"nvim-lint",
for_cat = 'lint',
-- cmd = { "" },
event = "FileType",
-- ft = "",
-- keys = "",
-- colorscheme = "",
after = function (plugin)
require('lint').linters_by_ft = {
-- NOTE: download some linters in lspsAndRuntimeDeps
-- and configure them here
-- markdown = {'vale',},
-- javascript = { 'eslint' },
-- typescript = { 'eslint' },
}
end,
},
}

View file

@ -1,3 +1,4 @@
-- TODO: completley out of date
-- load the plugins via paq-nvim when not on nix
-- YOU are in charge of putting the plugin
-- urls and build steps in here, which will only be used when not on nix.

View file

@ -107,8 +107,7 @@ vim.keymap.set('i', '<C-p>', '<C-r><C-p>+',
-- Diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
vim.keymap.set('n', '<leader>d', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
-- moving between splits
vim.keymap.set('n', '<C-h>', '<C-w>h', { desc = 'move to right split' })

View file

@ -30,7 +30,7 @@ if nixCats('always') then
-- didnt seem necessary.
vim.g.loaded_netrwPlugin = 1
require("oil").setup({
default_file_explorer = true,
default_file_explorer = false,
view_options = {
show_hidden = true
},
@ -63,8 +63,109 @@ if nixCats('always') then
vim.keymap.set("n", "<leader>-", "<cmd>Oil .<CR>", { noremap = true, desc = 'Open nvim root directory' })
end
if nixCats("always") then
-- Potentially checkout the lazygit module.
local Snacks = require("snacks")
Snacks.setup({
bufdelete = { enable = true },
dim = { enable = true },
git = { enable = true },
image = { enable = true },
input = { enable = true },
lazygit = { enable = true },
notifier = { enable = true },
scroll = { enable = true },
terminal = { enable = true },
toggle = { enable = true },
quickfile = { enable = true },
scope = { enable = true },
statuscolumn = { enable = true },
explorer = { replace_netrw = true },
picker = {
enabled = true,
ui_select = true,
matcher = {
fuzzy = true,
frecency = true,
},
previewers = {
diff = {
builtin = true, -- use Neovim for previewing diffs (true) or use an external tool (false)
cmd = { "delta" }, -- example to show a diff with delta
},
git = {
builtin = true, -- use Neovim for previewing git output (true) or use git (false)
},
},
},
indent = {
enabled = true,
animate = { enabled = false },
scope = { enabled = true },
chunk = { enabled = true },
},
})
-- setup keybinds.
vim.keymap.set("n", "<leader>bd", Snacks.bufdelete.delete, { desc = "delete buffer" })
vim.keymap.set("n", "<leader>t", function() Snacks.explorer() end, { desc = "File [T]ree" })
vim.keymap.set("n", "<leader>gb", Snacks.git.blame_line, { desc = "[G]it [B]lame" })
vim.keymap.set("n", "<leader>gl", Snacks.git.blame_line, { desc = "[L]azy[G]it" })
-- picker keybinds
vim.keymap.set("n", "<leader>fGb", Snacks.picker.grep_buffers, { desc = "[G]rep buffers" })
vim.keymap.set("n", "<leader>fGl", Snacks.picker.lines, { desc = "[L]ines in buffer" })
vim.keymap.set("n", "<leader>fb", Snacks.picker.buffers, { desc = "[B]uffers" })
vim.keymap.set("n", "<leader>ff", Snacks.picker.files, { desc = "[F]iles" })
vim.keymap.set("n", "<leader>fg", Snacks.picker.grep, { desc = "[G]rep all" })
vim.keymap.set("n", "<leader>fh", Snacks.picker.help, { desc = "[H]elp" })
vim.keymap.set("n", "<leader>fi", Snacks.picker.icons, { desc = "[I]cons" })
vim.keymap.set("n", "<leader>fm", Snacks.picker.marks, { desc = "[M]arks" })
vim.keymap.set("n", "<leader>fs", Snacks.picker.spelling, { desc = "[S]pelling" })
vim.keymap.set("n", "<leader>ft", Snacks.picker.treesitter, { desc = "[T]reesitter" })
vim.keymap.set("n", "<leader>fu", Snacks.picker.undo, { desc = "[U]ndo" })
vim.keymap.set("n", "<leader>fz", Snacks.picker.zoxide, { desc = "[Z]oxide" })
-- picker git keybinds
vim.keymap.set("n", "<leader>gb", Snacks.picker.git_branches, { desc = "[G]it [B]ranch" })
vim.keymap.set("n", "<leader>gl", Snacks.picker.git_log, { desc = "[G]it [L]og" })
vim.keymap.set("n", "<leader>gd", Snacks.picker.git_diff, { desc = "[G]it [D]iff" })
-- setup toggles
Snacks.toggle.option("spell", { name = "spelling" }):map("<leader>cs")
Snacks.toggle.option("relativenumber", { name = "Relative Numbering" }):map("<leader>n")
Snacks.toggle.dim():map("<leader>d")
-- terminal keybinds
vim.keymap.set("n", "<leader>s", function()
Snacks.terminal.toggle(nil, { win = { position = "float" } })
end, { desc = "terminal" })
vim.keymap.set("t", "<esc>", function(self)
self.esc_timer = self.esc_timer or (vim.uv or vim.loop).new_timer()
if self.esc_timer:is_active() then
self.esc_timer:stop()
vim.cmd("stopinsert")
else
self.esc_timer:start(200, 0, function() end)
return "<esc>"
end
end, { expr = true, desc = "Double tap to escape terminal" })
-- setup rename autocmds
local prev = { new_name = "", old_name = "" } -- Prevents duplicate events
vim.api.nvim_create_autocmd("User", {
pattern = "OilActionsPost",
callback = function(event)
if event.data.actions.type == "move" then
Snacks.rename.on_rename_file(event.data.actions.src_url, event.data.actions.dest_url)
end
end,
})
end
require('lze').load {
{ import = "myLuaConf.plugins.telescope", },
{ import = "myLuaConf.plugins.treesitter", },
{ import = "myLuaConf.plugins.completion", },
{
@ -82,7 +183,7 @@ require('lze').load {
{ "<leader>ms", "<cmd>MarkdownPreviewStop <CR>", mode = { "n" }, noremap = true, desc = "markdown preview stop" },
{ "<leader>mt", "<cmd>MarkdownPreviewToggle <CR>", mode = { "n" }, noremap = true, desc = "markdown preview toggle" },
},
before = function(plugin)
before = function()
vim.g.mkdp_auto_close = 0
end,
},
@ -90,7 +191,7 @@ require('lze').load {
"leap.nvim",
for_cat = 'always',
event = "DeferredUIEnter",
after = function(plugin)
after = function()
require('leap').set_default_mappings()
end,
},
@ -99,14 +200,14 @@ require('lze').load {
for_cat = 'always',
event = "DeferredUIEnter",
-- keys = "",
after = function(plugin)
after = function()
require('nvim-surround').setup()
end,
},
{
"marks.nvim",
for_cat = "always",
after = function(plugin)
after = function()
require('marks').setup({})
end
},
@ -120,42 +221,6 @@ require('lze').load {
vim.g.startuptime_exe_path = nixCats.packageBinPath
end,
},
{
"fidget.nvim",
for_cat = 'always',
event = "DeferredUIEnter",
-- keys = "",
after = function(plugin)
require('fidget').setup({})
end,
},
{
"toggleterm.nvim",
for_cat = "always",
after = function(plugin)
require("toggleterm").setup({
direction = "horizontal",
insert_mappings = false,
open_mapping = [[<c-\>]],
terminal_mappings = false,
})
local Terminal = require("toggleterm.terminal").Terminal
Floatingterm = Terminal:new({
hidden = true,
direction = "float",
})
vim.keymap.set(
"n",
"<leader>s",
function()
Floatingterm:toggle()
end,
{ desc = "toggle [S]cratch terminal", }
)
end
},
{
"lualine.nvim",
for_cat = 'always',
@ -164,7 +229,7 @@ require('lze').load {
-- ft = "",
-- keys = "",
-- colorscheme = "",
after = function(plugin)
after = function()
require('lualine').setup({
options = {
alwaysDivideMiddle = true,
@ -207,7 +272,7 @@ require('lze').load {
-- ft = "",
-- keys = "",
-- colorscheme = "",
after = function(plugin)
after = function()
require('gitsigns').setup({
-- See `:help gitsigns.txt`
signs = {
@ -286,79 +351,20 @@ require('lze').load {
{
"which-key.nvim",
for_cat = 'always',
after = function(plugin)
after = function()
require('which-key').setup({
})
require('which-key').add {
{ "<leader>g", group = "[g]it" },
{ "<leader>g", group = "[g]it" },
{ "<leader>z", group = "[z]ettelkasten" },
{ "<leader>gt", group = "[t]oggle" },
{ "<leader>m", group = "[m]arkdown" },
{ "<leader>f", group = "[f]ind" },
{ "<leader>t", group = "[t]ree" },
{ "<leader>c", group = "[c]heck" },
{ "<leader>l", group = "[l]sp" },
{ "<leader>m", group = "[m]arkdown" },
{ "<leader>f", group = "[f]ind" },
{ "<leader>t", group = "[t]ree" },
{ "<leader>c", group = "[c]heck" },
{ "<leader>l", group = "[l]sp" },
{ "<leader>lw", group = "[l]sp [w]orkspace" },
}
end,
},
{
"nvim-tree.lua",
for_cat = "tree",
keys = {
{ "<leader>t", "<cmd>NvimTreeToggle<CR>", desc = "Toggle file tree", },
},
after = function(plugin)
require("nvim-tree").setup()
end
},
{
-- TODO: Replace toggle term and nvim-tree with snacks equivilants?
-- Potentially checkout the lazygit module. Might even be able to replace
-- telescope?
-- if you do replace telescope, the picker module has a *ton* of interesting pickers, such as an undotree.
"snacks.nvim",
for_cat = "always",
priority = 10,
after = function()
local Snacks = require("snacks")
Snacks.setup({
input = {},
image = {},
notifier = {},
scroll = {},
picker = {
enabled = true,
ui_select = true,
},
terminal = {},
indent = {
animate = { enabled = true },
scope = { enabled = true },
chunk = { enabled = true },
},
})
-- setup rename autocmds
local prev = { new_name = "", old_name = "" } -- Prevents duplicate events
vim.api.nvim_create_autocmd("User", {
pattern = "NvimTreeSetup",
callback = function()
local events = require("nvim-tree.api").events
events.subscribe(events.Event.NodeRenamed, function(data)
if prev.new_name ~= data.new_name or prev.old_name ~= data.old_name then
data = data
Snacks.rename.on_rename_file(data.old_name, data.new_name)
end
end)
end,
})
vim.api.nvim_create_autocmd("User", {
pattern = "OilActionsPost",
callback = function(event)
if event.data.actions.type == "move" then
Snacks.rename.on_rename_file(event.data.actions.src_url, event.data.actions.dest_url)
end
end,
})
end
},
}

View file

@ -1,115 +0,0 @@
-- Telescope is a fuzzy finder that comes with a lot of different things that
-- it can fuzzy find! It's more than just a "file finder", it can search
-- many different aspects of Neovim, your workspace, LSP, and more!
--
-- The easiest way to use telescope, is to start by doing something like:
-- :Telescope help_tags
--
-- After running this command, a window will open up and you're able to
-- type in the prompt window. You'll see a list of help_tags options and
-- a corresponding preview of the help.
--
-- Two important keymaps to use while in telescope are:
-- - Insert mode: <c-/>
-- - Normal mode: ?
--
-- This opens a window that shows you all of the keymaps for the current
-- telescope picker. This is really useful to discover what Telescope can
-- do as well as how to actually do it!
-- [[ Configure Telescope ]]
-- See `:help telescope` and `:help telescope.setup()`
-- Telescope live_grep in git root
-- Function to find the git root directory based on the current buffer's path
local function find_git_root()
-- Use the current buffer's path as the starting point for the git search
local current_file = vim.api.nvim_buf_get_name(0)
local current_dir
local cwd = vim.fn.getcwd()
-- If the buffer is not associated with a file, return nil
if current_file == "" then
current_dir = cwd
else
-- Extract the directory from the current file's path
current_dir = vim.fn.fnamemodify(current_file, ":h")
end
-- Find the Git root directory from the current file's path
local git_root = vim.fn.systemlist("git -C " .. vim.fn.escape(current_dir, " ") .. " rev-parse --show-toplevel")[1]
if vim.v.shell_error ~= 0 then
print("Not a git repository. Searching on current working directory")
return cwd
end
return git_root
end
-- Custom live_grep function to search in git root
local function live_grep_git_root()
local git_root = find_git_root()
if git_root then
require('telescope.builtin').live_grep({
search_dirs = { git_root },
})
end
end
return {
{
"telescope.nvim",
for_cat = 'telescope',
cmd = { "Telescope", "LiveGrepGitRoot" },
-- NOTE: our on attach function defines keybinds that call telescope.
-- so, the on_require handler will load telescope when we use those.
on_require = { "telescope", },
-- event = "",
-- ft = "",
keys = {
{ "<leader>fM", '<cmd>Telescope notify<CR>', mode = {"n"}, desc = '[F]ind [M]essage', },
{ "<leader>fp",live_grep_git_root, mode = {"n"}, desc = '[F]ind git [P]roject root', },
{ "<leader>f/", function()
require('telescope.builtin').live_grep {
grep_open_files = true,
prompt_title = 'Live Grep in Open Files',
}
end, mode = {"n"}, desc = '[F]ind [/] in Open Files' },
{ "<leader>fb", function() return require('telescope.builtin').buffers() end, mode = {"n"}, desc = '[F]ind [B]uffers', },
{ "<leader>fr", function() return require('telescope.builtin').resume() end, mode = {"n"}, desc = '[F]ind [R]esume', },
{ "<leader>fd", function() return require('telescope.builtin').diagnostics() end, mode = {"n"}, desc = '[F]ind [D]iagnostics', },
{ "<leader>fg", function() return require('telescope.builtin').live_grep() end, mode = {"n"}, desc = '[F]ind by [G]rep', },
{ "<leader>fs", function() return require('telescope.builtin').builtin() end, mode = {"n"}, desc = '[F]ind [S]elect Telescope', },
{ "<leader>ff", function() return require('telescope.builtin').find_files() end, mode = {"n"}, desc = '[F]ind [F]iles', },
{ "<leader>fk", function() return require('telescope.builtin').keymaps() end, mode = {"n"}, desc = '[F]ind [K]eymaps', },
{ "<leader>fh", function() return require('telescope.builtin').help_tags() end, mode = {"n"}, desc = '[F]ind [H]elp', },
{ "<leader>fz", function() require("telescope").extensions.zoxide.list() end, mode = {"n"}, desc = '[F]ind [Z]oxide',},
{ "<leader>fi", function() require("telescope").extensions.file_browser.file_browser() end, mode={"n"}, desc = '[F]ind [I]nteractive file browser',},
},
load = function (name)
vim.cmd.packadd(name)
vim.cmd.packadd("telescope-ui-select.nvim")
vim.cmd.packadd("telescope-file-browser.nvim")
vim.cmd.packadd("telescope-zoxide")
end,
after = function (plugin)
local telescope = require("telescope")
telescope.setup {
-- You can put your default mappings / updates / etc. in here
-- All the info you're looking for is in `:help telescope.setup()`
--
-- pickers = {}
extensions = {
['ui-select'] = {
require('telescope.themes').get_dropdown(),
},
},
}
-- Enable telescope extensions, if they are installed
telescope.load_extension('ui-select')
telescope.load_extension('zoxide')
telescope.load_extension('file_browser')
vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {})
end,
},
}