From 81662b99b548d625125365db117430e7190f44f6 Mon Sep 17 00:00:00 2001 From: David Ibia Date: Sat, 2 May 2026 21:25:57 +0100 Subject: [PATCH] =?UTF-8?q?feat(nvim):=20phase=203=20=E2=80=94=20replace?= =?UTF-8?q?=20nvim-cmp=20with=20blink.cmp=20and=20telescope=20with=20snack?= =?UTF-8?q?s.picker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Swap the completion engine to blink.cmp v1.x, dropping nvim-cmp, its eight cmp-* sources, lspkind, and LuaSnip. Swap the picker to snacks.picker, removing telescope.nvim and six telescope extensions. LSP capabilities now sourced from blink.cmp; LSP navigation keymaps and the colorscheme/keymaps/todo pickers move to Snacks.picker. friendly-snippets is preserved as blink's snippet source. --- lazy-lock.json | 17 +- lua/absolute/after/blink-cmp.lua | 14 ++ lua/absolute/after/lsp-config.lua | 11 +- lua/absolute/after/nvim-cmp.lua | 72 ------- lua/absolute/after/snacks.lua | 33 ++++ lua/absolute/after/telescope.lua | 182 ------------------ lua/absolute/after/todo-comments.lua | 4 +- lua/absolute/core/colorscheme.lua | 7 +- lua/absolute/plugins/blink-cmp.lua | 9 + lua/absolute/plugins/nvim-cmp.lua | 18 -- lua/absolute/plugins/snacks.lua | 9 +- lua/absolute/plugins/telescope.lua | 21 -- lua/absolute/remap.lua | 6 +- .../utils/telescope_image_preview.lua | 127 ------------ 14 files changed, 81 insertions(+), 449 deletions(-) create mode 100644 lua/absolute/after/blink-cmp.lua delete mode 100644 lua/absolute/after/nvim-cmp.lua create mode 100644 lua/absolute/after/snacks.lua delete mode 100644 lua/absolute/after/telescope.lua create mode 100644 lua/absolute/plugins/blink-cmp.lua delete mode 100644 lua/absolute/plugins/nvim-cmp.lua delete mode 100644 lua/absolute/plugins/telescope.lua delete mode 100644 lua/absolute/utils/telescope_image_preview.lua diff --git a/lazy-lock.json b/lazy-lock.json index 40bb9d5..40a5442 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,12 +1,8 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, - "LuaSnip": { "branch": "master", "commit": "a62e1083a3cfe8b6b206e7d3d33a51091df25357" }, + "blink.cmp": { "branch": "main", "commit": "78336bc89ee5365633bcf754d93df01678b5c08f" }, "catppuccin": { "branch": "main", "commit": "426dbebe06b5c69fd846ceb17b42e12f890aedf1" }, "cheatsheet.nvim": { "branch": "master", "commit": "9716f9aaa94dd1fd6ce59b5aae0e5f25e2a463ef" }, - "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, - "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, - "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, - "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, "conform.nvim": { "branch": "master", "commit": "dca1a190aa85f9065979ef35802fb77131911106" }, "flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" }, "flutter-tools.nvim": { "branch": "main", "commit": "70430c32d176f4a15c6e2c80586cd2791e3a664e" }, @@ -18,17 +14,15 @@ "incline.nvim": { "branch": "main", "commit": "8b54c59bcb23366645ae10edca6edfb9d3a0853e" }, "indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, - "lspkind.nvim": { "branch": "master", "commit": "c7274c48137396526b59d86232eabcdc7fed8a32" }, "lualine.nvim": { "branch": "master", "commit": "131a558e13f9f28b15cd235557150ccb23f89286" }, "markview.nvim": { "branch": "main", "commit": "8b82823bbe7b452c5920ab22947e186c6cb067b4" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "0c2823e0418f3d9230ff8b201c976e84de1cb401" }, - "mason-registry": { "branch": "main", "commit": "7319e578b6b83281ef9783705471c573615b51d2" }, + "mason-registry": { "branch": "main", "commit": "a97499d40e68e8c786983f2af564caccda3af5d0" }, "mason.nvim": { "branch": "main", "commit": "cb8445f8ce85d957416c106b780efd51c6298f89" }, "mini.diff": { "branch": "main", "commit": "0ee0459152b141c0e1b0931eb6949105be4850a9" }, "mini.nvim": { "branch": "main", "commit": "0420076298c4457f200c2de468f65d080597a347" }, "nightfly": { "branch": "master", "commit": "4980ccc6de5f361fc9da116240ce7592e7d9a53a" }, "nvim-bqf": { "branch": "main", "commit": "c282a62bec6c0621a1ef5132aa3f4c9fc4dcc2c7" }, - "nvim-cmp": { "branch": "main", "commit": "a1d504892f2bc56c2e79b65c6faded2fd21f3eca" }, "nvim-dap": { "branch": "master", "commit": "45a69eba683a2c448dd9ecfc4de89511f0646b5f" }, "nvim-dap-ui": { "branch": "master", "commit": "1a66cabaa4a4da0be107d5eda6d57242f0fe7e49" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, @@ -45,17 +39,12 @@ "nvim_lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, "pkl-neovim": { "branch": "main", "commit": "da9d189b4fad7e67e6b2a5456a3cbc4c9d32a17f" }, "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, - "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, "rose-pine": { "branch": "main", "commit": "6a961effd67f6130d36df6d1c05c48c739796dd2" }, "smear-cursor.nvim": { "branch": "main", "commit": "4a0f7ac265b4ed1ce4d0af2afc13072763bfa691" }, "snacks.nvim": { "branch": "main", "commit": "ad9ede6a9cddf16cedbd31b8932d6dcdee9b716e" }, "tailwind-sorter.nvim": { "branch": "main", "commit": "717e5c9761ed8334dadbb9357df7d826aae97b92" }, "telescope-dap.nvim": { "branch": "master", "commit": "783366bd6c1e7fa0a5c59c07db37f49c805a28df" }, - "telescope-file-browser.nvim": { "branch": "master", "commit": "3610dc7dc91f06aa98b11dca5cc30dfa98626b7e" }, - "telescope-live-grep-args.nvim": { "branch": "master", "commit": "8ad632f793fd437865f99af5684f78300dac93fb" }, - "telescope-media-files.nvim": { "branch": "master", "commit": "0826c7a730bc4d36068f7c85cf4c5b3fd9fb570a" }, - "telescope-themes": { "branch": "main", "commit": "65721365bd7a04a6c9679e76b6387b60320fd5f3" }, - "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "telescope.nvim": { "branch": "master", "commit": "ec009610d5d259ec59a6edf0219ef3f7ee4732e5" }, "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, "toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, "tokyonight": { "branch": "main", "commit": "cdc07ac78467a233fd62c493de29a17e0cf2b2b6" }, diff --git a/lua/absolute/after/blink-cmp.lua b/lua/absolute/after/blink-cmp.lua new file mode 100644 index 0000000..95295ef --- /dev/null +++ b/lua/absolute/after/blink-cmp.lua @@ -0,0 +1,14 @@ +require("blink.cmp").setup({ + keymap = { preset = "default" }, + appearance = { + nerd_font_variant = "mono", + }, + sources = { + default = { "lsp", "path", "snippets", "buffer" }, + }, + cmdline = { + keymap = { preset = "cmdline" }, + completion = { menu = { auto_show = true } }, + }, + signature = { enabled = true }, +}) diff --git a/lua/absolute/after/lsp-config.lua b/lua/absolute/after/lsp-config.lua index ad32b0a..1f892b8 100644 --- a/lua/absolute/after/lsp-config.lua +++ b/lua/absolute/after/lsp-config.lua @@ -1,6 +1,5 @@ -- Setup language servers. local conform = require("conform") -local cmp_nvim_lsp = require("cmp_nvim_lsp") local opts = { noremap = true, silent = true } @@ -17,13 +16,13 @@ local on_attach = function(client, bufnr) vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) opts.desc = "Go to definitions" - vim.keymap.set("n", "gd", "Telescope lsp_definitions", opts) + vim.keymap.set("n", "gd", function() Snacks.picker.lsp_definitions() end, opts) opts.desc = "Show documentation for what is under cursor" vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) opts.desc = "Show LSP Implementation" - vim.keymap.set("n", "gi", "Telescope lsp_implementations", opts) + vim.keymap.set("n", "gi", function() Snacks.picker.lsp_implementations() end, opts) opts.desc = "Get Help" vim.keymap.set("n", "gh", vim.lsp.buf.signature_help, opts) @@ -35,7 +34,7 @@ local on_attach = function(client, bufnr) -- end, opts) opts.desc = "Show LSP type definitions" - vim.keymap.set("n", "gt", "Telescope lsp_type_definitions", opts) + vim.keymap.set("n", "gt", function() Snacks.picker.lsp_type_definitions() end, opts) opts.desc = "Smart rename" vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) @@ -44,7 +43,7 @@ local on_attach = function(client, bufnr) vim.keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) opts.desc = "Show LSP references" - vim.keymap.set("n", "cr", "Telescope lsp_references", opts) + vim.keymap.set("n", "cr", function() Snacks.picker.lsp_references() end, opts) opts.desc = "Format File" vim.keymap.set({ "n", "v" }, "f", function() @@ -67,7 +66,7 @@ local on_attach = function(client, bufnr) end end -local capabilities = cmp_nvim_lsp.default_capabilities() +local capabilities = require("blink.cmp").get_lsp_capabilities() -- Configure diagnostic signs (Neovim 0.10+ API; required in 0.12) vim.diagnostic.config({ diff --git a/lua/absolute/after/nvim-cmp.lua b/lua/absolute/after/nvim-cmp.lua deleted file mode 100644 index afa8650..0000000 --- a/lua/absolute/after/nvim-cmp.lua +++ /dev/null @@ -1,72 +0,0 @@ -local cmp = require("cmp") -local types = require("cmp.types") -local luasnip = require("luasnip") -local lspkind = require("lspkind") - --- loads vscode style snippets from installed plugins (e.g. friendly-snippets) -require("luasnip.loaders.from_vscode").lazy_load() - -cmp.setup({ - completion = { - completeopt = "menu,menuone,preview,noinsert,noselect", - autocomplete = { types.cmp.TriggerEvent.TextChanged }, - }, - window = { - documentation = { - border = { "┌", "─", "┐", "│", "┘", "─", "└", "│" }, - winhighlight = "Normal:CmpPmenu,FloatBorder:CmpPmenuBorder,CursorLine:PmenuSel,Search:None", - }, - completion = { - side_padding = 1, - border = { "┌", "─", "┐", "│", "┘", "─", "└", "│" }, - winhighlight = "Normal:CmpPmenu,FloatBorder:CmpPmenuBorder,CursorLine:PmenuSel,Search:None", - scrollbar = false, - }, - }, - snippet = { -- configure how nvim-cmp interacts with snippet engine - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.complete(), -- show completion suggestions - ["C-"] = cmp.mapping.abort(), -- close completion menu - [""] = cmp.mapping.confirm({ select = true }), -- accept current selection - }), - - -- sources for autocompletion - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "codecompanion" }, -- code companion for AI-assisted coding - { name = "luasnip" }, -- snippets - { name = "buffer" }, -- text within current buffer - { name = "path" }, -- file system paths, - { name = "nvim_lsp_signature_help" }, - }), - -- configure lspkind for vs-code like pictograms in completion menu - formatting = { - format = lspkind.cmp_format({ - maxwidth = 50, - ellipsis_char = "...", - }), - }, -}) - --- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). -cmp.setup.cmdline({ "/", "?" }, { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = "buffer" }, - }, -}) - --- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). -cmp.setup.cmdline(":", { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = "path" }, - }, { - { name = "cmdline" }, - }), - matching = { disallow_symbol_nonprefix_matching = false }, -}) diff --git a/lua/absolute/after/snacks.lua b/lua/absolute/after/snacks.lua new file mode 100644 index 0000000..55a3790 --- /dev/null +++ b/lua/absolute/after/snacks.lua @@ -0,0 +1,33 @@ +local map = vim.keymap.set + +local function with_desc(desc) + return { noremap = true, silent = true, desc = desc } +end + +map("n", "", function() + Snacks.picker.files() +end, with_desc("Find files")) + +map("n", "gf", function() + Snacks.picker.git_files() +end, with_desc("Find git files")) + +map("n", "pr", function() + Snacks.picker.recent() +end, with_desc("Recent files")) + +map("n", "ps", function() + Snacks.picker.grep() +end, with_desc("Live grep")) + +map("n", "sb", function() + Snacks.picker.grep_word() +end, with_desc("Grep word under cursor")) + +map("n", "pf", function() + Snacks.picker.explorer() +end, with_desc("File explorer (cwd)")) + +map("n", "cf", function() + Snacks.picker.explorer({ cwd = vim.fn.expand("%:p:h") }) +end, with_desc("File explorer (current file dir)")) diff --git a/lua/absolute/after/telescope.lua b/lua/absolute/after/telescope.lua deleted file mode 100644 index ad0a4a0..0000000 --- a/lua/absolute/after/telescope.lua +++ /dev/null @@ -1,182 +0,0 @@ -local telescope = require("telescope") -local builtin = require("telescope.builtin") -local actions = require("telescope.actions") -local trouble = require("trouble.sources.telescope") -local file_browser_actions = require("telescope._extensions.file_browser.actions") -local live_grep_shortcuts = require("telescope-live-grep-args.shortcuts") -local live_grep_actions = require("telescope-live-grep-args.actions") - -local image_preview = require("absolute.utils.telescope_image_preview") - --- local function chafa_previewer_mime_hook(filepath, bufnr, opts) --- local is_image = function(current_filepath) --- local image_extensions = { "png", "jpg", "jpeg", "gif" } -- Supported image formats --- local split_path = vim.split(current_filepath:lower(), ".", { plain = true }) --- local extension = split_path[#split_path] --- return vim.tbl_contains(image_extensions, extension) --- end --- if is_image(filepath) then --- local term = vim.api.nvim_open_term(bufnr, {}) --- local function send_output(_, data, _) --- for _, d in ipairs(data) do --- vim.api.nvim_chan_send(term, d .. "\r\n") --- end --- end --- vim.fn.jobstart("chafa --passthrough tmux --exact-size off --format=symbols " .. filepath, { --- on_stdout = send_output, --- stdout_buffered = true, --- }) --- else --- require("telescope.previewers.utils").set_preview_message(bufnr, opts.winid, "Binary cannot be previewed") --- end --- end - -telescope.setup({ - defaults = { - file_previewer = image_preview.file_previewer, - buffer_previewer_maker = image_preview.buffer_previewer_maker, - - vimgrep_arguments = { - "rg", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case", - "--follow", - "--hidden", - "--glob=!.git/", - }, - mappings = { - i = { - [""] = trouble.open, - [""] = actions.send_to_qflist, - }, - n = { - [""] = trouble.open, - [""] = actions.send_to_qflist, - }, - }, - }, - extensions = { - media_files = { - filetypes = { "png", "webp", "jpg", "jpeg", "svg" }, - find_cmd = "rg", - }, - live_grep_args = { - auto_quoting = false, - mappings = { - i = { - ["C-space"] = live_grep_actions.to_fuzzy_refine, - }, - }, - }, - - file_browser = { - hijack_netrw = true, - hide_parent_dir = true, - depth = 1, - respect_gitignore = vim.fn.executable("fd") == 1, - hidden = { file_browser = true, folder_browser = false }, - auto_depth = false, - browse_files = require("telescope._extensions.file_browser.finders").browse_files, - display_stat = { - date = true, - size = true, - mode = false, - }, - use_fd = true, - git_status = true, - mappings = { - ["i"] = { - [""] = file_browser_actions.create, - [""] = file_browser_actions.create_from_prompt, - [""] = file_browser_actions.rename, - [""] = file_browser_actions.move, - [""] = file_browser_actions.copy, - [""] = file_browser_actions.remove, - [""] = file_browser_actions.open, - [""] = file_browser_actions.goto_parent_dir, - [""] = file_browser_actions.goto_home_dir, - [""] = file_browser_actions.goto_cwd, - [""] = file_browser_actions.change_cwd, - [""] = file_browser_actions.toggle_browser, - [""] = file_browser_actions.toggle_hidden, - [""] = file_browser_actions.toggle_all, - [""] = file_browser_actions.backspace, - }, - ["n"] = { - ["c"] = file_browser_actions.create, - ["r"] = file_browser_actions.rename, - ["m"] = file_browser_actions.move, - ["y"] = file_browser_actions.copy, - ["d"] = file_browser_actions.remove, - ["o"] = file_browser_actions.open, - ["g"] = file_browser_actions.goto_parent_dir, - ["e"] = file_browser_actions.goto_home_dir, - ["w"] = file_browser_actions.goto_cwd, - ["t"] = file_browser_actions.change_cwd, - ["f"] = file_browser_actions.toggle_browser, - ["h"] = file_browser_actions.toggle_hidden, - ["s"] = file_browser_actions.toggle_all, - }, - }, - }, - }, -}) - -telescope.load_extension("live_grep_args") -telescope.load_extension("file_browser") -telescope.load_extension("media_files") -telescope.load_extension("themes") -telescope.load_extension("dap") - -local find_files = function() - builtin.find_files({ - find_command = { "rg", "--files", "--hidden", "--glob", "!.git" }, - }) -end - -local default_grep_files = function() - local input = vim.fn.input("[Global Search]: ") - local trimmed_input = vim.fn.trim(input) - - -- Check the length of the input - - local live_grep_args = telescope.extensions.live_grep_args - -- If the input is empty open the search prompt - - if trimmed_input == "" then - live_grep_args.live_grep_args() - return - end - - builtin.grep_string({ search = trimmed_input }) -end - --- Function to get the visually selected text - --- Pipe the visual selection into Telescope find_files -local opts = { noremap = true, silent = true } - -opts.desc = "Open file browser (cwd)" -vim.keymap.set("n", "pf", "Telescope file_browser", opts) - -opts.desc = "Open file browser (current file)" -vim.keymap.set("n", "cf", "Telescope file_browser path=%:p:h select_buffer=true", opts) - -opts.desc = "Fuzzy find files (cwd)" -vim.keymap.set("n", "", find_files, opts) - -opts.desc = "Fuzzy find recent files" -vim.keymap.set("n", "pr", builtin.oldfiles, opts) - -opts.desc = "Fuzzy find files in git in cwd" -vim.keymap.set("n", "gf", builtin.git_files, opts) - -opts.desc = "Fuzzy find files in cwd" -vim.keymap.set("n", "ps", default_grep_files, opts) - -opts.desc = "Fuzzy find word under cursor in cwd" -vim.keymap.set("n", "sb", live_grep_shortcuts.grep_word_under_cursor, opts) diff --git a/lua/absolute/after/todo-comments.lua b/lua/absolute/after/todo-comments.lua index 2cd25a3..25b1e7a 100644 --- a/lua/absolute/after/todo-comments.lua +++ b/lua/absolute/after/todo-comments.lua @@ -14,9 +14,9 @@ vim.keymap.set("n", "]t", function() todo_comments.jump_next() end, opts) -opts.desc = "Open Comments in Telescope" +opts.desc = "Open todo comments in picker" vim.keymap.set("n", "pt", function() - vim.cmd([[TodoTelescope]]) + Snacks.picker.todo_comments() end, opts) opts.desc = "Open Comments in Trouble" diff --git a/lua/absolute/core/colorscheme.lua b/lua/absolute/core/colorscheme.lua index 6eeeef3..21b6ead 100644 --- a/lua/absolute/core/colorscheme.lua +++ b/lua/absolute/core/colorscheme.lua @@ -147,7 +147,6 @@ SetupAutocommands() local opts = { noremap = true, silent = true } opts.desc = "Fuzzy find colorschemes" -vim.api.nvim_set_keymap("n", "cs", "Telescope colorscheme", opts) - -opts.desc = "Fuzzy find themes" -vim.api.nvim_set_keymap("n", "th", "Telescope themes", opts) +vim.keymap.set("n", "cs", function() + Snacks.picker.colorschemes() +end, opts) diff --git a/lua/absolute/plugins/blink-cmp.lua b/lua/absolute/plugins/blink-cmp.lua new file mode 100644 index 0000000..c3120af --- /dev/null +++ b/lua/absolute/plugins/blink-cmp.lua @@ -0,0 +1,9 @@ +return { + "saghen/blink.cmp", + version = "1.*", + event = "InsertEnter", + dependencies = { "rafamadriz/friendly-snippets" }, + config = function() + require("absolute.after.blink-cmp") + end, +} diff --git a/lua/absolute/plugins/nvim-cmp.lua b/lua/absolute/plugins/nvim-cmp.lua deleted file mode 100644 index 9b91dae..0000000 --- a/lua/absolute/plugins/nvim-cmp.lua +++ /dev/null @@ -1,18 +0,0 @@ -return { - 'hrsh7th/nvim-cmp', - event = "InsertEnter", - dependencies = { - 'neovim/nvim-lspconfig', - 'hrsh7th/cmp-nvim-lsp', - 'hrsh7th/cmp-buffer', --source for text in buffer - 'hrsh7th/cmp-path', --source for file system paths - 'hrsh7th/cmp-cmdline', - "saadparwaiz1/cmp_luasnip", --source for autocompletion - "onsails/lspkind.nvim", - "L3MON4D3/LuaSnip", --Snippet Engine - "rafamadriz/friendly-snippets", --Useful snippets - }, - config = function() - require("absolute.after.nvim-cmp") - end -} diff --git a/lua/absolute/plugins/snacks.lua b/lua/absolute/plugins/snacks.lua index f80b599..9bf398d 100644 --- a/lua/absolute/plugins/snacks.lua +++ b/lua/absolute/plugins/snacks.lua @@ -20,6 +20,13 @@ return { warn = "", }, }, - -- picker added in Phase 3 + picker = { + enabled = true, + ui_select = true, + }, }, + config = function(_, opts) + require("snacks").setup(opts) + require("absolute.after.snacks") + end, } diff --git a/lua/absolute/plugins/telescope.lua b/lua/absolute/plugins/telescope.lua deleted file mode 100644 index f4f7526..0000000 --- a/lua/absolute/plugins/telescope.lua +++ /dev/null @@ -1,21 +0,0 @@ -return { - "nvim-telescope/telescope.nvim", - branch = "0.1.x", - dependencies = { - "nvim-lua/popup.nvim", - "nvim-lua/plenary.nvim", - "nvim-telescope/telescope-dap.nvim", - "andrew-george/telescope-themes", - "nvim-telescope/telescope-media-files.nvim", - "nvim-telescope/telescope-file-browser.nvim", - { - "nvim-telescope/telescope-live-grep-args.nvim", - -- This will not install any breaking changes. - -- For major updates, this must be adjusted manually. - version = "^1.0.0", - }, - }, - config = function() - require("absolute.after.telescope") - end, -} diff --git a/lua/absolute/remap.lua b/lua/absolute/remap.lua index 1f161d6..99475a0 100644 --- a/lua/absolute/remap.lua +++ b/lua/absolute/remap.lua @@ -3,8 +3,10 @@ local opts = { silent = true, } -opts.desc = "Show Keymap" -vim.keymap.set("n", "?", "Telescope keymaps", opts) -- toggle file explorer +opts.desc = "Show keymaps" +vim.keymap.set("n", "?", function() + Snacks.picker.keymaps() +end, opts) opts.desc = "Select All" vim.keymap.set("n", "", "gg0vG$", opts) -- select all diff --git a/lua/absolute/utils/telescope_image_preview.lua b/lua/absolute/utils/telescope_image_preview.lua deleted file mode 100644 index ce0a272..0000000 --- a/lua/absolute/utils/telescope_image_preview.lua +++ /dev/null @@ -1,127 +0,0 @@ --- Sourced from github --- https://github.com/3rd/image.nvim/issues/183#issuecomment-2572606511 - -M = {} - -local supported_images = { "svg", "png", "jpg", "jpeg", "gif", "webp", "avif" } -local from_entry = require("telescope.from_entry") -local Path = require("plenary.path") -local conf = require("telescope.config").values -local Previewers = require("telescope.previewers") - -local previewers = require("telescope.previewers") -local image_api = require("image") - -local is_image_preview = false -local image = nil -local last_file_path = "" - -local is_supported_image = function(filepath) - local split_path = vim.split(filepath:lower(), ".", { plain = true }) - local extension = split_path[#split_path] - return vim.tbl_contains(supported_images, extension) -end - -local delete_image = function() - if not image then - return - end - - image:clear() - - is_image_preview = false -end - -local create_image = function(filepath, winid, bufnr) - image = image_api.hijack_buffer(filepath, winid, bufnr) - - if not image then - return - end - - vim.schedule(function() - image:render() - end) - - is_image_preview = true -end - -local function defaulter(f, default_opts) - default_opts = default_opts or {} - return { - new = function(opts) - if conf.preview == false and not opts.preview then - return false - end - opts.preview = type(opts.preview) ~= "table" and {} or opts.preview - if type(conf.preview) == "table" then - for k, v in pairs(conf.preview) do - opts.preview[k] = vim.F.if_nil(opts.preview[k], v) - end - end - return f(opts) - end, - __call = function() - local ok, err = pcall(f(default_opts)) - if not ok then - error(debug.traceback(err)) - end - end, - } -end - --- NOTE: Add teardown to cat previewer to clear image when close Telescope -local file_previewer = defaulter(function(opts) - opts = opts or {} - local cwd = opts.cwd or vim.fn.getcwd() - return Previewers.new_buffer_previewer({ - title = "File Preview", - dyn_title = function(_, entry) - return Path:new(from_entry.path(entry, true)):normalize(cwd) - end, - - get_buffer_by_name = function(_, entry) - return from_entry.path(entry, true) - end, - - define_preview = function(self, entry, _) - local p = from_entry.path(entry, true) - if p == nil or p == "" then - return - end - - conf.buffer_previewer_maker(p, self.state.bufnr, { - bufname = self.state.bufname, - winid = self.state.winid, - preview = opts.preview, - }) - end, - - teardown = function(_) - if is_image_preview then - delete_image() - end - end, - }) -end, {}) - -local buffer_previewer_maker = function(filepath, bufnr, opts) - -- NOTE: Clear image when preview other file - if is_image_preview and last_file_path ~= filepath then - delete_image() - end - - last_file_path = filepath - - if is_supported_image(filepath) then - filepath = string.gsub(filepath, " ", "%%20"):gsub("\\", "") - create_image(filepath, opts.winid, bufnr) - else - previewers.buffer_previewer_maker(filepath, bufnr, opts) - end -end - -M.buffer_previewer_maker = buffer_previewer_maker -M.file_previewer = file_previewer.new - -return M