diff options
| author | srdusr <trevorgray@srdusr.com> | 2023-07-14 17:35:37 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2023-07-14 17:35:37 +0200 |
| commit | 90982cf76ae6bf29840f2ecd6fc790151fc0fffe (patch) | |
| tree | c4b3cc68248dacbf9ed832647980d139ccea30f3 /.config/nvim/lua/plugins/telescope.lua | |
| parent | 863eda5cb97493b0d63ad457069d88c5c5b7a8f5 (diff) | |
| parent | d72187703f539920b879439c73ebf4849cc3dbdd (diff) | |
| download | dotfiles-90982cf76ae6bf29840f2ecd6fc790151fc0fffe.tar.gz dotfiles-90982cf76ae6bf29840f2ecd6fc790151fc0fffe.zip | |
Merge commit '600fd511151dec5bc6eafe7912579b9133921125'
Diffstat (limited to '.config/nvim/lua/plugins/telescope.lua')
| -rw-r--r-- | .config/nvim/lua/plugins/telescope.lua | 508 |
1 files changed, 274 insertions, 234 deletions
diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua index d6d7233..079f88b 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -9,9 +9,11 @@ local fb_actions = require("telescope").extensions.file_browser.actions --local action_state = require("telescope.actions.state") --local layout_actions = require("telescope.actions.layout") --local pickers = require("telescope.pickers") +local themes = require("telescope.themes") + require('telescope').setup({ - defaults = { + defaults = { vimgrep_arguments = { "rg", "--color=never", @@ -32,12 +34,13 @@ require('telescope').setup({ --path_display = { "smart" }, file_ignore_patterns = { "packer_compiled.lua", + "zcompdump", "%.DS_Store", "%.git/", "%.spl", --"%.log", "%[No Name%]", -- new files / sometimes folders (netrw) - "/$", -- ignore folders (netrw) + "/$", -- ignore folders (netrw) "node_modules", "%.png", "%.zip", @@ -49,112 +52,118 @@ require('telescope').setup({ "^music/", --"^node_modules/", --"^undodir/", - }, - mappings = { - i = { - ["<C-n>"] = actions.cycle_history_next, - ["<C-p>"] = actions.cycle_history_prev, - - ["<C-j>"] = actions.move_selection_next, - ["<C-k>"] = actions.move_selection_previous, - - --["<C-c>"] = actions.close, - ["<Esc>"] = actions.close, -- close w/ one esc - --["<Esc>"] = "close", -- close w/ one esc - ["<?>"] = actions.which_key, -- keys from pressing <C-/> - - ["<Down>"] = actions.move_selection_next, - ["<Up>"] = actions.move_selection_previous, - - ["<CR>"] = actions.select_default, - ["<C-x>"] = actions.select_horizontal, - ["<C-y>"] = actions.select_vertical, - ["<C-t>"] = actions.select_tab, - - ["<C-u>"] = actions.preview_scrolling_up, - ["<C-d>"] = actions.preview_scrolling_down, - - ["<PageUp>"] = actions.results_scrolling_up, - ["<PageDown>"] = actions.results_scrolling_down, - - ["<Tab>"] = actions.toggle_selection + actions.move_selection_worse, - ["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better, - ["<C-q>"] = actions.send_to_qflist + actions.open_qflist, - ["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist, - ["<C-l>"] = actions.complete_tag, - ["<C-_>"] = actions.which_key, -- keys from pressing <C-/> - --["<C-o>"] = function(prompt_bufnr) - -- local selection = require("telescope.actions.state").get_selected_entry() - -- local dir = vim.fn.fnamemodify(selection.path, ":p:h") - -- require("telescope.actions").close(prompt_bufnr) - -- -- Depending on what you want put `cd`, `lcd`, `tcd` - -- vim.cmd(string.format("silent lcd %s", dir)) - --end, - }, - - n = { - ["<esc>"] = actions.close, + }, + mappings = { + i = { + ["<C-n>"] = actions.cycle_history_next, + ["<C-p>"] = actions.cycle_history_prev, + + ["<C-j>"] = actions.move_selection_next, + ["<C-k>"] = actions.move_selection_previous, + + --["<C-c>"] = actions.close, + ["<Esc>"] = actions.close, -- close w/ one esc + --["<Esc>"] = "close", -- close w/ one esc + ["<?>"] = actions.which_key, -- keys from pressing <C-/> + + ["<Down>"] = actions.move_selection_next, + ["<Up>"] = actions.move_selection_previous, + + ["<CR>"] = actions.select_default, + ["<C-x>"] = actions.select_horizontal, + ["<C-y>"] = actions.select_vertical, + ["<C-t>"] = actions.select_tab, + + ["<C-u>"] = actions.preview_scrolling_up, + ["<C-d>"] = actions.preview_scrolling_down, + + ["<PageUp>"] = actions.results_scrolling_up, + ["<PageDown>"] = actions.results_scrolling_down, + + ["<Tab>"] = actions.toggle_selection + actions.move_selection_worse, + ["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better, + ["<C-q>"] = actions.send_to_qflist + actions.open_qflist, + ["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist, + ["<C-l>"] = actions.complete_tag, + ["<C-_>"] = actions.which_key, -- keys from pressing <C-/> + --["<C-o>"] = function(prompt_bufnr) + -- local selection = require("telescope.actions.state").get_selected_entry() + -- local dir = vim.fn.fnamemodify(selection.path, ":p:h") + -- require("telescope.actions").close(prompt_bufnr) + -- -- Depending on what you want put `cd`, `lcd`, `tcd` + -- vim.cmd(string.format("silent lcd %s", dir)) + --end, + }, + n = { + --["cd"] = function(prompt_bufnr) + -- local selection = require("telescope.actions.state").get_selected_entry() + -- local dir = vim.fn.fnamemodify(selection.path, ":p:h") + -- require("telescope.actions").close(prompt_bufnr) + -- -- Depending on what you want put `cd`, `lcd`, `tcd` + -- vim.cmd(string.format("silent lcd %s", dir)) + --end, + ["<esc>"] = actions.close, ["<q>"] = actions.close, - ["<CR>"] = actions.select_default, - ["<C-x>"] = actions.select_horizontal, - ["<C-y>"] = actions.select_vertical, - ["<C-t>"] = actions.select_tab, - - ["<Tab>"] = actions.toggle_selection + actions.move_selection_worse, - ["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better, - ["<C-q>"] = actions.send_to_qflist + actions.open_qflist, - ["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist, - - ["j"] = actions.move_selection_next, - ["k"] = actions.move_selection_previous, - ["H"] = actions.move_to_top, - ["M"] = actions.move_to_middle, - ["L"] = actions.move_to_bottom, - - ["<Down>"] = actions.move_selection_next, - ["<Up>"] = actions.move_selection_previous, - ["gg"] = actions.move_to_top, - ["G"] = actions.move_to_bottom, - - ["<C-u>"] = actions.preview_scrolling_up, - ["<C-d>"] = actions.preview_scrolling_down, - - ["<PageUp>"] = actions.results_scrolling_up, - ["<PageDown>"] = actions.results_scrolling_down, - - ["?"] = actions.which_key, - --["<C-o>"] = function(prompt_bufnr) - -- local selection = require("telescope.actions.state").get_selected_entry() - -- local dir = vim.fn.fnamemodify(selection.path, ":p:h") - -- require("telescope.actions").close(prompt_bufnr) - -- -- Depending on what you want put `cd`, `lcd`, `tcd` - -- vim.cmd(string.format("silent lcd %s", dir)) - --end, - }, - }, - }, - preview = { - filesize_limit = 3, - timeout = 250, + ["<CR>"] = actions.select_default, + ["<C-x>"] = actions.select_horizontal, + ["<C-y>"] = actions.select_vertical, + ["<C-t>"] = actions.select_tab, + + ["<Tab>"] = actions.toggle_selection + actions.move_selection_worse, + ["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better, + ["<C-q>"] = actions.send_to_qflist + actions.open_qflist, + ["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist, + + ["j"] = actions.move_selection_next, + ["k"] = actions.move_selection_previous, + ["H"] = actions.move_to_top, + ["M"] = actions.move_to_middle, + ["L"] = actions.move_to_bottom, + + ["<Down>"] = actions.move_selection_next, + ["<Up>"] = actions.move_selection_previous, + ["gg"] = actions.move_to_top, + ["G"] = actions.move_to_bottom, + + ["<C-u>"] = actions.preview_scrolling_up, + ["<C-d>"] = actions.preview_scrolling_down, + + ["<PageUp>"] = actions.results_scrolling_up, + ["<PageDown>"] = actions.results_scrolling_down, + + ["?"] = actions.which_key, + --["<C-o>"] = function(prompt_bufnr) + -- local selection = require("telescope.actions.state").get_selected_entry() + -- local dir = vim.fn.fnamemodify(selection.path, ":p:h") + -- require("telescope.actions").close(prompt_bufnr) + -- -- Depending on what you want put `cd`, `lcd`, `tcd` + -- vim.cmd(string.format("silent lcd %s", dir)) + --end, + }, + }, + }, + preview = { + filesize_limit = 3, + timeout = 250, + }, + selection_strategy = "reset", + sorting_strategy = "ascending", + scroll_strategy = "limit", + color_devicons = true, + layout_strategy = 'horizontal', + layout_config = { + horizontal = { + height = 0.95, + preview_cutoff = 70, + width = 0.92, + preview_width = { 0.55, max = 50 } + }, + bottom_pane = { + height = 12, + preview_cutoff = 70, + prompt_position = "bottom", }, - selection_strategy = "reset", - sorting_strategy = "ascending", - scroll_strategy = "limit", - color_devicons = true, - layout_strategy = 'horizontal', - layout_config = { - horizontal = { - height = 0.95, - preview_cutoff = 70, - width = 0.92, - preview_width = {0.55, max = 50} - }, - bottom_pane = { - height = 12, - preview_cutoff = 70, - prompt_position = "bottom", - }, - }, + }, --pickers = { -- live_grep = { -- disable_coordinates = true, @@ -165,89 +174,102 @@ require('telescope').setup({ -- }, -- }, --}, - --pickers = { - --lsp_references = { - -- prompt_prefix='⬅️', - -- show_line=false, - -- trim_text=true, - -- include_declaration=false, - -- initial_mode = "normal", - --}, - --lsp_definitions = { - -- prompt_prefix='➡️', - -- show_line=false, - -- trim_text=true, - -- initial_mode = "normal", - --}, - --lsp_document_symbols = { - -- prompt_prefix='* ', - -- show_line = false, - --}, - --treesitter = { - -- prompt_prefix=' ', - -- show_line = false, - --}, - --find_files = { - -- cwd='%:p:h', - -- prompt_prefix=' ', - -- hidden = true, - -- follow = true, - --}, - --keymaps = { prompt_prefix='? ' }, - --oldfiles = { prompt_prefix=' ' }, - --highlights = { prompt_prefix=' ' }, - --git_files = { - -- prompt_prefix=' ', - -- show_untracked = true, - -- path_display = { "tail" }, - --}, - --buffers = { - -- prompt_prefix=' ', - -- ignore_current_buffer = true, - -- initial_mode = "normal", - -- sort_mru = true, - --}, - --live_grep = { - -- cwd='%:p:h', - -- disable_coordinates=true, - -- prompt_title='Search in Folder', - -- prompt_prefix=' ', - --}, - --spell_suggest = { - -- initial_mode = "normal", - -- prompt_prefix = "暈", - -- theme = "cursor", - -- layout_config = { cursor = { width = 0.3 } } - --}, - --colorscheme = { - -- enable_preview = true, - -- prompt_prefix = '', - -- results_title = '', - -- layout_strategy = "bottom_pane", - --}, - --}, - - extensions = { - file_browser = { - theme = "dropdown", - -- disables netrw and use telescope-file-browser in its place - hijack_netrw = true, - mappings = { - -- your custom insert mode mappings - ["i"] = { - ["<C-w>"] = function() - vim.cmd("normal vbd") - end, + --pickers = { + -- live_grep = { + -- mappings = { + -- i = { + -- ["<C-f>"] = ts_select_dir_for_grep, + -- }, + -- n = { + -- ["<C-f>"] = ts_select_dir_for_grep, + -- }, + -- }, + -- }, + --}, + --pickers = { + --lsp_references = { + -- prompt_prefix='⬅️', + -- show_line=false, + -- trim_text=true, + -- include_declaration=false, + -- initial_mode = "normal", + --}, + --lsp_definitions = { + -- prompt_prefix='➡️', + -- show_line=false, + -- trim_text=true, + -- initial_mode = "normal", + --}, + --lsp_document_symbols = { + -- prompt_prefix='* ', + -- show_line = false, + --}, + --treesitter = { + -- prompt_prefix=' ', + -- show_line = false, + --}, + find_files = { + cwd = '%:p:h', + --cwd = vim.fn.getcwd(), + prompt_prefix = ' ', + hidden = true, + follow = true, + }, + --keymaps = { prompt_prefix='? ' }, + --oldfiles = { prompt_prefix=' ' }, + --highlights = { prompt_prefix=' ' }, + --git_files = { + -- prompt_prefix=' ', + -- show_untracked = true, + -- path_display = { "tail" }, + --}, + --buffers = { + -- prompt_prefix=' ', + -- ignore_current_buffer = true, + -- initial_mode = "normal", + -- sort_mru = true, + --}, + --live_grep = { + -- cwd='%:p:h', + -- disable_coordinates=true, + -- prompt_title='Search in Folder', + -- prompt_prefix=' ', + --}, + --spell_suggest = { + -- initial_mode = "normal", + -- prompt_prefix = "暈", + -- theme = "cursor", + -- layout_config = { cursor = { width = 0.3 } } + --}, + --colorscheme = { + -- enable_preview = true, + -- prompt_prefix = '', + -- results_title = '', + -- layout_strategy = "bottom_pane", + --}, + --}, + + extensions = { + file_browser = { + theme = "dropdown", + -- disables netrw and use telescope-file-browser in its place + hijack_netrw = true, + mappings = { + -- your custom insert mode mappings + ["i"] = { + ["<C-w>"] = function() + vim.cmd("normal vbd") + end, + --["<C-h>"] = fb_actions.goto_parent_dir, + }, + ["n"] = { + -- your custom normal mode mappings + ["N"] = fb_actions.create, --["<C-h>"] = fb_actions.goto_parent_dir, - }, - ["n"] = { - -- your custom normal mode mappings - ["N"] = fb_actions.create, - --["<C-h>"] = fb_actions.goto_parent_dir, - --["/"] = function() - -- vim.cmd("startinsert") - --end, - }, + --["/"] = function() + -- vim.cmd("startinsert") + --end, + }, }, }, }, @@ -266,6 +288,17 @@ require('telescope').load_extension('media_files') require('telescope').load_extension('notify') require('telescope').load_extension('dap') require("telescope").load_extension("session-lens") +require("telescope").load_extension("flutter") + +--M.curbuf = function(opts) +-- opts = opts +-- or themes.get_dropdown({ +-- previewer = false, +-- shorten_path = false, +-- border = true, +-- }) +-- require("telescope.builtin").current_buffer_fuzzy_find(opts) +--end function M.find_configs() require("telescope.builtin").find_files { @@ -285,8 +318,13 @@ function M.find_configs() "~/.config/bspwm", "~/.config/sxhkd", "~/.config/picom", - "~/.ssh", + "~/.config/polybar", "~/.bashrc", + "~/.ssh", + "~/.vim", + "~/.profile", + "~/.zprofile", + "~/README.md", }, -- cwd = "~/.config/nvim/", file_ignore_patterns = { @@ -297,6 +335,9 @@ function M.find_configs() --"^~/.config/tmux/plugins", "%.txt", ".git", + "autoload/plugged", + "plug.vim", + "zcompdump", }, layout_strategy = "horizontal", layout_config = { preview_width = 0.65, width = 0.75 }, @@ -378,22 +419,22 @@ end -------------------------------------------------------------------------------- local dropdown = require('telescope.themes').get_dropdown({ - hidden = true, - no_ignore = true, - previewer = false, - prompt_title = '', - preview_title = '', - results_title = '', - layout_config = { - --anchor = "S", - prompt_position = 'top' - }, + hidden = true, + no_ignore = true, + previewer = false, + prompt_title = '', + preview_title = '', + results_title = '', + layout_config = { + --anchor = "S", + prompt_position = 'top' + }, }) -- File browser always relative to buffer -local opts_file_browser = vim.tbl_extend('force', dropdown, { - path_display = { '%:p:h' }, -}) +--local opts_file_browser = vim.tbl_extend('force', dropdown, { +-- path_display = { '%:p:h' }, +--}) -- Set current folder as prompt title local with_title = function(opts, extra) @@ -413,37 +454,36 @@ local with_title = function(opts, extra) }, extra or {}) end -----vim.api.nvim_create_augroup('startup', { clear = true }) -----vim.api.nvim_command('augroup startup') -----vim.api.nvim_command('autocmd!') -----vim.api.nvim_command('autocmd VimEnter * lua require("plugins/telescope").startup()') -----vim.api.nvim_command('augroup END') --- --- ---local startup = function() --- -- Open file browser if argument is a folder --- local arg = vim.api.nvim_eval('argv(0)') --- if arg and (vim.fn.isdirectory(arg) ~= 0 or arg == "") then --- vim.defer_fn(function() --- require('telescope.builtin').find_files(with_title(dropdown)) ----- require'telescope.builtin'.find_files(require('telescope.themes').get_dropdown({ ----- hidden = true, ----- results_title = '', ----- layout_config = { prompt_position = 'top' }, ----- })) --- end, 10) --- end ---end --- --- --- ----- Define the custom command startup/findhere ---vim.cmd('command! Startup lua require("plugins.telescope").startup()') ---vim.cmd('command! Findhere lua require("plugins.telescope").startup()') --- -----vim.api.nvim_command('autocmd VimEnter * lua require("plugins/telescope").startup()') --- ----- Merge the existing M table with the startup function table ---M = vim.tbl_extend('force', M, { startup = startup }) +--vim.api.nvim_create_augroup('findhere', { clear = true }) +--vim.api.nvim_command('augroup findhere') +--vim.api.nvim_command('autocmd!') +--vim.api.nvim_command('autocmd VimEnter * lua require("plugins/telescope").findhere()') +--vim.api.nvim_command('augroup END') + + +--local findhere = function() +function M.findhere() + -- Open file browser if argument is a folder + local arg = vim.api.nvim_eval('argv(0)') + if arg and (vim.fn.isdirectory(arg) ~= 0 or arg == "") then + vim.defer_fn(function() + require('telescope.builtin').find_files(with_title(dropdown)) +-- require'telescope.builtin'.find_files(require('telescope.themes').get_dropdown({ +-- hidden = true, +-- results_title = '', +-- layout_config = { prompt_position = 'top' }, +-- })) + end, 10) + end +end + +-- Define the custom command findhere/startup +vim.cmd('command! Findhere lua require("plugins.telescope").findhere()') +--vim.cmd('command! Startup lua require("plugins.telescope").findhere()') + +--vim.api.nvim_command('autocmd VimEnter * lua require("plugins/telescope").findhere()') + +-- Merge the existing M table with the startup function table +--M = vim.tbl_extend('force', M, { findhere = findhere }) return M |
