From 57122d01c5329566cfb51121be9c2e12e370052e Mon Sep 17 00:00:00 2001 From: Lucas Garcia Rubio Date: Sat, 10 May 2025 19:29:17 -0300 Subject: [PATCH] feat: configure aider, vim-test, keymaps... --- .gitignore | 1 + after/compiler/maven.vim | 57 +++++++++++++++++++++ lazy-lock.json | 8 +-- lua/custom/plugins/neotest-maven.lua | 76 ++++++++++++++-------------- lua/custom/plugins/nvim-aider.lua | 46 +++++++++++++++++ lua/custom/plugins/vim-test.lua | 30 +++++++++++ 6 files changed, 177 insertions(+), 41 deletions(-) create mode 100644 after/compiler/maven.vim create mode 100644 lua/custom/plugins/nvim-aider.lua create mode 100644 lua/custom/plugins/vim-test.lua diff --git a/.gitignore b/.gitignore index 8a192cab..a83eb232 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ test.sh nvim spell/ +.aider* diff --git a/after/compiler/maven.vim b/after/compiler/maven.vim new file mode 100644 index 00000000..c7ac8c4e --- /dev/null +++ b/after/compiler/maven.vim @@ -0,0 +1,57 @@ +"if exists("current_compiler") +" finish +"endif +" + +let current_compiler = "maven" + +CompilerSet makeprg=mvn\ -B\ $* + +" The errorformat for recognize following errors +" 1. Error due to POM file +" 2. Compliation error +" 2.1. Ignore the lines after '[INFO] BUILD FAILURE' because the error message of +" compiler has been perceived before it. +" 3. Warning +" 4. Errors for unit test +" + +" Ignored message +CompilerSet errorformat= + \%-G[INFO]\ %.%#, + \%-G[WARNING]\ %.%#, + \%-G[debug]\ %.%#, + \%-GWARNING:\ %.%#, + \%-G%.%#on\ the\ class\ %.%#, + \%-G%.%#unless\ at\ least\ %.%#, + \%-G%.%#path\ is\ specified\ %.%#, + \%-G%.%#processing\ is\ enabled\ %.%#, + \%-G%.%#Use\ -Xlint%.%#, + \%-G%.%#Use\ -proc%.%#, + \%-G%\\d%\\+%.%#, + \%-G\\s%#, + \%-G\[ERROR]\ Failed\ to\ execute\ goal%.%#, + \%-G\[ERROR]\ Please\ refer\ to\ %.%#, + \%-G\[ERROR]\ ->\ \[Help\ 1]%.%#, + \%-G\[ERROR]\ To\ see\ the\ full\ stack\ trace%.%#, + \%-G\[ERROR]\ Re-run\ Maven\ using\ the\ -X\ switch%.%#, + \%-G\[ERROR]\ For\ more\ information\ about\ the\ errors%.%#, + \%-G\[ERROR]\ \[Help\ 1]\ http%.%#, + \%-G\[ERROR]\ + +" Error message for POM +CompilerSet errorformat+= + \[FATAL]\ Non-parseable\ POM\ %f:\ %m%\\s%\\+@%.%#line\ %l\\,\ column\ %c%.%#, + \[%tRROR]\ Malformed\ POM\ %f:\ %m%\\s%\\+@%.%#line\ %l\\,\ column\ %c%.%# + +" Error message for compiling +CompilerSet errorformat+= + \[%tARNING]\ %f:[%l\\,%c]\ %m, + \[%tRROR]\ %f:[%l\\,%c]\ %m + +" Message from JUnit 5(5.3.X), TestNG(6.14.X), JMockit(1.43), and AssertJ(3.11.X) +CompilerSet errorformat+= + \%+E%>[ERROR]\ %.%\\+Time\ elapsed:%.%\\+<<<\ FAILURE!, + \%+E%>[ERROR]\ %.%\\+Time\ elapsed:%.%\\+<<<\ ERROR!, + \%+Z%\\s%#at\ %f(%\\f%\\+:%l), + \%+C%.%# diff --git a/lazy-lock.json b/lazy-lock.json index a6be4cd1..d0ef0b7d 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -21,9 +21,8 @@ "mini.nvim": { "branch": "main", "commit": "e744b5dbb3158242af77124bd6763a8647ea82ed" }, "neo-tree.nvim": { "branch": "main", "commit": "9b5d67119c46e3262ffe1508fe6d8540b79ad75d" }, "neogit": { "branch": "master", "commit": "0542ca3aa9bf0b67b7b7713e4d230f9c1fc2c631" }, - "neotest": { "branch": "master", "commit": "dddbe8fe358b05b2b7e54fe4faab50563171a76d" }, - "neotest-maven": { "branch": "main", "commit": "3fc7b6743c4d9c659653150926838376190230c7" }, "nui.nvim": { "branch": "main", "commit": "8d3bce9764e627b62b07424e0df77f680d47ffdb" }, + "nvim-aider": { "branch": "main", "commit": "3d1d733a7a3cf726dc41d1c4f15df01d208c09e5" }, "nvim-autopairs": { "branch": "master", "commit": "2a406cdd8c373ae7fe378a9e062a5424472bd8d8" }, "nvim-cmp": { "branch": "main", "commit": "059e89495b3ec09395262f16b1ad441a38081d04" }, "nvim-dap": { "branch": "master", "commit": "7aade9e99bef5f0735cf966e715b3ce45515d786" }, @@ -37,6 +36,7 @@ "nvim-treesitter": { "branch": "master", "commit": "205faba1768a6e4c854f156bc6a21a41b242599c" }, "nvim-web-devicons": { "branch": "master", "commit": "481bdaa3dca70c5f1863e634db6afede8980488c" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, + "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, "springboot-nvim": { "branch": "main", "commit": "43567bc417c5767bd6d5eb8ff9f8ba8e98d6a9c2" }, "telescope-dap.nvim": { "branch": "master", "commit": "783366bd6c1e7fa0a5c59c07db37f49c805a28df" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, @@ -45,7 +45,9 @@ "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, - "vim-be-good": { "branch": "master", "commit": "0ae3de14eb8efc6effe7704b5e46495e91931cc5" }, + "vim-dispatch": { "branch": "master", "commit": "a2ff28abdb2d89725192db5b8562977d392a4d3f" }, + "vim-maven-plugin": { "branch": "master", "commit": "904c38d6e2643cab70c18c11da7e1b968b9e87ac" }, "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, + "vim-test": { "branch": "master", "commit": "b0c3e13249699a522c8b472ff79eff40d2935476" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } } diff --git a/lua/custom/plugins/neotest-maven.lua b/lua/custom/plugins/neotest-maven.lua index 74d501df..ac9e3c53 100644 --- a/lua/custom/plugins/neotest-maven.lua +++ b/lua/custom/plugins/neotest-maven.lua @@ -1,40 +1,40 @@ return { - { - 'lucas-garcia-rubio/neotest-maven', - -- dir = '~/Repositories/pessoal/plugins/neotest-maven', - name = 'neotest-maven', - ft = 'java', - dependencies = { - 'mfussenegger/nvim-jdtls', - 'mfussenegger/nvim-dap', -- for the debugger - 'rcarriga/nvim-dap-ui', -- recommended - 'theHamsta/nvim-dap-virtual-text', -- recommended - 'nvim-lua/plenary.nvim', - 'nvim-treesitter/nvim-treesitter', - }, - config = function() - local function neotest_output_and_switch() - require('neotest').output.open { enter = true } - end - - -- Set key mapping for the function - vim.keymap.set('n', 'lw', neotest_output_and_switch, { desc = 'Neotest output and enter its window' }) - end, - }, - { - 'nvim-neotest/neotest', - dependencies = { - 'neotest-maven', - 'nvim-neotest/nvim-nio', - 'nvim-lua/plenary.nvim', - 'nvim-treesitter/nvim-treesitter', - }, - init = function() - require('neotest').setup { - adapters = { - require 'neotest-maven', - }, - } - end, - }, + -- { + -- 'lucas-garcia-rubio/neotest-maven', + -- -- dir = '~/Repositories/pessoal/plugins/neotest-maven', + -- name = 'neotest-maven', + -- ft = 'java', + -- dependencies = { + -- 'mfussenegger/nvim-jdtls', + -- 'mfussenegger/nvim-dap', -- for the debugger + -- 'rcarriga/nvim-dap-ui', -- recommended + -- 'theHamsta/nvim-dap-virtual-text', -- recommended + -- 'nvim-lua/plenary.nvim', + -- 'nvim-treesitter/nvim-treesitter', + -- }, + -- config = function() + -- local function neotest_output_and_switch() + -- require('neotest').output.open { enter = true } + -- end + -- + -- -- Set key mapping for the function + -- vim.keymap.set('n', 'lw', neotest_output_and_switch, { desc = 'Neotest output and enter its window' }) + -- end, + -- }, + -- { + -- 'nvim-neotest/neotest', + -- dependencies = { + -- 'neotest-maven', + -- 'nvim-neotest/nvim-nio', + -- 'nvim-lua/plenary.nvim', + -- 'nvim-treesitter/nvim-treesitter', + -- }, + -- init = function() + -- require('neotest').setup { + -- adapters = { + -- require 'neotest-maven', + -- }, + -- } + -- end, + -- }, } diff --git a/lua/custom/plugins/nvim-aider.lua b/lua/custom/plugins/nvim-aider.lua new file mode 100644 index 00000000..6fa8a8de --- /dev/null +++ b/lua/custom/plugins/nvim-aider.lua @@ -0,0 +1,46 @@ +return { + { + 'GeorgesAlkhouri/nvim-aider', + cmd = 'Aider', + -- Example key mappings for common actions: + keys = { + { 'i/', 'Aider toggle', desc = 'Toggle Aider' }, + { 'is', 'Aider send', desc = 'Send to Aider', mode = { 'n', 'v' } }, + { 'ic', 'Aider command', desc = 'Aider Commands' }, + { 'ib', 'Aider buffer', desc = 'Send Buffer' }, + { 'i+', 'Aider add', desc = 'Add File' }, + { 'i-', 'Aider drop', desc = 'Drop File' }, + { 'ir', 'Aider add readonly', desc = 'Add Read-Only' }, + { 'iR', 'Aider reset', desc = 'Reset Session' }, + }, + dependencies = { + 'folke/snacks.nvim', + --- The below dependencies are optional + --- Neo-tree integration + { + 'nvim-neo-tree/neo-tree.nvim', + opts = function(_, opts) + -- Example mapping configuration (already set by default) + -- opts.window = { + -- mappings = { + -- ["+"] = { "nvim_aider_add", desc = "add to aider" }, + -- ["-"] = { "nvim_aider_drop", desc = "drop from aider" } + -- ["="] = { "nvim_aider_add_read_only", desc = "add read-only to aider" } + -- } + -- } + require('nvim_aider.neo_tree').setup(opts) + end, + }, + }, + config = true, + opts = { + auto_reload = true, + }, + init = function() + local wk = require 'which-key' + wk.add { + { 'i', group = 'A[i]der commands' }, + } + end, + }, +} diff --git a/lua/custom/plugins/vim-test.lua b/lua/custom/plugins/vim-test.lua new file mode 100644 index 00000000..50d1b4d4 --- /dev/null +++ b/lua/custom/plugins/vim-test.lua @@ -0,0 +1,30 @@ +return { + 'vim-test/vim-test', + dependencies = { + 'tpope/vim-dispatch', + 'mikelue/vim-maven-plugin', + }, + init = function() + vim.g['test#strategy'] = 'dispatch' + -- vim.g.test_echo_command = 1 -- Adicionado para mostrar o comando de teste + vim.g['test#java#maventest#options'] = '-B' + + vim.api.nvim_create_autocmd('FileType', { + pattern = { 'java' }, + callback = function() + vim.api.nvim_buf_set_keymap(0, 'n', 'ef', 'TestFile', { desc = 'Test entire file' }) + vim.api.nvim_buf_set_keymap(0, 'n', 'en', 'TestNearest', { desc = 'Test nearest method' }) + vim.api.nvim_buf_set_keymap(0, 'n', 'es', 'TestSuite', { desc = 'Test entire suite of tests' }) + vim.api.nvim_buf_set_keymap(0, 'n', 'edn', 'TestNearest -Dmaven.surefire.debug=true', { desc = 'Debug nearest method' }) + vim.api.nvim_buf_set_keymap(0, 'n', 'edf', 'TestFile -Dmaven.surefire.debug=true', { desc = 'Debug entire file' }) + vim.api.nvim_buf_set_keymap(0, 'n', 'eds', 'TestSuite -Dmaven.surefire.debug=true', { desc = 'Debug entire suite of tests' }) + end, + }) + + local wk = require 'which-key' + wk.add { + { 'e', group = 'T[e]sts' }, + { 'ed', group = '[D]ebug' }, + } + end, +}