diff --git a/nvim/init.lua b/nvim/init.lua index 4cc88d2..77c8b84 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -179,7 +179,6 @@ local function lspsetup() -- other { "K", vim.lsp.buf.hover }, { "", vim.lsp.buf.rename }, - { "rn", function() Snacks.rename.rename_file() end }, { "ca", vim.lsp.buf.code_action, { "n", "x" } }, } for _, key in ipairs(keyspec) do @@ -568,15 +567,6 @@ local function makespecs_utilbundles() version = false, opts = {}, }, - { - "echasnovski/mini.bufremove", - version = false, - opts = {}, - keys = { - { "", function() require("mini.bufremove").wipeout() end, noremap = true }, - { "", function() require("mini.bufremove").wipeout(nil, true) end, noremap = true }, - }, - }, { "folke/snacks.nvim", priority = 1000, @@ -598,12 +588,55 @@ local function makespecs_utilbundles() end) end, }, - notifier = { enabled = true }, - indent = { enabled = true }, - quickfile = { enabled = true }, + bufdelete = { enabled = true }, image = { enabled = true }, + indent = { enabled = true }, + lazygit = { enabled = vim.fn.has("lazygit") == 1 }, + notifier = { + enabled = true, + style = "minimal", + refresh = 500, + top_down = false, + }, + ---@class snacks.picker + picker = { + formatters = { file = { filename_first = true } }, + win = { preview = { wo = { statuscolumn = "" } } }, + }, + quickfile = { enabled = true }, rename = { enabled = true }, }, + keys = { + { "r", function() Snacks.rename.rename_file() end, desc = "Rename File" }, + { "", function() Snacks.bufdelete() end, desc = "Delete Buffer" }, + { "G", function() Snacks.lazygit() end, desc = "Launch Lazygit" }, + { ".", function() Snacks.scratch.open() end, desc = "Scratch Buffer" }, + -- find + { "", function() Snacks.picker.git_files() end, desc = "Find Git Files" }, + { "", function() Snacks.picker.files() end, desc = "Find Files" }, + { "", function() Snacks.picker.buffers() end, desc = "Find Buffers" }, + { "d", function() Snacks.picker.files({ cwd = "/home/hjalmarlucius/dotfiles" }) end, desc = "Find Config" }, + { "n", function() Snacks.picker.files({ cwd = "/home/hjalmarlucius/notes" }) end, desc = "Find Note" }, + -- search + { "", function() Snacks.picker.help() end, desc = "Help Pages" }, + { "", function() Snacks.picker.colorschemes() end, desc = "Colorschemes" }, + { "", function() Snacks.picker.grep() end, desc = "Grep" }, + { "*", function() Snacks.picker.grep_word() end, desc = "Visual selection or word", mode = { "n", "x" } }, + { "/", function() Snacks.picker.search_history() end, desc = "Search History" }, + { "b", function() Snacks.picker.lines() end, desc = "Grep Buffer" }, + { "B", function() Snacks.picker.grep_buffers() end, desc = "Grep Buffers" }, + { "D", function() Snacks.picker.grep({ cwd = "/home/hjalmarlucius/dotfiles" }) end, desc = "Find Config Content" }, + { "N", function() Snacks.picker.grep({ cwd = "/home/hjalmarlucius/notes" }) end, desc = "Find Notes Content" }, + { "i", function() Snacks.picker.diagnostics() end, desc = "Diagnostics" }, + { "l", function() Snacks.picker.loclist() end, desc = "Location List" }, + { "h", function() Snacks.picker.notifications() end, desc = "Notification History" }, + { "p", function() Snacks.picker.projects() end, desc = "Find Projects" }, + { "q", function() Snacks.picker.qflist() end, desc = "Quickfix List" }, + { "ΓΈ", function() Snacks.picker.command_history() end, desc = "Command History" }, + { "ss", function() Snacks.picker.lsp_symbols() end, desc = "LSP Symbols" }, + { "sS", function() Snacks.picker.lsp_workspace_symbols() end, desc = "LSP Workspace Symbols" }, + { "u", function() Snacks.picker.undo() end, desc = "Undo History" }, + }, }, } end @@ -627,8 +660,8 @@ local function makespecs_filemgmt() view_options = { show_hidden = true }, }, keys = { - { "b", "Oil .", noremap = true }, - { "B", "Oil --float .", noremap = true }, + { "e", "Oil .", noremap = true }, + { "E", "Oil --float .", noremap = true }, }, init = function() vim.api.nvim_create_autocmd("User", { @@ -814,123 +847,6 @@ local function makespecs_git() } end -local function makespecs_telescope() - local function findfiles() require("telescope.builtin").find_files({ layout_config = { width = 0.99 } }) end - local function findgitfiles() - local cwd = vim.fn.getcwd() - vim.fn.system("git rev-parse --is-inside-work-tree") - local is_inside_work_tree = vim.v.shell_error == 0 - local opts = { layout_config = { width = 0.99 } } - if is_inside_work_tree then - require("telescope.builtin").git_files(opts) - else - require("telescope.builtin").find_files(opts) - end - end - local function showdiagnostics() - require("telescope.builtin").diagnostics({ - layout_strategy = "vertical", - layout_config = { width = 0.99 }, - }) - end - local function searchfiles() require("telescope").extensions.live_grep_args.live_grep_args() end - local function colorschemes() - require("telescope.builtin").colorscheme({ - layout_config = { width = 0.5 }, - enable_preview = true, - ignore_builtins = true, - }) - end - return { - { - "nvim-telescope/telescope.nvim", - version = false, - dependencies = { - "sharkdp/fd", - "nvim-lua/plenary.nvim", - "nvim-telescope/telescope-live-grep-args.nvim", - }, - keys = { - { "", findfiles, noremap = true }, - { "", findgitfiles, noremap = true }, - { "", showdiagnostics, noremap = true }, - { "", searchfiles, noremap = true }, - { "", function() require("telescope.builtin").filetypes() end, noremap = true }, - { "", function() require("telescope.builtin").search_history() end, noremap = true }, - { "", colorschemes, noremap = true }, - }, - config = function() - -- TODO grep with regex - local actions = require("telescope.actions") - require("telescope").setup({ - defaults = { - layout_config = { horizontal = { width = 0.99 } }, - mappings = { - i = { - [""] = "close", - [""] = "select_default", - [""] = "move_selection_next", - [""] = "move_selection_previous", - [""] = "preview_scrolling_up", - [""] = "preview_scrolling_down", - [""] = "select_horizontal", - [""] = "select_vertical", - [""] = "select_tab", - [""] = actions.toggle_selection + actions.move_selection_worse, - [""] = actions.toggle_selection + actions.move_selection_better, - [""] = actions.send_to_loclist + actions.open_loclist, - [""] = actions.send_selected_to_loclist + actions.open_loclist, - [""] = require("telescope.actions.layout").toggle_preview, - [""] = "results_scrolling_up", - [""] = "results_scrolling_down", - }, - n = { [""] = require("telescope.actions.layout").toggle_preview }, - }, - file_ignore_patterns = {}, - set_env = { ["COLORTERM"] = "truecolor" }, - }, - }) - end, - }, - { - "debugloop/telescope-undo.nvim", - dependencies = { - { - "nvim-telescope/telescope.nvim", - dependencies = { "nvim-lua/plenary.nvim" }, - }, - }, - keys = { - { - "", - function() require("telescope").extensions.undo.undo() end, - desc = "undo history", - }, - }, - opts = { - extensions = { - undo = { - side_by_side = true, - vim_diff_opts = { ctxlen = vim.o.scrolloff }, - entry_format = "state #$ID, $STAT, $TIME", - time_format = "%H:%M:%S %m/%d/%Y", - saved_only = false, - layout_strategy = "vertical", - layout_config = { preview_height = 0.6, width = 0.99 }, - }, - }, - }, - config = function(_, opts) - -- Calling telescope's setup from multiple specs does not hurt, it will happily merge the - -- configs for us. We won't use data, as everything is in it's own namespace (telescope - -- defaults, as well as each extension). - require("telescope").setup(opts) - require("telescope").load_extension("undo") - end, - }, - } -end - local function makespec_todolists() return { "folke/todo-comments.nvim", @@ -1248,7 +1164,6 @@ for _, specs in ipairs({ makespecs_themes(), makespecs_utilbundles(), makespecs_filemgmt(), - makespecs_telescope(), makespecs_previewers(), makespecs_git(), }) do