.clang-format
.clang-tidy
.gitignore
.vimrc
BrowserTab.cpp
BrowserTab.h
BrowserView.cpp
BrowserView.h
CMakeLists.txt
DatabaseManager.cpp
DatabaseManager.h
DownloadBar.cpp
DownloadBar.h
DownloadWidget.cpp
DownloadWidget.h
MainWindow.cpp
MainWindow.h
Makefile
MasterPasswordDialog.cpp
MasterPasswordDialog.h
PasswordHelper.cpp
PasswordHelper.h
README.md
ThemeConfig.h
VaultManager.cpp
VaultManager.h
browser.desktop
browser.qrc
compile_commands.json
main.cpp
.vimrc
raw
1let g:_executable = 'main'
2let g:_arguments = ''
3let g:_envs = {}
4let g:_make = 'make'
5
6set makeprg=make
7set errorformat=%f:%l:%c:\ %m
8packadd termdebug
9
10let g:termdebug_config = {}
11let g:termdebug_config['variables_window'] = v:true
12let g:ale_linters = { 'cpp': ['clangd', 'cppcheck'] }
13
14nnoremap <leader>x :call LocalRun()<CR>
15nnoremap <leader>c :call LocalMake()<CR>
16nnoremap <leader>m :call LocalDebugMain()<CR>
17nnoremap <leader>n :call LocalDebugLine()<CR>
18nnoremap <leader>z :call LocalBuildAndRun()<CR>
19
20function! LocalRun() abort
21 let envs = join( map(items(g:_envs), { _, kv -> kv[0] . '=' . kv[1] }), ' ')
22 execute printf("term env %s ./%s %s", envs, g:_executable, g:_arguments)
23endfunction
24
25function! LocalDebugMain() abort
26 execute printf('Termdebug %s %s', g:_executable, g:_arguments)
27
28 for [k, v] in items(g:_envs)
29 call TermDebugSendCommand(printf('set env %s %s', k, v))
30 endfor
31
32 call TermDebugSendCommand('directory ' . getcwd())
33 call TermDebugSendCommand('break main')
34 call TermDebugSendCommand('run')
35endfunction
36
37function! LocalDebugLine() abort
38 execute printf('Termdebug %s %s', g:_executable, g:_arguments)
39
40 for [k, v] in items(g:_envs)
41 call TermDebugSendCommand(printf('set env %s %s', k, v))
42 endfor
43
44 call TermDebugSendCommand('directory ' . getcwd())
45 call TermDebugSendCommand(printf('break %s:%d', expand('%:p'), line('.')))
46 call TermDebugSendCommand('run')
47endfunction
48
49function! LocalMake() abort
50 let envs = join( map(items(g:_envs), { _, kv -> kv[0] . '=' . kv[1] }), ' ')
51 execute printf('silent !env %s %s', g:_make, envs)
52
53 " Filter non valid errors out of quicklist.
54 let qfl = getqflist()
55 let filtered = filter(copy(qfl), {_, entry -> entry.valid == 1})
56 call setqflist(filtered, 'r')
57
58 redraw!
59
60 if len(filtered) > 0
61 execute exists(':CtrlPQuickfix') ? 'CtrlPQuickfix' : 'copen'
62 else
63 cclose
64 endif
65endfunction
66
67function! LocalBuildAndRun() abort
68 let envs = join(map(items(g:_envs), { _, kv -> kv[0] . '=' . kv[1] }), ' ')
69 let cmd = printf('env %s %s', envs, g:_make)
70 let result = system(cmd)
71 let status = v:shell_error
72
73 execute 'call LocalMake()'
74
75 if status == 0
76 call LocalRun()
77 else
78 echohl ErrorMsg | echo "Build failed (exit code " . status . ")" | echohl None
79 endif
80endfunction