dotfiles

My dotfiles for Arch Linux
Log | Files | Refs | README

vimrc (6246B)


      1 " Plugins {{{
      2 call plug#begin('~/.vim/plugged')
      3 Plug 'easymotion/vim-easymotion'
      4 Plug 'vimwiki/vimwiki'
      5 Plug 'mechatroner/rainbow_csv'
      6 
      7 "Coding
      8 Plug 'dense-analysis/ale'
      9 Plug 'Raimondi/delimitMate'
     10 
     11 " Search
     12 Plug 'wincent/command-t', {
     13 			\ 'do': 'cd ruby/command-t/ext/command-t && ruby extconf.rb && make'
     14 			\ }
     15 Plug 'justinmk/vim-sneak'
     16 
     17 " Writing text
     18 Plug 'junegunn/goyo.vim'
     19 
     20 " Themes
     21 Plug 'arcticicestudio/nord-vim'
     22 Plug 'morhetz/gruvbox'
     23 
     24 Plug 'tpope/vim-surround'
     25 Plug 'tpope/vim-repeat'
     26 Plug 'camspiers/lens.vim'
     27 Plug 'jlanzarotta/bufexplorer'
     28 
     29 " R Setup
     30 "Plug 'jalvesaq/Nvim-R'
     31 "Plug 'ncm2/ncm2'
     32 "Plug 'roxma/nvim-yarp'
     33 "Plug 'gaalcaras/ncm-R'
     34 if !has('nvim')
     35     Plug 'roxma/vim-hug-neovim-rpc'
     36 endif
     37 
     38 " Python
     39 "Plug 'ncm2/ncm2-jedi'
     40 call plug#end()
     41 if has("autocmd")
     42   filetype plugin indent on
     43 endif
     44 
     45 " Configure vim-sneak
     46 map f <Plug>Sneak_s
     47 map F <Plug>Sneak_S
     48 
     49 " Configure NCM2
     50 "autocmd BufEnter * call ncm2#enable_for_buffer()    " To enable ncm2 for all buffers.
     51 "set completeopt=noinsert,menuone,noselect           " :help Ncm2PopupOpen for more
     52 
     53  " }}}
     54 
     55 " Basics {{{
     56 set encoding=utf-8 " Encoding
     57 set number " Display line numbers
     58 set relativenumber " Enable relative line numbers
     59 set splitbelow splitright " Sensible splitting behavior
     60 set nocompatible
     61 set nomodeline
     62 set cursorline
     63 set clipboard+=unnamedplus " Yank and Paste directly to and from clipboard
     64 " Enable file autocompletion and fuzzy find
     65 set wildmode=longest,list,full
     66 set wildmenu
     67 set path+=**
     68 " Change leader key
     69 let mapleader = ','
     70 " Set the time the leader key is active (in ms)
     71 set timeoutlen=2000
     72 " Show tabs
     73 set listchars=tab:>-
     74 " Leave insert mode
     75 inoremap jk <ESC>
     76  " }}}
     77 
     78 " Syntax highlighting {{{
     79 let g:solarized_termcolors=256 " If using solarized color scheme
     80 let g:gruvbox_contrast_dark="soft" " If using gruvbox color scheme
     81 let g:gruvbox_contrast_light="hard"
     82 if has("syntax")
     83   syntax on
     84   colorscheme nord
     85 endif
     86 " }}}
     87 
     88 " Statusline {{{
     89 set laststatus=2
     90 set statusline=
     91 "set statusline+=%7*\[%n]                                  "buffernr
     92 set statusline+=%1*\ %<%F\                                "Filename
     93 set statusline+=%2*\ %y\                                  "FileType
     94 set statusline+=%3*\ %{''.(&fenc!=''?&fenc:&enc).''}      "Encoding
     95 set statusline+=%3*\ %{(&bomb?\",BOM\":\"\")}\            "Encoding2
     96 set statusline+=%4*\ %{&ff}\                              "FileFormat (dos/unix..)
     97 set statusline+=%5*\ %{&spelllang}\                       "Spellanguage
     98 set statusline+=%8*\ %=\ %l:%v\                           "Rownr:Colnr
     99 set statusline+=%0*\ \ %m%r%w\ %P\ \                      "Modified? Readonly? Top/bot.
    100  " }}}
    101 
    102 " Snippets {{{
    103 " Python
    104 nnoremap <Leader>pydef :-1read $HOME/.vim/snippets/python/skel_func.py<CR>wf(a
    105 nnoremap <Leader>pyclass :-1read $HOME/.vim/snippets/python/skel_class.py<CR>wi 
    106 " LaTeX
    107 nnoremap <Leader>item :-1read $HOME/.vim/snippets/latex/skel_itemize.tex<CR>1j$i
    108 nnoremap <Leader>enum :-1read $HOME/.vim/snippets/latex/skel_enumerate.tex<CR>1j$i
    109 nnoremap <Leader>fig :-1read $HOME/.vim/snippets/latex/skel_figure.tex<CR>1j$i
    110 nnoremap <Leader>outline :-1read $HOME/.vim/snippets/latex/skel_outline.tex<CR>1j$i
    111 " Markdown
    112 nnoremap <Leader>mdtab :-1read $HOME/.vim/snippets/markdown/skel_table.md<CR>2li
    113 nnoremap <Leader>mdimg :-1read $HOME/.vim/snippets/markdown/skel_image.md<CR>f[a
    114 nnoremap <Leader>mdlink :-1read $HOME/.vim/snippets/markdown/skel_link.md<CR>f[a
    115 nnoremap <Leader>mdblock :-1read $HOME/.vim/snippets/markdown/skel_codeblock.md<CR>$i
    116 nnoremap <Leader>mdmeta :-1read $HOME/.vim/snippets/markdown/skel_meta.md<CR>3j$"=strftime("%Y-%m-%d")<CR>Pgg01j$i
    117 " Bibtex
    118 nnoremap <Leader>bibinp :-1read $HOME/.vim/snippets/bibtex/skel_inproceedings.bib<CR>f{a
    119 nnoremap <Leader>bibart :-1read $HOME/.vim/snippets/bibtex/skel_article.bib<CR>f{a
    120 " }}}
    121 
    122 " run programs silently {{{
    123 command! -nargs=* RunSilent
    124 	\ | execute ':silent !'.'<args>'
    125 	\ | execute ':redraw!'
    126 " }}}
    127 
    128 " markdown preview with pandoc {{{
    129 nmap <Leader>pc :RunSilent pandoc -f markdown -o /tmp/vim-pandoc-out.pdf % && pkill -1 mupdf<CR>
    130 nmap <Leader>pp :RunSilent zathura /tmp/vim-pandoc-out.pdf &<CR>
    131  " }}}
    132 
    133 " Search through vimwiki {{{
    134 command! -nargs=1 Wikigrep vimgrep "<args>" $HOME/vimwiki/**/*.wiki
    135 nnoremap <Leader>w :Wikigrep<space>
    136 " }}}
    137 
    138 " run make {{{
    139 nmap <Leader>mk :RunSilent make<CR>
    140 "}}}
    141 
    142 " Normal, write and code modes {{{
    143 command Normalmode set background=dark | colorscheme nord | Goyo! | set nolinebreak | set norelativenumber | set nospell | set cursorline
    144 command Writemode set background=light | colorscheme solarized | set linebreak | set spell | set nocursorline | Goyo 80
    145 command Codemode set background=dark | colorscheme obsidian | Goyo! | set nolinebreak | set nospell | set cursorline
    146 nmap <Leader>nm :Normalmode<CR>
    147 nmap <Leader>wm :Writemode<CR>
    148 nmap <Leader>cm :Codemode<CR>
    149 " }}}
    150 
    151 " Insert current date {{{
    152 nmap <Leader>d "=strftime("%Y-%m-%d")<CR>P
    153 " }}}
    154 
    155 " Commands {{{
    156 " Requires ctags to be installed
    157 command! MakeTags !ctags -R .
    158 command! Make !make
    159 nnoremap <Leader>m :Make<CR>
    160 " }}}
    161 
    162 " autocmds {{{
    163 " reopening a file at same position
    164 if has("autocmd")
    165   au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
    166   autocmd BufRead,BufNewFile ~/.mutt/temp/mutt* :Goyo 80 | set linebreak | set spell
    167   " automatically deletes all trailing whitespace on save
    168   " autocmd BufWritePre * %s/\s\+$//e
    169 endif
    170 
    171 " Use specific colorscheme for buffer if b:colors_name is set
    172 au BufEnter * if (exists("b:colors_name")) | let b:current_colors=colors_name
    173  \| execute "colorscheme " . b:colors_name | endif
    174 au BufLeave * if (exists("b:current_colors")) | execute "colorscheme " . b:current_colors | endif
    175 " }}}
    176 
    177 " Open vimrc {{{
    178 nnoremap <Leader>ev :vsp ~/.vimrc<CR>
    179 nnoremap <Leader>sv :source ~/.vimrc <bar> :doautocmd BufRead<CR>
    180 " }}}
    181 
    182 " Disable arrow and page keys {{{
    183 noremap <Down> <Nop>
    184 noremap <Left> <Nop>
    185 noremap <Right> <Nop>
    186 noremap <Up> <Nop>
    187 noremap <PageUp> <Nop>
    188 noremap <PageDown> <Nop>
    189 noremap! <Down> <Nop>
    190 noremap! <Left> <Nop>
    191 noremap! <Right> <Nop>
    192 noremap! <Up> <Nop>
    193 noremap! <PageUp> <Nop>
    194 noremap! <PageDown> <Nop>
    195 " }}}
    196 
    197 " Folding {{{
    198 set foldenable
    199 set foldlevelstart=10
    200 set foldnestmax=10
    201 set foldmethod=syntax
    202 nnoremap <space> za
    203 " }}}