From b2857e226c02261b117559a054563d5f474cce0b Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Thu, 24 Oct 2024 01:49:45 +0300 Subject: [PATCH] chore(nvim): telescope config tweaks --- config/nvim/lua/plugins/telescope.lua | 37 ++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/config/nvim/lua/plugins/telescope.lua b/config/nvim/lua/plugins/telescope.lua index ae79084..c69e727 100644 --- a/config/nvim/lua/plugins/telescope.lua +++ b/config/nvim/lua/plugins/telescope.lua @@ -14,6 +14,10 @@ return { -- https://github.com/polirritmico/telescope-lazy-plugins.nvim { 'polirritmico/telescope-lazy-plugins.nvim' }, + -- Neovim plugin. Telescope.nvim extension that adds LuaSnip integration. + -- https://github.com/benfowler/telescope-luasnip.nvim + { 'benfowler/telescope-luasnip.nvim' }, + -- Fuzzy Finder Algorithm which requires local dependencies to be built. -- Only load if `make` is available { @@ -21,6 +25,10 @@ return { build = 'make', cond = vim.fn.executable 'make' == 1, }, + + -- Import modules with ease + -- https://github.com/piersolenski/telescope-import.nvim + { 'piersolenski/telescope-import.nvim' }, }, config = function() local t = require 'telescope' @@ -51,6 +59,23 @@ return { -- Must be a valid path to the file containing the lazy spec and setup() call. lazy_config = vim.fn.stdpath 'config' .. '/init.lua', }, + import = { + -- Imports can be added at a specified line whilst keeping the cursor in place + insert_at_top = true, + -- Optionally support additional languages or modify existing languages... + custom_languages = { + { + -- The filetypes that ripgrep supports (find these via `rg --type-list`) + extensions = { 'js', 'ts' }, + -- The Vim filetypes + filetypes = { 'vue' }, + -- Optionally set a line other than 1 + insert_at_line = 2, ---@type function|number + -- The regex pattern for the import statement + regex = [[^(?:import(?:[\"'\s]*([\w*{}\n, ]+)from\s*)?[\"'\s](.*?)[\"'\s].*)]], + }, + }, + }, }, } @@ -58,6 +83,8 @@ return { pcall(t.load_extension, 'harpoon') pcall(t.load_extension, 'git_worktree') pcall(t.load_extension, 'lazy_plugins') + pcall(t.load_extension, 'luasnip') + pcall(t.load_extension, 'import') -- Enable telescope fzf native, if installed pcall(t.load_extension, 'fzf') @@ -67,10 +94,12 @@ return { -- See `:help telescope.keymap` vim.keymap.set('n', '/', function() -- You can pass additional configuration to telescope to change theme, layout, etc. - require('telescope.builtin').current_buffer_fuzzy_find(themes.get_dropdown { - winblend = 10, - previewer = true, - }) + require('telescope.builtin').current_buffer_fuzzy_find( + themes.get_dropdown { + winblend = 20, + previewer = true, + } + ) end, { desc = '[/] Fuzzily search in current buffer]' }) end, }