From 4d7c7b7c9ebf9773a8f3420dc07dc852266ea9f2 Mon Sep 17 00:00:00 2001 From: Natercio Moniz Date: Tue, 26 Aug 2025 20:19:13 +0100 Subject: [PATCH] add a bunch of essential plugins --- lua/community.lua | 7 +++- lua/plugins/astrocore.lua | 81 +++++++++++++++++++++++++++---------- lua/plugins/astrolsp.lua | 31 ++++++++------ lua/plugins/astroui.lua | 1 + lua/plugins/claude-code.lua | 9 +++++ lua/plugins/neoscroll.lua | 47 --------------------- 6 files changed, 94 insertions(+), 82 deletions(-) create mode 100644 lua/plugins/claude-code.lua delete mode 100644 lua/plugins/neoscroll.lua diff --git a/lua/community.lua b/lua/community.lua index 7b39f83..e9e6603 100644 --- a/lua/community.lua +++ b/lua/community.lua @@ -8,6 +8,11 @@ return { { import = 'astrocommunity.colorscheme.tokyonight-nvim' }, - { import = 'astrocommunity.pack.lua' }, + { import = 'astrocommunity.editing-support.conform-nvim' }, + { import = 'astrocommunity.git.diffview-nvim' }, + { import = 'astrocommunity.pack.go' }, + { import = 'astrocommunity.pack.lua' }, + + { import = 'astrocommunity.test.neotest' }, } diff --git a/lua/plugins/astrocore.lua b/lua/plugins/astrocore.lua index 34cd06c..2704612 100644 --- a/lua/plugins/astrocore.lua +++ b/lua/plugins/astrocore.lua @@ -10,12 +10,12 @@ return { opts = { -- Configure core features of AstroNvim features = { - large_buf = { size = 1024 * 256, lines = 10000 }, -- set global limits for large files for disabling features like treesitter - autopairs = true, -- enable autopairs at start - cmp = true, -- enable completion at start + large_buf = { size = 1024 * 256, lines = 10000 }, -- set global limits for large files for disabling features like treesitter + autopairs = true, -- enable autopairs at start + cmp = true, -- enable completion at start diagnostics = { virtual_text = true, virtual_lines = false }, -- diagnostic settings on startup - highlighturl = true, -- highlight URLs at start - notifications = true, -- enable notifications at start + highlighturl = true, -- highlight URLs at start + notifications = true, -- enable notifications at start }, -- Diagnostics configuration (for vim.diagnostics.config({...})) when diagnostics are on diagnostics = { @@ -37,14 +37,14 @@ return { }, -- vim options can be configured here options = { - opt = { -- vim.opt. + opt = { -- vim.opt. relativenumber = true, -- sets vim.opt.relativenumber - number = true, -- sets vim.opt.number - spell = false, -- sets vim.opt.spell - signcolumn = 'yes', -- sets vim.opt.signcolumn to yes - wrap = false, -- sets vim.opt.wrap + number = true, -- sets vim.opt.number + spell = false, -- sets vim.opt.spell + signcolumn = 'yes', -- sets vim.opt.signcolumn to yes + wrap = false, -- sets vim.opt.wrap }, - g = { -- vim.g. + g = { -- vim.g. -- configure global vim variables (vim.g) -- NOTE: `mapleader` and `maplocalleader` must be set in the AstroNvim opts or before `lazy.setup` -- This can be found in the `lua/lazy_setup.lua` file @@ -83,14 +83,22 @@ return { ['xq'] = { function() - local qf_open = vim.tbl_isempty(vim.tbl_filter(function(win) - return win.quickfix == 1 - end, vim.fn.getwininfo())) + local win_id + for _, win in ipairs(vim.fn.getwininfo()) do + if win.quickfix == 1 then + win_id = win.winid + break + end + end - if qf_open then - vim.cmd.copen() + if win_id then + if vim.api.nvim_get_current_win() ~= win_id then + vim.api.nvim_set_current_win(win_id) + else + vim.cmd.cclose() + end else - vim.cmd.cclose() + vim.cmd.copen() end end, desc = 'Toggle Quickfix list', @@ -98,12 +106,20 @@ return { ['xl'] = { function() - local ll_open = vim.tbl_isempty(vim.tbl_filter(function(win) - return win.loclist == 1 - end, vim.fn.getwininfo())) + local win_id + for _, win in ipairs(vim.fn.getwininfo()) do + if win.loclist == 1 then + win_id = win.winid + break + end + end - if ll_open then - vim.cmd.lclose() + if win_id then + if vim.api.nvim_get_current_win() ~= win_id then + vim.api.nvim_set_current_win(win_id) + else + vim.cmd.lclose() + end else vim.cmd.lopen() end @@ -111,6 +127,27 @@ return { desc = 'Toggle Local list', }, + ['tr'] = { + function() + require('neotest').run.run() + end, + desc = 'Test: run nearest test', + }, + + ['td'] = { + function() + require('neotest').run.run { strategy = 'dap' } + end, + desc = 'Test: debug nearest test', + }, + + ['ta'] = { + function() + require('neotest').run.run(vim.fn.expand '%') + end, + desc = 'Test: run all test in file', + }, + -- tables with just a `desc` key will be registered with which-key if it's installed -- this is useful for naming menus -- ["b"] = { desc = "Buffers" }, diff --git a/lua/plugins/astrolsp.lua b/lua/plugins/astrolsp.lua index 0dc7cf5..2e07509 100644 --- a/lua/plugins/astrolsp.lua +++ b/lua/plugins/astrolsp.lua @@ -5,7 +5,7 @@ ---@type LazySpec return { - "AstroNvim/astrolsp", + 'AstroNvim/astrolsp', ---@type AstroLSPOpts opts = { -- Configuration table of features provided by AstroLSP @@ -61,16 +61,18 @@ return { -- can either be a string of a client capability or a function of `fun(client, bufnr): boolean` -- condition will be resolved for each client on each execution and if it ever fails for all clients, -- the auto commands will be deleted for that buffer - cond = "textDocument/codeLens", + cond = 'textDocument/codeLens', -- cond = function(client, bufnr) return client.name == "lua_ls" end, -- list of auto commands to set { -- events to trigger - event = { "InsertLeave", "BufEnter" }, + event = { 'InsertLeave', 'BufEnter' }, -- the rest of the autocmd options (:h nvim_create_autocmd) - desc = "Refresh codelens (buffer)", + desc = 'Refresh codelens (buffer)', callback = function(args) - if require("astrolsp").config.features.codelens then vim.lsp.codelens.refresh { bufnr = args.buf } end + if require('astrolsp').config.features.codelens then + vim.lsp.codelens.refresh { bufnr = args.buf } + end end, }, }, @@ -80,19 +82,24 @@ return { n = { -- a `cond` key can provided as the string of a server capability to be required to attach, or a function with `client` and `bufnr` parameters from the `on_attach` that returns a boolean gD = { - function() vim.lsp.buf.declaration() end, - desc = "Declaration of current symbol", - cond = "textDocument/declaration", + function() + vim.lsp.buf.declaration() + end, + desc = 'Declaration of current symbol', + cond = 'textDocument/declaration', }, - ["uY"] = { - function() require("astrolsp.toggles").buffer_semantic_tokens() end, - desc = "Toggle LSP semantic highlight (buffer)", + ['uY'] = { + function() + require('astrolsp.toggles').buffer_semantic_tokens() + end, + desc = 'Toggle LSP semantic highlight (buffer)', cond = function(client) - return client.supports_method "textDocument/semanticTokens/full" and vim.lsp.semantic_tokens ~= nil + return client.supports_method 'textDocument/semanticTokens/full' and vim.lsp.semantic_tokens ~= nil end, }, }, }, + -- A custom `on_attach` function to be run after the default `on_attach` function -- takes two parameters `client` and `bufnr` (`:h lspconfig-setup`) on_attach = function(client, bufnr) diff --git a/lua/plugins/astroui.lua b/lua/plugins/astroui.lua index 756cb5e..ad4b2d7 100644 --- a/lua/plugins/astroui.lua +++ b/lua/plugins/astroui.lua @@ -16,6 +16,7 @@ return { -- Normal = { bg = "#000000" }, }, }, + folding = false, -- Icons can be configured throughout the interface icons = { -- configure the loading of the lsp in the status line diff --git a/lua/plugins/claude-code.lua b/lua/plugins/claude-code.lua new file mode 100644 index 0000000..b08aae2 --- /dev/null +++ b/lua/plugins/claude-code.lua @@ -0,0 +1,9 @@ +return { + 'greggh/claude-code.nvim', + dependencies = { + 'nvim-lua/plenary.nvim', + }, + config = function() + require('claude-code').setup() + end, +} diff --git a/lua/plugins/neoscroll.lua b/lua/plugins/neoscroll.lua deleted file mode 100644 index ba5dbff..0000000 --- a/lua/plugins/neoscroll.lua +++ /dev/null @@ -1,47 +0,0 @@ -return { - 'karb94/neoscroll.nvim', - config = function() - local neoscroll = require 'neoscroll' - neoscroll.setup { - mappings = { - '', - '', - '', - '', - 'zt', - 'zz', - 'zb', - }, - easing = 'circ', - respect_scrolloff = true, - } - - local keymap = { - [''] = function() - neoscroll.ctrl_u { duration = 200 } - end, - [''] = function() - neoscroll.ctrl_d { duration = 200 } - end, - [''] = function() - neoscroll.ctrl_b { duration = 300 } - end, - [''] = function() - neoscroll.ctrl_f { duration = 300 } - end, - ['zt'] = function() - neoscroll.zt { half_win_duration = 100 } - end, - ['zz'] = function() - neoscroll.zz { half_win_duration = 100 } - end, - ['zb'] = function() - neoscroll.zb { half_win_duration = 100 } - end, - } - local modes = { 'n', 'v', 'x' } - for key, func in pairs(keymap) do - vim.keymap.set(modes, key, func) - end - end, -}