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 set showtabline=0 " performance? set lazyredraw nocursorline ttyfast " use system clipboard instead of internal set clipboard=unnamedplus " when using c, do not overwrite clipboard nnoremap c "-c let mapleader = "," set shell=/bin/sh hi Search cterm=NONE ctermfg=white ctermbg=blue hi StatusLine ctermbg=NONE cterm=italic hi SignColumn ctermbg=NONE autocmd InsertEnter * hi StatusLine cterm=bold autocmd InsertLeave * hi StatusLine cterm=italic highlight LineNr ctermfg=grey " Disable highlighting when searching nnoremap :noh " NetRW 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() Vexplore endfunction aug netrw_close au! au WinEnter * if winnr('$') == 1 && getbufvar(winbufnr(winnr()), "&filetype") == "netrw"|q|endif aug END nnoremap - :call OpenNetRW() " gdb integration let g:termdebug_popup = 0 let g:termdebug_wide = 50 " Enter insert mode automatically in terminal windows "au BufEnter term://* startinsert au BufEnter *.c,*.cpp,*.h,*.hpp packadd termdebug au TermOpen * setlocal nonumber norelativenumber tnoremap " start debugger nnoremap dd :execute "Termdebug" $HOME .. "/.cache/termdebug/" .. expand("%:r"):Source " compile function Compile() if exists(":Source") Source endif w execute "make ~/.cache/termdebug/" .. expand("%:r") .. " -f ~/.config/nvim/makefile" endfunction nnoremap dc :call Compile() " 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 rw :call WriteInput() " 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 endfunction nnoremap ri :call RunInput() " start, stop, continue forwards nnoremap rs :Run nnoremap rr :Stop nnoremap rf :Continue " clear, add breakpoints nnoremap dsc :Clear nnoremap dsf :Break nnoremap :vertical resize -5 nnoremap :vertical resize +5 nnoremap :Step nnoremap :Over " quickfix window (after running make) nnoremap dqf :tab cope nnoremap df :tabNext vnoremap K :'<,'>Evaluate " tab, window management nnoremap w nnoremap W " exit all (akin to ZZ, ZQ) nnoremap ZF :qa " copy URL under cursor to clipboard bind :nnoremap uu :let @+ = expand('') " edit figure in Inkscape function EditFig() let figure_fname = expand('') exec "silent !typst-figure " .. figure_fname vsp exec "term inkscape-shortcut-manager" quit endfunc :nnoremap ff :call EditFig() " compile typst doc on write function TypstWatch() vsp vertical resize 50 exec 'terminal ' .. 'typst watch ' .. expand("%:t") exec "norm \h" endfunc :nnoremap fc :call TypstWatch() " Plugins " Run PlugInstall if there are missing plugins if $SYSTEM_PROFILE == "DEFAULT" autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) \| PlugInstall --sync | source $MYVIMRC \| endif endif " The rest will not be sourced if the system is on minimal settings. if $SYSTEM_PROFILE == "MINIMAL" finish endif call plug#begin() filetype plugin indent on if $SYSTEM_PROFILE == "DEFAULT" 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") Plug 'SirVer/ultisnips' let g:UltiSnipsExpandTrigger="" let g:UltiSnipsJumpForwardTrigger="" let g:UltiSnipsJumpBackwardTrigger="" let g:UltiSnipsSnippetDirectories=[$HOME.'/.config/nvim/ultisnips/'] endif if $SYSTEM_PROFILE == "DEFAULT" Plug 'neovim/nvim-lspconfig' Plug 'nvim-lua/lsp-status.nvim' Plug 'hrsh7th/nvim-cmp' Plug 'hrsh7th/cmp-nvim-lsp' Plug 'stevearc/dressing.nvim' Plug 'nvim-treesitter/nvim-treesitter' " Code folding set foldmethod=expr set foldexpr=nvim_treesitter#foldexpr() "autocmd BufEnter * normal zR " 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 / :Ack! " use ripgrep let g:ackprg = 'rg --vimgrep --smart-case' endif Plug 'axieax/urlview.nvim' Plug 'ggandor/leap.nvim' call plug#end() if $SYSTEM_PROFILE == "DEFAULT" " see .config/nvim/lua/init.lua lua require('init') endif