diff --git a/init.lua b/init.lua index aca118b..7388f30 100644 --- a/init.lua +++ b/init.lua @@ -14,6 +14,27 @@ require 'lazy_init' require('helpers').edit_cf('v', '/init.lua') +--[[ +TODO: Neovim configurations I want to add: +- Clearer line numbers (weirdly not as simple as it sounds) +- Debugging keymap that works like PHPStorm +- Improve snippet expansion (an get rid of that stupid #endsection snippet) +- Better organising of buffers when opening side panels (like AI chat and test summary) +- Close test panel when opening debugger and vice versa using edgy +- Close terminal from inside terminal buffer +- Get shift key bindings working inside tmux +- Fix ctrl+shift+a keybinding for AI actions +- Get VectorCode working +- Add LSP symbols for Pest tests +- More prompts +- Give AI better context and tools for working with Hylark +- Figure out workspaces +- Figure out agentic workflow +- Figure out a better way to add relevant buffers to AI +- Figure out debug expressions +- Better keymaps for debug movements +]] + -- " Auto-Commands --- {{{ -- -- augroup modes diff --git a/lua/keymap.lua b/lua/keymap.lua index 8800f27..68356f8 100644 --- a/lua/keymap.lua +++ b/lua/keymap.lua @@ -138,8 +138,8 @@ vim.api.nvim_create_autocmd('FileType', { local models = { 'gpt-4.1', 'gemini-2.5-pro', 'gemini-2.0-flash-001', 'claude-3.7-sonnet-thought', 'o4-mini' } -- Loop through models and create keymaps for each for i, model in ipairs(models) do - vim.keymap.set('n', '', 'mzggj0WC' .. model .. '`z', { buffer = true, desc = 'Switch to ' .. model }) - vim.keymap.set('i', '', 'mzggj0WC' .. model .. '`za', { buffer = true, desc = 'Switch to ' .. model }) + vim.keymap.set('n', '', 'mzggj0W"_C' .. model .. '`z', { desc = 'Switch to ' .. model }) + vim.keymap.set('i', '', 'mzggj0W"_C' .. model .. '`za', { desc = 'Switch to ' .. model }) end end, }) @@ -189,8 +189,33 @@ local test_maps = { { keys = { '', 'td' }, action = function() - require('neotest').run.run_last { strategy = 'dap' } - require('neotest').summary.open() -- Note: Doesn't call open_test() like the others + local dap = require 'dap' + if dap.session() == nil then + dap.continue() + end + require('dapui').open() + local neotest = require 'neotest' + local bufnr = vim.api.nvim_get_current_buf() + local row = vim.api.nvim_win_get_cursor(0)[1] - 1 + + local adapters = neotest.state.adapter_ids() + local found = false + + for _, adapter_id in ipairs(adapters) do + local tree = neotest.state.positions(adapter_id, { buffer = bufnr }) + if tree then + local nearest = require('neotest.lib.positions').nearest(tree, row) + if nearest and nearest:data().type ~= 'file' then + neotest.run.run() + found = true + break + end + end + end + + if not found then + neotest.run.run_last() + end end, desc = 'Run last test with debugger', }, diff --git a/lua/plugins/debug.lua b/lua/plugins/debug.lua index 5a2bd54..4ff3046 100644 --- a/lua/plugins/debug.lua +++ b/lua/plugins/debug.lua @@ -161,15 +161,53 @@ return { } -- Change breakpoint icons - -- vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' }) - -- vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' }) - -- local breakpoint_icons = vim.g.have_nerd_font - -- and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' } - -- or { Breakpoint = '●', BreakpointCondition = '⊜', BreakpointRejected = '⊘', LogPoint = '◆', Stopped = '⭔' } - -- for type, icon in pairs(breakpoint_icons) do - -- local tp = 'Dap' .. type - -- local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak' - -- vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl }) + vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' }) + vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' }) + local breakpoint_icons = vim.g.have_nerd_font + and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' } + or { Breakpoint = '●', BreakpointCondition = '⊜', BreakpointRejected = '⊘', LogPoint = '◆', Stopped = '⭔' } + for type, icon in pairs(breakpoint_icons) do + local tp = 'Dap' .. type + local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak' + vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl }) + end + + local function get_php_ini_dir() + local handle = io.popen 'php --ini 2>/dev/null' + if not handle then + return nil + end + local result = handle:read '*a' + handle:close() + local dir = result:match 'Scan for additional .ini files in:%s+([^\n]+)' + if dir and dir:find '%(none%)' == nil then + return vim.trim(dir) + end + return nil + end + + local function enable_xdebug() + local ini_dir = get_php_ini_dir() + if not ini_dir then + return + end + os.execute(string.format('mv "%s/20-xdebug.ini.disabled" "%s/20-xdebug.ini" 2>/dev/null', ini_dir, ini_dir)) + end + + local function disable_xdebug() + local ini_dir = get_php_ini_dir() + if not ini_dir then + return + end + os.execute(string.format('mv "%s/20-xdebug.ini" "%s/20-xdebug.ini.disabled" 2>/dev/null', ini_dir, ini_dir)) + end + + dap.listeners.after.event_initialized['xdebug_enable'] = enable_xdebug + dap.listeners.before.event_terminated['xdebug_disable'] = disable_xdebug + dap.listeners.before.event_exited['xdebug_disable'] = disable_xdebug + + -- dap.listeners.after.event_output['neotest_display'] = function(_, body) + -- require('neotest').output.open { enter = true, last = true } -- end dap.listeners.after.event_initialized['dapui_config'] = dapui.open