dotfiles

My dotfiles, nothing really interesting to see ...
git clone https://git.onna.be/dotfiles.git
Log | Files | Refs | README

init.vim (6568B)


      1 " my silly vimrc
      2 " Basic config {{{
      3 set shiftwidth=4   " Number of spaces to use for each step of (auto)indent
      4 set tabstop=4      " Number of spaces that a <Tab> in the file counts for
      5 set softtabstop=4  " Number of spaces that a <Tab> counts for while performing editing
      6 set expandtab      " use spaces instead of tabs
      7 set scrolloff=2    " show 2 lines before/after cursor always
      8 set number
      9 set relativenumber
     10 set cursorline
     11 set cursorcolumn
     12 set ignorecase
     13 set smartcase      " don't use ignorecase when we search for a cased pattern
     14 set hidden         " avoiding annoying messages (no write since last change)
     15 set splitright     " split windows on the right !
     16 set list           " mark non-printable chars as per above instructions
     17 set listchars=tab:▸\ ,trail:·,precedes:«,extends:»,nbsp:+
     18 set wildmode=longest,list:longest                  " command completion works as I want
     19 set foldmethod=syntax
     20 set foldlevelstart=10   " open most folds by default
     21 set foldnestmax=10      " 10 nested fold max
     22 set updatetime=1000
     23 set lazyredraw " redraw less, let's see how it goes
     24 set path+=**
     25 set completeopt=noinsert,menuone,noselect " required by ncm2
     26 set nrformats+=alpha " with C-a can increment dec, hex, bin, and chars too
     27 " }}}
     28 
     29 " Color {{{
     30 color lucius
     31 LuciusBlackLowContrast
     32 " }}}
     33 
     34 " Buffer/Filetype configs {{{
     35 augroup buffft
     36     autocmd!
     37     autocmd BufNewFile,BufRead Rexfile setfiletYPe perl
     38     autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab
     39     autocmd FileType yaml setlocal ts=2 sts=2 sw=2
     40     autocmd FileType openscad setlocal ts=2 sts=2 sw=2
     41     autocmd BufNewFile,BufRead *.txt set tw=72 wrap lbr formatprg=fmt\ -72
     42     autocmd BufReadPost *mutt-* set syntax=mail tw=72 wrap lbr formatprg=fmt\ -72
     43     autocmd BufEnter * call ncm2#enable_for_buffer()
     44 augroup END
     45 " }}}
     46 
     47 " Templates {{{
     48 augroup templates
     49     autocmd!
     50     autocmd BufNewFile *.sh 0r $HOME/.config/nvim/templates/template.sh
     51     autocmd BufNewFile *.pl 0r $HOME/.config/nvim/templates/template.pl
     52     autocmd BufNewFile *.c 0r $HOME/.config/nvim/templates/template.c
     53     autocmd BufNewFile *.go 0r $HOME/.config/nvim/templates/template.go
     54     autocmd BufNewFile *.py 0r $HOME/.config/nvim/templates/template.py
     55 augroup END
     56 " }}}
     57 
     58 " Mappings {{{
     59 augroup perftmappings
     60     autocmd!
     61     " perltidy
     62     autocmd Filetype perl nnoremap <silent> <Leader>t :mark t <bar> execute'%!perltidy' <bar> execute 'normal! `t' <bar> delmarks t<CR>
     63     autocmd Filetype perl vnoremap <silent> <Leader>t :!perltidy<CR>
     64     " same for c (astyle)
     65     autocmd Filetype c,cpp,arduino nnoremap <silent> <Leader>t :mark t <bar> execute'%!astyle' <bar> execute 'normal! `t' <bar> delmarks t<CR>
     66     autocmd Filetype c,cpp,arduino vnoremap <buffer> <Leader>t :!astyle<CR>
     67     " and for python
     68     autocmd FileType python nnoremap <silent> <Leader>i :!isort %<CR><CR>
     69     autocmd FileType python nnoremap <silent> <Leader>t :mark t <bar> execute'%!yapf' <bar> execute 'normal! `t' <bar> delmarks t<CR>
     70     autocmd Filetype python vnoremap <silent> <Leader>t :!yapf<CR>
     71     autocmd FileType python setlocal textwidth=79 shiftround
     72     " and for go ...
     73     autocmd Filetype go nnoremap <silent> <Leader>t :mark t <bar> execute'%!gofmt' <bar> execute 'normal! `t' <bar> delmarks t<CR>
     74     autocmd Filetype go vnoremap <silent> <Leader>t :!gofmt<CR>
     75 augroup END
     76 " space bar un-highlights search
     77 noremap <silent> <Space> :silent noh<Bar>echo<CR>
     78 " \space open/closes folds
     79 nnoremap <Leader><space> za
     80 " better behaviour of > in visual mode
     81 vnoremap > >gv
     82 vnoremap < <gv
     83 " search with true regexp, not vim's ...
     84 nnoremap / /\v
     85 vnoremap / /\v
     86 " next prev tab
     87 let i = 1
     88 while i < 10
     89     execute 'nnoremap <leader>'.i.' '.i.'gt'
     90     let i += 1
     91 endwhile
     92 nmap <leader>[ :tabprevious<CR>
     93 nmap <leader>] :tabnext<CR>
     94 " go fast to home end of line
     95 inoremap <C-e> <C-o>$
     96 inoremap <C-a> <C-o>0
     97 " char forward back in insert mode (useful for auto-close)
     98 inoremap <C-f> <C-o>a
     99 inoremap <C-b> <C-o>h
    100 " copy and paste from system easily
    101 if has("mac")
    102     nnoremap cp "*p
    103     vnoremap cy "*y
    104 else
    105     nnoremap cp "+p
    106     vnoremap cy "+y
    107 endif
    108 " \b calls make
    109 nnoremap <leader>b :make<CR>
    110 " sanity in terminal mode
    111 tnoremap <Esc> <C-\><C-n>
    112 tnoremap <C-v><Esc> <Esc>
    113 " }}}
    114 
    115 " Plugins {{{
    116 " ALE {{{
    117 nmap <silent> <Leader>k <Plug>(ale_previous_wrap)
    118 nmap <silent> <Leader>j <Plug>(ale_next_wrap)
    119 " }}}
    120 " Nerdcommenter {{{
    121 let g:NERDSpaceDelims = 1
    122 let g:NERDDefaultAlign = 'left'
    123 let g:NERDCommentEmptyLines = 1
    124 let g:NERDTrimTrailingWhitespace = 1
    125 let g:NERDCompactSexyComs = 1
    126 " }}}
    127 " vim-go {{{
    128 let g:go_highlight_functions = 1
    129 let g:go_highlight_methods = 1
    130 let g:go_highlight_fields = 1
    131 let g:go_highlight_types = 1
    132 let g:go_highlight_operators = 1
    133 let g:go_highlight_build_constraints = 1
    134 let g:go_highlight_extra_types = 1
    135 let g:go_fmt_command = "goimports"
    136 let g:go_template_autocreate = 0
    137 let g:go_info_mode = 'guru'
    138 " }}}
    139 " vim-grepper {{{
    140 let g:grepper = {}
    141 let g:grepper.tools = ['rg', 'git', 'grep']
    142 nnoremap <Leader>* :Grepper -cword -noprompt
    143 nmap gs <plug>(GrepperOperator)
    144 xmap gs <plug>(GrepperOperator)
    145 " }}}
    146 " UltiSnips {{{
    147 let g:UltiSnipsEnableSnipMate = 0
    148 " }}}
    149 " vim-slackcat {{{
    150 let g:slackcat_default_channel = "festeban"
    151 " }}}
    152 " }}}
    153 
    154 " Tabline {{{
    155 " tabline with numbers
    156 " shamelessly taken form
    157 " https://github.com/mkitt/tabline.vim/blob/master/plugin/tabline.vim
    158 " and modified slightly
    159 function! Tabline()
    160   let s = ''
    161   for i in range(tabpagenr('$'))
    162     let tab = i + 1
    163     let winnr = tabpagewinnr(tab)
    164     let buflist = tabpagebuflist(tab)
    165     let bufnr = buflist[winnr - 1]
    166     let bufname = bufname(bufnr)
    167     let bufmodified = getbufvar(bufnr, "&mod")
    168 
    169     let s .= '%' . tab . 'T'
    170     let s .= (tab == tabpagenr() ? '%#TabLineSel#' : '%#TabLine#')
    171     let s .= ' ' . tab
    172 	let n = tabpagewinnr(tab,'$') " get the number of windows in the current tab
    173 	if n > 1
    174 		let s .= '(' . n .')' " if there's more than one, add a colon and display the count
    175 	endif
    176     let s .= ':'
    177     let s .= (bufname != '' ? '['. pathshorten(fnamemodify(bufname, ':~:.')) . '] ' : '[No Name] ')
    178 
    179     if bufmodified
    180       let s .= '[+] '
    181     endif
    182   endfor
    183 
    184   let s .= '%#TabLineFill#'
    185   if (exists("g:tablineclosebutton"))
    186     let s .= '%=%999XX'
    187   endif
    188   return s
    189 endfunction
    190 set tabline=%!Tabline()
    191 " }}}
    192 
    193 " Statusline {{{
    194 set laststatus=2
    195 set statusline=\[%n]
    196 set statusline+=\ >>\ %f
    197 set statusline+=\ %m%r%h
    198 set statusline+=\ %y
    199 set statusline+=\ \[%{(&fenc!=''?&fenc:&enc)}/%{&ff}]
    200 set statusline+=\ %=
    201 set statusline+=\ L:%4l/%4L\ C:%3c
    202 set statusline+=\ [%3p%%]
    203 " }}}
    204 
    205 " vim:foldmethod=marker:foldlevel=0