From 45bc42047321f6e51f32adb24ec5fc95333c6380 Mon Sep 17 00:00:00 2001 From: omagdy Date: Sat, 26 Jul 2025 02:33:10 +0300 Subject: nvim: switched to blink.nvim + some other stuff I guess --- nvim/.config/nvim/lazy-lock.json | 9 +- nvim/.config/nvim/lazyvim.json | 5 +- nvim/.config/nvim/lua/config/lazy.lua | 2 +- nvim/.config/nvim/lua/config/options.lua | 3 +- nvim/.config/nvim/lua/plugins/blink.lua | 144 ++++++++++++++++++++ nvim/.config/nvim/lua/plugins/links.lua | 52 ++++++++ nvim/.config/nvim/lua/plugins/neo-tree.lua | 196 ++++++++++++++-------------- nvim/.config/nvim/lua/plugins/telescope.lua | 4 +- nvim/.config/nvim/lua/plugins/undotree.lua | 3 +- 9 files changed, 306 insertions(+), 112 deletions(-) create mode 100644 nvim/.config/nvim/lua/plugins/blink.lua create mode 100644 nvim/.config/nvim/lua/plugins/links.lua (limited to 'nvim') diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 9606910..f79fc91 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -2,11 +2,8 @@ "LazyVim": { "branch": "main", "commit": "25abbf546d564dc484cf903804661ba12de45507" }, "LuaSnip": { "branch": "master", "commit": "66b5c2707e624dcd2cd3605676c64a2efe47e9d1" }, "SchemaStore.nvim": { "branch": "main", "commit": "36fb914c0defa2274207e670182253508e5569d5" }, + "blink.cmp": { "branch": "main", "commit": "bae4bae0eedd1fa55f34b685862e94a222d5c6f8" }, "catppuccin": { "branch": "main", "commit": "fa42eb5e26819ef58884257d5ae95dd0552b9a66" }, - "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" }, - "cmp-path": { "branch": "main", "commit": "e52e640b7befd8113b3350f46e8cfcfe98fcf730" }, - "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, "competitest.nvim": { "branch": "master", "commit": "b42c06ca308906f07912ba9aff015ac2c0831f85" }, "compiler-explorer.nvim": { "branch": "master", "commit": "ee8e7a2808bdad67cd2acb61b5c9ffa7735c7ec9" }, "compiler.nvim": { "branch": "main", "commit": "725e4dc7c4e261a11c98de020fe268f0bb69ad4b" }, @@ -25,7 +22,6 @@ "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, "litee-calltree.nvim": { "branch": "main", "commit": "b50c809d136ad479caf761a7f030da98c56c7976" }, "litee.nvim": { "branch": "main", "commit": "4efaf373322d9e71eaff31164abb393417cc6f6a" }, - "lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" }, "lualine-macro-recording.nvim": { "branch": "main", "commit": "e2dcf63ba74e6111b53e1520a4f8a17a3d7427a1" }, "lualine-so-fancy.nvim": { "branch": "main", "commit": "6ba7b138f2ca435673eb04c2cf85f0757df69b07" }, "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, @@ -34,12 +30,12 @@ "mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" }, "material.nvim": { "branch": "main", "commit": "0004ec60f91d581d47563a39f7dac62cb758f7ea" }, "mini.ai": { "branch": "main", "commit": "96cd250fdea1fec929a62c7432de73e0f59788cd" }, + "mini.hipatterns": { "branch": "main", "commit": "2b78f3d475d60ea1793a6d595ff65a0db9ac3a67" }, "mini.icons": { "branch": "main", "commit": "94848dad1589a199f876539bd79befb0c5e3abf0" }, "mini.move": { "branch": "main", "commit": "f471ecb98395781827ef1dffee61afe1af0ace29" }, "mini.nvim": { "branch": "main", "commit": "c8d4b45745b9c05217d33c7841230af4d03a5f1b" }, "mini.pairs": { "branch": "main", "commit": "42407ccb80ec59c84e7c91d815f42ed90a8cc093" }, "mini.surround": { "branch": "main", "commit": "1a2b59c77a0c4713a5bd8972da322f842f4821b1" }, - "neo-tree.nvim": { "branch": "main", "commit": "84c3df0aa276da7f6095b000de314986f7b5ac98" }, "neogit": { "branch": "master", "commit": "59725524d25f9a8a9474f113d60db52bad8504d0" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, @@ -50,7 +46,6 @@ "nvim-lint": { "branch": "master", "commit": "3c5e34c24834a67b1cb37600ab7663eefd2b0390" }, "nvim-lspconfig": { "branch": "master", "commit": "8c5efd1269160fc2fdf61e3d7176be5015860a8f" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, - "nvim-snippets": { "branch": "main", "commit": "56b4052f71220144689caaa2e5b66222ba5661eb" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "89ebe73cd2836db80a22d9748999ace0241917a5" }, "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, diff --git a/nvim/.config/nvim/lazyvim.json b/nvim/.config/nvim/lazyvim.json index 501b904..30d4bc7 100644 --- a/nvim/.config/nvim/lazyvim.json +++ b/nvim/.config/nvim/lazyvim.json @@ -1,9 +1,12 @@ { "extras": [ + "lazyvim.plugins.extras.coding.blink", "lazyvim.plugins.extras.coding.nvim-cmp", "lazyvim.plugins.extras.dap.core", + "lazyvim.plugins.extras.editor.snacks_explorer", "lazyvim.plugins.extras.editor.telescope", - "lazyvim.plugins.extras.lang.tex" + "lazyvim.plugins.extras.lang.tex", + "lazyvim.plugins.extras.util.mini-hipatterns" ], "install_version": 7, "news": { diff --git a/nvim/.config/nvim/lua/config/lazy.lua b/nvim/.config/nvim/lua/config/lazy.lua index 674639d..b1411a4 100644 --- a/nvim/.config/nvim/lua/config/lazy.lua +++ b/nvim/.config/nvim/lua/config/lazy.lua @@ -41,7 +41,7 @@ require("lazy").setup({ -- "netrwPlugin", "tarPlugin", "tohtml", - "tutor", + -- "tutor", "zipPlugin", }, }, diff --git a/nvim/.config/nvim/lua/config/options.lua b/nvim/.config/nvim/lua/config/options.lua index c86b443..ef5c5f7 100644 --- a/nvim/.config/nvim/lua/config/options.lua +++ b/nvim/.config/nvim/lua/config/options.lua @@ -6,7 +6,8 @@ vim.opt.ch = 0 vim.opt.list = false vim.opt.confirm = false -- vim.o.clipboard = "" -vim.o.guifont = "Monaspace Radon:h12:bold" -- text below applies for VimScript +vim.o.guifont = "Monaspace Radon:bold,Noto Color Emoji:h10" -- text below applies for VimScript +vim.o.undofile = true vim.o.spell = false diff --git a/nvim/.config/nvim/lua/plugins/blink.lua b/nvim/.config/nvim/lua/plugins/blink.lua new file mode 100644 index 0000000..b74f909 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/blink.lua @@ -0,0 +1,144 @@ +return { + "saghen/blink.cmp", + version = not vim.g.lazyvim_blink_main and "*", + build = vim.g.lazyvim_blink_main and "cargo build --release", + opts_extend = { + "sources.completion.enabled_providers", + "sources.compat", + "sources.default", + }, + dependencies = { + "rafamadriz/friendly-snippets", + -- add blink.compat to dependencies + { + "saghen/blink.compat", + optional = true, -- make optional so it's only enabled if any extras need it + opts = {}, + version = not vim.g.lazyvim_blink_main and "*", + }, + }, + event = "InsertEnter", + + ---@module 'blink.cmp' + ---@type blink.cmp.Config + opts = { + snippets = { + expand = function(snippet, _) + return LazyVim.cmp.expand(snippet) + end, + }, + appearance = { + -- sets the fallback highlight groups to nvim-cmp's highlight groups + -- useful for when your theme doesn't support blink.cmp + -- will be removed in a future release, assuming themes add support + use_nvim_cmp_as_default = false, + -- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- adjusts spacing to ensure icons are aligned + nerd_font_variant = "mono", + }, + completion = { + accept = { + -- experimental auto-brackets support + auto_brackets = { + enabled = true, + }, + }, + menu = { + draw = { + treesitter = { "lsp" }, + }, + }, + documentation = { + auto_show = true, + auto_show_delay_ms = 200, + }, + ghost_text = { + enabled = vim.g.ai_cmp, + }, + }, + + -- experimental signature help support + -- signature = { enabled = true }, + + sources = { + -- adding any nvim-cmp sources here will enable them + -- with blink.compat + compat = {}, + default = { "lsp", "path", "snippets", "buffer" }, + }, + + cmdline = { + enabled = false, + }, + + keymap = { + preset = "enter", + [""] = { "select_and_accept" }, + }, + }, + ---@param opts blink.cmp.Config | { sources: { compat: string[] } } + config = function(_, opts) + -- setup compat sources + local enabled = opts.sources.default + for _, source in ipairs(opts.sources.compat or {}) do + opts.sources.providers[source] = vim.tbl_deep_extend( + "force", + { name = source, module = "blink.compat.source" }, + opts.sources.providers[source] or {} + ) + if type(enabled) == "table" and not vim.tbl_contains(enabled, source) then + table.insert(enabled, source) + end + end + + -- add ai_accept to key + if not opts.keymap[""] then + if opts.keymap.preset == "super-tab" then -- super-tab + opts.keymap[""] = { + require("blink.cmp.keymap.presets")["super-tab"][""][1], + LazyVim.cmp.map({ "snippet_forward", "ai_accept" }), + "fallback", + } + else -- other presets + opts.keymap[""] = { + LazyVim.cmp.map({ "snippet_forward", "ai_accept" }), + "fallback", + } + end + end + + -- Unset custom prop to pass blink.cmp validation + opts.sources.compat = nil + + -- check if we need to override symbol kinds + for _, provider in pairs(opts.sources.providers or {}) do + ---@cast provider blink.cmp.SourceProviderConfig|{kind?:string} + if provider.kind then + local CompletionItemKind = require("blink.cmp.types").CompletionItemKind + local kind_idx = #CompletionItemKind + 1 + + CompletionItemKind[kind_idx] = provider.kind + ---@diagnostic disable-next-line: no-unknown + CompletionItemKind[provider.kind] = kind_idx + + ---@type fun(ctx: blink.cmp.Context, items: blink.cmp.CompletionItem[]): blink.cmp.CompletionItem[] + local transform_items = provider.transform_items + ---@param ctx blink.cmp.Context + ---@param items blink.cmp.CompletionItem[] + provider.transform_items = function(ctx, items) + items = transform_items and transform_items(ctx, items) or items + for _, item in ipairs(items) do + item.kind = kind_idx or item.kind + item.kind_icon = LazyVim.config.icons.kinds[item.kind_name] or item.kind_icon or nil + end + return items + end + + -- Unset custom prop to pass blink.cmp validation + provider.kind = nil + end + end + + require("blink.cmp").setup(opts) + end, +} diff --git a/nvim/.config/nvim/lua/plugins/links.lua b/nvim/.config/nvim/lua/plugins/links.lua new file mode 100644 index 0000000..7edb68d --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/links.lua @@ -0,0 +1,52 @@ +return { + "nvim-telescope/telescope.nvim", + keys = { + { + "fl", + function() + local pickers = require("telescope.pickers") + local finders = require("telescope.finders") + local conf = require("telescope.config").values + local actions = require("telescope.actions") + local action_state = require("telescope.actions.state") + + local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false) + local urls, seen = {}, {} + + for _, line in ipairs(lines) do + for url in line:gmatch("https?://[%w-_%%&?./=+#]+") do + if not seen[url] then + seen[url] = true + table.insert(urls, url) + end + end + end + + if vim.tbl_isempty(urls) then + print("No links found in buffer") + return + end + + pickers + .new({}, { + prompt_title = "Buffer Links", + finder = finders.new_table({ results = urls }), + sorter = conf.generic_sorter({}), + attach_mappings = function(prompt_bufnr, map) + local copy_and_close = function() + local selection = action_state.get_selected_entry().value + vim.fn.system({ "wl-copy" }, selection) + print("Copied ➜ " .. selection) + actions.close(prompt_bufnr) + end + map("i", "", copy_and_close) + map("n", "", copy_and_close) + return true + end, + }) + :find() + end, + desc = "Find links in current buffer", + }, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/neo-tree.lua b/nvim/.config/nvim/lua/plugins/neo-tree.lua index 3f11836..488ca77 100644 --- a/nvim/.config/nvim/lua/plugins/neo-tree.lua +++ b/nvim/.config/nvim/lua/plugins/neo-tree.lua @@ -1,98 +1,98 @@ -return { - "nvim-neo-tree/neo-tree.nvim", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", - "MunifTanjim/nui.nvim", - }, - event = "VeryLazy", - keys = { - { "", ":Neotree toggle float", silent = true, desc = "Float File Explorer" }, - { "e", ":Neotree toggle left", silent = true, desc = "Left File Explorer" }, - }, - config = function() - require("neo-tree").setup({ - close_if_last_window = true, - popup_border_style = "single", - enable_git_status = true, - enable_modified_markers = true, - enable_diagnostics = true, - sort_case_insensitive = true, - default_component_configs = { - indent = { - with_markers = true, - with_expanders = true, - }, - modified = { - symbol = " ", - highlight = "NeoTreeModified", - }, - icon = { - folder_closed = "", - folder_open = "", - folder_empty = "", - folder_empty_open = "", - }, - git_status = { - symbols = { - -- Change type - added = "", - deleted = "", - modified = "", - renamed = "", - -- Status type - untracked = "", - ignored = "", - unstaged = "", - staged = "", - conflict = "", - }, - }, - }, - window = { - position = "float", - width = 35, - }, - filesystem = { - use_libuv_file_watcher = true, - filtered_items = { - hide_dotfiles = false, - hide_gitignored = false, - hide_by_name = { - "node_modules", - }, - never_show = { - ".DS_Store", - "thumbs.db", - }, - }, - }, - source_selector = { - winbar = true, - sources = { - { source = "filesystem", display_name = "  Files " }, - { source = "buffers", display_name = "  Bufs " }, - { source = "git_status", display_name = "  Git " }, - }, - }, - event_handlers = { - { - event = "neo_tree_window_after_open", - handler = function(args) - if args.position == "left" or args.position == "right" then - vim.cmd("wincmd =") - end - end, - }, - { - event = "neo_tree_window_after_close", - handler = function(args) - if args.position == "left" or args.position == "right" then - vim.cmd("wincmd =") - end - end, - }, - }, - }) - end, -} +-- return { +-- "nvim-neo-tree/neo-tree.nvim", +-- dependencies = { +-- "nvim-lua/plenary.nvim", +-- "nvim-tree/nvim-web-devicons", +-- "MunifTanjim/nui.nvim", +-- }, +-- event = "VeryLazy", +-- keys = { +-- { "", ":Neotree toggle float", silent = true, desc = "Float File Explorer" }, +-- { "e", ":Neotree toggle left", silent = true, desc = "Left File Explorer" }, +-- }, +-- config = function() +-- require("neo-tree").setup({ +-- close_if_last_window = true, +-- popup_border_style = "single", +-- enable_git_status = true, +-- enable_modified_markers = true, +-- enable_diagnostics = true, +-- sort_case_insensitive = true, +-- default_component_configs = { +-- indent = { +-- with_markers = true, +-- with_expanders = true, +-- }, +-- modified = { +-- symbol = " ", +-- highlight = "NeoTreeModified", +-- }, +-- icon = { +-- folder_closed = "", +-- folder_open = "", +-- folder_empty = "", +-- folder_empty_open = "", +-- }, +-- git_status = { +-- symbols = { +-- -- Change type +-- added = "", +-- deleted = "", +-- modified = "", +-- renamed = "", +-- -- Status type +-- untracked = "", +-- ignored = "", +-- unstaged = "", +-- staged = "", +-- conflict = "", +-- }, +-- }, +-- }, +-- window = { +-- position = "float", +-- width = 35, +-- }, +-- filesystem = { +-- use_libuv_file_watcher = true, +-- filtered_items = { +-- hide_dotfiles = false, +-- hide_gitignored = false, +-- hide_by_name = { +-- "node_modules", +-- }, +-- never_show = { +-- ".DS_Store", +-- "thumbs.db", +-- }, +-- }, +-- }, +-- source_selector = { +-- winbar = true, +-- sources = { +-- { source = "filesystem", display_name = "  Files " }, +-- { source = "buffers", display_name = "  Bufs " }, +-- { source = "git_status", display_name = "  Git " }, +-- }, +-- }, +-- event_handlers = { +-- { +-- event = "neo_tree_window_after_open", +-- handler = function(args) +-- if args.position == "left" or args.position == "right" then +-- vim.cmd("wincmd =") +-- end +-- end, +-- }, +-- { +-- event = "neo_tree_window_after_close", +-- handler = function(args) +-- if args.position == "left" or args.position == "right" then +-- vim.cmd("wincmd =") +-- end +-- end, +-- }, +-- }, +-- }) +-- end, +-- } diff --git a/nvim/.config/nvim/lua/plugins/telescope.lua b/nvim/.config/nvim/lua/plugins/telescope.lua index f8dcfc5..40817dc 100644 --- a/nvim/.config/nvim/lua/plugins/telescope.lua +++ b/nvim/.config/nvim/lua/plugins/telescope.lua @@ -78,9 +78,9 @@ return { { "ft", function() - require("telescope.builtin").help_tags() + require("telescope.builtin").treesitter() end, - desc = "Find help tags", + desc = "Find treesitter nodes", }, { "fh", diff --git a/nvim/.config/nvim/lua/plugins/undotree.lua b/nvim/.config/nvim/lua/plugins/undotree.lua index a09ac4a..3cdb7af 100644 --- a/nvim/.config/nvim/lua/plugins/undotree.lua +++ b/nvim/.config/nvim/lua/plugins/undotree.lua @@ -1,10 +1,9 @@ return { "mbbill/undotree", lazy = false, - keys = { { - "ut", + "u", "UndotreeToggle", desc = "Toggle UndoTree", }, -- cgit v1.2.3