From 23de12baba9fbfc4ca24581b37c374aa5345cc25 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Mon, 25 Nov 2024 13:30:37 +0100 Subject: update nvim config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Günzler --- .vim/lua/internal/plugins/telescope.lua | 137 ++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 .vim/lua/internal/plugins/telescope.lua (limited to '.vim/lua/internal/plugins/telescope.lua') diff --git a/.vim/lua/internal/plugins/telescope.lua b/.vim/lua/internal/plugins/telescope.lua new file mode 100644 index 0000000..6339a2c --- /dev/null +++ b/.vim/lua/internal/plugins/telescope.lua @@ -0,0 +1,137 @@ +return { + { + 'nvim-telescope/telescope.nvim', + lazy = false, + dependencies = { + { 'nvim-lua/plenary.nvim' }, + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'cmake -S. -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release', + }, + { 'nvim-telescope/telescope-ui-select.nvim' }, + }, + config = function(spec, _) + require('telescope').setup({ + defaults = require('telescope.themes').get_ivy({ + prompt = false, + borderchars = { + preview = { '─', '│', '─', '│', '┌', '┐', '┘', '└' }, + }, + }), + + extensions = { + wrap_results = true, + + fzf = {}, + + ['ui-select'] = { + require('telescope.themes').get_ivy({ + prompt = false, + -- sharp edges please + borderchars = { + preview = { '─', '│', '─', '│', '┌', '┐', '┘', '└' }, + }, + layout_config = { height = 9 }, + }), + }, + }, + }) + + pcall(require('telescope').load_extension, 'fzf') + pcall(require('telescope').load_extension, 'ui-select') + + -- user commands + vim.api.nvim_create_user_command( + 'F', + 'Telescope find_files search_dirs=', + { desc = 'Telescope find_files', nargs = '?' } + ) + vim.api.nvim_create_user_command( + 'G', + 'Telescope live_grep search_dirs=', + { desc = 'Telescope live_grep', nargs = '?' } + ) + + -- keymaps + local builtin = require('telescope.builtin') + for _, o in ipairs(spec.keys) do + if not o[2] then + local mod = vim.split(o.desc, ': ')[2] + vim.keymap.set(o.mode, o[1], builtin[mod], { desc = o.desc }) + end + end + + -- highlights + vim.schedule(function() + vim.api.nvim_set_hl(0, 'TelescopeBorder', { fg = 'NvimDarkGrey4', force = true }) + vim.api.nvim_set_hl(0, 'TelescopeTitle', { fg = 'NvimLightMagenta', force = true }) + vim.api.nvim_set_hl(0, 'NormalFloat', { link = 'TelescopeNormal', force = true }) + end) + end, + keys = { + { mode = 'n', ';/', desc = 'telescope: current_buffer_fuzzy_find' }, + { mode = 'n', ';b', desc = 'telescope: buffers' }, + { mode = 'n', ';f', desc = 'telescope: find_files' }, + { mode = 'n', ';g', desc = 'telescope: live_grep' }, + { mode = 'n', ';d', desc = 'telescope: diagnostics' }, + { + mode = 'n', + ';v', + function() + require('telescope.builtin').find_files({ + prompt_title = 'vimrc', + search_dirs = { + vim.fn.stdpath('config'), + }, + }) + end, + desc = 'telescope: vim_config', + }, + { + mode = 'n', + ';;t', + 'Telescope', + desc = 'telescope: select (interactive)', + }, + { + mode = 'n', + ';;f', + function() + local dir + if vim.opt.filetype:get() == 'oil' then + dir = require('oil').get_current_dir() + else + dir = vim.fn.expand('%:p') + end + _G.feedkeys(':Telescope find_files search_dirs=' .. dir) + end, + desc = 'telescope: find_files (interactive)', + }, + { + mode = 'n', + ';;g', + function() + local dir + if vim.opt.filetype:get() == 'oil' then + dir = require('oil').get_current_dir() + else + dir = vim.fn.expand('%:p') + end + _G.feedkeys(':Telescope live_grep search_dirs=' .. dir) + end, + desc = 'telescope: live_grep (interactive)', + }, + }, + }, + + { + 'prochri/telescope-all-recent.nvim', + lazy = false, + dependencies = { + 'nvim-telescope/telescope.nvim', + 'kkharji/sqlite.lua', + }, + after = { 'nvim-telescope/telescope-ui-select.nvim' }, + opts = {}, + }, +} -- cgit 1.4.1