diff --git a/content/posts/2026-01-09-vim.md b/content/posts/2026-01-09-vim.md index cd3cea74e29d24aa6399a8b1642072e802489563..74e0b159b7d12feb11d9aa69e60e8027befbd421 100644 --- a/content/posts/2026-01-09-vim.md +++ b/content/posts/2026-01-09-vim.md @@ -126,8 +126,8 @@ let g:termdebug_config['variables_window'] = v:true nnoremap x :call LocalRun() nnoremap c :call LocalMake() -nnoremap v :call LocalDebugMain() -nnoremap b :call LocalDebugLine() +nnoremap m :call LocalDebugMain() +nnoremap l :call LocalDebugLine() function! LocalRun() abort let envs = join( map(items(g:_envs), { _, kv -> kv[0] . '=' . kv[1] }), ' ') @@ -159,8 +159,11 @@ call TermDebugSendCommand('run') endfunction function! LocalMake() abort - let envs = join( map(items(g:_envs), { _, kv -> kv[0] . '=' . kv[1] }), ' ') - execute printf('silent !env %s %s', g:_make, envs) + for [k, v] in items(g:_envs) + execute printf("let $%s = %s", k, string(v)) + endfor + + silent make " Filter non valid errors out of quicklist. let qfl = getqflist() @@ -168,25 +171,20 @@ let filtered = filter(copy(qfl), {_, entry -> entry.valid == 1}) call setqflist(filtered, 'r') redraw! - - if len(filtered) > 0 - execute exists(':CtrlPQuickfix') ? 'CtrlPQuickfix' : 'copen' - else - cclose - endif + execute len(filtered) > 0 ? 'copen' : 'cclose' endfunction ``` -I am using the CtrlP plugin, so I also use it for displaying the Quickfix List. -But if the plugin is not found; it will default to native quicklist with -`:copen`. +> **Note**: If any errors are found during the compilation mode the Quickfix +> list will be populated and opened. You could CtrlP Quickfix for this as well, +> I just want to stick to what Vim supports natively. Lets check these keybindings. - `Leader+x` - runs the binary in the terminal above and providing environment variables and argument - `Leader+c` - runs make and puts error in Quickfix List then opens with `:copen` -- `Leader+v` - launches DebugTerm/DBG debugger with all variables and breaks on main -- `Leader+b` - launches DebugTerm/DBG debugger with all variables and breaks on current line +- `Leader+m` - launches DebugTerm/DBG debugger with all variables and breaks on main +- `Leader+l` - launches DebugTerm/DBG debugger with all variables and breaks on current line This setup can get even more elaborate. Depending on your needs. This example works really well for projects using C, but anything goes here.