dotfiles

Cross platform dotfiles for linux, mac and windows
git clone git@getsh.org:dotfiles.git
Log | Files | Refs

.vimrc (4582B)


      1 syntax on indent off
      2 if has("&viminfofile")
      3     set viminfofile=$XDG_CACHE_DIR/vim/viminfo
      4 endif
      5 
      6 " reject netrw, embrace ls
      7 "let loaded_netrwPlugin = 1
      8 "let g:netrw_home = $XDG_DATA_HOME . "/vim"
      9 
     10 set complete-=i
     11 set foldmethod=marker
     12 set foldmarker={,}
     13 set foldlevel=20
     14 set foldopen-=search
     15 set background=dark
     16 
     17 " Debug
     18 let g:termdebug_config = {'sign': '>>', 'winbar': 0, 'wide':163}
     19 
     20 " General
     21 set nocompatible
     22 set mouse=
     23 set cursorline
     24 if has('cursorlineopt')
     25 	set cursorlineopt=number
     26 endif
     27 set exrc
     28 
     29 " Turn backup off
     30 set nobackup
     31 set nowb
     32 set noswapfile
     33 
     34 " Map leader to space
     35 nnoremap <space> <Nop>
     36 let mapleader = " "
     37 
     38 " Enable hidden buffers
     39 set hidden
     40 
     41 " Disable auto fixing end of line
     42 " Useful when opening binary files
     43 set nofixendofline
     44 
     45 " Disable vim intro message
     46 set shortmess=Iat
     47 set shortmess-=F
     48 
     49 " Search
     50 set hlsearch
     51 set incsearch
     52 set nowrapscan
     53 
     54 " Pro tab
     55 filetype plugin indent on
     56 set tabstop=4
     57 set shiftwidth=4
     58 set expandtab
     59 
     60 " Netrw customization
     61 let g:netrw_banner = 0
     62 let g:netrw_liststyle = 3
     63 let g:netrw_fastbrowse = 2
     64 let g:netrw_dirhistmax = 0
     65 
     66 " Disable status
     67 set laststatus=1
     68 
     69 set nolazyredraw
     70 set ttyfast
     71 set nospell
     72 
     73 
     74 " Common vimrc
     75 source $XDG_DATA_HOME/vim/vimrc
     76 
     77 source $XDG_DATA_HOME/vim/keybindings.vim
     78 
     79 set packpath^=$XDG_DATA_HOME/vim
     80 
     81 function! FZYFiles() abort
     82     let l:tempname = tempname()
     83     " fzf | awk '{ print $1":1:0" }' > file
     84     execute 'silent !git ls-files --recurse-submodules | fzf > ' . fnameescape(l:tempname)
     85 	let l:tcontents = join(readfile(l:tempname))
     86     try
     87 		" TODO Add option to add multiple files to argslist
     88 		"execute 'argadd ' . l:tcontents
     89 		 let bufnr = bufadd(l:tcontents)
     90 		call bufload(bufnr)
     91 		"call setbufline(bufnr, 1, ['some', 'text'])
     92         execute 'edit ' . l:tcontents
     93         redraw!
     94     finally
     95         call delete(l:tempname)
     96     endtry
     97 endfunction
     98 let g:lsc_server_commands = {'cpp': 'clangd --log=error'}
     99 let g:lsc_auto_map = {
    100     \ 'GoToDefinition': '<C-]>',
    101     \ 'GoToDefinitionSplit': ['<C-W>]', '<C-W><C-]>'],
    102     \ 'FindReferences': 'gr',
    103     \ 'FindImplementations': 'gI',
    104     \ 'FindCodeActions': 'ga',
    105     \ 'Rename': 'gR',
    106     \ 'ShowHover': v:true,
    107     \ 'DocumentSymbol': 'go',
    108     \ 'WorkspaceSymbol': 'gS',
    109     \ 'SignatureHelp': 'gm',
    110     \ 'Completion': 'completefunc',
    111     \}
    112 let g:lsc_enable_autocomplete  = v:true
    113 let g:lsc_enable_diagnostics   = v:true
    114 let g:lsc_reference_highlights = v:false
    115 let g:lsc_trace_level          = 'off'
    116 
    117 function! s:load_plugins(t) abort
    118 	set synmaxcol=128
    119 	" Use XDG Paths for vim
    120 	" TODO compile hard constants somewhere based on OS
    121 	set runtimepath^='$XDG_CONFIG_HOME/vim'
    122 	set runtimepath+='$XDG_DATA_HOME/vim'
    123 	set runtimepath+='$XDG_CONFIG_HOME/vim/after'
    124 
    125 	let g:netrw_home = $XDG_DATA_HOME . "/vim"
    126 	call mkdir($XDG_DATA_HOME . "/vim/spell", 'p')
    127 	set viewdir=$XDG_DATA_HOME/vim/view | call mkdir(&viewdir, 'p')
    128 
    129 	set backupdir=$XDG_CACHE_HOME/vim/backup | call mkdir(&backupdir, 'p')
    130 	set directory=$XDG_CACHE_HOME/vim/swap   | call mkdir(&directory, 'p')
    131 	set undodir=$XDG_CACHE_HOME/vim/undo     | call mkdir(&undodir,   'p')
    132 	packadd vim-tmux-navigator
    133 	packadd vim-commentary
    134 	packadd vim-surround
    135 	packadd vim-ninja-feet
    136 	packadd vim-fugitive
    137 	packadd vim-unimpaired
    138 	packadd vim-better-whitespace
    139 	packadd notmuch-vim
    140 	packadd vim-dispatch
    141 	packadd termdebug
    142 	let g:termdebug_wide=163
    143 	let g:notmuch_use_fzf = 1
    144 	let g:notmuch_open_command = 'fzf'
    145 	let g:notmuch_fzf_command = 'fzf --reverse'
    146 	let g:notmuch_use_conversation_view = 1
    147 	let sendmail_path = systemlist('sed -n "s/^set sendmail=\(.*\)$/\1/p; $!d" ~/.mailrc')
    148 	if len(sendmail_path) > 0
    149 		let g:notmuch_sendmail=sendmail_path[0]
    150 	endif
    151 endfunction
    152 augroup user_cmds
    153 	autocmd!
    154 	autocmd VimEnter * call timer_start(20, function('s:load_plugins'))
    155 augroup END
    156 
    157 if has("gui")
    158 	set guioptions=
    159 endif
    160 
    161 if has("win32")
    162 set shell=cmd
    163 	set shellquote=\" 
    164 	" shellxquote must be a literal space character.
    165 	set shellxquote=  
    166 else
    167     set shell=sh
    168 endif
    169 
    170 " TODO load this automatically
    171 source $XDG_CONFIG_HOME/vim/ftplugin/cpp.vim
    172 source $XDG_DATA_HOME/vim/plugin.vim
    173 
    174 let g:birck_default_chan="irc.libera.chat"
    175 
    176 " Map key chord `jk` to <Esc>
    177 let g:esc_j_lasttime = 0
    178 let g:esc_k_lasttime = 0
    179 function! JKescape(key)
    180 	if a:key == 'j' | let g:esc_j_lasttime = reltimefloat(reltime()) | endif
    181 	if a:key == 'k' | let g:esc_k_lasttime = reltimefloat(reltime()) | endif
    182 	let l:timediff = abs(g:esc_j_lasttime - g:esc_k_lasttime)
    183 	return (l:timediff <= 0.05 && l:timediff >=0.001) ? "\b\e" : a:key
    184 endfunction
    185 inoremap <expr> j JKescape('j')
    186 inoremap <expr> k JKescape('k')