adding harpoon and live grep args

adding:
- harpoon
- live grep args
- cpp debug
This commit is contained in:
Simon Ayoub 2024-11-06 22:09:52 +11:00
parent 2f9238d2d3
commit 4f7d45ed42
4 changed files with 72 additions and 21 deletions

View file

@ -361,9 +361,16 @@ require('lazy').setup({
end, end,
}, },
{ 'nvim-telescope/telescope-ui-select.nvim' }, { 'nvim-telescope/telescope-ui-select.nvim' },
{ 'ThePrimeagen/harpoon' },
-- Useful for getting pretty icons, but requires a Nerd Font. -- Useful for getting pretty icons, but requires a Nerd Font.
{ 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
{
'nvim-telescope/telescope-live-grep-args.nvim',
-- This will not install any breaking changes.
-- For major updates, this must be adjusted manually.
version = '^1.0.0',
},
}, },
config = function() config = function()
-- Telescope is a fuzzy finder that comes with a lot of different things that -- Telescope is a fuzzy finder that comes with a lot of different things that
@ -393,7 +400,7 @@ require('lazy').setup({
-- --
defaults = { defaults = {
mappings = { mappings = {
i = { ['<c-enter>'] = 'to_fuzzy_refine' }, i = { ['<C-enter>'] = 'to_fuzzy_refine' },
}, },
file_ignore_patterns = { file_ignore_patterns = {
'build/*', 'build/*',
@ -410,6 +417,7 @@ require('lazy').setup({
-- Enable Telescope extensions if they are installed -- Enable Telescope extensions if they are installed
pcall(require('telescope').load_extension, 'fzf') pcall(require('telescope').load_extension, 'fzf')
pcall(require('telescope').load_extension, 'ui-select') pcall(require('telescope').load_extension, 'ui-select')
pcall(require('telescope').load_extension, 'live_grep_args')
-- See `:help telescope.builtin` -- See `:help telescope.builtin`
local builtin = require 'telescope.builtin' local builtin = require 'telescope.builtin'
@ -418,7 +426,9 @@ require('lazy').setup({
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' }) vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) -- vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>sg', "<cmd>lua require('telescope').extensions.live_grep_args.live_grep_args()<CR>", { desc = 'Live Grep' })
vim.keymap.set('n', '<leader>sc', '<cmd>lua require("telescope.builtin").live_grep({ glob_pattern = "!{spec,test}"})<CR>', { desc = 'Live Grep Code' })
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' }) vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
@ -468,7 +478,16 @@ require('lazy').setup({
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',
dependencies = { dependencies = {
-- Automatically install LSPs and related tools to stdpath for Neovim -- Automatically install LSPs and related tools to stdpath for Neovim
{ 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants {
'williamboman/mason.nvim',
opts = {
ensure_installed = {
'clangd',
'codelldb',
},
},
config = true,
}, -- NOTE: Must be loaded before dependants
'williamboman/mason-lspconfig.nvim', 'williamboman/mason-lspconfig.nvim',
'WhoIsSethDaniel/mason-tool-installer.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim',
@ -703,22 +722,22 @@ require('lazy').setup({
opts = { opts = {
autoformat = true, autoformat = true,
notify_on_error = false, notify_on_error = false,
format_on_save = function(bufnr) -- format_on_save = function(bufnr)
-- Disable "format_on_save lsp_fallback" for languages that don't -- -- Disable "format_on_save lsp_fallback" for languages that don't
-- have a well standardized coding style. You can add additional -- -- have a well standardized coding style. You can add additional
-- languages here or re-enable it for the disabled ones. -- -- languages here or re-enable it for the disabled ones.
local disable_filetypes = { c = true, cpp = true } -- local disable_filetypes = { c = true, cpp = true }
local lsp_format_opt -- local lsp_format_opt
if disable_filetypes[vim.bo[bufnr].filetype] then -- if disable_filetypes[vim.bo[bufnr].filetype] then
lsp_format_opt = 'never' -- lsp_format_opt = 'never'
else -- else
lsp_format_opt = 'fallback' -- lsp_format_opt = 'fallback'
end -- end
return { -- return {
timeout_ms = 500, -- timeout_ms = 500,
lsp_format = lsp_format_opt, -- lsp_format = lsp_format_opt,
} -- }
end, -- end,
formatters_by_ft = { formatters_by_ft = {
lua = { 'stylua' }, lua = { 'stylua' },
cpp = { 'clang-format' }, cpp = { 'clang-format' },
@ -958,7 +977,7 @@ require('lazy').setup({
-- Here are some example plugins that I've included in the Kickstart repository. -- Here are some example plugins that I've included in the Kickstart repository.
-- Uncomment any of the lines below to enable them (you will need to restart nvim). -- Uncomment any of the lines below to enable them (you will need to restart nvim).
-- --
-- require 'kickstart.plugins.debug', require 'kickstart.plugins.debug',
require 'kickstart.plugins.indent_line', require 'kickstart.plugins.indent_line',
-- require 'kickstart.plugins.lint', -- require 'kickstart.plugins.lint',
require 'kickstart.plugins.autopairs', require 'kickstart.plugins.autopairs',

View file

@ -0,0 +1,8 @@
return {
{
'rmagatti/goto-preview',
event = 'BufEnter',
config = true, -- necessary as per https://github.com/rmagatti/goto-preview/issues/88
default_mappings = true,
},
}

View file

@ -0,0 +1,23 @@
return {
"ThePrimeagen/harpoon",
config = function()
local mark = require("harpoon.mark")
local ui = require("harpoon.ui")
vim.keymap.set("n", "<leader>a", mark.add_file, { desc = "Harpoon: Mark File" })
vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu, { desc = "Toggle Harpoon Menu" })
vim.keymap.set("n", "<C-t>", function()
ui.nav_file(1)
end, { desc = "Harpoon File 1" })
vim.keymap.set("n", "<C-s>", function()
ui.nav_file(2)
end, { desc = "Harpoon File 2" })
vim.keymap.set("n", "<C-b>", function()
ui.nav_file(3)
end, { desc = "Harpoon File 3" })
vim.keymap.set("n", "<C-g>", function()
ui.nav_file(4)
end, { desc = "Harpoon File 4" })
end,
}

View file

@ -63,7 +63,8 @@ return {
-- online, please don't ask me how to install them :) -- online, please don't ask me how to install them :)
ensure_installed = { ensure_installed = {
-- Update this to ensure that you have the debuggers for the langs you want -- Update this to ensure that you have the debuggers for the langs you want
'delve', -- 'delve',
'codelldb',
}, },
} }