From 35472c5be5640826398b90db493c9196825dfd67 Mon Sep 17 00:00:00 2001 From: Simon Ayoub Date: Mon, 17 Mar 2025 15:35:59 +1100 Subject: [PATCH] added trouble and neotest plugins added trouble and neotest plugins --- init.lua | 290 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 229 insertions(+), 61 deletions(-) diff --git a/init.lua b/init.lua index 637bf5f2..fff877e3 100644 --- a/init.lua +++ b/init.lua @@ -149,7 +149,7 @@ vim.opt.splitbelow = true -- See `:help 'list'` -- and `:help 'listchars'` vim.opt.list = true -vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } +vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣', eol = '↲'} -- Preview substitutions live, as you type! vim.opt.inccommand = 'split' @@ -340,7 +340,7 @@ require('lazy').setup({ -- -- Use the `dependencies` key to specify the dependencies of a particular plugin { - "folke/snacks.nvim", + 'folke/snacks.nvim', priority = 1000, lazy = false, ---@type snacks.Config @@ -361,49 +361,154 @@ require('lazy').setup({ styles = { notification = { -- wo = { wrap = true } -- Wrap notifications - } - } + }, + }, }, keys = { - { "z", function() Snacks.zen() end, desc = "Toggle Zen Mode" }, - { "Z", function() Snacks.zen.zoom() end, desc = "Toggle Zoom" }, - { ".", function() Snacks.scratch() end, desc = "Toggle Scratch Buffer" }, - { "S", function() Snacks.scratch.select() end, desc = "Select Scratch Buffer" }, - { "n", function() Snacks.notifier.show_history() end, desc = "Notification History" }, - { "bd", function() Snacks.bufdelete() end, desc = "Delete Buffer" }, - { "cR", function() Snacks.rename.rename_file() end, desc = "Rename File" }, - { "gB", function() Snacks.gitbrowse() end, desc = "Git Browse", mode = { "n", "v" } }, - { "gb", function() Snacks.git.blame_line() end, desc = "Git Blame Line" }, - { "gf", function() Snacks.lazygit.log_file() end, desc = "Lazygit Current File History" }, - { "gg", function() Snacks.lazygit() end, desc = "Lazygit" }, - { "gl", function() Snacks.lazygit.log() end, desc = "Lazygit Log (cwd)" }, - { "un", function() Snacks.notifier.hide() end, desc = "Dismiss All Notifications" }, - { "", function() Snacks.terminal() end, desc = "Toggle Terminal" }, - { "", function() Snacks.terminal() end, desc = "which_key_ignore" }, - { "]]", function() Snacks.words.jump(vim.v.count1) end, desc = "Next Reference", mode = { "n", "t" } }, - { "[[", function() Snacks.words.jump(-vim.v.count1) end, desc = "Prev Reference", mode = { "n", "t" } }, { - "N", - desc = "Neovim News", + 'z', function() - Snacks.win({ - file = vim.api.nvim_get_runtime_file("doc/news.txt", false)[1], + Snacks.zen() + end, + desc = 'Toggle Zen Mode', + }, + { + 'Z', + function() + Snacks.zen.zoom() + end, + desc = 'Toggle Zoom', + }, + { + '.', + function() + Snacks.scratch() + end, + desc = 'Toggle Scratch Buffer', + }, + { + 'S', + function() + Snacks.scratch.select() + end, + desc = 'Select Scratch Buffer', + }, + { + 'n', + function() + Snacks.notifier.show_history() + end, + desc = 'Notification History', + }, + { + 'bd', + function() + Snacks.bufdelete() + end, + desc = 'Delete Buffer', + }, + { + 'cR', + function() + Snacks.rename.rename_file() + end, + desc = 'Rename File', + }, + { + 'gB', + function() + Snacks.gitbrowse() + end, + desc = 'Git Browse', + mode = { 'n', 'v' }, + }, + { + 'gb', + function() + Snacks.git.blame_line() + end, + desc = 'Git Blame Line', + }, + { + 'gf', + function() + Snacks.lazygit.log_file() + end, + desc = 'Lazygit Current File History', + }, + { + 'gg', + function() + Snacks.lazygit() + end, + desc = 'Lazygit', + }, + { + 'gl', + function() + Snacks.lazygit.log() + end, + desc = 'Lazygit Log (cwd)', + }, + { + 'un', + function() + Snacks.notifier.hide() + end, + desc = 'Dismiss All Notifications', + }, + { + '', + function() + Snacks.terminal() + end, + desc = 'Toggle Terminal', + }, + { + '', + function() + Snacks.terminal() + end, + desc = 'which_key_ignore', + }, + { + ']]', + function() + Snacks.words.jump(vim.v.count1) + end, + desc = 'Next Reference', + mode = { 'n', 't' }, + }, + { + '[[', + function() + Snacks.words.jump(-vim.v.count1) + end, + desc = 'Prev Reference', + mode = { 'n', 't' }, + }, + { + 'N', + desc = 'Neovim News', + function() + Snacks.win { + file = vim.api.nvim_get_runtime_file('doc/news.txt', false)[1], width = 0.6, height = 0.6, wo = { spell = false, wrap = false, - signcolumn = "yes", - statuscolumn = " ", + signcolumn = 'yes', + statuscolumn = ' ', conceallevel = 3, }, - }) + } end, - } + }, }, init = function() - vim.api.nvim_create_autocmd("User", { - pattern = "VeryLazy", + vim.api.nvim_create_autocmd('User', { + pattern = 'VeryLazy', callback = function() -- Setup some globals for debugging (lazy-loaded) _G.dd = function(...) @@ -415,17 +520,17 @@ require('lazy').setup({ vim.print = _G.dd -- Override print to use snacks for `:=` command -- Create some toggle mappings - Snacks.toggle.option("spell", { name = "Spelling" }):map("us") - Snacks.toggle.option("wrap", { name = "Wrap" }):map("uw") - Snacks.toggle.option("relativenumber", { name = "Relative Number" }):map("uL") - Snacks.toggle.diagnostics():map("ud") - Snacks.toggle.line_number():map("ul") - Snacks.toggle.option("conceallevel", { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }):map("uc") - Snacks.toggle.treesitter():map("uT") - Snacks.toggle.option("background", { off = "light", on = "dark", name = "Dark Background" }):map("ub") - Snacks.toggle.inlay_hints():map("uh") - Snacks.toggle.indent():map("ug") - Snacks.toggle.dim():map("uD") + Snacks.toggle.option('spell', { name = 'Spelling' }):map 'us' + Snacks.toggle.option('wrap', { name = 'Wrap' }):map 'uw' + Snacks.toggle.option('relativenumber', { name = 'Relative Number' }):map 'uL' + Snacks.toggle.diagnostics():map 'ud' + Snacks.toggle.line_number():map 'ul' + Snacks.toggle.option('conceallevel', { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }):map 'uc' + Snacks.toggle.treesitter():map 'uT' + Snacks.toggle.option('background', { off = 'light', on = 'dark', name = 'Dark Background' }):map 'ub' + Snacks.toggle.inlay_hints():map 'uh' + Snacks.toggle.indent():map 'ug' + Snacks.toggle.dim():map 'uD' end, }) end, @@ -727,14 +832,14 @@ require('lazy').setup({ }) -- Change diagnostic symbols in the sign column (gutter) - -- if vim.g.have_nerd_font then - -- local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' } - -- local diagnostic_signs = {} - -- for type, icon in pairs(signs) do - -- diagnostic_signs[vim.diagnostic.severity[type]] = icon - -- end - -- vim.diagnostic.config { signs = { text = diagnostic_signs } } - -- end + if vim.g.have_nerd_font then + local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' } + local diagnostic_signs = {} + for type, icon in pairs(signs) do + diagnostic_signs[vim.diagnostic.severity[type]] = icon + end + vim.diagnostic.config { signs = { text = diagnostic_signs } } + end -- LSP servers and clients are able to communicate to each other what features they support. -- By default, Neovim doesn't support everything that is in the LSP specification. @@ -1082,18 +1187,82 @@ require('lazy').setup({ }, { 'mg979/vim-visual-multi', - -- See https://github.com/mg979/vim-visual-multi/issues/241 - init = function() - vim.g.VM_default_mappings = 0 - vim.g.VM_maps = { - ['Find Under'] = '' - } - vim.g.VM_add_cursor_at_pos_no_mappings = 1 - end, + -- See https://github.com/mg979/vim-visual-multi/issues/241 + init = function() + vim.g.VM_default_mappings = 0 + vim.g.VM_maps = { + ['Find Under'] = '', + } + vim.g.VM_add_cursor_at_pos_no_mappings = 1 + end, }, { 'wakatime/vim-wakatime', - lazy = false + lazy = false, + }, + { + 'nvim-neotest/neotest', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-neotest/nvim-nio', + 'nvim-lua/plenary.nvim', + 'antoinemadec/FixCursorHold.nvim', + 'nvim-treesitter/nvim-treesitter', + 'alfaix/neotest-gtest', + }, + config = function() + require('neotest').setup { + adapters = { + require('neotest-gtest').setup { + -- Add neotest-gtest specific configuration here if needed + -- For example, to specify the test runner: + -- runner = "path/to/your/gtest_runner", -- If not in your PATH + -- Or other options as described in the neotest-gtest documentation. + }, + }, + -- Add neotest general configuration here if needed + -- For example, to change the default behavior: + -- open_on_run = true, + -- ... other neotest options + } + end, + }, + { + "folke/trouble.nvim", + opts = {}, -- for default options, refer to the configuration section for custom setup. + cmd = "Trouble", + keys = { + { + "xx", + "Trouble diagnostics toggle", + desc = "Diagnostics (Trouble)", + }, + { + "xX", + "Trouble diagnostics toggle filter.buf=0", + desc = "Buffer Diagnostics (Trouble)", + }, + { + "cs", + "Trouble symbols toggle focus=false", + desc = "Symbols (Trouble)", + }, + { + "cl", + "Trouble lsp toggle focus=false win.position=right", + desc = "LSP Definitions / references / ... (Trouble)", + }, + { + "xL", + "Trouble loclist toggle", + desc = "Location List (Trouble)", + }, + { + "xQ", + "Trouble qflist toggle", + desc = "Quickfix List (Trouble)", + }, + }, }, -- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the -- init.lua. If you want these files, they are in the repository, so you can just download them and @@ -1117,8 +1286,7 @@ require('lazy').setup({ -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` { import = 'custom.plugins' }, -}, -{ +}, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the -- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table