dotfiles/.config/vim/vimrc

87 lines
3.4 KiB
VimL
Raw Normal View History

2020-10-11 20:56:08 +02:00
set undodir=${VIMDOTDIR}/undo
set directory=${VIMDOTDIR}/swap
set backupdir=${VIMDOTDIR}/backup
set viewdir=${VIMDOTDIR}/view
set viminfo+='1000,n${VIMDOTDIR}/viminfo
2020-10-11 20:19:58 +02:00
set runtimepath=$XDG_CONFIG_HOME/vim,$VIMRUNTIME,$XDG_CONFIG_HOME/vim/after
2020-07-02 11:28:40 +02:00
" Install vim-plug
2020-10-11 20:56:08 +02:00
if empty(glob('${VIMDOTDIR}/autoload/plug.vim'))
silent !curl -fLo ${VIMDOTDIR}/autoload/plug.vim --create-dirs
2020-07-02 11:28:40 +02:00
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
2020-10-11 20:56:08 +02:00
autocmd VimEnter * PlugInstall --sync | source $VIMRC
2020-07-02 11:28:40 +02:00
endif
" Specify a directory for plugins
" Install plugins
2020-10-11 20:56:08 +02:00
call plug#begin('$VIMDOTDIR/plugged')
2020-07-02 11:28:40 +02:00
Plug 'elzr/vim-json'
Plug 'arcticicestudio/nord-vim'
" Initialize plugin system
call plug#end()
2020-01-05 23:04:27 +01:00
set nocompatible " Vim defaults rather than vi ones. Keep at top.
filetype plugin indent on " Enable filetype-specific settings.
syntax on " Enable syntax highlighting.
set backspace=2 " Make the backspace behave as most applications.
set autoindent " Use current indent for new lines.
set display=lastline " Show as much of the line as will fit.
set wildmenu " Better tab completion in the commandline.
set wildmode=list:longest " List all matches and complete to the longest match.
set showcmd " Show (partial) command in bottom-right.
set expandtab " Use spaces instead of tabs for indentation.
set smarttab " Backspace removes 'shiftwidth' worth of spaces.
set number " Show line numbers.
set laststatus=2 " Always show the statusline.
set ruler " Show the ruler in the statusline.
set textwidth=80 " Wrap at n characters.
set incsearch " Jump to search match while typing.
set hlsearch " Highlight the last used search pattern.
set nrformats-=octal " Remove octal support from 'nrformats'.
set tabstop=2 " Size of a Tab character.
2020-06-05 10:39:51 +02:00
set shiftwidth=2 " Use same value as 'tabstop'.
set softtabstop=2 " Use same value as 'shiftwidth'.
2020-01-05 23:04:27 +01:00
set encoding=utf-8 " Set encoding
2020-07-02 11:06:35 +02:00
color nord " Use Nord color scheme
2020-06-05 10:39:51 +02:00
set list listchars=tab:»⤍·,trail,eol,nbsp" Show invisible chars
" set colorcolumn=80 " Highlight the 80th collumn
set wrap linebreak nolist " Softwrap long lines at window border, don't break words
set showbreak= " Intend softwrapped lines with unbreakable space
" Highlight the line the cursor is on in markdown files
autocmd FileType markdown set cursorline
2020-01-05 23:04:27 +01:00
" Go to the last cursor location when opening a file.
augroup jump
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit'
\| exe 'normal! g`"'
\| endif
augroup end
" Clean trailing whitespace.
fun! s:trim_whitespace()
let l:save = winsaveview()
keeppatterns %s/\s\+$//e
call winrestview(l:save)
2016-04-16 16:31:54 +02:00
endfun
2020-01-05 23:04:27 +01:00
command! TrimWhitespace call s:trim_whitespace()
2016-04-16 16:31:54 +02:00
" Highlight characters behind the 80 chars margin
2020-06-05 10:39:51 +02:00
" :au BufWinEnter * let w:m2=matchadd('ColumnMargin', '\%>80v.\+', -1)
2016-04-16 16:31:54 +02:00
2020-06-05 10:39:51 +02:00
" Treat all .md files as markdown
autocmd BufNewFile,BufRead *.md set filetype=markdown
2016-04-16 16:31:54 +02:00
" make uses real tabs
au FileType make set noexpandtab
" add json syntax highlighting
au BufNewFile,BufRead *.json set ft=javascript
" make Python follow PEP8 ( http://www.python.org/dev/peps/pep-0008/ )
au FileType python set softtabstop=4 tabstop=4 shiftwidth=4 textwidth=79