commit 3be0639a9062658804becb993d8b2687c123c9c2 from: Andre M. Bertachini date: Sat May 10 21:48:32 2025 UTC Improve Telescope config commit - 6c74fe11071df85192d74581a021ecf67c13edb8 commit + 3be0639a9062658804becb993d8b2687c123c9c2 blob - 46e36084159eccf1f4a24a0259cea6e60da43b32 blob + 90b9c4a7b0a0a6a9f017bdc48ffac8843a9392d2 --- init.lua +++ init.lua @@ -1,9 +1,11 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -require 'config.options' require 'plugins.lazy' -require("lazy").setup({ - require 'plugins/telescope', +require('lazy').setup({ + require 'plugins/telescope' }) + +require 'config.options' +require 'config.keymaps' blob - a3eaa5736f0c1a2c5e030cda7d130ffbfacb0ea7 blob + 995738b008bada3c6825615a94fbd1640f7a7c32 --- lazy-lock.json +++ lazy-lock.json @@ -2,6 +2,5 @@ "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, - "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, - "telescope.nvim": { "branch": "master", "commit": "a4ed82509cecc56df1c7138920a1aeaf246c0ac5" } + "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" } } blob - 24b261b466bd7a9f0419af6d5d5c1f40403b415d blob + 0974f2dad9ec8b6ca79d7e71136f442486e8c4bc --- lua/config/keymaps.lua +++ lua/config/keymaps.lua @@ -1,18 +1,27 @@ -- Clear highlights on search when pressing in normal mode --- See `:help hlsearch` +-- See `:help hlsearch` vim.keymap.set('n', '', 'nohlsearch') +-- Faster netrw mapping +-- See `:help netrw` +vim.keymap.set('n', 'e', ':Ex') + -- Diagnostic keymaps vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) -- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier -- for people to discover. Otherwise, you normally need to press , which -- is not what someone will guess without a bit more experience. --- + -- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping -- or just use to exit terminal mode -vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) +-- See `:help terminal` +vim.keymap.set('n', '', 'nohlsearch') +vim.keymap.set('n', 'e', ':Ex') +-- Diagnostic keymaps +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) + -- TIP: Disable arrow keys in normal mode vim.keymap.set('n', '', 'echo "No Arrows!"') vim.keymap.set('n', '', 'echo "No Arrows!"') @@ -20,8 +29,7 @@ vim.keymap.set('n', '', 'echo "No Arrows!"', 'echo "No Arrows!"') -- Keybinds to make split navigation easier. --- Use CTRL+ to switch between windows --- +-- Use CTRL+ to switch between windows -- See `:help wincmd` for a list of all window commands vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) @@ -30,8 +38,8 @@ vim.keymap.set('n', '', '', { desc = 'M -- Highlight when yanking (copying) text --- Try it with `yap` in normal mode --- See `:help vim.highlight.on_yank()` +-- Try it with `yap` in normal mode +-- See `:help vim.highlight.on_yank()` vim.api.nvim_create_autocmd('TextYankPost', { desc = 'Highlight when yanking (copying) text', group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), @@ -39,5 +47,28 @@ vim.api.nvim_create_autocmd('TextYankPost', { vim.highlight.on_yank() end, }) +vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) --- vim: ts=2 sts=2 sw=2 et +-- TIP: Disable arrow keys in normal mode +vim.keymap.set('n', '', 'echo "No Arrows!"') +vim.keymap.set('n', '', 'echo "No Arrows!"') +vim.keymap.set('n', '', 'echo "No Arrows!"') +vim.keymap.set('n', '', 'echo "No Arrows!"') + +-- Keybinds to make split navigation easier. +-- Use CTRL+ to switch between windows +-- See `:help wincmd` for a list of all window commands +vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) + +-- Telescope keymaps +-- See `:help telescope.builtin` +vim.keymap.set('n', 'sf', 'Telescope find_files', { desc = 'Find files' }) +vim.keymap.set('n', 'sg', 'Telescope live_grep', { desc = 'Search text in files' }) +vim.keymap.set('n', 'sb', 'Telescope buffers', { desc = 'List open buffers' }) +vim.keymap.set('n', 'gf', 'Telescope git_files', { desc = 'Find Git-tracked files' }) +vim.keymap.set('n', 'sh', 'Telescope help_tags', { desc = 'Search help tags' }) +vim.keymap.set('n', 'sr', 'Telescope oldfiles', { desc = 'List recent files' }) +vim.keymap.set('n', 'sz', 'Telescope current_buffer_fuzzy_find', { desc = 'Fuzzy find in current buffer' }) blob - 74c1e9ff7bb15a60dfb158b85524b8f9f96962ba blob + cfba14dc15db438fe815d17a0d21d3f65ecaea4f --- lua/config/options.lua +++ lua/config/options.lua @@ -26,7 +26,7 @@ vim.o.smartcase = true vim.o.signcolumn = 'yes' -- Decrease update time -vim.o.updatetime = 250 +vim.o.updatetime = 100 -- Decrease mapped sequence wait time vim.o.timeoutlen = 300 blob - ec610290e8d92a2f7a0683406c04e234a26a9887 blob + 242ede334e2859fea69f50f538bf9c6b6aad4d82 --- lua/plugins/lazy.lua +++ lua/plugins/lazy.lua @@ -1,4 +1,3 @@ --- Bootstrap lazy.nvim local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then local lazyrepo = "https://github.com/folke/lazy.nvim.git" blob - a3f45e823be3663fe5a6c315f3e505b8998c9138 blob + 4338fe2b02e3d3bdb5f6336488b458890784eaaa --- lua/plugins/telescope.lua +++ lua/plugins/telescope.lua @@ -1,53 +1,48 @@ return { - "nvim-telescope/telescope.nvim", - event = "VimEnter", - dependencies = { - "nvim-lua/plenary.nvim", - { - "nvim-telescope/telescope-fzf-native.nvim", - build = "make", - cond = function() - return vim.fn.executable "make" == 1 - end, - }, - { "nvim-telescope/telescope-ui-select.nvim" }, - }, - config = function() - require("telescope").setup { - extensions = { - ["ui-select"] = { - require("telescope.themes").get_dropdown(), - }, + 'nvim-telescope/telescope.nvim', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + { + '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, }, - } - pcall(require("telescope").load_extension, "fzf") - pcall(require("telescope").load_extension, "ui-select") - local builtin = require("telescope.builtin") - 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" }) - vim.keymap.set("n", "", builtin.buffers, { desc = "[ ] Find existing buffers" }) - vim.keymap.set("n", "/", function() - builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown { - winblend = 10, - previewer = false, - }) - end, { desc = "[/] Fuzzily search in current buffer" }) - vim.keymap.set("n", "s/", function() - builtin.live_grep { - grep_open_files = true, - prompt_title = "Live Grep in Open Files", - } - end, { desc = "[S]earch [/] in Open Files" }) - vim.keymap.set("n", "sn", function() - builtin.find_files { cwd = vim.fn.stdpath "config" } - end, { desc = "[S]earch [N]eovim files" }) - end, + }, + cmd = 'Telescope', -- Lazy-load on :Telescope command + config = function() + pcall(require('telescope').load_extension, 'fzf') + require('telescope').setup({ + defaults = { + -- Minimal layout for speed + layout_strategy = 'horizontal', + layout_config = { + width = 0.8, + height = 0.8, + preview_width = 0.6, + }, + -- Disable costly folders + file_ignore_patterns = { 'node_modules', '.git/' }, + -- Basic mappings for efficiency + mappings = { + i = { + [''] = 'move_selection_next', + [''] = 'move_selection_previous', + [''] = 'close', + }, + n = { + ['q'] = 'close', + }, + }, + }, + }) + end, } --- vim: ts=2 sts=2 sw=2 et