From 307fceea38b7352a79b0bdb87025a34b76973867 Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Thu, 19 Jun 2025 18:34:13 +0900 Subject: updates --- .../lua/thesiahxyz/plugins/telescope.lua | 1084 -------------------- 1 file changed, 1084 deletions(-) delete mode 100644 ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/telescope.lua (limited to 'ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/telescope.lua') diff --git a/ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/telescope.lua b/ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/telescope.lua deleted file mode 100644 index 6f931de..0000000 --- a/ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/telescope.lua +++ /dev/null @@ -1,1084 +0,0 @@ -local have_make = vim.fn.executable("make") == 1 -local have_cmake = vim.fn.executable("cmake") == 1 - -function vim.live_grep_from_project_git_root() - local function get_git_toplevel() - local path = vim.fn.system("git rev-parse --show-toplevel") - if vim.v.shell_error then - return nil - end - return path - end - - local opts = { cwd = get_git_toplevel() } - - require("telescope.builtin").live_grep(opts) -end - -local function find_nvim_plugin_files(prompt_bufnr) - local actions = require("telescope.actions") - local action_state = require("telescope.actions.state") - - actions.close(prompt_bufnr) - - local selection = action_state.get_selected_entry() - if selection and selection.value then - -- Construct the full path - local base_path = vim.fn.stdpath("data") - local full_path = vim.fn.resolve(base_path .. "/" .. selection.value) - - require("mini.files").open(full_path, true) - end -end - -return { - { - "nvim-telescope/telescope-file-browser.nvim", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-telescope/telescope.nvim", - }, - -- init = function() - -- vim.api.nvim_create_autocmd("VimEnter", { - -- group = vim.api.nvim_create_augroup("TelescopeFileBrowserStartDirectory", { clear = true }), - -- desc = "Start telescope-file-browser with directory", - -- once = true, - -- callback = function() - -- if package.loaded["telescope-file-browser.nvim"] then - -- return - -- else - -- local stats = vim.uv.fs_stat(vim.fn.argv(0)) - -- if stats and stats.type == "directory" then - -- require("telescope").extensions.file_browser.file_browser() - -- end - -- end - -- end, - -- }) - -- end, - config = function() - local fb_actions = require("telescope._extensions.file_browser.actions") - - require("telescope").setup({ - extensions = { - file_browser = { - path = vim.uv.cwd(), - cwd = vim.uv.cwd(), - cwd_to_path = false, - grouped = true, - files = true, - add_dirs = true, - depth = 1, - auto_depth = true, - select_buffer = true, - hidden = { file_browser = false, folder_browser = false }, - respect_gitignore = vim.fn.executable("fd") == 1, - no_ignore = true, - follow_symlinks = true, - browse_files = require("telescope._extensions.file_browser.finders").browse_files, - browse_folders = require("telescope._extensions.file_browser.finders").browse_folders, - hide_parent_dir = false, - collapse_dirs = true, - prompt_path = true, - quiet = true, - dir_icon = "", - dir_icon_hl = "Default", - display_stat = { date = true, size = true, mode = true }, - hijack_netrw = false, - use_fd = true, - git_status = true, - mappings = { - ["i"] = { - [""] = fb_actions.create, - [""] = fb_actions.create_from_prompt, - [""] = fb_actions.rename, - [""] = fb_actions.move, - [""] = fb_actions.copy, - [""] = fb_actions.remove, - [""] = fb_actions.open, - [""] = fb_actions.goto_parent_dir, - [""] = fb_actions.goto_home_dir, - [""] = fb_actions.goto_cwd, - [""] = fb_actions.change_cwd, - [""] = fb_actions.toggle_browser, - [""] = fb_actions.toggle_hidden, - [""] = fb_actions.toggle_all, - [""] = fb_actions.backspace, - }, - ["n"] = { - ["a"] = fb_actions.create, - ["n"] = fb_actions.create_from_prompt, - ["r"] = fb_actions.rename, - ["d"] = fb_actions.move, - ["y"] = fb_actions.copy, - ["Del"] = fb_actions.remove, - ["o"] = fb_actions.open, - ["h"] = fb_actions.goto_parent_dir, - ["gh"] = fb_actions.goto_home_dir, - [""] = fb_actions.goto_cwd, - [""] = fb_actions.change_cwd, - ["f"] = fb_actions.toggle_browser, - ["/"] = fb_actions.toggle_hidden, - ["t"] = fb_actions.toggle_all, - }, - }, - results_title = vim.fn.fnamemodify(vim.uv.cwd(), ":~"), - }, - }, - }) - - require("telescope").load_extension("file_browser") - - vim.keymap.set( - "n", - "et", - ":Telescope file_browser path=%:p:h select_buffer=true", - { desc = "File browser (cwd)" } - ) - vim.keymap.set("n", "eT", ":Telescope file_browser", { desc = "File browser" }) - end, - }, - { - "nvim-telescope/telescope.nvim", - branch = "master", - dependencies = { - { "nvim-lua/plenary.nvim" }, - { - "nvim-telescope/telescope-fzf-native.nvim", - build = have_make and "make" - or "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build", - enabled = have_make or have_cmake, - config = function() - require("telescope").load_extension("fzf") - end, - }, - { - "nvim-telescope/telescope-github.nvim", - init = function() - local wk = require("which-key") - wk.add({ - mode = { "n" }, - { "gh", group = "gh" }, - }) - end, - config = function() - require("telescope").load_extension("gh") - vim.keymap.set({ "n", "v" }, "gi", ":Telescope gh issues ", { desc = "Find gh issues" }) - vim.keymap.set( - { "n", "v" }, - "gp", - ":Telescope gh pull_request ", - { desc = "Find gh pull request" } - ) - vim.keymap.set({ "n", "v" }, "ght", ":Telescope gh gist ", { desc = "Find gh gist" }) - vim.keymap.set({ "n", "v" }, "ghr", ":Telescope gh run ", { desc = "Find gh run" }) - end, - }, - { - "nvim-telescope/telescope-ui-select.nvim", - config = function() - require("telescope").setup({ - extensions = { - ["ui-select"] = { - require("telescope.themes").get_dropdown({ - -- even more opts - }), - - -- pseudo code / specification for writing custom displays, like the one - -- for "codeactions" - -- specific_opts = { - -- make_indexed = function(items) -> indexed_items, width, - -- [kind] = { - -- make_displayer = function(widths) -> displayer - -- make_display = function(displayer) -> function(e) - -- make_ordinal = function(e) -> string - -- }, - -- -- for example to disable the custom builtin "codeactions" display - -- do the following - -- codeactions = false, - -- } - }, - }, - }) - require("telescope").load_extension("ui-select") - end, - }, - { - "jvgrootveld/telescope-zoxide", - dependencies = { "nvim-lua/popup.nvim" }, - config = function() - require("telescope").setup({ - extensions = { - zoxide = { - prompt_title = "[ TheSiahxyz ]", - mappings = { - default = { - action = function(selection) - vim.cmd.cd(selection.path) - end, - after_action = function(selection) - print("Update to (" .. selection.z_score .. ") " .. selection.path) - end, - }, - [""] = { - action = require("telescope._extensions.zoxide.utils").create_basic_command( - "split" - ), - opts = { desc = "split" }, - }, - [""] = { - action = require("telescope._extensions.zoxide.utils").create_basic_command( - "vsplit" - ), - }, - [""] = { - action = require("telescope._extensions.zoxide.utils").create_basic_command( - "edit" - ), - }, - [""] = { - keepinsert = true, - action = function(selection) - require("telescope").extensions.file_browser.file_browser({ - cwd = selection.path, - }) - end, - }, - }, - }, - }, - }) - require("telescope").load_extension("zoxide") - - vim.keymap.set("n", "fz", function() - require("telescope").extensions.zoxide.list() - end, { desc = "Find files (zoxide)" }) - end, - }, - { - "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", - init = function() - local wk = require("which-key") - wk.add({ - mode = { "n", "v" }, - { "f", group = "Find" }, - { "fl", group = "Live grep" }, - }) - end, - config = function() - local lga_actions = require("telescope-live-grep-args.actions") - local actions = require("telescope.actions") - - require("telescope").setup({ - extensions = { - live_grep_args = { - auto_quoting = true, -- enable/disable auto-quoting - -- define mappings, e.g. - mappings = { -- extend mappings - i = { - [""] = lga_actions.quote_prompt(), - [""] = lga_actions.quote_prompt({ postfix = " --iglob " }), - -- freeze the current list and start a fuzzy search in the frozen list - [""] = actions.to_fuzzy_refine, - }, - }, - vimgrep_arguments = { - "rg", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case", - "--follow", - "--hidden", - "--no-ignore", - }, - -- ... also accepts theme settings, for example: - -- theme = "dropdown", -- use dropdown theme - -- theme = { }, -- use own theme spec - -- layout_config = { mirror=true }, -- mirror preview pane - }, - }, - }) - require("telescope").load_extension("live_grep_args") - vim.keymap.set("n", "flf", function() - require("telescope").extensions.live_grep_args.live_grep_args() - end, { desc = "Find live grep args" }) - - local live_grep_args_shortcuts = require("telescope-live-grep-args.shortcuts") - vim.keymap.set( - "n", - "ss", - live_grep_args_shortcuts.grep_word_under_cursor, - { desc = "Search shortcuts (Live grep)" } - ) - - local function search_git(visual) - -- Retrieve the git root path - local handle = io.popen("git rev-parse --show-toplevel") - if not handle then - print("Error: Unable to open git handle") - return - end - - local git_root_path = handle:read("*a"):gsub("%s+", "") - handle:close() - - if not git_root_path or git_root_path == "" then - print("Error: Unable to retrieve git root path") - return - end - - local opts = { - prompt_title = visual and ("Visual-Grep in " .. git_root_path) - or ("Live-Grep in " .. git_root_path), - shorten_path = false, - cwd = git_root_path, - file_ignore_patterns = { ".git", ".png", "tags" }, - initial_mode = "insert", - selection_strategy = "reset", - theme = require("telescope.themes").get_dropdown({}), - } - - if visual then - -- Capture the selected text in visual mode - vim.cmd('normal! "vy') - local visual_selection = vim.fn.getreg("v") - opts.search = visual_selection - require("telescope.builtin").grep_string(opts) - else - require("telescope.builtin").live_grep(opts) - end - end - - vim.keymap.set("n", "flg", function() - search_git(false) - end, { remap = true, silent = false, desc = "Live grep in the git root folder" }) - - vim.keymap.set("v", "flg", function() - search_git(true) - end, { remap = true, silent = false, desc = "Grep in the git root folder" }) - -- Retrieve the current tmux session path - -- This will not change when we navigate to a different pane - local function search_tmux(visual) - local handle = io.popen("tmux display-message -p '#{session_path}'") - if not handle then - print("Error: Unable to open tmux handle") - return - end - - local tmux_session_path = handle:read("*a"):gsub("%s+", "") - handle:close() - - if not tmux_session_path or tmux_session_path == "" then - print("Error: Unable to retrieve tmux session path") - return - end - - local opts = { - prompt_title = visual and ("Visual-Grep in " .. tmux_session_path) - or ("Live-Grep in " .. tmux_session_path), - shorten_path = false, - cwd = tmux_session_path, - file_ignore_patterns = { ".git", ".png", "tags" }, - initial_mode = "insert", - selection_strategy = "reset", - theme = require("telescope.themes").get_dropdown({}), - } - - if visual then - require("telescope.builtin").grep_string(opts) - else - require("telescope.builtin").live_grep(opts) - end - end - - vim.keymap.set("n", "flt", function() - search_tmux(false) - end, { remap = true, silent = false, desc = "Live grep in the current tmux session folder" }) - - vim.keymap.set("v", "flt", function() - search_tmux(true) - end, { remap = true, silent = false, desc = "Grep string in the current tmux session folder" }) - vim.api.nvim_set_keymap( - "v", - "fls", - 'y:Telescope live_grep default_text=0 search_dirs={"$PWD"}', - { noremap = true, silent = true, desc = "Live grep default text" } - ) - vim.keymap.set("n", "f/", function() - require("telescope.builtin").current_buffer_fuzzy_find( - require("telescope.themes").get_dropdown({ - winblend = 10, - previewer = false, - relative = "editor", - }) - ) - end, { desc = "Find in current buffer" }) - end, - }, - { - "xiyaowong/telescope-emoji.nvim", - config = function() - require("telescope").setup({ - extensions = { - emoji = { - action = function(emoji) - -- argument emoji is a table. - -- {name="", value="", cagegory="", description=""} - - vim.fn.setreg("*", emoji.value) - print([[Press p or "*p to paste this emoji]] .. emoji.value) - - -- insert emoji when picked - -- vim.api.nvim_put({ emoji.value }, 'c', false, true) - end, - }, - }, - }) - require("telescope").load_extension("emoji") - end, - keys = { - { "se", ":Telescope emoji", desc = "Search emoji" }, - }, - }, - { - "nvim-telescope/telescope-bibtex.nvim", - requires = { - { "nvim-telescope/telescope.nvim" }, - }, - config = function() - local bibtex_actions = require("telescope-bibtex.actions") - require("telescope").setup({ - extensions = { - bibtex = { - -- Use context awareness - context = true, - -- Use non-contextual behavior if no context found - -- This setting has no effect if context = false - context_fallback = true, - mappings = { - i = { - [""] = bibtex_actions.key_append("%s"), -- format is determined by filetype if the user has not set it explictly - [""] = bibtex_actions.entry_append, - [""] = bibtex_actions.citation_append("{{author}} ({{year}}), {{title}}."), - }, - }, - }, - }, - }) - require("telescope").load_extension("bibtex") - end, - keys = { - { - "sB", - function() - require("telescope").extensions.bibtex.bibtex() - end, - desc = "Search bibtex", - }, - }, - }, - { - "mzlogin/vim-markdown-toc", - keys = { - { "tg", "GenTocGFM", desc = "Generate ToC to GFM" }, - { "tr", "GenTocRedcarpet", desc = "Generate ToC to Redcarpet" }, - { "tl", "GenTocGitLab", desc = "Generate ToC to Gitlab" }, - { "tm", "GenTocMarked", desc = "Generate ToC to Marked" }, - }, - }, - { - "ThePrimeagen/harpoon", - branch = "harpoon2", - dependencies = { "nvim-lua/plenary.nvim" }, - }, - { - "folke/trouble.nvim", - }, - }, - init = function() - local wk = require("which-key") - wk.add({ - mode = { "n" }, - { "f", group = "Find" }, - { "fp", group = "Private/Public" }, - { "s", group = "Search" }, - { "sb", group = "Buffer" }, - }) - end, - config = function() - local actions = require("telescope.actions") - local actions_state = require("telescope.actions.state") - local actions_layout = require("telescope.actions.layout") - local open_with_trouble = require("trouble.sources.telescope").open - local add_to_trouble = require("trouble.sources.telescope").add - - require("telescope").setup({ - defaults = { - mappings = { - i = { - [""] = add_to_trouble, - [""] = actions.complete_tag, - [""] = function(prompt_bufnr) - local selection = actions_state.get_selected_entry() - local dir = vim.fn.fnamemodify(selection.path, ":p:h") - actions.close(prompt_bufnr) - -- Depending on what you want put `cd`, `lcd`, `tcd` - vim.cmd(string.format("silent lcd %s", dir)) - end, - [""] = actions.nop, - [""] = actions.nop, - [""] = actions.nop, - [""] = actions_layout.toggle_preview, - [""] = actions.preview_scrolling_down, - [""] = actions.preview_scrolling_up, - [""] = actions.preview_scrolling_left, - [""] = actions.preview_scrolling_right, - [""] = actions.send_to_qflist + actions.open_qflist, - [""] = actions.send_selected_to_qflist + actions.open_qflist, - [""] = open_with_trouble, - [""] = actions.select_horizontal, - [""] = { "", type = "command" }, - [""] = actions.insert_original_cword, - [""] = actions.insert_original_cWORD, - [""] = actions.insert_original_cfile, - [""] = actions.insert_original_cline, - [""] = actions.nop, - [""] = actions.nop, - }, - n = { - ["q"] = actions.close, - [""] = add_to_trouble, - [""] = actions.close, - [""] = actions.nop, - [""] = actions.nop, - [""] = actions_layout.toggle_preview, - [""] = actions.nop, - [""] = actions.complete_tag, - [""] = { - function(prompt_bufnr) - local selection = actions_state.get_selected_entry() - local dir = vim.fn.fnamemodify(selection.path, ":p:h") - actions.close(prompt_bufnr) - -- Depending on what you want put `cd`, `lcd`, `tcd` - vim.cmd(string.format("silent lcd %s", dir)) - end, - opts = { desc = "Change directory" }, - }, - [""] = actions.preview_scrolling_down, - [""] = actions.preview_scrolling_up, - [""] = actions.preview_scrolling_left, - [""] = actions.preview_scrolling_right, - [""] = actions.send_to_qflist + actions.open_qflist, - [""] = actions.send_selected_to_qflist + actions.open_qflist, - [""] = open_with_trouble, - [""] = actions.select_horizontal, - ["