From d186f510e3a09f775a091292521f5aec159f42b7 Mon Sep 17 00:00:00 2001 From: Ray Andrew Date: Thu, 20 Nov 2025 01:26:50 -0600 Subject: [PATCH] fix regression quickfix compilation mode --- home/neovim/config/init.lua | 69 ++++++++++++++------ home/neovim/config/lua/compile-mode.lua | 84 +++++++++++++------------ 2 files changed, 93 insertions(+), 60 deletions(-) diff --git a/home/neovim/config/init.lua b/home/neovim/config/init.lua index bdd3034..7f71656 100644 --- a/home/neovim/config/init.lua +++ b/home/neovim/config/init.lua @@ -25,13 +25,7 @@ local path_package = vim.fn.stdpath 'data' .. '/site/' local mini_path = path_package .. 'pack/deps/start/mini.nvim' if not vim.uv.fs_stat(mini_path) then vim.cmd 'echo "Installing mini.nvim" | redraw' - vim.fn.system { - 'git', - 'clone', - '--filter=blob:none', - 'https://github.com/echasnovski/mini.nvim', - mini_path, - } + vim.fn.system { 'git', 'clone', '--filter=blob:none', 'https://github.com/echasnovski/mini.nvim', mini_path } vim.cmd 'packadd mini.nvim | helptags ALL' end @@ -53,12 +47,12 @@ add 'NeogitOrg/neogit' add 'nvim-lua/plenary.nvim' add 'sindrets/diffview.nvim' add 'folke/which-key.nvim' -add { - source = 'saghen/blink.cmp', - checkout = 'v1.8.0', -} +add { source = 'saghen/blink.cmp', checkout = 'v1.8.0' } add 'stevearc/conform.nvim' add 'coder/claudecode.nvim' +add 'mbbill/undotree' +add 'cbochs/grapple.nvim' +add 'fang2hou/blink-copilot' now(function() require('mini.icons').setup { @@ -171,10 +165,26 @@ later(function() require('fyler').setup { views = { + ---@diagnostic disable finder = { confirm_simple = true, close_on_select = false, + watcher = { + enabled = true, + }, + win = { + kind = 'replace', + kinds = { + split_left_most = { + width = '10%', + win_opts = { + winfixwidth = true, + }, + }, + }, + }, }, + ---@diagnostic enable }, } @@ -183,12 +193,7 @@ later(function() on_directory_enter = function(dir) require('oil').open(dir) end, } - require('compile-mode').setup { - -- split_mode = "vertical-right", - on_exit = function(qf_list, _) - if #qf_list > 0 then require('quicker').open { focus = false } end - end, - } + require('compile-mode').setup {} require('neogit').setup { integrations = { @@ -213,6 +218,11 @@ later(function() } require('claudecode').setup {} + + require('grapple').setup { + scope = 'git_branch', + icons = false, + } end) later(function() @@ -271,7 +281,14 @@ later(function() nerd_font_variant = 'mono', }, sources = { - default = { 'lsp', 'path', 'buffer' }, + default = { 'lsp', 'path', 'snippets', 'buffer', 'copilot' }, + providers = { + copilot = { + name = 'copilot', + module = 'blink-copilot', + async = true, + }, + }, }, completion = { menu = { @@ -321,6 +338,7 @@ later(function() 'pyright', -- Python 'rust_analyzer', -- Rust 'clangd', -- C/C++ + 'copilot', }, automatic_installation = true, } @@ -450,7 +468,7 @@ later(function() } -- Enable language servers - vim.lsp.enable { 'lua_ls', 'ts_ls', 'pyright', 'rust_analyzer', 'clangd' } + vim.lsp.enable { 'lua_ls', 'ts_ls', 'pyright', 'rust_analyzer', 'clangd', 'copilot' } end) local map = function(mode, lhs, rhs, opts) @@ -481,6 +499,19 @@ map('n', 'ch', 'checkhealth', 'Check health') map('n', 'cf', 'Format', 'Format buffer') map('n', 'gg', function() require('neogit').open() end, 'Open Neogit') +map('n', 'ut', 'UndotreeToggle', 'Toggle undotree') + +-- Grapple keymaps (harpoon-style) +map('n', 'ma', 'Grapple toggle', 'Grapple toggle tag') +map('n', 'mm', 'Grapple toggle_tags', 'Grapple tags menu') +map('n', 'm1', 'Grapple select index=1', 'Grapple select 1') +map('n', 'm2', 'Grapple select index=2', 'Grapple select 2') +map('n', 'm3', 'Grapple select index=3', 'Grapple select 3') +map('n', 'm4', 'Grapple select index=4', 'Grapple select 4') +map('n', 'mn', 'Grapple cycle_tags next', 'Grapple next tag') +map('n', 'mp', 'Grapple cycle_tags prev', 'Grapple prev tag') +map('n', 'mga', 'Grapple toggle scope=global', 'Grapple add global tag') +map('n', 'mgm', 'Grapple toggle_tags scope=global', 'Grapple global tags menu') -- Claude Code keymaps map('n', 'ac', 'ClaudeCode', 'Toggle Claude') diff --git a/home/neovim/config/lua/compile-mode.lua b/home/neovim/config/lua/compile-mode.lua index 2ee1e95..eab8742 100644 --- a/home/neovim/config/lua/compile-mode.lua +++ b/home/neovim/config/lua/compile-mode.lua @@ -34,7 +34,9 @@ local MAX_HISTORY_SIZE = 200 local config = { on_success = nil, on_error = nil, - on_exit = nil, + on_exit = function(qf_list, _) + if #qf_list > 0 then vim.cmd 'copen' end + end, buffer_keymaps = { close = 'q', recompile = 'g', @@ -282,41 +284,6 @@ local function run_compile(cmd) valid_entries = vim.tbl_filter(function(item) return item.valid == 1 end, qf_list) vim.b[bufnr].line_to_qf = line_to_qf - - vim.schedule(function() - for _, buf in ipairs(vim.api.nvim_list_bufs()) do - if vim.api.nvim_buf_is_valid(buf) and vim.bo[buf].buftype == 'quickfix' then - local function qf_jump() - local line = vim.api.nvim_win_get_cursor(0)[1] - local qf_entries = vim.fn.getqflist() - - if line <= #qf_entries then - local entry = qf_entries[line] - - if entry.valid == 1 and entry.bufnr > 0 then - vim.cmd('cc ' .. line) - else - for i = line - 1, 1, -1 do - if qf_entries[i].valid == 1 and qf_entries[i].bufnr > 0 then - vim.cmd('cc ' .. i) - return - end - end - for i = line + 1, #qf_entries do - if qf_entries[i].valid == 1 and qf_entries[i].bufnr > 0 then - vim.cmd('cc ' .. i) - return - end - end - end - end - end - - vim.keymap.set('n', '', qf_jump, { buffer = buf, desc = 'Jump to error location' }) - vim.keymap.set('n', '<2-LeftMouse>', qf_jump, { buffer = buf, desc = 'Jump to error location' }) - end - end - end) end vim.schedule(function() @@ -776,9 +743,7 @@ function M.compile() if config.input_keymaps.history_prev then vim.keymap.set('i', config.input_keymaps.history_prev, function() if #command_history > 0 then - if history_index == 0 then - saved_input = get_input() - end + if history_index == 0 then saved_input = get_input() end if history_index < #command_history then history_index = history_index + 1 current_input = command_history[#command_history - history_index + 1] @@ -824,7 +789,8 @@ function M.compile() -- Close compile prompt ---@type string[] - local close_keys = type(config.input_keymaps.close) == 'table' and config.input_keymaps.close --[[@as string[] ]] or { config.input_keymaps.close } + local close_keys = type(config.input_keymaps.close) == 'table' and config.input_keymaps.close --[[@as string[] ]] + or { config.input_keymaps.close } for _, key in ipairs(close_keys) do if key then vim.keymap.set({ 'i', 'n' }, key, function() vim.schedule(close) end, opts) end end @@ -883,7 +849,9 @@ function M.setup(opts) vim.api.nvim_create_autocmd('FileType', { pattern = 'compilation', callback = function() - if config.buffer_keymaps.close then vim.keymap.set('n', config.buffer_keymaps.close, 'close', { buffer = true, desc = 'Close compilation buffer' }) end + if config.buffer_keymaps.close then + vim.keymap.set('n', config.buffer_keymaps.close, 'close', { buffer = true, desc = 'Close compilation buffer' }) + end if config.buffer_keymaps.recompile then vim.keymap.set('n', config.buffer_keymaps.recompile, M.recompile, { buffer = true, desc = 'Recompile' }) end local function jump_to_error() @@ -946,6 +914,40 @@ function M.setup(opts) vim.keymap.set('n', '<2-LeftMouse>', jump_to_error, { buffer = true, desc = 'Jump to error location' }) end, }) + + vim.api.nvim_create_autocmd('FileType', { + pattern = 'qf', + callback = function() + local function qf_jump() + local line = vim.api.nvim_win_get_cursor(0)[1] + local qf_entries = vim.fn.getqflist() + + if line <= #qf_entries then + local entry = qf_entries[line] + + if entry.valid == 1 and entry.bufnr > 0 then + vim.cmd('cc ' .. line) + else + for i = line - 1, 1, -1 do + if qf_entries[i].valid == 1 and qf_entries[i].bufnr > 0 then + vim.cmd('cc ' .. i) + return + end + end + for i = line + 1, #qf_entries do + if qf_entries[i].valid == 1 and qf_entries[i].bufnr > 0 then + vim.cmd('cc ' .. i) + return + end + end + end + end + end + + vim.keymap.set('n', '', qf_jump, { buffer = true, desc = 'Jump to error location' }) + vim.keymap.set('n', '<2-LeftMouse>', qf_jump, { buffer = true, desc = 'Jump to error location' }) + end, + }) end return M