dotfiles

My dotfiles for Arch Linux
git clone git://git.janispagel.de/dotfiles.git
Log | Files | Refs | README

vimrc (7643B)


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