2023-04-30 12:56:57 -04:00
|
|
|
set tabstop=4 shiftwidth=4 noexpandtab ai nosmd ignorecase smartcase
|
|
|
|
|
|
|
|
" sign column on top of the line number (gutter for things like breakpoints, warnings)
|
|
|
|
set scl=number
|
|
|
|
|
|
|
|
" enable line numbers
|
|
|
|
set number relativenumber
|
|
|
|
|
|
|
|
" disable bottom right status line
|
|
|
|
set noruler
|
2023-03-19 13:10:16 -04:00
|
|
|
set showtabline=0
|
2023-04-30 12:56:57 -04:00
|
|
|
|
|
|
|
" performance?
|
2022-07-04 21:39:27 -04:00
|
|
|
set lazyredraw nocursorline ttyfast
|
2023-04-30 12:56:57 -04:00
|
|
|
|
|
|
|
" use system clipboard instead of internal
|
2023-04-11 18:06:02 -04:00
|
|
|
set clipboard=unnamedplus
|
2023-05-03 21:21:59 -04:00
|
|
|
" when using c or s, do not overwrite clipboard
|
2023-04-30 12:56:57 -04:00
|
|
|
nnoremap c "-c
|
2023-05-03 21:21:59 -04:00
|
|
|
nnoremap s "-s
|
2021-06-19 15:50:50 -04:00
|
|
|
|
2023-03-19 12:55:08 -04:00
|
|
|
let mapleader = ","
|
2022-12-10 11:45:48 -05:00
|
|
|
|
|
|
|
set shell=/bin/sh
|
|
|
|
|
2021-07-26 09:32:48 -04:00
|
|
|
hi Search cterm=NONE ctermfg=white ctermbg=blue
|
2021-08-24 21:36:54 -04:00
|
|
|
hi StatusLine ctermbg=NONE cterm=italic
|
2023-04-12 18:19:11 -04:00
|
|
|
hi SignColumn ctermbg=NONE
|
|
|
|
|
2021-08-24 21:36:54 -04:00
|
|
|
|
|
|
|
autocmd InsertEnter * hi StatusLine cterm=bold
|
|
|
|
autocmd InsertLeave * hi StatusLine cterm=italic
|
2021-07-26 09:32:48 -04:00
|
|
|
|
2021-06-19 15:50:50 -04:00
|
|
|
highlight LineNr ctermfg=grey
|
2022-06-01 20:02:57 -04:00
|
|
|
|
2022-07-01 18:18:55 -04:00
|
|
|
" Disable highlighting when searching
|
2022-07-05 17:28:32 -04:00
|
|
|
nnoremap <silent> <esc> :noh<return><esc>
|
2022-06-28 21:14:41 -04:00
|
|
|
|
2023-05-03 21:21:59 -04:00
|
|
|
" see :help digraphs
|
|
|
|
" these digraphs are reminiscent of canadian french keyboard layout
|
|
|
|
call digraph_setlist([
|
|
|
|
\["'a", 'à'],
|
|
|
|
\["'e", 'è'],
|
|
|
|
\["'u", 'ù'],
|
|
|
|
\["/e", 'é'],
|
|
|
|
\["}a", 'ä'],
|
|
|
|
\["}e", 'ë'],
|
|
|
|
\["}i", 'ï'],
|
|
|
|
\["}o", 'ö'],
|
|
|
|
\["}u", 'ü'],
|
|
|
|
\["}y", 'ÿ'],
|
|
|
|
\["]c", 'ç'],
|
|
|
|
\["[a", 'â'],
|
|
|
|
\["[e", 'ê'],
|
|
|
|
\["[i", 'î'],
|
|
|
|
\["[o", 'ô'],
|
|
|
|
\["[u", 'û'],
|
|
|
|
\])
|
|
|
|
|
|
|
|
" misc funny digraphs
|
|
|
|
call digraph_setlist([
|
|
|
|
\["++", '✝'],
|
|
|
|
\["+-", '†'],
|
|
|
|
\])
|
2022-07-01 18:18:55 -04:00
|
|
|
|
|
|
|
" NetRW
|
|
|
|
|
2022-06-28 21:14:41 -04:00
|
|
|
set splitbelow splitright
|
|
|
|
|
|
|
|
let g:netrw_banner = 0
|
|
|
|
let g:netrw_liststyle = 3
|
|
|
|
let g:netrw_browse_split = 4
|
|
|
|
let g:netrw_altv = 1
|
|
|
|
let g:netrw_winsize = 20
|
|
|
|
|
|
|
|
function! OpenNetRW()
|
2022-06-28 21:46:11 -04:00
|
|
|
Vexplore
|
2022-06-28 21:14:41 -04:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
aug netrw_close
|
|
|
|
au!
|
|
|
|
au WinEnter * if winnr('$') == 1 && getbufvar(winbufnr(winnr()), "&filetype") == "netrw"|q|endif
|
|
|
|
aug END
|
2022-06-28 21:46:11 -04:00
|
|
|
|
2022-07-01 18:18:55 -04:00
|
|
|
nnoremap - :call OpenNetRW()<cr>
|
|
|
|
|
|
|
|
|
|
|
|
" gdb integration
|
|
|
|
|
|
|
|
let g:termdebug_popup = 0
|
2023-03-19 12:55:08 -04:00
|
|
|
let g:termdebug_wide = 50
|
2022-07-01 18:18:55 -04:00
|
|
|
|
2022-08-01 16:08:28 -04:00
|
|
|
" Enter insert mode automatically in terminal windows
|
|
|
|
"au BufEnter term://* startinsert
|
|
|
|
|
2022-07-01 18:18:55 -04:00
|
|
|
au BufEnter *.c,*.cpp,*.h,*.hpp packadd termdebug
|
2023-03-19 13:10:16 -04:00
|
|
|
au TermOpen * setlocal nonumber norelativenumber
|
2022-07-01 18:18:55 -04:00
|
|
|
|
2022-07-16 18:56:03 -04:00
|
|
|
tnoremap <silent> <esc> <c-\><c-n><c-\><c-n>
|
2023-03-19 12:55:08 -04:00
|
|
|
" start debugger
|
|
|
|
nnoremap <silent> <leader>dd :execute "Termdebug" $HOME .. "/.cache/termdebug/" .. expand("%:r")<cr>:Source<cr>
|
2023-04-11 19:43:21 -04:00
|
|
|
|
2023-03-19 12:55:08 -04:00
|
|
|
" compile
|
2023-04-11 18:06:02 -04:00
|
|
|
function Compile()
|
|
|
|
if exists(":Source")
|
|
|
|
Source
|
|
|
|
endif
|
2023-04-18 20:07:49 -04:00
|
|
|
w
|
2023-04-11 18:06:02 -04:00
|
|
|
execute "make ~/.cache/termdebug/" .. expand("%:r") .. " -f ~/.config/nvim/makefile"
|
|
|
|
endfunction
|
|
|
|
nnoremap <silent> <leader>dc :call Compile()<cr>
|
2023-04-11 19:43:21 -04:00
|
|
|
|
|
|
|
" write clipboard into input file
|
|
|
|
function WriteInput()
|
|
|
|
let inputfile=$HOME .. "/.cache/termdebug/input/" .. expand("%:r")
|
|
|
|
echo "Written input to '" .. inputfile .. "'."
|
|
|
|
call writefile(getreg('+', 1, 1), inputfile)
|
|
|
|
endfunction
|
|
|
|
nnoremap <silent> <leader>rw :call WriteInput()<cr>
|
|
|
|
|
|
|
|
" start from input file
|
|
|
|
function RunInput()
|
|
|
|
Stop
|
|
|
|
Run
|
|
|
|
Source
|
|
|
|
let inputfile=$HOME .. "/.cache/termdebug/input/" .. expand("%:r")
|
|
|
|
let @x = join(readfile(inputfile), "\n") .. "\n\n"
|
|
|
|
Program
|
|
|
|
normal G"xp
|
2023-05-06 11:30:35 -04:00
|
|
|
Source
|
2023-04-11 19:43:21 -04:00
|
|
|
endfunction
|
|
|
|
nnoremap <silent> <leader>ri :call RunInput()<cr>
|
|
|
|
|
2023-03-19 12:55:08 -04:00
|
|
|
" start, stop, continue forwards
|
|
|
|
nnoremap <silent> <leader>rs :Run<cr>
|
|
|
|
nnoremap <silent> <leader>rr :Stop<cr>
|
|
|
|
nnoremap <silent> <leader>rf :Continue<cr>
|
|
|
|
" clear, add breakpoints
|
|
|
|
nnoremap <silent> <leader>dsc :Clear<cr>
|
|
|
|
nnoremap <silent> <leader>dsf :Break<cr>
|
2022-07-09 18:57:36 -04:00
|
|
|
|
2022-08-01 16:08:28 -04:00
|
|
|
nnoremap <silent> <C-h> :vertical resize -5<cr>
|
|
|
|
nnoremap <silent> <C-l> :vertical resize +5<cr>
|
2022-07-05 17:28:32 -04:00
|
|
|
nnoremap <silent> <c-p> :Step<cr>
|
2022-07-09 18:57:36 -04:00
|
|
|
nnoremap <silent> <c-n> :Over<cr>
|
|
|
|
|
2023-03-19 12:55:08 -04:00
|
|
|
" quickfix window (after running make)
|
|
|
|
nnoremap <silent> <leader>dqf :tab cope<cr>
|
|
|
|
nnoremap <silent> <leader>df :tabNext<cr>
|
|
|
|
|
2022-07-09 18:57:36 -04:00
|
|
|
vnoremap <silent> K :'<,'>Evaluate<cr>
|
2022-12-10 11:45:48 -05:00
|
|
|
|
2023-03-19 12:55:08 -04:00
|
|
|
" tab, window management
|
|
|
|
nnoremap <C-j> <C-w>w
|
|
|
|
nnoremap <C-k> <C-w>W
|
2023-04-11 19:43:21 -04:00
|
|
|
" exit all (akin to ZZ, ZQ)
|
|
|
|
nnoremap <silent> ZF :qa<cr>
|
2023-03-19 12:55:08 -04:00
|
|
|
|
2023-04-13 10:17:39 -04:00
|
|
|
" copy URL under cursor to clipboard bind
|
|
|
|
:nnoremap <silent><leader>uu :let @+ = expand('<cfile>')<CR>
|
|
|
|
|
2023-04-21 21:48:27 -04:00
|
|
|
" edit figure in Inkscape
|
|
|
|
function EditFig()
|
|
|
|
let figure_fname = expand('<cfile>')
|
|
|
|
exec "silent !typst-figure " .. figure_fname
|
2023-04-22 17:49:26 -04:00
|
|
|
vsp
|
|
|
|
exec "term inkscape-shortcut-manager"
|
|
|
|
quit
|
2023-04-21 21:48:27 -04:00
|
|
|
endfunc
|
|
|
|
|
|
|
|
:nnoremap <silent><leader>ff :call EditFig()<cr>
|
2023-04-22 17:49:26 -04:00
|
|
|
|
|
|
|
" compile typst doc on write
|
|
|
|
function TypstWatch()
|
|
|
|
vsp
|
|
|
|
vertical resize 50
|
|
|
|
exec 'terminal ' .. 'typst watch ' .. expand("%:t")
|
|
|
|
exec "norm \<c-w>h"
|
|
|
|
endfunc
|
|
|
|
:nnoremap <silent><leader>fc :call TypstWatch()<cr>
|
|
|
|
|
2022-12-10 11:45:48 -05:00
|
|
|
" Plugins
|
|
|
|
|
2023-01-12 18:18:34 -05:00
|
|
|
" Run PlugInstall if there are missing plugins
|
2023-04-13 10:17:39 -04:00
|
|
|
if $SYSTEM_PROFILE == "DEFAULT"
|
|
|
|
autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
|
|
|
|
\| PlugInstall --sync | source $MYVIMRC
|
|
|
|
\| endif
|
|
|
|
endif
|
2023-02-14 19:16:14 -05:00
|
|
|
|
2023-04-13 10:17:39 -04:00
|
|
|
" The rest will not be sourced if the system is on minimal settings.
|
|
|
|
if $SYSTEM_PROFILE == "MINIMAL"
|
|
|
|
finish
|
|
|
|
endif
|
2023-01-12 18:18:34 -05:00
|
|
|
|
2022-12-10 11:45:48 -05:00
|
|
|
call plug#begin()
|
|
|
|
|
|
|
|
filetype plugin indent on
|
|
|
|
|
2023-04-30 20:00:33 -04:00
|
|
|
" i don't use LaTeX anymore, but you can comment out && 0 to
|
|
|
|
if $SYSTEM_PROFILE == "DEFAULT" && 0
|
2023-04-13 10:17:39 -04:00
|
|
|
Plug 'lervag/vimtex'
|
|
|
|
let g:vimtex_view_method = 'zathura'
|
|
|
|
let g:vimtex_compiler_method = 'latexmk'
|
|
|
|
set conceallevel=0
|
|
|
|
let g:tex_conceal='abdmg'
|
|
|
|
let g:vimtex_view_forward_search_on_start=1
|
|
|
|
let g:vimtex_compiler_latexmk = {
|
|
|
|
\ 'build_dir' : $HOME.'/.cache/latexmk/',
|
|
|
|
\ 'callback' : 1,
|
|
|
|
\ 'continuous' : 1,
|
|
|
|
\ 'executable' : 'latexmk',
|
|
|
|
\ 'hooks' : [],
|
|
|
|
\ 'options' : [
|
|
|
|
\ '-verbose',
|
|
|
|
\ '-file-line-error',
|
|
|
|
\ '-synctex=1',
|
|
|
|
\ '-interaction=nonstopmode',
|
|
|
|
\ ],
|
|
|
|
\}
|
|
|
|
|
|
|
|
" spellcheck
|
|
|
|
au BufEnter *.tex set spell spelllang=en_ca
|
|
|
|
|
|
|
|
" Autowrite in tex files
|
|
|
|
" au TextChanged,TextChangedI *.tex silent write
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
if has('python3') && ($SYSTEM_PROFILE == "DEFAULT" || $SYSTEM_PROFILE == "SLIM")
|
2023-01-20 20:27:07 -05:00
|
|
|
Plug 'SirVer/ultisnips'
|
|
|
|
let g:UltiSnipsExpandTrigger="<c-m>"
|
|
|
|
let g:UltiSnipsJumpForwardTrigger="<c-m>"
|
|
|
|
let g:UltiSnipsJumpBackwardTrigger="<c-b>"
|
|
|
|
let g:UltiSnipsSnippetDirectories=[$HOME.'/.config/nvim/ultisnips/']
|
2023-04-13 10:17:39 -04:00
|
|
|
endif
|
2023-04-12 18:19:11 -04:00
|
|
|
|
2023-04-13 10:17:39 -04:00
|
|
|
if $SYSTEM_PROFILE == "DEFAULT"
|
2023-04-12 18:19:11 -04:00
|
|
|
Plug 'neovim/nvim-lspconfig'
|
|
|
|
Plug 'nvim-lua/lsp-status.nvim'
|
2023-04-12 18:49:17 -04:00
|
|
|
|
|
|
|
Plug 'hrsh7th/nvim-cmp'
|
|
|
|
Plug 'hrsh7th/cmp-nvim-lsp'
|
|
|
|
|
2023-04-12 18:19:11 -04:00
|
|
|
Plug 'stevearc/dressing.nvim'
|
2022-12-10 11:45:48 -05:00
|
|
|
|
2023-04-13 10:17:39 -04:00
|
|
|
Plug 'nvim-treesitter/nvim-treesitter'
|
|
|
|
" Code folding
|
|
|
|
set foldmethod=expr
|
|
|
|
set foldexpr=nvim_treesitter#foldexpr()
|
|
|
|
"autocmd BufEnter * normal zR
|
2023-04-30 19:56:33 -04:00
|
|
|
|
|
|
|
" typst filetype support
|
|
|
|
Plug 'kaarmu/typst.vim'
|
|
|
|
|
|
|
|
" project-wide searching
|
|
|
|
Plug 'mileszs/ack.vim'
|
|
|
|
" close quickfix list after pressing enter
|
|
|
|
let g:ack_autoclose = 1
|
|
|
|
" Ack! does not jump to first result
|
|
|
|
nnoremap <Leader>/ :Ack!<Space>
|
|
|
|
" use ripgrep
|
|
|
|
let g:ackprg = 'rg --vimgrep --smart-case'
|
2023-04-13 10:17:39 -04:00
|
|
|
endif
|
2023-01-21 21:46:35 -05:00
|
|
|
|
2023-04-09 12:23:12 -04:00
|
|
|
Plug 'axieax/urlview.nvim'
|
|
|
|
|
2023-04-12 18:19:11 -04:00
|
|
|
Plug 'ggandor/leap.nvim'
|
2023-04-12 11:20:21 -04:00
|
|
|
|
2022-12-10 11:45:48 -05:00
|
|
|
call plug#end()
|
2023-01-21 21:46:35 -05:00
|
|
|
|
2023-04-13 10:17:39 -04:00
|
|
|
if $SYSTEM_PROFILE == "DEFAULT"
|
|
|
|
" see .config/nvim/lua/init.lua
|
|
|
|
lua require('init')
|
|
|
|
endif
|