diff options
| author | beeb5k (Vivek Tiwari) <beebeeb5k@gmail.com> | 2026-06-04 20:25:23 +0530 |
|---|---|---|
| committer | beeb5k (Vivek Tiwari) <beebeeb5k@gmail.com> | 2026-06-04 20:25:23 +0530 |
| commit | bfe5ef76b95725451707f6061d5dfa5e3b024c61 (patch) | |
| tree | e61fd46ffbb77e131edbc0ffe1019cef2d7662a9 /lua | |
| parent | 3ab5bbeda2c86b62999b5a662374c38e3ef0c01b (diff) | |
Use better Plugins
- codediff
- neogit
- nvim-surround
- hlchunk
- fff.nvim
- gitsigns
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/bee/LSPs/init.lua | 325 | ||||
| -rw-r--r-- | lua/bee/LSPs/on_attach.lua | 80 | ||||
| -rw-r--r-- | lua/bee/init.lua | 53 | ||||
| -rw-r--r-- | lua/bee/plugins/blink.lua | 290 | ||||
| -rw-r--r-- | lua/bee/plugins/git.lua | 99 | ||||
| -rw-r--r-- | lua/bee/plugins/init.lua | 11 | ||||
| -rw-r--r-- | lua/bee/plugins/oil.lua | 138 | ||||
| -rw-r--r-- | lua/bee/plugins/picker.lua | 62 | ||||
| -rw-r--r-- | lua/bee/plugins/ui.lua | 51 |
9 files changed, 692 insertions, 417 deletions
diff --git a/lua/bee/LSPs/init.lua b/lua/bee/LSPs/init.lua index 3bc86a5..69f34cf 100644 --- a/lua/bee/LSPs/init.lua +++ b/lua/bee/LSPs/init.lua @@ -1,148 +1,185 @@ local MP = ... local get_nixd_opts = nixInfo(nil, "info", "nixdExtras", "get_configs") return { - { - "mason.nvim", - auto_enable = true, - priority = 55, - on_plugin = { "nvim-lspconfig" }, - lsp = function(plugin) - vim.cmd.MasonInstall(plugin.name) - end, - }, - { - "nvim-lspconfig", - auto_enable = true, - priority = 50, - lsp = function(plugin) - vim.lsp.config(plugin.name, plugin.lsp or {}) - vim.lsp.enable(plugin.name) - end, - before = function(_) - vim.lsp.config("*", { - on_attach = require(MP:relpath("on_attach")), - }) - end, - }, - { - "lua_ls", - for_cat = "lua", - lsp = { - filetypes = { "lua" }, - settings = { - Lua = { - runtime = { version = "LuaJIT" }, - formatters = { - ignoreComments = true, - }, - signatureHelp = { enabled = true }, - diagnostics = { - globals = { "vim", "make_test" }, - disable = {}, - }, - workspace = { - checkThirdParty = false, - library = { - -- '${3rd}/luv/library', - -- unpack(vim.api.nvim_get_runtime_file('', true)), - }, - }, - completion = { - callSnippet = "Replace", - }, - telemetry = { enabled = false }, - }, - }, - }, - }, - { - "nixd", - for_cat = "nix", - after = function(_) - vim.api.nvim_create_user_command("StartNilLSP", function() - vim.lsp.start(vim.lsp.config.nil_ls) - end, { desc = "Run nil-ls (when you really need docs for the builtins and nixd refuse)" }) - end, - lsp = { - filetypes = { "nix" }, - settings = { - nixd = { - nixpkgs = { - expr = nixInfo("import <nixpkgs> {}", "info", "nixdExtras", "nixpkgs"), - }, - formatting = { - command = { "nixfmt" }, - }, - options = { - -- (builtins.getFlake "path:${builtins.toString <path_to_system_flake>}").legacyPackages.<system>.nixosConfigurations."<user@host>".options - nixos = { - expr = get_nixd_opts - and get_nixd_opts("nixos", nixInfo(nil, "info", "nixdExtras", "flake-path")), - }, - -- (builtins.getFlake "path:${builtins.toString <path_to_system_flake>}").legacyPackages.<system>.homeConfigurations."<user@host>".options - ["home-manager"] = { - expr = get_nixd_opts - and get_nixd_opts("home-manager", nixInfo(nil, "info", "nixdExtras", "flake-path")), -- <- if flake-path is nil it will be lsp root dir - }, - }, - diagnostic = { - suppress = { - "sema-escaping-with", - }, - }, - }, - }, - }, - }, - { - "clangd", - for_cat = "C", - lsp = { - filetypes = { "c", "cpp", "objc", "objcpp", "cuda", "proto" }, - on_attach = function(client, bufnr) - require(MP:relpath("on_attach"))(client, bufnr) - -- the stuff they were adding that was overriding my on_attach - dofile(nixInfo.utils.get_nix_plugin_path("nvim-lspconfig") .. "/lsp/clangd.lua").on_attach( - client, - bufnr - ) - end, - -- unneded thanks to clangd_extensions-nvim I think - -- settings = { - -- clangd_config = { - -- init_options = { - -- compilationDatabasePath="./build", - -- }, - -- } - -- } - }, - }, - { - "gopls", - for_cat = "go", - lsp = { - filetypes = { "go", "gomod", "gowork", "gotmpl", "templ" }, - }, - }, - { - "zls", - for_cat = "zig", - lsp = { - filetypes = { "zig", "zir" }, - }, - }, - { - "rust_analyzer", - for_cat = "rust", - lsp = { - filetypes = { "rust" }, - }, - }, - { - "bashls", - for_cat = "bash", - lsp = { - filetypes = { "bash", "sh" }, - }, - }, + { + "mason.nvim", + auto_enable = true, + priority = 55, + on_plugin = { "nvim-lspconfig" }, + lsp = function(plugin) + vim.cmd.MasonInstall(plugin.name) + end, + }, + { + "nvim-lspconfig", + auto_enable = true, + priority = 50, + lsp = function(plugin) + vim.lsp.config(plugin.name, plugin.lsp or {}) + vim.lsp.enable(plugin.name) + end, + before = function(_) + vim.lsp.config("*", { + on_attach = require(MP:relpath("on_attach")), + }) + end, + }, + { + "rustaceanvim", + auto_enable = true, + lazy = false, -- lazy loaded by default + before = function(_) + local RustLsp = function(mode, keymap, action, bufnr) + vim.keymap.set(mode, keymap, function() + vim.cmd.RustLsp(action) + end, { silent = true, buffer = bufnr }) + end + + vim.g.rustaceanvim = { + tools = {}, + server = { + on_attach = function(client, bufnr) + RustLsp({ "n", "x" }, "<leader>ca", "codeAction", bufnr) + RustLsp("n", "<leader>ee", "explainError", bufnr) + RustLsp("n", "K", { "hover", "actions" }, bufnr) + RustLsp("n", "L", { "hover", "range" }, bufnr) + RustLsp("n", "<F5>", "debuggables", bufnr) + end, + default_settings = { + ["rust-analyzer"] = { + checkOnSave = { + enable = true, + command = "clippy", + }, + procMacro = { + enable = true, + }, + }, + }, + }, + -- dap = {}, + } + end, + }, + { + "lua_ls", + for_cat = "lua", + lsp = { + filetypes = { "lua" }, + settings = { + Lua = { + runtime = { version = "LuaJIT" }, + formatters = { + ignoreComments = true, + }, + signatureHelp = { enabled = true }, + diagnostics = { + globals = { "vim", "make_test" }, + disable = {}, + }, + workspace = { + checkThirdParty = false, + library = { + -- '${3rd}/luv/library', + -- unpack(vim.api.nvim_get_runtime_file('', true)), + }, + }, + completion = { + callSnippet = "Replace", + }, + telemetry = { enabled = false }, + }, + }, + }, + }, + { + "nixd", + for_cat = "nix", + after = function(_) + vim.api.nvim_create_user_command("StartNilLSP", function() + vim.lsp.start(vim.lsp.config.nil_ls) + end, { desc = "Run nil-ls (when you really need docs for the builtins and nixd refuse)" }) + end, + lsp = { + filetypes = { "nix" }, + settings = { + nixd = { + nixpkgs = { + expr = nixInfo("import <nixpkgs> {}", "info", "nixdExtras", "nixpkgs"), + }, + formatting = { + command = { "nixfmt" }, + }, + options = { + -- (builtins.getFlake "path:${builtins.toString <path_to_system_flake>}").legacyPackages.<system>.nixosConfigurations."<user@host>".options + nixos = { + expr = get_nixd_opts + and get_nixd_opts("nixos", nixInfo(nil, "info", "nixdExtras", "flake-path")), + }, + -- (builtins.getFlake "path:${builtins.toString <path_to_system_flake>}").legacyPackages.<system>.homeConfigurations."<user@host>".options + ["home-manager"] = { + expr = get_nixd_opts + and get_nixd_opts("home-manager", nixInfo(nil, "info", "nixdExtras", "flake-path")), -- <- if flake-path is nil it will be lsp root dir + }, + }, + diagnostic = { + suppress = { + "sema-escaping-with", + }, + }, + }, + }, + }, + }, + { + "clangd", + for_cat = "C", + lsp = { + filetypes = { "c", "cpp", "objc", "objcpp", "cuda", "proto" }, + on_attach = function(client, bufnr) + require(MP:relpath("on_attach"))(client, bufnr) + -- the stuff they were adding that was overriding my on_attach + dofile(nixInfo.utils.get_nix_plugin_path("nvim-lspconfig") .. "/lsp/clangd.lua").on_attach( + client, + bufnr + ) + end, + -- unneded thanks to clangd_extensions-nvim I think + -- settings = { + -- clangd_config = { + -- init_options = { + -- compilationDatabasePath="./build", + -- }, + -- } + -- } + }, + }, + { + "gopls", + for_cat = "go", + lsp = { + filetypes = { "go", "gomod", "gowork", "gotmpl", "templ" }, + }, + }, + { + "zls", + for_cat = "zig", + lsp = { + filetypes = { "zig", "zir" }, + }, + }, + -- { + -- "rust_analyzer", + -- for_cat = "rust", + -- lsp = { + -- filetypes = { "rust" }, + -- }, + -- }, + { + "bashls", + for_cat = "bash", + lsp = { + filetypes = { "bash", "sh" }, + }, + }, } diff --git a/lua/bee/LSPs/on_attach.lua b/lua/bee/LSPs/on_attach.lua index d4d69e4..8199fb1 100644 --- a/lua/bee/LSPs/on_attach.lua +++ b/lua/bee/LSPs/on_attach.lua @@ -5,50 +5,50 @@ -- end, -- }) return function(_, 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. + -- 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 map = function(keys, func, desc, mode) - if desc then - desc = "LSP: " .. desc - end - vim.keymap.set(mode or "n", keys, func, { buffer = bufnr, desc = desc }) - end + local map = function(keys, func, desc, mode) + if desc then + desc = "LSP: " .. desc + end + vim.keymap.set(mode or "n", keys, func, { buffer = bufnr, desc = desc }) + end - map("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame") - map("<leader>la", vim.lsp.buf.code_action, "[L]sp [A]ction") + map("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame") + map("<leader>la", vim.lsp.buf.code_action, "[L]sp [A]ction") - -- See `:help K` for why this keymap - map("K", vim.lsp.buf.hover, "Hover Documentation") - map("<C-k>", vim.lsp.buf.signature_help, "Signature Documentation") + -- See `:help K` for why this keymap + map("K", vim.lsp.buf.hover, "Hover Documentation") + map("<C-k>", vim.lsp.buf.signature_help, "Signature Documentation") - -- Lesser used LSP functionality - map("<leader>wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder") - map("<leader>wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder") - map("<leader>wl", function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, "[W]orkspace [L]ist Folders") + -- Lesser used LSP functionality + map("<leader>wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder") + map("<leader>wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder") + map("<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" }) - map("<leader>Fl", ":Format<CR>", "[F]ormat with [l]sp") - map("<leader>FL", ":Format<CR>", "[F]ormat with [L]SP") - -- The following two autocommands are used to highlight references of the - -- word under your cursor when your cursor rests there for a little while. - -- See `:help CursorHold` for information about when this is executed - -- When you move your cursor, the highlights will be cleared (the second autocommand). - -- local client = vim.lsp.get_client_by_id(event.data.client_id) - -- if client and client.server_capabilities.documentHighlightProvider then - -- vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { - -- buffer = event.buf, - -- callback = vim.lsp.buf.document_highlight, - -- }) + -- 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" }) + map("<leader>Fl", ":Format<CR>", "[F]ormat with [l]sp") + map("<leader>FL", ":Format<CR>", "[F]ormat with [L]SP") + -- The following two autocommands are used to highlight references of the + -- word under your cursor when your cursor rests there for a little while. + -- See `:help CursorHold` for information about when this is executed + -- When you move your cursor, the highlights will be cleared (the second autocommand). + -- local client = vim.lsp.get_client_by_id(event.data.client_id) + -- if client and client.server_capabilities.documentHighlightProvider then + -- vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { + -- buffer = event.buf, + -- callback = vim.lsp.buf.document_highlight, + -- }) - -- vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { - -- buffer = event.buf, - -- callback = vim.lsp.buf.clear_references, - -- }) - -- end + -- vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { + -- buffer = event.buf, + -- callback = vim.lsp.buf.clear_references, + -- }) + -- end end diff --git a/lua/bee/init.lua b/lua/bee/init.lua index 23991ef..2b71bc4 100644 --- a/lua/bee/init.lua +++ b/lua/bee/init.lua @@ -57,21 +57,48 @@ nixInfo.lze.load({ end, }, { - "mini.pick", - lazy = true, + "nvim-surround", auto_enable = true, - keys = { - { "<leader>ff", desc = "File finder" }, - { "<leader>bb", desc = "List open buffers" }, - { "<leader>sg", desc = "Live grep" }, - { "<leader>/", desc = "Grep" }, - }, + event = "DeferredUIEnter", + before = function(_) + vim.g.nvim_surround_no_mappings = true + end, after = function(_) - require("mini.pick").setup({ - vim.keymap.set("n", "<leader>ff", "<cmd>Pick files<cr>", { desc = "File finder" }), - vim.keymap.set("n", "<leader>bb", "<cmd>Pick buffers<cr>", { desc = "List open buffers" }), - vim.keymap.set("n", "<leader>sg", "<cmd>Pick grep_live<cr>", { desc = "live grep" }), - vim.keymap.set("n", "<leader>/", "<cmd>Pick grep<cr>", { desc = "Grep" }), + require("nvim-surround").setup({ + keymaps = false, + }) + vim.keymap.set("i", "<C-g>s", "<Plug>(nvim-surround-insert)", { + desc = "Add a surrounding pair around the cursor (insert mode)", + }) + vim.keymap.set("i", "<C-g>S", "<Plug>(nvim-surround-insert-line)", { + desc = "Add a surrounding pair around the cursor, on new lines (insert mode)", + }) + vim.keymap.set("n", "sa", "<Plug>(nvim-surround-normal)", { + desc = "Add a surrounding pair around a motion (normal mode)", + }) + vim.keymap.set("n", "saa", "<Plug>(nvim-surround-normal-cur)", { + desc = "Add a surrounding pair around the current line (normal mode)", + }) + vim.keymap.set("n", "sA", "<Plug>(nvim-surround-normal-line)", { + desc = "Add a surrounding pair around a motion, on new lines (normal mode)", + }) + vim.keymap.set("n", "sAA", "<Plug>(nvim-surround-normal-cur-line)", { + desc = "Add a surrounding pair around the current line, on new lines (normal mode)", + }) + vim.keymap.set("x", "S", "<Plug>(nvim-surround-visual)", { + desc = "Add a surrounding pair around a visual selection", + }) + vim.keymap.set("x", "gS", "<Plug>(nvim-surround-visual-line)", { + desc = "Add a surrounding pair around a visual selection, on new lines", + }) + vim.keymap.set("n", "sd", "<Plug>(nvim-surround-delete)", { + desc = "Delete a surrounding pair", + }) + vim.keymap.set("n", "cs", "<Plug>(nvim-surround-change)", { + desc = "Change a surrounding pair", + }) + vim.keymap.set("n", "cS", "<Plug>(nvim-surround-change-line)", { + desc = "Change a surrounding pair, putting replacements on new lines", }) end, }, diff --git a/lua/bee/plugins/blink.lua b/lua/bee/plugins/blink.lua index 7fd147b..2dae119 100644 --- a/lua/bee/plugins/blink.lua +++ b/lua/bee/plugins/blink.lua @@ -1,150 +1,150 @@ local MP = ... return { - { - "luasnip", - auto_enable = true, - dep_of = { "blink.cmp" }, - after = function(_) - local luasnip = require("luasnip") - require("luasnip.loaders.from_vscode").lazy_load() - luasnip.config.setup({}) + { + "luasnip", + auto_enable = true, + dep_of = { "blink.cmp" }, + after = function(_) + local luasnip = require("luasnip") + require("luasnip.loaders.from_vscode").lazy_load() + luasnip.config.setup({}) - local ls = require("luasnip") - local s = ls.snippet - local t = ls.text_node - local i = ls.insert_node - local extras = require("luasnip.extras") - local rep = extras.rep - local fmta = require("luasnip.extras.fmt").fmta - local c = ls.choice_node - local f = ls.function_node - local d = ls.dynamic_node - local sn = ls.snippet_node + local ls = require("luasnip") + local s = ls.snippet + local t = ls.text_node + local i = ls.insert_node + local extras = require("luasnip.extras") + local rep = extras.rep + local fmta = require("luasnip.extras.fmt").fmta + local c = ls.choice_node + local f = ls.function_node + local d = ls.dynamic_node + local sn = ls.snippet_node - vim.keymap.set({ "i", "s" }, "<M-n>", function() - if ls.choice_active() then - ls.change_choice(1) - end - end) - end, - }, - { - "colorful-menu.nvim", - auto_enable = true, - on_plugin = { "blink.cmp" }, - }, - { - "blink.cmp", - auto_enable = true, - event = { "InsertEnter", "CmdlineEnter" }, - after = function(_) - require("blink.cmp").setup({ - keymap = { preset = "default" }, - cmdline = { - enabled = true, - completion = { - menu = { - auto_show = true, - }, - }, - sources = function() - local type = vim.fn.getcmdtype() - -- Search forward and backward - if type == "/" or type == "?" then - return { "buffer" } - end - -- Commands - if type == ":" or type == "@" then - return { "cmdline" } - end - return {} - end, - }, - term = { - enabled = false, - }, - fuzzy = { - sorts = { - "exact", - "score", - "sort_text", - }, - }, - appearance = { - nerd_font_variant = "mono", - }, - signature = { - enabled = true, - window = { - show_documentation = true, - }, - }, - completion = { - menu = { - draw = { - columns = { - { "label", "label_description", gap = 1 }, - { "srckind" }, - }, - treesitter = { "lsp" }, - components = { - srckind = { - ellipsis = false, - width = { fill = true }, - text = function(ctx) - return ctx.kind - end, - highlight = function(ctx) - return ctx.kind_hl - end, - }, - label = { - text = function(ctx) - return require("colorful-menu").blink_components_text(ctx) - end, - highlight = function(ctx) - return require("colorful-menu").blink_components_highlight(ctx) - end, - }, - }, - }, - }, - documentation = { - auto_show = true, - }, - }, - ---@type blink.cmp.SnippetsConfig - snippets = { - preset = "luasnip", - active = function(filter) - local snippet = require("luasnip") - local blink = require("blink.cmp") - if snippet.in_snippet() and not blink.is_visible() then - return true - else - if not snippet.in_snippet() and vim.fn.mode() == "n" then - snippet.unlink_current() - vim.snippet.stop() - end - return false - end - end, - }, - sources = { - default = { "lsp", "path", "snippets", "buffer", "omni" }, - providers = { - path = { - score_offset = 50, - }, - lsp = { - score_offset = 40, - }, - snippets = { - score_offset = 40, - }, - }, - }, - }) - end, - }, + vim.keymap.set({ "i", "s" }, "<M-n>", function() + if ls.choice_active() then + ls.change_choice(1) + end + end) + end, + }, + { + "colorful-menu.nvim", + auto_enable = true, + on_plugin = { "blink.cmp" }, + }, + { + "blink.cmp", + auto_enable = true, + event = { "InsertEnter", "CmdlineEnter" }, + after = function(_) + require("blink.cmp").setup({ + keymap = { preset = "default" }, + cmdline = { + enabled = true, + completion = { + menu = { + auto_show = true, + }, + }, + sources = function() + local type = vim.fn.getcmdtype() + -- Search forward and backward + if type == "/" or type == "?" then + return { "buffer" } + end + -- Commands + if type == ":" or type == "@" then + return { "cmdline" } + end + return {} + end, + }, + term = { + enabled = false, + }, + fuzzy = { + sorts = { + "exact", + "score", + "sort_text", + }, + }, + appearance = { + nerd_font_variant = "mono", + }, + signature = { + enabled = true, + window = { + show_documentation = true, + }, + }, + completion = { + menu = { + draw = { + columns = { + { "label", "label_description", gap = 1 }, + { "srckind" }, + }, + treesitter = { "lsp" }, + components = { + srckind = { + ellipsis = false, + width = { fill = true }, + text = function(ctx) + return ctx.kind + end, + highlight = function(ctx) + return ctx.kind_hl + end, + }, + label = { + text = function(ctx) + return require("colorful-menu").blink_components_text(ctx) + end, + highlight = function(ctx) + return require("colorful-menu").blink_components_highlight(ctx) + end, + }, + }, + }, + }, + documentation = { + auto_show = true, + }, + }, + ---@type blink.cmp.SnippetsConfig + snippets = { + preset = "luasnip", + active = function(filter) + local snippet = require("luasnip") + local blink = require("blink.cmp") + if snippet.in_snippet() and not blink.is_visible() then + return true + else + if not snippet.in_snippet() and vim.fn.mode() == "n" then + snippet.unlink_current() + vim.snippet.stop() + end + return false + end + end, + }, + sources = { + default = { "lsp", "path", "snippets", "buffer", "omni" }, + providers = { + path = { + score_offset = 50, + }, + lsp = { + score_offset = 40, + }, + snippets = { + score_offset = 40, + }, + }, + }, + }) + end, + }, } diff --git a/lua/bee/plugins/git.lua b/lua/bee/plugins/git.lua index 78be9b4..ed696cf 100644 --- a/lua/bee/plugins/git.lua +++ b/lua/bee/plugins/git.lua @@ -37,6 +37,25 @@ return { end, }, { + "neogit", + auto_enable = true, + keys = { { "<leader>gg", "<CMD>Neogit<CR>", desc = "Open git" } }, + cmd = { "Neogit" }, + after = function(_) + require("neogit").setup() + end, + }, + { + "codediff.nvim", + auto_enable = true, + dep_of = { "neogit" }, + cmd = "CodeDiff", + after = function() + require("codediff").setup() + end, + }, + + { "mini.diff", auto_enable = true, event = "DeferredUIEnter", @@ -59,4 +78,84 @@ return { }) end, }, + { + "gitsigns.nvim", + auto_enable = true, + event = "DeferredUIEnter", + after = function(_) + 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, + }, } diff --git a/lua/bee/plugins/init.lua b/lua/bee/plugins/init.lua index 59e0a41..43d69e0 100644 --- a/lua/bee/plugins/init.lua +++ b/lua/bee/plugins/init.lua @@ -1,9 +1,10 @@ local MP = ... return { - { import = MP:relpath("ui") }, - { import = MP:relpath("oil") }, - { import = MP:relpath("git") }, - { import = MP:relpath("blink") }, - { import = MP:relpath("treesitter") }, + { import = MP:relpath("ui") }, + { import = MP:relpath("oil") }, + { import = MP:relpath("git") }, + { import = MP:relpath("blink") }, + { import = MP:relpath("picker") }, + { import = MP:relpath("treesitter") }, } diff --git a/lua/bee/plugins/oil.lua b/lua/bee/plugins/oil.lua index 5f8c6d6..6a5e69b 100644 --- a/lua/bee/plugins/oil.lua +++ b/lua/bee/plugins/oil.lua @@ -1,72 +1,70 @@ return { - { - "oil.nvim", - lazy = true, - keys = { { "<leader>o", "<CMD>Oil<CR>", desc = "Open oil" } }, - auto_enable = true, - after = function() - vim.g.loaded_netrwPlugin = 1 - vim.keymap.set("n", "<leader>o", "<cmd>Oil .<CR>", { noremap = true, desc = "Open nvim root directory" }) - require("oil").setup({ - keymaps = { - ["-"] = "actions.parent", - ["<CR>"] = "actions.select", - ["<C-v>"] = "actions.select_vsplit", - ["<C-s>"] = "actions.select_split", - }, - vim.keymap.set("n", "<leader>o", "<cmd>Oil<cr>", { desc = "Open Oil" }), - - -- Oil will take over directory buffers (e.g. `vim .` or `:e src/`) - -- Set to false if you still want to use netrw. - default_file_explorer = true, - -- Id is automatically added at the beginning, and name at the end - -- See :help oil-columns - columns = { - "icon", - "permissions", - "size", - -- "mtime", - }, - -- Buffer-local options to use for oil buffers - buf_options = { - buflisted = false, - bufhidden = "hide", - }, - -- Window-local options to use for oil buffers - win_options = { - wrap = false, - signcolumn = "no", - cursorcolumn = false, - foldcolumn = "0", - spell = false, - list = false, - conceallevel = 3, - concealcursor = "nvic", - }, - -- Send deleted files to the trash instead of permanently deleting them (:help oil-trash) - delete_to_trash = false, - -- Skip the confirmation popup for simple operations (:help oil.skip_confirm_for_simple_edits) - skip_confirm_for_simple_edits = false, - -- Selecting a new/moved/renamed file or directory will prompt you to save changes first - -- (:help prompt_save_on_select_new_entry) - prompt_save_on_select_new_entry = true, - -- Oil will automatically delete hidden buffers after this delay - -- You can set the delay to false to disable cleanup entirely - -- Note that the cleanup process only starts when none of the oil buffers are currently displayed - cleanup_delay_ms = 2000, - lsp_file_methods = { - -- Time to wait for LSP file operations to complete before skipping - timeout_ms = 1000, - -- Set to true to autosave buffers that are updated with LSP willRenameFiles - -- Set to "unmodified" to only save unmodified buffers - autosave_changes = false, - }, - -- Constrain the cursor to the editable parts of the oil buffer - -- Set to `false` to disable, or "name" to keep it on the file names - constrain_cursor = "editable", - -- Set to true to watch the filesystem for changes and reload oil - experimental_watch_for_changes = false, - }) - end, - }, + { + "oil.nvim", + lazy = false, + keys = { { "<leader>o", "<CMD>Oil<CR>", desc = "Open oil" } }, + cmd = "Oil", + auto_enable = true, + after = function() + vim.g.loaded_netrwPlugin = 1 + require("oil").setup({ + keymaps = { + ["-"] = "actions.parent", + ["<CR>"] = "actions.select", + ["<C-v>"] = "actions.select_vsplit", + ["<C-s>"] = "actions.select_split", + }, + -- Oil will take over directory buffers (e.g. `vim .` or `:e src/`) + -- Set to false if you still want to use netrw. + default_file_explorer = true, + -- Id is automatically added at the beginning, and name at the end + -- See :help oil-columns + columns = { + "icon", + "permissions", + "size", + -- "mtime", + }, + -- Buffer-local options to use for oil buffers + buf_options = { + buflisted = false, + bufhidden = "hide", + }, + -- Window-local options to use for oil buffers + win_options = { + wrap = false, + signcolumn = "no", + cursorcolumn = false, + foldcolumn = "0", + spell = false, + list = false, + conceallevel = 3, + concealcursor = "nvic", + }, + -- Send deleted files to the trash instead of permanently deleting them (:help oil-trash) + delete_to_trash = false, + -- Skip the confirmation popup for simple operations (:help oil.skip_confirm_for_simple_edits) + skip_confirm_for_simple_edits = false, + -- Selecting a new/moved/renamed file or directory will prompt you to save changes first + -- (:help prompt_save_on_select_new_entry) + prompt_save_on_select_new_entry = true, + -- Oil will automatically delete hidden buffers after this delay + -- You can set the delay to false to disable cleanup entirely + -- Note that the cleanup process only starts when none of the oil buffers are currently displayed + cleanup_delay_ms = 2000, + lsp_file_methods = { + -- Time to wait for LSP file operations to complete before skipping + timeout_ms = 1000, + -- Set to true to autosave buffers that are updated with LSP willRenameFiles + -- Set to "unmodified" to only save unmodified buffers + autosave_changes = false, + }, + -- Constrain the cursor to the editable parts of the oil buffer + -- Set to `false` to disable, or "name" to keep it on the file names + constrain_cursor = "editable", + -- Set to true to watch the filesystem for changes and reload oil + experimental_watch_for_changes = false, + }) + end, + }, } diff --git a/lua/bee/plugins/picker.lua b/lua/bee/plugins/picker.lua new file mode 100644 index 0000000..9d23faa --- /dev/null +++ b/lua/bee/plugins/picker.lua @@ -0,0 +1,62 @@ +return { + { + "fff.nvim", + auto_enable = true, + lazy = false, -- the plugin lazy-initialises itself + before = function(_) + vim.g.fff = { + lazy_sync = true, + debug = { enabled = false, show_scores = false }, + } + end, + keys = { + { + "ff", + function() + require("fff").find_files() + end, + desc = "Find files", + }, + { + "fg", + function() + require("fff").live_grep() + end, + desc = "Live grep", + }, + { + "fz", + function() + require("fff").live_grep({ grep = { modes = { "fuzzy", "plain" } } }) + end, + desc = "Live fuzy grep", + }, + { + "fc", + function() + require("fff").live_grep({ query = vim.fn.expand("<cword>") }) + end, + desc = "Search current word", + }, + }, + }, + { + "mini.pick", + lazy = true, + auto_enable = true, + keys = { + { "<leader>ff", desc = "File finder" }, + { "<leader>bb", desc = "List open buffers" }, + { "<leader>fg", desc = "Live grep" }, + { "<leader>/", desc = "Grep" }, + }, + after = function(_) + require("mini.pick").setup({ + vim.keymap.set("n", "<leader>ff", "<cmd>Pick files<cr>", { desc = "File finder" }), + vim.keymap.set("n", "<leader>bb", "<cmd>Pick buffers<cr>", { desc = "List open buffers" }), + vim.keymap.set("n", "<leader>sg", "<cmd>Pick grep_live<cr>", { desc = "live grep" }), + vim.keymap.set("n", "<leader>/", "<cmd>Pick grep<cr>", { desc = "Grep" }), + }) + end, + }, +} diff --git a/lua/bee/plugins/ui.lua b/lua/bee/plugins/ui.lua index 8ce2a3c..2a5a4fc 100644 --- a/lua/bee/plugins/ui.lua +++ b/lua/bee/plugins/ui.lua @@ -1,6 +1,7 @@ return { { "lualine.nvim", + event = "DeferredUIEnter", auto_enable = true, after = function(_) require("lualine").setup({ @@ -66,4 +67,54 @@ return { }) end, }, + { + "hlchunk.nvim", + auto_enable = false, + event = "DeferredUIEnter", + after = function() + local ignored_filetypes = { + gitcommit = true, + oil = true, + Neogitstatus = true, + TelescopePrompt = true, + NvimTree = true, + help = true, + -- nix = true, + } + + require("hlchunk").setup({ + chunk = { + enable = true, + priority = 15, + -- use_treesitter = true, + chars = { + horizontal_line = "─", + vertical_line = "│", + left_top = "┌", + left_bottom = "└", + right_arrow = "─", + }, + textobject = "", + exclude_filetypes = ignored_filetypes, + max_file_size = 1024 * 1024, + error_sign = false, + straight = true, + use_treesitter = true, + -- animation related + duration = 0, + delay = 200, + }, + indent = { + enable = true, + priority = 10, + style = { vim.api.nvim_get_hl(0, { name = "Whitespace" }) }, + use_treesitter = true, + exclude_filetypes = ignored_filetypes, + chars = { "│" }, + ahead_lines = 5, + delay = 100, + }, + }) + end, + }, } |
