diff --git a/common/.config/nvim/after/ftplugin/rust.lua b/common/.config/nvim/after/ftplugin/rust.lua index bbac929..b250ec4 100644 --- a/common/.config/nvim/after/ftplugin/rust.lua +++ b/common/.config/nvim/after/ftplugin/rust.lua @@ -8,3 +8,23 @@ if pcall(require, "rustaceanvim") then vim.keymap.set("n", "rM", "RustLsp view mir", { desc = "View Mid-Level IR", buffer = bufnr }) vim.keymap.set("n", "rH", "RustLsp view hir", { desc = "View High-Level IR", buffer = bufnr }) end + +local function run_tests_with_coverage() + -- Run tests through neotest + require("neotest").run.run(vim.fn.expand("%")) + + -- Generate coverage after tests complete + vim.fn.jobstart("cargo llvm-cov --lcov --output-path coverage.lcov", { + on_exit = function(_, code) + if code == 0 then + -- Load coverage data + require("coverage").load(true) + print("Coverage updated") + else + print("Coverage generation failed") + end + end, + }) +end + +vim.keymap.set("n", "tc", run_tests_with_coverage, { desc = "Test: Run tests with coverage" }) diff --git a/common/.config/nvim/lua/core/lsp.lua b/common/.config/nvim/lua/core/lsp.lua index 6db1a15..27b361c 100644 --- a/common/.config/nvim/lua/core/lsp.lua +++ b/common/.config/nvim/lua/core/lsp.lua @@ -38,7 +38,7 @@ local to_installed = vim.tbl_keys({ -- Setup native diagnostic vim.diagnostic.config({ - underline = true, + underline = false, update_in_insert = false, severity_sort = true, float = { @@ -49,10 +49,10 @@ vim.diagnostic.config({ enabled = true, severity = { min = vim.diagnostic.severity.ERROR }, }, - virtual_lines = { - current_line = true, - severity = { min = vim.diagnostic.severity.INFO }, - }, + -- virtual_lines = { + -- current_line = true, + -- severity = { min = vim.diagnostic.severity.INFO }, + -- }, }) -- Change diagnostic symbols in the sign column (gutter) @@ -97,6 +97,16 @@ vim.api.nvim_create_autocmd("LspAttach", { map("ct", require("telescope.builtin").lsp_type_definitions, "Goto Type Definition") map("cd", require("telescope.builtin").diagnostics, "List Diagnostics") + Snacks.toggle({ + name = "Diagnostics Virtual Text", + get = function() + return vim.diagnostic.config().virtual_text ~= false + end, + set = function(state) + vim.diagnostic.config({ virtual_text = state }) + end, + }):map("dx") + -- Native lsp inline virtual text / inlay hints if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then vim.lsp.inlay_hint.enable(true) diff --git a/common/.config/nvim/lua/plugins/code-generic.lua b/common/.config/nvim/lua/plugins/code-generic.lua index 5c96bae..79e89b9 100644 --- a/common/.config/nvim/lua/plugins/code-generic.lua +++ b/common/.config/nvim/lua/plugins/code-generic.lua @@ -241,31 +241,7 @@ return { require("lazy.core.loader").add_to_rtp(plugin) require("nvim-treesitter.query_predicates") end, - dependencies = { - "nvim-treesitter/nvim-treesitter-textobjects", - config = function() - -- When in diff mode, we want to use the default - -- vim text objects c & C instead of the treesitter ones. - local move = require("nvim-treesitter.textobjects.move") ---@type table - local configs = require("nvim-treesitter.configs") - for name, fn in pairs(move) do - if name:find("goto") == 1 then - move[name] = function(q, ...) - if vim.wo.diff then - local config = configs.get_module("textobjects.move")[name] ---@type table - for key, query in pairs(config or {}) do - if q == query and key:find("[%]%[][cC]") then - vim.cmd("normal! " .. key) - return - end - end - end - return fn(q, ...) - end - end - end - end, - }, + dependencies = { "nvim-treesitter/nvim-treesitter-textobjects" }, config = function() -- See `:help nvim-treesitter` @@ -301,7 +277,7 @@ return { }, auto_install = true, - highlight = { enable = true }, + -- highlight = { enable = true }, indent = { enable = true }, incremental_selection = { @@ -339,18 +315,22 @@ return { goto_next_start = { ["]f"] = { query = "@function.outer", desc = "Goto next inner function start" }, ["]c"] = { query = "@class.outer", desc = "Goto next inner class start" }, + ["]o"] = { query = "@loop.*", desc = "Goto next loop start" }, }, goto_next_end = { ["]F"] = { query = "@function.outer", desc = "Goto next outer function end" }, ["]C"] = { query = "@class.outer", desc = "Goto next outer class end" }, + ["]O"] = { query = "@loop.*", desc = "Goto next loop end" }, }, goto_previous_start = { ["[f"] = { query = "@function.outer", desc = "Goto goto previous inner function start" }, ["[c"] = { query = "@class.outer", desc = "Previous inner class start" }, + ["[o"] = { query = "@loop.*", desc = "Goto previous loop start" }, }, goto_previous_end = { ["[F"] = { query = "@function.outer", desc = "Goto goto previous outer function start" }, ["[C"] = { query = "@class.outer", desc = "Goto previous outer class start" }, + ["[O"] = { query = "@loop.*", desc = "Goto previous loop start" }, }, }, diff --git a/common/.config/nvim/lua/plugins/code-testing.lua b/common/.config/nvim/lua/plugins/code-testing.lua index 6c467e0..50d188d 100644 --- a/common/.config/nvim/lua/plugins/code-testing.lua +++ b/common/.config/nvim/lua/plugins/code-testing.lua @@ -121,4 +121,30 @@ return { { "tS", function() require("neotest").summary.toggle() end, desc = "Test: Toggle Summary Panel" }, }, }, + + { + "andythigpen/nvim-coverage", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + require("coverage").setup({ + auto_load = true, + commands = true, -- Enable coverage commands + highlights = { + covered = { fg = "#C3E88D" }, -- Green for covered lines + uncovered = { fg = "#F07178" }, -- Red for uncovered lines + }, + signs = { + covered = { hl = "CoverageCovered", text = "▎" }, + uncovered = { hl = "CoverageUncovered", text = "▎" }, + }, + summary = { + min_coverage = 80.0, -- Minimum coverage percentage + }, + }) + + vim.keymap.set("n", "tC", function() + require("coverage").summary() + end, { desc = "Test: Toggle coverage" }) + end, + }, } diff --git a/common/.config/nvim/lua/plugins/completion.lua b/common/.config/nvim/lua/plugins/completion.lua index 28108ed..ea42290 100644 --- a/common/.config/nvim/lua/plugins/completion.lua +++ b/common/.config/nvim/lua/plugins/completion.lua @@ -55,10 +55,6 @@ return { border = "rounded", draw = { treesitter = { "lsp" } }, }, - documentation = { - auto_show = true, - auto_show_delay_ms = 100, - }, ghost_text = { enabled = false }, trigger = { show_on_trigger_character = true }, }, diff --git a/common/.config/nvim/lua/plugins/navigation.lua b/common/.config/nvim/lua/plugins/navigation.lua index c231a6d..e5771b6 100644 --- a/common/.config/nvim/lua/plugins/navigation.lua +++ b/common/.config/nvim/lua/plugins/navigation.lua @@ -6,6 +6,18 @@ return { }, }, + { + "unblevable/quick-scope", + init = function() + vim.g.qs_highlight_on_keys = { "f", "F", "t", "T" } + + vim.cmd([[ + highlight QuickScopePrimary guifg='#afff5f' gui=underline ctermfg=155 cterm=underline + highlight QuickScopeSecondary guifg='#00C7DF' gui=underline ctermfg=81 cterm=underline + ]]) + end, + }, + -- File Explorer: Neotree { "nvim-neo-tree/neo-tree.nvim", @@ -169,8 +181,7 @@ return { vim.keymap.set("n", "", require("telescope.builtin").live_grep, { desc = "Search/LiveGrep the Project" }) -- List - -- NOTE: Needs terminal configured to send correct key code to NeoVim: \x1b[80;5u - vim.keymap.set("n", "", require("telescope.builtin").find_files, { desc = "Search Files" }) + vim.keymap.set("n", "", require("telescope.builtin").find_files, { desc = "Search Files" }) -- Git vim.keymap.set("n", "gc", require("telescope.builtin").git_commits, { desc = "Git: Commits" })