dots/src/.config/nvim/init.vim

276 lines
6.3 KiB
VimL
Raw Normal View History

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
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
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
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
hi StatusLine ctermbg=NONE cterm=italic
2023-04-12 18:19:11 -04:00
hi SignColumn ctermbg=NONE
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-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()
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-07-01 18:18:55 -04:00
nnoremap - :call OpenNetRW()<cr>
" gdb integration
let g:termdebug_popup = 0
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
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>
" start debugger
nnoremap <silent> <leader>dd :execute "Termdebug" $HOME .. "/.cache/termdebug/" .. expand("%:r")<cr>:Source<cr>
" compile
function Compile()
if exists(":Source")
Source
endif
2023-04-18 20:07:49 -04:00
w
execute "make ~/.cache/termdebug/" .. expand("%:r") .. " -f ~/.config/nvim/makefile"
endfunction
nnoremap <silent> <leader>dc :call Compile()<cr>
" 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
Source
endfunction
nnoremap <silent> <leader>ri :call RunInput()<cr>
" 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-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>
nnoremap <silent> <c-n> :Over<cr>
" quickfix window (after running make)
nnoremap <silent> <leader>dqf :tab cope<cr>
nnoremap <silent> <leader>df :tabNext<cr>
vnoremap <silent> K :'<,'>Evaluate<cr>
2022-12-10 11:45:48 -05:00
" tab, window management
nnoremap <C-j> <C-w>w
nnoremap <C-k> <C-w>W
" exit all (akin to ZZ, ZQ)
nnoremap <silent> ZF :qa<cr>
" copy URL under cursor to clipboard bind
:nnoremap <silent><leader>uu :let @+ = expand('<cfile>')<CR>
" edit figure in Inkscape
function EditFig()
let figure_fname = expand('<cfile>')
exec "silent !typst-figure " .. figure_fname
vsp
exec "term inkscape-shortcut-manager"
quit
endfunc
:nnoremap <silent><leader>ff :call EditFig()<cr>
" 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
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
" 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
" 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',
\ ],
\}
" 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="<c-m>"
let g:UltiSnipsJumpForwardTrigger="<c-m>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"
let g:UltiSnipsSnippetDirectories=[$HOME.'/.config/nvim/ultisnips/']
endif
2023-04-12 18:19:11 -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
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'
endif
2023-01-21 21:46:35 -05:00
Plug 'axieax/urlview.nvim'
2023-04-12 18:19:11 -04:00
Plug 'ggandor/leap.nvim'
2022-12-10 11:45:48 -05:00
call plug#end()
2023-01-21 21:46:35 -05:00
if $SYSTEM_PROFILE == "DEFAULT"
" see .config/nvim/lua/init.lua
lua require('init')
endif