From 9365a8e96827cbf7bc5adad6d29bcd05b4d761b2 Mon Sep 17 00:00:00 2001 From: bee Date: Tue, 5 May 2026 22:37:10 +0530 Subject: Migrate from nixcats to nix-wrapper-modules --- lua/bee/plugins/blink.lua | 150 ++++++++++++++++++++++++++++++++ lua/bee/plugins/git.lua | 62 +++++++++++++ lua/bee/plugins/init.lua | 9 ++ lua/bee/plugins/oil.lua | 72 ++++++++++++++++ lua/bee/plugins/treesitter.lua | 192 +++++++++++++++++++++++++++++++++++++++++ lua/bee/plugins/ui.lua | 69 +++++++++++++++ 6 files changed, 554 insertions(+) create mode 100644 lua/bee/plugins/blink.lua create mode 100644 lua/bee/plugins/git.lua create mode 100644 lua/bee/plugins/init.lua create mode 100644 lua/bee/plugins/oil.lua create mode 100644 lua/bee/plugins/treesitter.lua create mode 100644 lua/bee/plugins/ui.lua (limited to 'lua/bee/plugins') diff --git a/lua/bee/plugins/blink.lua b/lua/bee/plugins/blink.lua new file mode 100644 index 0000000..7fd147b --- /dev/null +++ b/lua/bee/plugins/blink.lua @@ -0,0 +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({}) + + 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" }, "", 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 new file mode 100644 index 0000000..78be9b4 --- /dev/null +++ b/lua/bee/plugins/git.lua @@ -0,0 +1,62 @@ +return { + { + "vim-fugitive", + auto_enable = { + "vim-fugitive", + "vim-rhubarb", + }, + keys = { { "gg", "G", desc = "Open git" } }, + cmd = { + "G", + "Git", + "Gdiffsplit", + "Gvdiffsplit", + "Gedit", + "Gread", + "Gwrite", + "Ggrep", + "GMove", + "Glgrep", + "GRename", + "GDelete", + "GRemove", + "GBrowse", + "DiffviewOpen", + "DiffviewClose", + "DiffviewToggleFiles", + "DiffviewFocusFiles", + "DiffviewRefresh", + "DiffviewFileHistory", + }, + load = function(name) + nixInfo.lze.loaders.multi({ + name, + "vim-rhubarb", + "diffview.nvim", + }) + end, + }, + { + "mini.diff", + auto_enable = true, + event = "DeferredUIEnter", + after = function(_) + require("mini.diff").setup({ + view = { + style = "sign", + signs = { add = "│", change = "~", delete = "-" }, + priority = 9, + }, + mappings = { + apply = "", + reset = "", + textobject = "", + goto_first = "", + goto_prev = "", + goto_next = "", + goto_last = "", + }, + }) + end, + }, +} diff --git a/lua/bee/plugins/init.lua b/lua/bee/plugins/init.lua new file mode 100644 index 0000000..59e0a41 --- /dev/null +++ b/lua/bee/plugins/init.lua @@ -0,0 +1,9 @@ +local MP = ... + +return { + { import = MP:relpath("ui") }, + { import = MP:relpath("oil") }, + { import = MP:relpath("git") }, + { import = MP:relpath("blink") }, + { import = MP:relpath("treesitter") }, +} diff --git a/lua/bee/plugins/oil.lua b/lua/bee/plugins/oil.lua new file mode 100644 index 0000000..5f8c6d6 --- /dev/null +++ b/lua/bee/plugins/oil.lua @@ -0,0 +1,72 @@ +return { + { + "oil.nvim", + lazy = true, + keys = { { "o", "Oil", desc = "Open oil" } }, + auto_enable = true, + after = function() + vim.g.loaded_netrwPlugin = 1 + vim.keymap.set("n", "o", "Oil .", { noremap = true, desc = "Open nvim root directory" }) + require("oil").setup({ + keymaps = { + ["-"] = "actions.parent", + [""] = "actions.select", + [""] = "actions.select_vsplit", + [""] = "actions.select_split", + }, + vim.keymap.set("n", "o", "Oil", { 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, + }, +} diff --git a/lua/bee/plugins/treesitter.lua b/lua/bee/plugins/treesitter.lua new file mode 100644 index 0000000..bfce021 --- /dev/null +++ b/lua/bee/plugins/treesitter.lua @@ -0,0 +1,192 @@ +-- Docs say not to lazy load it +return { + { + "nvim-treesitter", + auto_enable = true, + 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 false + end + vim.treesitter.start(buf, language) + + -- enables treesitter based folds + vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" + vim.wo.foldmethod = "expr" + -- ensure folds are open to begin with + vim.o.foldlevel = 99 + + -- enables treesitter based indentation + vim.b.did_indent = 1 -- this right here prevents built-in indent scripts from loading + vim.bo.indentexpr = "v:lua.require'nvim-treesitter.indent'.get_indent(v:lnum)" + + return true + end + + local installable_parsers = nixInfo.isNix or 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 + + if not treesitter_try_attach(buf, language) and not nixInfo.isNix then + -- we do something more interesting in nix and don't do this there + ---@cast installable_parsers string[] + if vim.tbl_contains(installable_parsers, language) then + -- not already installed, so try to install them via nvim-treesitter if possible + require("nvim-treesitter").install(language):await(function() + treesitter_try_attach(buf, language) + end) + end + end + end, + }) + end, + }, + { + "nvim-treesitter-textobjects", + auto_enable = true, + lazy = false, + before = function(plugin) + vim.g.no_plugin_maps = true + end, + after = function(plugin) + require("nvim-treesitter-textobjects").setup({ + select = { + -- Automatically jump forward to textobj, similar to targets.vim + lookahead = true, + -- You can choose the select mode (default is charwise 'v') + -- + -- Can also be a function which gets passed a table with the keys + -- * query_string: eg '@function.inner' + -- * method: eg 'v' or 'o' + -- and should return the mode ('v', 'V', or '') or a table + -- mapping query_strings to modes. + selection_modes = { + ["@parameter.outer"] = "v", -- charwise + ["@function.outer"] = "V", -- linewise + -- ['@class.outer'] = '', -- blockwise + }, + -- If you set this to `true` (default is `false`) then any textobject is + -- extended to include preceding or succeeding whitespace. Succeeding + -- whitespace has priority in order to act similarly to eg the built-in + -- `ap`. + -- + -- Can also be a function which gets passed a table with the keys + -- * query_string: eg '@function.inner' + -- * selection_mode: eg 'v' + -- and should return true of false + include_surrounding_whitespace = false, + }, + move = { + set_jumps = true, + }, + }) + + -- keymaps + -- You can use the capture groups defined in `textobjects.scm` + vim.keymap.set({ "x", "o" }, "am", function() + require("nvim-treesitter-textobjects.select").select_textobject("@function.outer", "textobjects") + end) + vim.keymap.set({ "x", "o" }, "im", function() + require("nvim-treesitter-textobjects.select").select_textobject("@function.inner", "textobjects") + end) + vim.keymap.set({ "x", "o" }, "ac", function() + require("nvim-treesitter-textobjects.select").select_textobject("@class.outer", "textobjects") + end) + vim.keymap.set({ "x", "o" }, "ic", function() + require("nvim-treesitter-textobjects.select").select_textobject("@class.inner", "textobjects") + end) + -- You can also use captures from other query groups like `locals.scm` + vim.keymap.set({ "x", "o" }, "as", function() + require("nvim-treesitter-textobjects.select").select_textobject("@local.scope", "locals") + end) + vim.keymap.set("n", "a", function() + require("nvim-treesitter-textobjects.swap").swap_next("@parameter.inner") + end) + vim.keymap.set("n", "A", function() + require("nvim-treesitter-textobjects.swap").swap_previous("@parameter.outer") + end) + + -- You can use the capture groups defined in `textobjects.scm` + vim.keymap.set({ "n", "x", "o" }, "]m", function() + require("nvim-treesitter-textobjects.move").goto_next_start("@function.outer", "textobjects") + end) + vim.keymap.set({ "n", "x", "o" }, "]]", function() + require("nvim-treesitter-textobjects.move").goto_next_start("@class.outer", "textobjects") + end) + -- You can also pass a list to group multiple queries. + vim.keymap.set({ "n", "x", "o" }, "]o", function() + require("nvim-treesitter-textobjects.move").goto_next_start( + { "@loop.inner", "@loop.outer" }, + "textobjects" + ) + end) + -- You can also use captures from other query groups like `locals.scm` or `folds.scm` + vim.keymap.set({ "n", "x", "o" }, "]s", function() + require("nvim-treesitter-textobjects.move").goto_next_start("@local.scope", "locals") + end) + vim.keymap.set({ "n", "x", "o" }, "]z", function() + require("nvim-treesitter-textobjects.move").goto_next_start("@fold", "folds") + end) + + vim.keymap.set({ "n", "x", "o" }, "]M", function() + require("nvim-treesitter-textobjects.move").goto_next_end("@function.outer", "textobjects") + end) + vim.keymap.set({ "n", "x", "o" }, "][", function() + require("nvim-treesitter-textobjects.move").goto_next_end("@class.outer", "textobjects") + end) + + vim.keymap.set({ "n", "x", "o" }, "[m", function() + require("nvim-treesitter-textobjects.move").goto_previous_start("@function.outer", "textobjects") + end) + vim.keymap.set({ "n", "x", "o" }, "[[", function() + require("nvim-treesitter-textobjects.move").goto_previous_start("@class.outer", "textobjects") + end) + + vim.keymap.set({ "n", "x", "o" }, "[M", function() + require("nvim-treesitter-textobjects.move").goto_previous_end("@function.outer", "textobjects") + end) + vim.keymap.set({ "n", "x", "o" }, "[]", function() + require("nvim-treesitter-textobjects.move").goto_previous_end("@class.outer", "textobjects") + end) + local ts_repeat_move = require("nvim-treesitter-textobjects.repeatable_move") + + -- Repeat movement with ; and , + -- ensure ; goes forward and , goes backward regardless of the last direction + -- vim.keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move_next) + -- vim.keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move_previous) + + -- vim way: ; goes to the direction you were moving. + vim.keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move) + vim.keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move_opposite) + + -- Optionally, make builtin f, F, t, T also repeatable with ; and , + vim.keymap.set({ "n", "x", "o" }, "f", ts_repeat_move.builtin_f_expr, { expr = true }) + vim.keymap.set({ "n", "x", "o" }, "F", ts_repeat_move.builtin_F_expr, { expr = true }) + vim.keymap.set({ "n", "x", "o" }, "t", ts_repeat_move.builtin_t_expr, { expr = true }) + vim.keymap.set({ "n", "x", "o" }, "T", ts_repeat_move.builtin_T_expr, { expr = true }) + end, + }, + { + "nvim-ts-autotag", + auto_enable = true, + lazy = false, + after = function(plugin) + require("nvim-ts-autotag").setup({ + opts = { + enable_close = true, + enable_rename = true, + enable_close_on_slash = false, + }, + }) + end, + }, +} diff --git a/lua/bee/plugins/ui.lua b/lua/bee/plugins/ui.lua new file mode 100644 index 0000000..8ce2a3c --- /dev/null +++ b/lua/bee/plugins/ui.lua @@ -0,0 +1,69 @@ +return { + { + "lualine.nvim", + auto_enable = true, + after = function(_) + require("lualine").setup({ + options = { + component_separators = { left = "|", right = "|" }, + section_separators = {}, + }, + sections = { + lualine_a = { + { + "mode", + fmt = function(mode) + return ({ + ["NORMAL"] = "っ( ' ᵕ ' )っ", + ["O-PENDING"] = "っ( º _ º )っ", + ["INSERT"] = "っ(>‿<)っ✎", + ["VISUAL"] = "っ(⊙‿⊙)っ", + ["V-LINE"] = "っ(ò_ó)っ¤=[]::>", + ["V-BLOCK"] = "っ[ •̀ ⌂ •́ ]っ", + ["REPLACE"] = "っ( O )っ", + ["V-REPLACE"] = "っ[ O ]っ", + ["COMMAND"] = "っ(ง •̀_•́)ง", + ["TERMINAL"] = "っ( ͡° ͜ʖ ͡°)っ", + ["EX"] = "っ( ͡ಠ ͜ʖ ͡ಠ)ง", + ["SHELL"] = "っ(©_©)っ", + ["MORE"] = "っ(°-° )っ", + ["CONFIRM"] = "っ( 0_0)?", + + -- ["SELECT"] = "っ(づ。◕‿‿◕。)づ", + -- ["S-LINE"] = "っ(づ。◕‿‿◕。)づ¤", + -- ["S-BLOCK"] = "っ[づ。◕‿‿◕。]づ", + })[mode] or mode + end, + }, + }, + lualine_c = { + { + "filename", + path = 1, + }, + }, + }, + inactive_sections = { + lualine_a = { "filename" }, + lualine_b = {}, + lualine_c = {}, + lualine_x = {}, + lualine_y = {}, + lualine_z = { "location" }, + }, + }) + end, + }, + { + "mini.indentscope", + auto_enable = true, + event = "DeferredUIEnter", + after = function(_) + require("mini.indentscope").setup({ + draw = { + delay = 200, + }, + }) + end, + }, +} -- cgit v1.3.1