From 04756b7991a3cd0d1951f9545909dd2c27efab18 Mon Sep 17 00:00:00 2001 From: Karolis Arbaciauskas Date: Fri, 15 Nov 2024 22:27:57 +0200 Subject: [PATCH] Add telescope live grep args plugin --- init.lua | 5 ++- lua/custom/plugins/copilot.lua | 67 ++++++++++++++++++++++------- lua/custom/plugins/copilot_chat.lua | 51 ---------------------- 3 files changed, 56 insertions(+), 67 deletions(-) delete mode 100644 lua/custom/plugins/copilot_chat.lua diff --git a/init.lua b/init.lua index a0a58afd..a3caa2a5 100644 --- a/init.lua +++ b/init.lua @@ -357,6 +357,7 @@ require('lazy').setup({ -- Useful for getting pretty icons, but requires a Nerd Font. { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, + { 'nvim-telescope/telescope-live-grep-args.nvim' }, }, config = function() -- Telescope is a fuzzy finder that comes with a lot of different things that @@ -400,15 +401,17 @@ require('lazy').setup({ -- Enable Telescope extensions if they are installed pcall(require('telescope').load_extension, 'fzf') pcall(require('telescope').load_extension, 'ui-select') + pcall(require('telescope').load_extension, 'live_grep_args') -- See `:help telescope.builtin` + local telescope = require 'telescope' 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', 'sg', telescope.extensions.live_grep_args.live_grep_args, { 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)' }) diff --git a/lua/custom/plugins/copilot.lua b/lua/custom/plugins/copilot.lua index 845f133f..59747ee1 100644 --- a/lua/custom/plugins/copilot.lua +++ b/lua/custom/plugins/copilot.lua @@ -11,15 +11,63 @@ local on_attach = function(on_attach, name) end return { + { + 'CopilotC-Nvim/CopilotChat.nvim', + branch = 'canary', + dependencies = { + { 'zbirenbaum/copilot.lua' }, -- or github/copilot.vim + { 'nvim-lua/plenary.nvim' }, -- for curl, log wrapper + }, + build = 'make tiktoken', -- Only on MacOS or Linux + opts = { + debug = true, -- Enable debugging + context = 'buffer', + }, + keys = { + { + 'aa', + function() + local chat = require 'CopilotChat' + chat.toggle() + end, + desc = 'Copilot toggle chat', + }, + { + 'aq', + function() + local input = vim.fn.input 'Quick Chat: ' + if input ~= '' then + require('CopilotChat').ask(input, { selection = require('CopilotChat.select').buffer }) + end + end, + desc = 'Copilot quick chat', + }, + { + 'ax', + function() + local chat = require 'CopilotChat' + chat.reset() + end, + desc = 'Copilot chat reset', + }, + { + 'ap', + function() + local actions = require 'CopilotChat.actions' + require('CopilotChat.integrations.telescope').pick(actions.prompt_actions()) + end, + desc = 'Copilot chat prompt actions', + }, + }, + }, { 'zbirenbaum/copilot.lua', cmd = 'Copilot', - -- new - -- event = 'InsertEnter', + event = 'InsertEnter', build = ':Copilot auth', opts = { - suggestion = { enabled = false }, - panel = { enabled = false }, + -- suggestion = { enabled = false }, + -- panel = { enabled = false }, filetypes = { markdown = true, help = true, @@ -38,15 +86,4 @@ return { end, 'copilot') end, }, - { - 'olimorris/codecompanion.nvim', - dependencies = { - 'nvim-lua/plenary.nvim', - 'nvim-treesitter/nvim-treesitter', - 'hrsh7th/nvim-cmp', -- Optional: For using slash commands and variables in the chat buffer - 'nvim-telescope/telescope.nvim', -- Optional: For using slash commands - { 'stevearc/dressing.nvim', opts = {} }, -- Optional: Improves `vim.ui.select` - }, - config = true, - }, } diff --git a/lua/custom/plugins/copilot_chat.lua b/lua/custom/plugins/copilot_chat.lua deleted file mode 100644 index da009981..00000000 --- a/lua/custom/plugins/copilot_chat.lua +++ /dev/null @@ -1,51 +0,0 @@ -return { - { - 'CopilotC-Nvim/CopilotChat.nvim', - branch = 'canary', - dependencies = { - { 'zbirenbaum/copilot.lua' }, -- or github/copilot.vim - { 'nvim-lua/plenary.nvim' }, -- for curl, log wrapper - }, - build = 'make tiktoken', -- Only on MacOS or Linux - opts = { - debug = true, -- Enable debugging - context = 'buffer', - }, - keys = { - { - 'aa', - function() - local chat = require 'CopilotChat' - chat.toggle() - end, - desc = 'Copilot toggle chat', - }, - { - 'aq', - function() - local input = vim.fn.input 'Quick Chat: ' - if input ~= '' then - require('CopilotChat').ask(input, { selection = require('CopilotChat.select').buffer }) - end - end, - desc = 'Copilot quick chat', - }, - { - 'ax', - function() - local chat = require 'CopilotChat' - chat.reset() - end, - desc = 'Copilot chat reset', - }, - { - 'ap', - function() - local actions = require 'CopilotChat.actions' - require('CopilotChat.integrations.telescope').pick(actions.prompt_actions()) - end, - desc = 'Copilot chat prompt actions', - }, - }, - }, -}