From 87336bbfcb4434ec851af1da43a91a37ec740c7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hend=C3=A9n?= Date: Tue, 7 Jan 2025 09:54:26 -0500 Subject: [PATCH] break out telescope to its own plugin file change telescope key from [s]earch to [f]ind comment out telescope keys i dont knwo or use --- init.lua | 184 ++------------------------------------ lazy-lock.json | 22 ++--- lua/plugins/telescope.lua | 167 ++++++++++++++++++++++++++++++++++ 3 files changed, 183 insertions(+), 190 deletions(-) create mode 100644 lua/plugins/telescope.lua diff --git a/init.lua b/init.lua index 435cdb98..a0d69465 100644 --- a/init.lua +++ b/init.lua @@ -234,183 +234,6 @@ require('lazy').setup({ -- -- Use the `dependencies` key to specify the dependencies of a particular plugin - { -- Fuzzy Finder (files, lsp, etc) - 'nvim-telescope/telescope.nvim', - event = 'VimEnter', - branch = '0.1.x', - dependencies = { - 'nvim-lua/plenary.nvim', - { -- If encountering errors, see telescope-fzf-native README for installation instructions - 'nvim-telescope/telescope-fzf-native.nvim', - - -- `build` is used to run some command when the plugin is installed/updated. - -- This is only run then, not every time Neovim starts up. - build = 'make', - - -- `cond` is a condition used to determine whether this plugin should be - -- installed and loaded. - cond = function() - return vim.fn.executable 'make' == 1 - end, - }, - { 'nvim-telescope/telescope-ui-select.nvim' }, - - -- Useful for getting pretty icons, but requires a Nerd Font. - { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, - }, - config = function() - -- Telescope is a fuzzy finder that comes with a lot of different things that - -- it can fuzzy find! It's more than just a "file finder", it can search - -- many different aspects of Neovim, your workspace, LSP, and more! - -- - -- The easiest way to use Telescope, is to start by doing something like: - -- :Telescope help_tags - -- - -- After running this command, a window will open up and you're able to - -- type in the prompt window. You'll see a list of `help_tags` options and - -- a corresponding preview of the help. - -- - -- Two important keymaps to use while in Telescope are: - -- - Insert mode: - -- - Normal mode: ? - -- - -- This opens a window that shows you all of the keymaps for the current - -- Telescope picker. This is really useful to discover what Telescope can - -- do as well as how to actually do it! - - -- [[ Configure Telescope ]] - -- See `:help telescope` and `:help telescope.setup()` - require('telescope').setup { - -- You can put your default mappings / updates / etc. in here - -- All the info you're looking for is in `:help telescope.setup()` - -- - defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - -- }, - layout_strategy = 'horizontal', - pickers = { - current_buffer_fuzzy_find = { - theme = 'ivy', - previewer = false, - }, - buffers = { - sort_lastused = true, - -- theme = "dropdown", - theme = 'ivy', - layout_config = { height = 10 }, - previewer = false, - mappings = { - i = { [''] = require('telescope.actions').delete_buffer }, - n = { [''] = require('telescope.actions').delete_buffer }, - }, - }, - find_files = { - theme = 'ivy', - layout_config = { height = 10 }, - previewer = false, - }, - oldfiles = { - sort_lastused = true, - theme = 'ivy', - layout_config = { height = 10 }, - previewer = false, - }, - command_history = { - sort_lastused = true, - theme = 'ivy', - layout_config = { height = 10 }, - previewer = false, - }, - }, - - --[[ - layout_config = { - - width = function(_, max_columns) - local percentage = 0.7 - local max = 70 - return math.min(math.floor(percentage * max_columns), max) - end, - - height = function(_, _, max_lines) - local percentage = 0.7 - local min = 70 - return math.max(math.floor(percentage * max_lines), min) - end, - - -- preview_cutoff = 120, - }, - --]] - --[[ - layout_config = { - -- defaults = { - layout_strategy = 'vertical', - height = vim.o.lines, -- maximally available lines - width = vim.o.columns, -- maximally available columns - prompt_position = 'top', - -- preview_height = 0.6, -- 60% of available lines - }, - --]] - }, - extensions = { - ['ui-select'] = { - require('telescope.themes').get_dropdown(), - }, - }, - } - - -- Enable Telescope extensions if they are installed - pcall(require('telescope').load_extension, 'fzf') - pcall(require('telescope').load_extension, 'ui-select') - - -- See `:help telescope.builtin` - local builtin = require 'telescope.builtin' - vim.keymap.set('n', 'sc', builtin.colorscheme, { desc = '[S]earch [C]colorscheme' }) - vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) - vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) - vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) - vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) - vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) - vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) - vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) - - -- Slightly advanced example of overriding default behavior and theme - -- vim.keymap.set('n', '/', builtin.current_buffer_fuzzy_find, { desc = '[/] Fuzzily search in current buffer' }) - vim.keymap.set('n', '/', function() - builtin.current_buffer_fuzzy_find { - previewer = false, - } - end, { desc = '[/] Fuzzily search in current buffer' }) - --[[ - vim.keymap.set('n', '/', function() - -- You can pass additional configuration to Telescope to change the theme, layout, etc. - builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 20, - previewer = false, - }) - end, { desc = '[/] Fuzzily search in current buffer' }) - --]] - - -- It's also possible to pass additional configuration options. - -- See `:help telescope.builtin.live_grep()` for information about particular keys - vim.keymap.set('n', '', function() - builtin.live_grep { - grep_open_files = true, - prompt_title = 'Live Grep in Open Files', - } - end, { desc = '[S]earch [/] in Open Files' }) - - -- Shortcut for searching your Neovim configuration files - vim.keymap.set('n', 'sn', function() - builtin.find_files { cwd = vim.fn.stdpath 'config' } - end, { desc = '[S]earch [N]eovim files' }) - end, - }, - { -- Lush colorscheme helper 'rktjmp/lush.nvim', -- if you wish to use your own colorscheme: @@ -430,7 +253,9 @@ require('lazy').setup({ }, }, }, + { 'Bilal2453/luvit-meta', lazy = true }, + { -- Main LSP Configuration 'neovim/nvim-lspconfig', @@ -919,9 +744,10 @@ require('lazy').setup({ -- require 'plugins.debug', -- require 'plugins.indent_line', -- require 'plugins.lint', - require 'plugins.autopairs', + require 'plugins.telescope', + -- require 'plugins.autopairs', require 'plugins.neo-tree', - require 'plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'plugins.gitsigns', require 'plugins.codeium', require 'plugins.chatgpt', require 'plugins.auto-session', diff --git a/lazy-lock.json b/lazy-lock.json index d875f008..c4179bb5 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -3,45 +3,45 @@ "auto-session": { "branch": "main", "commit": "021b64ed7d4ac68a37be3ad28d8e1cba5bec582c" }, "catppuccin": { "branch": "main", "commit": "f67b886d65a029f12ffa298701fb8f1efd89295d" }, "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, - "codeium.nvim": { "branch": "main", "commit": "27d2b1ce8c7ba14dbf6e4504bdea8e5548be5476" }, + "codeium.nvim": { "branch": "main", "commit": "ebed4f7cc8a18184d8332d421ca10bed5f7d59a1" }, "conform.nvim": { "branch": "master", "commit": "70019124aa4f2e6838be9fbd2007f6d13b27a96d" }, "copilot.vim": { "branch": "release", "commit": "87038123804796ca7af20d1b71c3428d858a9124" }, - "cyberdream.nvim": { "branch": "main", "commit": "4f8dcaa5a989ef207f7a06ffaf5db9d17b9f9156" }, + "cyberdream.nvim": { "branch": "main", "commit": "77c27cb822b638d7b332cfff6c6fb09473a7d180" }, "fidget.nvim": { "branch": "main", "commit": "9238947645ce17d96f30842e61ba81147185b657" }, "flybuf.nvim": { "branch": "main", "commit": "fe1fbd9699f6988a1db3b2e2ffa599154784c6e1" }, "gitsigns.nvim": { "branch": "main", "commit": "5f808b5e4fef30bd8aca1b803b4e555da07fc412" }, "indent-blankline.nvim": { "branch": "master", "commit": "259357fa4097e232730341fa60988087d189193a" }, "kanagawa.nvim": { "branch": "master", "commit": "18ae5771b22d8f913ef541c827a8180b4cb12c8a" }, - "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" }, + "lazy.nvim": { "branch": "main", "commit": "d8f26efd456190241afd1b0f5235fe6fdba13d4a" }, "lazydev.nvim": { "branch": "main", "commit": "8620f82ee3f59ff2187647167b6b47387a13a018" }, "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, "lush.nvim": { "branch": "main", "commit": "45a79ec4acb5af783a6a29673a999ce37f00497e" }, "luvit-meta": { "branch": "main", "commit": "55709f183b0742a7e4f47688c284f81148ad4dc0" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "c6c686781f9841d855bf1b926e10aa5e19430a38" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "97d9f1d3ad205dece6bcafd1d71cf1507608f3c7" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "mini.nvim": { "branch": "main", "commit": "546b9c8bd8ebba594bd18811e54bd3e6f9a662ec" }, + "mini.nvim": { "branch": "main", "commit": "b1af49d98233180c6045e81f4aef5b663d032b62" }, "neo-tree.nvim": { "branch": "main", "commit": "a77af2e764c5ed4038d27d1c463fa49cd4794e07" }, "newpaper.nvim": { "branch": "main", "commit": "ff1038a92f0a5d6a5e705becb086ccf38c27046d" }, "nightfox.nvim": { "branch": "main", "commit": "595ffb8f291fc4a9bef3201a28b7c0379a41cdee" }, "nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" }, "nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" }, - "nvim-cmp": { "branch": "main", "commit": "b555203ce4bd7ff6192e759af3362f9d217e8c89" }, - "nvim-lspconfig": { "branch": "master", "commit": "a8ef5e6e497b3ebeaaf35b939c07c211563b2e05" }, + "nvim-cmp": { "branch": "main", "commit": "8c82d0bd31299dbff7f8e780f5e06d2283de9678" }, + "nvim-lspconfig": { "branch": "master", "commit": "8121483b8132b7053120fafd83728178fb3febf6" }, "nvim-tree.lua": { "branch": "master", "commit": "68fc4c20f5803444277022c681785c5edd11916d" }, - "nvim-treesitter": { "branch": "master", "commit": "6935286b4ee3d938954e446d657eebee71b4d07a" }, + "nvim-treesitter": { "branch": "master", "commit": "622a4a6ba76d1de52b72a965159213ae655b4ac7" }, "nvim-web-devicons": { "branch": "master", "commit": "5740b7382429d20b6ed0bbdb0694185af9507d44" }, "obsidian.nvim": { "branch": "main", "commit": "ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b" }, "onedark": { "branch": "master", "commit": "67a74c275d1116d575ab25485d1bfa6b2a9c38a6" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, - "snacks.nvim": { "branch": "main", "commit": "d312053f78b4fb55523def179ac502438dd93193" }, + "snacks.nvim": { "branch": "main", "commit": "14e89401da348f5d14509fca164fb7bcec83e597" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "dae2eac9d91464448b584c7949a31df8faefec56" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, - "tokyonight.nvim": { "branch": "main", "commit": "45d22cf0e1b93476d3b6d362d720412b3d34465c" }, + "tokyonight.nvim": { "branch": "main", "commit": "7bb270adaa7692c2c33befc35f5567fc596a2504" }, "trouble.nvim": { "branch": "main", "commit": "46cf952fc115f4c2b98d4e208ed1e2dce08c9bf6" }, "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, - "which-key.nvim": { "branch": "main", "commit": "8ab96b38a2530eacba5be717f52e04601eb59326" }, + "which-key.nvim": { "branch": "main", "commit": "1f8d414f61e0b05958c342df9b6a4c89ce268766" }, "zenbones.nvim": { "branch": "main", "commit": "3c0b86bb912d41d191d90c019a346f6a1d27f588" } } diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 00000000..94deaa67 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,167 @@ +return { + 'nvim-telescope/telescope.nvim', + event = 'VimEnter', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + { -- If encountering errors, see telescope-fzf-native README for installation instructions + 'nvim-telescope/telescope-fzf-native.nvim', + + -- `build` is used to run some command when the plugin is installed/updated. + -- This is only run then, not every time Neovim starts up. + build = 'make', + + -- `cond` is a condition used to determine whether this plugin should be + -- installed and loaded. + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + { 'nvim-telescope/telescope-ui-select.nvim' }, + + -- Useful for getting pretty icons, but requires a Nerd Font. + { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, + }, + config = function() + -- Telescope is a fuzzy finder that comes with a lot of different things that + -- it can fuzzy find! It's more than just a "file finder", it can search + -- many different aspects of Neovim, your workspace, LSP, and more! + -- + -- The easiest way to use Telescope, is to start by doing something like: + -- :Telescope help_tags + -- + -- After running this command, a window will open up and you're able to + -- type in the prompt window. You'll see a list of `help_tags` options and + -- a corresponding preview of the help. + -- + -- Two important keymaps to use while in Telescope are: + -- - Insert mode: + -- - Normal mode: ? + -- + -- This opens a window that shows you all of the keymaps for the current + -- Telescope picker. This is really useful to discover what Telescope can + -- do as well as how to actually do it! + + -- [[ Configure Telescope ]] + -- See `:help telescope` and `:help telescope.setup()` + require('telescope').setup { + -- You can put your default mappings / updates / etc. in here + -- All the info you're looking for is in `:help telescope.setup()` + -- + defaults = { + -- mappings = { + -- i = { [''] = 'to_fuzzy_refine' }, + -- }, + -- }, + layout_strategy = 'horizontal', + pickers = { + current_buffer_fuzzy_find = { + theme = 'ivy', + previewer = false, + }, + buffers = { + sort_lastused = true, + -- theme = "dropdown", + theme = 'ivy', + layout_config = { height = 10 }, + previewer = false, + mappings = { + i = { [''] = require('telescope.actions').delete_buffer }, + n = { [''] = require('telescope.actions').delete_buffer }, + }, + }, + find_files = { + theme = 'ivy', + layout_config = { height = 10 }, + previewer = false, + }, + oldfiles = { + sort_lastused = true, + theme = 'ivy', + layout_config = { height = 10 }, + previewer = false, + }, + command_history = { + sort_lastused = true, + theme = 'ivy', + layout_config = { height = 10 }, + previewer = false, + }, + }, + + --[[ + layout_config = { + + width = function(_, max_columns) + local percentage = 0.7 + local max = 70 + return math.min(math.floor(percentage * max_columns), max) + end, + + height = function(_, _, max_lines) + local percentage = 0.7 + local min = 70 + return math.max(math.floor(percentage * max_lines), min) + end, + + -- preview_cutoff = 120, + }, + --]] + --[[ + layout_config = { + -- defaults = { + layout_strategy = 'vertical', + height = vim.o.lines, -- maximally available lines + width = vim.o.columns, -- maximally available columns + prompt_position = 'top', + -- preview_height = 0.6, -- 60% of available lines + }, + --]] + }, + extensions = { + ['ui-select'] = { + require('telescope.themes').get_dropdown(), + }, + }, + } + + -- Enable Telescope extensions if they are installed + pcall(require('telescope').load_extension, 'fzf') + pcall(require('telescope').load_extension, 'ui-select') + + -- See `:help telescope.builtin` + local builtin = require 'telescope.builtin' + vim.keymap.set('n', 'fc', builtin.colorscheme, { desc = '[S]earch [C]colorscheme' }) + -- vim.keymap.set('n', 'fh', builtin.help_tags, { desc = '[S]earch [H]elp' }) + -- vim.keymap.set('n', 'fk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) + vim.keymap.set('n', 'ff', builtin.find_files, { desc = '[S]earch [F]iles' }) + -- vim.keymap.set('n', 'fs', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) + vim.keymap.set('n', 'fw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) + -- vim.keymap.set('n', 'fg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) + -- vim.keymap.set('n', 'fd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) + vim.keymap.set('n', 'fr', builtin.resume, { desc = '[S]earch [R]esume' }) + vim.keymap.set('n', 'f.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + + -- Slightly advanced example of overriding default behavior and theme + -- vim.keymap.set('n', '/', builtin.current_buffer_fuzzy_find, { desc = '[/] Fuzzily search in current buffer' }) + vim.keymap.set('n', '/', function() + builtin.current_buffer_fuzzy_find { + previewer = false, + } + end, { desc = '[/] Fuzzily search in current buffer' }) + + -- It's also possible to pass additional configuration options. + -- See `:help telescope.builtin.live_grep()` for information about particular keys + vim.keymap.set('n', '', function() + builtin.live_grep { + grep_open_files = true, + prompt_title = 'Live Grep in Open Files', + } + end, { desc = '[S]earch [/] in Open Files' }) + + -- Shortcut for searching your Neovim configuration files + vim.keymap.set('n', 'sn', function() + builtin.find_files { cwd = vim.fn.stdpath 'config' } + end, { desc = '[S]earch [N]eovim files' }) + end, +}