.agents/
.cargo/
.codex/
.config/
.gnupg/
.local/
.vim/
bin/
etc/
images/
.dircolors
4.2 KiB
.fzy.zsh
1.1 KiB
.ghci
501 B
.gitconfig
2.2 KiB
.gitignore
0 B
.gitsigners
282 B
.ignore
136 B
.rgrc
174 B
.vimrc
12.7 KiB
.vimrc.lua
113 B
.wacom
260 B
.vimrc
raw
| 1 | " |
| 2 | " .vimrc |
| 3 | " |
| 4 | " Tabs and Spaces |
| 5 | set tabstop=4 |
| 6 | set shiftwidth=2 |
| 7 | set softtabstop=2 |
| 8 | set backspace=indent,eol,start |
| 9 | set expandtab |
| 10 | set autoindent |
| 11 | set cindent |
| 12 | set smarttab |
| 13 | |
| 14 | " Misc |
| 15 | set number |
| 16 | set ruler |
| 17 | set showmatch |
| 18 | set wildmenu |
| 19 | set wildmode=full |
| 20 | set nowrap |
| 21 | set hidden |
| 22 | set modeline |
| 23 | set hlsearch |
| 24 | set incsearch |
| 25 | set autoread " Auto-reload modified files (with no local changes) |
| 26 | set ignorecase " Ignore case in search |
| 27 | set smartcase " Override ignorecase if uppercase is used in search string |
| 28 | set report=0 " Report all changes |
| 29 | set laststatus=3 " Always show status-line |
| 30 | set nocursorline " Highlight current line |
| 31 | set scrolloff=4 |
| 32 | set nofoldenable |
| 33 | set timeoutlen=200 " Set timeout between key sequences |
| 34 | set background=light |
| 35 | set mouse=a " Enable mouse in all modes |
| 36 | set directory=~/tmp,/var/tmp,/tmp,. " Keep swap files in one of these |
| 37 | set wmh=0 " Minimum window height = 0 |
| 38 | set noshowcmd |
| 39 | set updatetime=250 " How long before 'CursorHold' event |
| 40 | set nobackup |
| 41 | set nowritebackup |
| 42 | set noswapfile |
| 43 | set nostartofline |
| 44 | set noshowmode " Don't show stuff like `-- INSERT --` |
| 45 | set foldlevel=99 " Open all folds by default |
| 46 | set cmdheight=1 |
| 47 | set matchtime=2 " Shorter brace match time |
| 48 | set virtualedit=block |
| 49 | set tags+=.tags |
| 50 | set tags+=./tags,tags; |
| 51 | set tags+=codex.tags |
| 52 | set undofile |
| 53 | set gdefault " Always use /g with %s/ |
| 54 | set colorcolumn=80 |
| 55 | set list |
| 56 | set listchars=tab:·\ ,eol:¬,trail:█ |
| 57 | set fillchars=diff:\ ,vert:│ |
| 58 | set diffopt=filler,vertical,foldcolumn:0,algorithm:patience |
| 59 | set statusline=%<%f\ (%{gitbranch#name()})\ %h%m%r%=%y\ \ %-14(%{&sw}:%{&sts}:%{&ts}%)%-14.(%l,%c%V%)\ %P |
| 60 | set guicursor=n-v-c:block-Cursor/lCursor-blinkon0,i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor |
| 61 | set spelllang=en_us,en_gb |
| 62 | set completeopt=menu |
| 63 | set shell=/bin/sh |
| 64 | set signcolumn=yes |
| 65 | set notermguicolors |
| 66 | |
| 67 | " Copy all yanked text to system clipboard (requires `xclip`) |
| 68 | " set clipboard+=unnamedplus |
| 69 | |
| 70 | " We don't use tabs much, but at least try and show less cruft |
| 71 | function! Tabline() |
| 72 | let s = '' |
| 73 | for i in range(tabpagenr('$')) |
| 74 | let tab = i + 1 |
| 75 | let winnr = tabpagewinnr(tab) |
| 76 | let buflist = tabpagebuflist(tab) |
| 77 | let bufnr = buflist[winnr - 1] |
| 78 | let bufname = bufname(bufnr) |
| 79 | |
| 80 | let s .= (tab == tabpagenr() ? '%#TabLineSel#' : '%#TabLine#') |
| 81 | let s .= ' ' . (!empty(bufname) ? fnamemodify(bufname, ':t') : '[No Name]') . ' ' |
| 82 | endfor |
| 83 | return s |
| 84 | endfunction |
| 85 | set tabline=%!Tabline() |
| 86 | |
| 87 | if !has("nvim") |
| 88 | set nocompatible " Don't try to be compatible with vi |
| 89 | set ttyfast |
| 90 | set t_Co=256 |
| 91 | else |
| 92 | " Number column |
| 93 | let &statuscolumn='%=%s%{v:lnum} ' |
| 94 | endif |
| 95 | |
| 96 | let mapleader = "\<Space>" |
| 97 | |
| 98 | " vim.wiki |
| 99 | let g:wiki_filetypes = ['wiki'] |
| 100 | |
| 101 | " signify |
| 102 | let g:signify_vcs_list = ['git'] |
| 103 | |
| 104 | " Latex |
| 105 | let g:vimtex_quickfix_mode = 0 |
| 106 | |
| 107 | " Why this is not the default, I don't know. |
| 108 | let g:c_syntax_for_h = 1 |
| 109 | |
| 110 | " inccommand |
| 111 | if has("nvim") |
| 112 | set inccommand=nosplit |
| 113 | endif |
| 114 | |
| 115 | " Save on focus lost |
| 116 | au FocusLost * call s:SaveOnFocusLost() |
| 117 | function! s:SaveOnFocusLost() |
| 118 | if !empty(expand('%:p')) && &modified |
| 119 | write |
| 120 | endif |
| 121 | endfunction |
| 122 | |
| 123 | " Per file-type indentation |
| 124 | au FileType haskell setlocal number sts=4 sw=4 expandtab formatprg=stylish-haskell |
| 125 | au FileType javascript setlocal number sts=2 sw=2 expandtab nowrap |
| 126 | au FileType typescript setlocal number sts=2 sw=2 expandtab nowrap |
| 127 | au FileType css setlocal number sts=2 sw=2 expandtab nowrap |
| 128 | au FileType go setlocal number ts=4 sw=4 noexpandtab nowrap |
| 129 | au FileType c,cpp,glsl setlocal number ts=4 sw=4 noexpandtab nowrap |
| 130 | au FileType lua setlocal number sw=2 expandtab |
| 131 | au FileType sh,zsh setlocal number sts=2 sw=2 expandtab |
| 132 | au FileType vim,ruby setlocal number sts=2 sw=2 expandtab |
| 133 | au FileType help setlocal number ts=4 sw=4 noexpandtab |
| 134 | au FileType solidity setlocal number ts=4 sw=4 expandtab nowrap |
| 135 | au FileType graphql setlocal number ts=4 sw=4 expandtab nowrap |
| 136 | au FileType rust setlocal number signcolumn=yes nowrap colorcolumn=100 textwidth=100 |
| 137 | au FileType plain setlocal nonumber noai nocin nosi inde= wrap linebreak textwidth=80 |
| 138 | au FileType pandoc setlocal nonumber |
| 139 | au FileType markdown setlocal nonumber nowrap conceallevel=0 formatprg=fmt\ -w\ 80 |
| 140 | au FileType rst setlocal nonumber sw=2 expandtab wrap linebreak textwidth=80 |
| 141 | au FileType todo setlocal nonumber sw=2 expandtab nolinebreak nowrap textwidth=0 |
| 142 | au FileType fountain setlocal nonumber noai nocin nosi inde= wrap linebreak |
| 143 | au FileType tex setlocal |
| 144 | au FileType verilog setlocal commentstring=//\ %s |
| 145 | au FileType riscv setlocal number sts=4 sw=4 expandtab noautoindent commentstring=#\ %s |
| 146 | au FileType radiance setlocal number ts=4 sw=4 expandtab nowrap commentstring=//\ %s comments=:///,://!,:// |
| 147 | |
| 148 | au BufRead,BufNewFile *.md setf markdown |
| 149 | au BufRead,BufNewFile *.tex setf tex |
| 150 | au BufRead,BufNewFile *.todo setf todo |
| 151 | au BufRead,BufNewFile *.tikz setf tex |
| 152 | au BufRead,BufNewFile *.toml setf toml |
| 153 | au BufRead,BufNewFile *.rs setf rust |
| 154 | au BufRead,BufNewFile *.mustache setf mustache |
| 155 | au BufRead,BufNewFile *.tera setf htmldjango |
| 156 | au BufRead,BufNewFile *.wiki setf wiki |
| 157 | au BufRead,BufNewFile *.r setf radiance |
| 158 | au BufRead,BufNewFile *.ril setf ril |
| 159 | au BufRead,BufNewFile *.ras setf ras |
| 160 | au BufRead,BufNewFile *.h setf c |
| 161 | |
| 162 | " If no file-type is detected, set to plain. |
| 163 | autocmd BufEnter * if &filetype == "" | setlocal ft=plain | endif |
| 164 | |
| 165 | let c_no_curly_error = 1 |
| 166 | |
| 167 | if has("nvim") |
| 168 | au TermOpen * set nonumber modifiable |
| 169 | endif |
| 170 | |
| 171 | " Remove trailing whitespace on save |
| 172 | autocmd BufWritePre * call s:StripTrailing() |
| 173 | function! s:StripTrailing() |
| 174 | if &ft =~ 'rust' |
| 175 | return |
| 176 | endif |
| 177 | |
| 178 | let l = line(".") |
| 179 | let c = col(".") |
| 180 | %s/\s\+$//e |
| 181 | call cursor(l, c) |
| 182 | endfunction |
| 183 | |
| 184 | " Markdown, highlight YAML frontmatter |
| 185 | let g:vim_markdown_frontmatter = 1 |
| 186 | let g:vim_markdown_auto_insert_bullets = 0 |
| 187 | let g:vim_markdown_new_list_item_indent = 0 |
| 188 | let g:vim_markdown_no_default_key_mappings = 1 |
| 189 | |
| 190 | " We use a POSIX shell |
| 191 | let g:is_posix = 1 |
| 192 | |
| 193 | " Haskell |
| 194 | let g:haskellmode_completion_ghc = 0 |
| 195 | let g:haskell_enable_quantification = 1 |
| 196 | au FileType haskell setlocal omnifunc=necoghc#omnifunc |
| 197 | au FileType haskell setlocal makeprg=stack\ build\ --fast |
| 198 | au FileType haskell setlocal errorformat= |
| 199 | \%-G, |
| 200 | \%-Z\ %#, |
| 201 | \%W%f:%l:%c:\ Warning:\ %m, |
| 202 | \%E%f:%l:%c:\ %m, |
| 203 | \%E%>%f:%l:%c:, |
| 204 | \%+C\ \ %#%m, |
| 205 | \%W%>%f:%l:%c:, |
| 206 | \%+C\ \ %#%tarning:\ %m, |
| 207 | |
| 208 | if executable('haskell-tags') |
| 209 | au BufWritePost *.hs silent !haskell-tags % '.tags' |
| 210 | au BufWritePost *.hsc silent !haskell-tags % '.tags' |
| 211 | endif |
| 212 | |
| 213 | if executable('ctags') |
| 214 | nnoremap <silent> <Leader>j <C-]> |
| 215 | endif |
| 216 | |
| 217 | " File-type |
| 218 | filetype on |
| 219 | filetype plugin on |
| 220 | filetype indent on |
| 221 | |
| 222 | nnoremap <Space> <NOP> |
| 223 | nnoremap Q <NOP> |
| 224 | |
| 225 | " Make `Y` behave like `D` and `C` |
| 226 | nnoremap Y y$ |
| 227 | |
| 228 | " Copy selected text to clipboard |
| 229 | xnoremap Y "+y |
| 230 | |
| 231 | " Paste form clipboard |
| 232 | noremap PP "+p |
| 233 | |
| 234 | " Easy command mode switch |
| 235 | inoremap kj <Esc> |
| 236 | inoremap <C-l> <C-x><C-l> |
| 237 | |
| 238 | " Correct spelling mistakes |
| 239 | inoremap <C-s> <c-g>u<Esc>[s1z=`]a<c-g>u |
| 240 | |
| 241 | " Jump to high/low and scroll |
| 242 | noremap <C-k> H{ |
| 243 | noremap <C-j> L} |
| 244 | |
| 245 | " Move easily between ^ and $ |
| 246 | noremap <C-h> ^ |
| 247 | noremap <C-l> $ |
| 248 | noremap j gj |
| 249 | noremap k gk |
| 250 | |
| 251 | " Like '*' but stays on the original word |
| 252 | nnoremap <C-n> *N |
| 253 | nnoremap <C-p> #N |
| 254 | nnoremap c* *Ncgn |
| 255 | nnoremap <Leader>h :nohl<CR> |
| 256 | |
| 257 | nnoremap <Leader>n :cnext<CR> |
| 258 | nnoremap <Leader>p :cprev<CR> |
| 259 | |
| 260 | autocmd BufRead fugitive\:* xnoremap <buffer> dp :diffput<CR> |
| 261 | autocmd BufRead fugitive\:* xnoremap <buffer> do :diffget<CR> |
| 262 | |
| 263 | " Support jsonc comments in json files |
| 264 | autocmd FileType json syntax match Comment +\/\/.\+$+ |
| 265 | |
| 266 | " Select recently pasted text |
| 267 | nnoremap <leader>v V`] |
| 268 | |
| 269 | " Switch buffers easily |
| 270 | nnoremap <Tab> <C-^> |
| 271 | |
| 272 | " Switch between .c and .h files easily |
| 273 | autocmd BufRead,BufNewFile *.c,*.h nnoremap <silent> <S-Tab> :e %:p:s,.h$,.X123X,:s,.c$,.h,:s,.X123X$,.c,<CR> |
| 274 | |
| 275 | " Actually easier to type and I do it by mistake anyway |
| 276 | cnoreabbrev W w |
| 277 | cnoreabbrev Q q |
| 278 | |
| 279 | " File navigation/search |
| 280 | nnoremap <Leader>o :FuzzyOpen<CR> |
| 281 | nnoremap <Leader>f :FuzzyGrep<CR> |
| 282 | nnoremap <Leader>t :FuzzyTodo<CR> |
| 283 | |
| 284 | " Navigate relative to the current file |
| 285 | cmap %/ %:p:h/ |
| 286 | |
| 287 | map <Leader>m :make<CR> |
| 288 | map <Leader>e :e ~/.vimrc<CR> |
| 289 | map <Leader>s :source ~/.vimrc<CR> |
| 290 | |
| 291 | " Repeat previous command |
| 292 | map <Leader><Space> @: |
| 293 | |
| 294 | " Commenting |
| 295 | nmap <C-/> <Plug>CommentaryLine |
| 296 | xmap <C-/> <Plug>Commentary |
| 297 | |
| 298 | if has("nvim") |
| 299 | tnoremap <Esc> <C-\><C-n> |
| 300 | endif |
| 301 | |
| 302 | " Grep |
| 303 | if executable('rg') |
| 304 | set grepprg=rg\ --vimgrep\ --smart-case |
| 305 | set grepformat=%f:%l:%c:%m |
| 306 | endif |
| 307 | command! -nargs=+ -complete=file Rg call Ripgrep(<q-args>) |
| 308 | command! -nargs=+ -complete=file RgAll call Ripgrep(<q-args>, '--no-ignore') |
| 309 | |
| 310 | function! Ripgrep(query, ...) |
| 311 | " Get additional flags (like --no-ignore) |
| 312 | let l:extra_flags = a:0 > 0 ? a:1 : '' |
| 313 | " Build the search command |
| 314 | let l:cmd = 'silent grep! ' . l:extra_flags . ' ' . shellescape(a:query) |
| 315 | " Execute search and open quickfix |
| 316 | execute l:cmd |
| 317 | copen 12 |
| 318 | endfunction |
| 319 | |
| 320 | autocmd FileType qf nnoremap <buffer> <CR> <CR> |
| 321 | |
| 322 | " Syntax coloring |
| 323 | syntax enable |
| 324 | |
| 325 | " Profiling |
| 326 | command! ProfileStart call s:ProfileStart() |
| 327 | function! s:ProfileStart() |
| 328 | profile start profile |
| 329 | profile func * |
| 330 | profile file * |
| 331 | endfunction |
| 332 | |
| 333 | command! ProfileStop call s:ProfileStop() |
| 334 | function! s:ProfileStop() |
| 335 | profile stop |
| 336 | tabnew profile |
| 337 | endfunction |
| 338 | |
| 339 | " Get highlight group under cursor |
| 340 | command! Syn call s:Syn() |
| 341 | function! s:Syn() |
| 342 | echo synIDattr(synID(line("."), col("."), 1), "name") |
| 343 | endfunction |
| 344 | |
| 345 | if has("nvim") |
| 346 | call plug#begin() |
| 347 | |
| 348 | Plug 'tpope/vim-commentary' |
| 349 | Plug 'pangloss/vim-javascript', { 'for': ['javascript'] } |
| 350 | Plug 'bronson/vim-visual-star-search' |
| 351 | Plug 'cloudhead/neovim-fuzzy' |
| 352 | Plug 'cloudhead/shady.vim' |
| 353 | Plug 'tikhomirov/vim-glsl' |
| 354 | Plug 'junegunn/goyo.vim' |
| 355 | Plug 'exu/pgsql.vim' |
| 356 | Plug 'lervag/vimtex', { 'for': ['tex'] } |
| 357 | Plug 'itchyny/vim-gitbranch' |
| 358 | Plug 'cespare/vim-toml' |
| 359 | Plug 'rust-lang/rust.vim' |
| 360 | Plug 'neoclide/coc.nvim', { 'branch': 'release', 'for': ['rust', 'typescript', 'c'] } |
| 361 | Plug 'neovim/nvim-lspconfig' |
| 362 | Plug 'lewis6991/gitsigns.nvim' |
| 363 | Plug 'leafgarland/typescript-vim', { 'for': ['typescript'] } |
| 364 | Plug 'lervag/wiki.vim' |
| 365 | Plug 'laurelmay/riscv.vim' |
| 366 | Plug 'kblin/vim-fountain' |
| 367 | |
| 368 | call plug#end() |
| 369 | endif |
| 370 | |
| 371 | " |
| 372 | " Quickfix Signs |
| 373 | " |
| 374 | sign define quickfix-error text=× texthl=ErrorSign |
| 375 | |
| 376 | command! QuickfixSigns call s:QuickfixSigns() |
| 377 | |
| 378 | " autocmd BufWrite * sign unplace * |
| 379 | autocmd CursorHold *.rs silent QuickfixSigns |
| 380 | |
| 381 | function! s:QuickfixSigns() |
| 382 | " Only try to read from .errors if it exists and is non-empty |
| 383 | if filereadable('.errors') && getfsize('.errors') > 0 |
| 384 | silent! cgetfile |
| 385 | endif |
| 386 | |
| 387 | sign unplace * |
| 388 | for dict in getqflist() |
| 389 | if dict.type != 'E' |
| 390 | continue |
| 391 | endif |
| 392 | try |
| 393 | silent exe "sign" |
| 394 | \ "place" |
| 395 | \ dict.lnum |
| 396 | \ "line=" . string(dict.lnum) |
| 397 | \ "name=" . "quickfix-error" |
| 398 | \ "file=" . bufname(dict.bufnr) |
| 399 | catch |
| 400 | |
| 401 | endtry |
| 402 | endfor |
| 403 | endfunction |
| 404 | |
| 405 | command! Write setlocal spell | Goyo 100x98% |
| 406 | command! Code setlocal nospell | Goyo! |
| 407 | command! GitAdd silent !git add % |
| 408 | command! GitStage silent :Gitsigns stage_hunk |
| 409 | command! GitReset silent :Gitsigns reset_hunk |
| 410 | xnoremap <silent> <leader>s :Gitsigns stage_hunk<CR> |
| 411 | |
| 412 | " Delete the current file. |
| 413 | command! Delete call delete(expand('%')) | bdelete! |
| 414 | |
| 415 | if has("nvim") |
| 416 | " Make sure we dont' load the rust cargo plugin from rust.vim! |
| 417 | let g:loaded_rust_vim_plugin_cargo = 1 |
| 418 | " Don't add errors to quickfix if rustfmt fails. |
| 419 | let g:rustfmt_fail_silently = 1 |
| 420 | endif |
| 421 | |
| 422 | " coc.vim |
| 423 | function! SetupCoc() |
| 424 | nmap <silent> gd <Plug>(coc-definition) |
| 425 | nmap <silent> gy <Plug>(coc-type-definition) |
| 426 | nmap <silent> gi <Plug>(coc-implementation) |
| 427 | nmap <silent> gr <Plug>(coc-references) |
| 428 | nmap <silent> gj <Plug>(coc-diagnostic-next) |
| 429 | nmap <silent> gk <Plug>(coc-diagnostic-prev) |
| 430 | nmap <silent> <leader>/ :CocList --interactive symbols<CR> |
| 431 | nmap <silent> <leader>r <Plug>(coc-rename) |
| 432 | |
| 433 | " Use K to show documentation in preview window |
| 434 | nnoremap <silent> K :call <SID>show_documentation()<CR> |
| 435 | |
| 436 | function! s:show_documentation() |
| 437 | if (index(['vim','help'], &filetype) >= 0) |
| 438 | execute 'h '.expand('<cword>') |
| 439 | else |
| 440 | call CocAction('doHover') |
| 441 | endif |
| 442 | endfunction |
| 443 | |
| 444 | inoremap <expr> <cr> coc#pum#visible() ? coc#_select_confirm() : "\<CR>" |
| 445 | endfunction |
| 446 | |
| 447 | autocmd User CocNvimInit call SetupCoc() |
| 448 | command! CocStop call coc#rpc#stop() |
| 449 | command! CocLspLogs CocCommand workspace.showOutput |
| 450 | |
| 451 | " Use custom colors. |
| 452 | " This has to go after plugin initialization. |
| 453 | try |
| 454 | colorscheme shady |
| 455 | catch |
| 456 | endtry |