diff --git a/.vimrc b/.vimrc new file mode 100644 index 0000000..fee465b --- /dev/null +++ b/.vimrc @@ -0,0 +1,191 @@ +" Set up vim + +" Basic configuration +set nocompatible + +set encoding=utf-8 +set binary + +" Presentation settings +set number " Precede each line with its line number +set numberwidth=3 " Number of culumns for line numbers +set textwidth=0 " Do not wrap words (insert) +set wrap " Wrap words (view) +set showcmd " Show (partial) command in status line. +set showmatch " Show matching brackets. +set ruler " Line and column number of the cursor position +set wildmenu " Enhanced command completion +set visualbell " Use visual bell instead of beeping +set noerrorbells " Disable error bells" +set laststatus=2 " Always show the status lines +set cursorline " Highligh the cursor line +set t_Co=256 " Use 256 colors +set background=dark " Use a dark background + +" Highlight spell errors +hi SpellErrors guibg=red guifg=black ctermbg=red ctermfg=black + +" Toggle spell check with F7 +map :setlocal spell! spell? + +" Behavior +" Ignore these files when completing names and in explorer +set wildignore=.svn,CVS,.git,.hg,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif +set shell=$SHELL " Use current shell for shell commands +set hidden " Enable multiple modified buffers +set history=1000 " History size +set autoread " Automatically read feil that has been changed on disk and doesn't have changes in vim +set backspace=indent,eol,start +set guioptions-=T " Disable toolbar" +set completeopt=menuone,preview +set cinoptions=:0,(s,u0,U1,g0,t0 " Some indentation options ':h cinoptions' for details +set modelines=5 " Number of lines to check for vim: directives at the start/end of file +set autoindent " AutomaticAlly indent new line + +" Indentation +set ts=4 " Number of spaces in a tab +set sw=4 " Number of spaces for indent +set et " Expand tabs into spaces + +" Mouse settings +if has("mouse") + set mouse=a +endif +set mousehide " Hide mouse pointer on insert mode." + +" Search settings +set incsearch " Incremental search +set nohlsearch " Do not highlight search match +set ignorecase " Do case insensitive matching +set smartcase " Do not ignore if search pattern has CAPS + +" Directory settings +set nobackup " Do not write backup files +set noswapfile " Do not write .swp files + +" Stop here if running in restricted mode +if v:progname =~? "rvim" + finish +endif + +" Backup settings +if has("persistent_undo") + silent !mkdir -vp ~/.backup/vim/undo/ > /dev/null 2>&1 + set backupdir=~/.backup/vim,. " List of directories for the backup file + set directory=~/.backup/vim,~/tmp,. " List of directory names for the swap file + set undofile + set undodir=~/.backup/vim/undo/,~/tmp,. +endif + +" Folding +if has("folding") + set foldcolumn=0 " Columns for folding + set foldmethod=indent + set foldlevel=9 + set nofoldenable " Don't fold by default +endif + +if has("user_commands") + let mapleader = "," + let maplocalleader = "\\" +endif + +" Remember last position in file +if has("autocmd") + autocmd BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ exe "normal g`\"" | + \ endif +endif + +" Download and install vim-plug +if empty(glob('~/.vim/autoload/plug.vim')) + silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs + \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + autocmd VimEnter * PlugInstall --sync | source $MYVIMRC +endif + +" Plug-ins +call plug#begin('~/.vim/plugged') +Plug 'vim-scripts/Indent-Guides' +Plug 'ambv/black' +Plug 'bronson/vim-trailing-whitespace' +Plug 'chriskempson/base16-vim' +Plug 'ekalinin/Dockerfile.vim' +Plug 'hynek/vim-python-pep8-indent' +Plug 'python-mode/python-mode' +Plug 'tpope/vim-commentary' +Plug 'tpope/vim-fugitive' +Plug 'tpope/vim-markdown' +Plug 'tmux-plugins/vim-tmux' +Plug 'vim-airline/vim-airline' +Plug 'vim-airline/vim-airline-themes' +Plug 'w0rp/ale' +call plug#end() + +" In this house we obey the laws of airline +let g:airline_powerline_fonts = 1 +let g:airline_enable_fugitive = 1 +let g:airline_theme = 'base16' + +" Use Q for formatting +map Q gq + +" In many terminal emulators the mouse works just fine, thus enable it. +if has('mouse') + set mouse=a +endif + +if has("autocmd") + " Put these in an autocmd group, so that we can delete them easily. + augroup vimrcEx + au! + + " For all text files set 'textwidth' to 78 characters. + autocmd FileType text setlocal textwidth=78 + + " When editing a file, always jump to the last known cursor position. + " Don't do it when the position is invalid or when inside an event handler + " (happens when dropping a file on gvim). + " Also don't do it when the mark is in the first line, that is the default + " position when opening a file. + autocmd BufReadPost * + \ if line("'\"") > 1 && line("'\"") <= line("$") | + \ exe "normal! g`\"" | + \ endif + + augroup END + + " Makefile sanity + autocmd BufEnter ?akefile* set noet ts=8 sw=8 + autocmd BufEnter */debian/rules set noet ts=8 sw=8 +endif " has("autocmd") + +" Various options +set shortmess+=I " Don't show the intro message when starting vim +set complete+=k " Scan files with the 'dictionary' option +set completeopt+=longest +set scrolloff=15 " Minimal number of screen lines above/below the cursor +set linebreak " Wrap long lines at a blank + + +if has("syntax") + syntax on " Enable syntax highlighting + filetype plugin indent on +endif + +:noremap k gk +:noremap j gj + +"" Take care of screen/tmux settings +if &term =~ '^screen' + " tmux will send xterm-style keys when its xterm-keys option is on + execute "set =\e[1;*A" + execute "set =\e[1;*B" + execute "set =\e[1;*C" + execute "set =\e[1;*D" +endif + +" base16 color theme +let base16colorspace=256 +colorscheme base16-solarized-dark