diff --git a/src/.config/nvim/coding.vim b/src/.config/nvim/coding.vim new file mode 100644 index 0000000..8f6151e --- /dev/null +++ b/src/.config/nvim/coding.vim @@ -0,0 +1,35 @@ +" configurations for coding +" ------------------------- + +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 + +" 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' + + +" debugger interface atop many many abstractions +" (works on a lot of languages though!) +Plug 'puremourning/vimspector' +source $XDG_CONFIG_HOME/nvim/vimspector.vim + +" bracket closing +Plug 'jiangmiao/auto-pairs' +let g:AutoPairsShortcutToggle = "@@" diff --git a/src/.config/nvim/digraphs.vim b/src/.config/nvim/digraphs.vim new file mode 100644 index 0000000..c3c99bc --- /dev/null +++ b/src/.config/nvim/digraphs.vim @@ -0,0 +1,26 @@ +" 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([ + \["++", '✝'], + \["+-", '†'], + \]) diff --git a/src/.config/nvim/init.vim b/src/.config/nvim/init.vim index 0e64f68..793c88d 100755 --- a/src/.config/nvim/init.vim +++ b/src/.config/nvim/init.vim @@ -1,5 +1,11 @@ set tabstop=4 shiftwidth=4 noexpandtab ai nosmd ignorecase smartcase +" terminal settings +" disable line numbers +au TermOpen * setlocal nonumber norelativenumber +" make ESC go to normal mode +tnoremap + " sign column on top of the line number (gutter for things like breakpoints, warnings) set scl=number @@ -27,7 +33,6 @@ 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 @@ -36,149 +41,23 @@ highlight LineNr ctermfg=grey " Disable highlighting when searching nnoremap :noh -" 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([ - \["++", '✝'], - \["+-", '†'], - \]) - -" 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 - Source -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 +" shortcuts to type symbols easier +source $XDG_CONFIG_HOME/nvim/digraphs.vim vnoremap K :'<,'>Evaluate " tab, window management +set splitbelow splitright nnoremap w nnoremap W +nnoremap :vertical resize -5 +nnoremap :vertical resize +5 " 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 @@ -197,70 +76,17 @@ call plug#begin() filetype plugin indent on -" i don't use LaTeX anymore, but you can comment out && 0 to -if $SYSTEM_PROFILE == "DEFAULT" && 0 - 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', - \ ], - \} +" i don't use LaTeX anymore, but you can uncomment this to +"source $XDG_CONFIG_HOME/nvim/vimtex.vim - " 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 +source $XDG_CONFIG_HOME/nvim/ultisnips.vim if $SYSTEM_PROFILE == "DEFAULT" - Plug 'neovim/nvim-lspconfig' - Plug 'nvim-lua/lsp-status.nvim' + " notes and documents stuff + source $XDG_CONFIG_HOME/nvim/typst.vim - 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' + " plugins for IDE-like nvim + source $XDG_CONFIG_HOME/nvim/coding.vim endif " URL motions @@ -269,10 +95,6 @@ Plug 'axieax/urlview.nvim' " fancy motions Plug 'ggandor/leap.nvim' -" bracket closing -Plug 'jiangmiao/auto-pairs' -let g:AutoPairsShortcutToggle = "@@" - call plug#end() if $SYSTEM_PROFILE == "DEFAULT" diff --git a/src/.config/nvim/lua/init.lua b/src/.config/nvim/lua/init.lua index 610ad40..c33bdb0 100644 --- a/src/.config/nvim/lua/init.lua +++ b/src/.config/nvim/lua/init.lua @@ -55,7 +55,7 @@ local servers = { pydocstyle = { enabled = true, convention = "numpy", - addIgnore = {"D100", "D101", "D102", "D105"} + addIgnore = {"D100", "D101", "D102", "D103" ,"D105"} }, black = { enabled = true, diff --git a/src/.config/nvim/typst.vim b/src/.config/nvim/typst.vim new file mode 100644 index 0000000..b412955 --- /dev/null +++ b/src/.config/nvim/typst.vim @@ -0,0 +1,22 @@ +" typst filetype support +Plug 'kaarmu/typst.vim' + +" 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() diff --git a/src/.config/nvim/ultisnips.vim b/src/.config/nvim/ultisnips.vim new file mode 100644 index 0000000..d4a05d9 --- /dev/null +++ b/src/.config/nvim/ultisnips.vim @@ -0,0 +1,9 @@ +" snippet engine (see .config/nvim/ultisnips/) + +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 diff --git a/src/.config/nvim/vimspector.vim b/src/.config/nvim/vimspector.vim new file mode 100644 index 0000000..60a4cbf --- /dev/null +++ b/src/.config/nvim/vimspector.vim @@ -0,0 +1,57 @@ +let g:vimspector_sidebar_width = 30 +let g:vimspector_terminal_maxwidth = 30 + +func VimspectorTerminalSetup() +endfunc +au User VimspectorTerminalOpened call VimspectorTerminalSetup() +func VimspectorUISetup() + "call win_gotoid(g:vimspector_session_windows.stack_trace) +endfunc +au User VimspectorUICreated call VimspectorUISetup() + +" compile +function Compile() + if exists("g:vimspector_session_windows.code") + call win_gotoid(g:vimspector_session_windows.code) + endif + w + execute "make ~/.cache/termdebug/" .. expand("%:r") .. " -f ~/.config/nvim/makefile" +endfunction +nnoremap dc :call Compile() + +" quickfix window (after running make) +nnoremap dqf :tab cope +nnoremap df :tabNext + +nnoremap dd :call vimspector#Launch() +nnoremap de :call vimspector#Reset() + +" 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() + call vimspector#Stop() + call vimspector#Restart() + call win_gotoid(g:vimspector_session_windows.code) + let inputfile=$HOME .. "/.cache/termdebug/input/" .. expand("%:r") + let @x = join(readfile(inputfile), "\n") .. "\n\n" + call win_gotoid(g:vimspector_session_windows.terminal) + normal G"xp +endfunction +nnoremap ri :call RunInput() + +" debugging program flow +nnoremap rs :call vimspector#Restart() +nnoremap rr :call vimspector#Stop() +nnoremap rf :call vimspector#Continue() +nnoremap :vimspector#StepInto() +nnoremap :vimspector#StepOver() + +" breakpoints +nnoremap dsf :call vimspector#ToggleBreakpoint() diff --git a/src/.config/nvim/vimtex.vim b/src/.config/nvim/vimtex.vim new file mode 100644 index 0000000..e6584e3 --- /dev/null +++ b/src/.config/nvim/vimtex.vim @@ -0,0 +1,27 @@ +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