summary refs log tree commit diff
path: root/configs/rcs/vimrc
blob: 92e23b9286946fb4f67f8f9b63a007f63735ff36 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
set encoding=utf-8
scriptencoding utf-8

call plug#begin('~/.local/share/nvim/plugged')
Plug 'fatih/vim-go'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
Plug 'mileszs/ack.vim'
Plug 'plasticboy/vim-markdown'

call plug#end()


set ttyfast       " assume fast terminal and send more chars for smooth redraw
set lazyredraw    " don't redraw while executing macros, register and cmds

syntax on

let &statusline = '[%n] %<%F %m%r%w%y %= (%l,%c) %P of %L'
set laststatus=2           " every window gets a statusline, always(=2)
set scrolloff=5            " scroll edge offset (to keep some context)
set shortmess=a            " abbreviate all(=a) messages when possible
set showcmd                " show last command

" command line completion similar to zsh default
" complete up to longest match and display the list of possible matches
set wildmode=list:longest

set list listchars=tab:»‧,trail:░,precedes:◄,extends:►,nbsp:‧
set fillchars+=vert:\ 

set hidden                      " don't unload but hide buffers when dismissed
set splitbelow splitright       " new window split to below, vsplit to right
set autochdir                   " change cwd to file's in selected buffer
set autoread                    " pickup file changes under unmodified buffer
set autowrite                   " write to before :next, :make, :suspend, ...
set autoindent                  " always-be-indenting
set copyindent                  " copy the existing indenting behavior of file
set expandtab                   " spaces over tabs for indentation
set shiftwidth=2                " without wasting too much screen estate
set softtabstop=-1              " equal to 'shiftwidth'
set ignorecase smartcase        " case insensitive search if all lowercase
set incsearch                   " incrementally move to match and highlight
set hlsearch                    " highlight previous search pattern
set history=1000                " command and search pattern history size
set novisualbell                " use visual bell instead of beeping
set backspace=indent,eol,start  " backspace over everything

let g:mapleader = "\<Space>"

" Detect file types. Load '&rtp/{ftplugin, indent}/<ft>.vim'.
filetype plugin indent on

" 'undofile' is off by default but when enabled keep them together under
" a well-known location instead of same directory with edited files.
set undodir=~/.local/share/vim/.undo/

" Keep viminfo file under ~/.vim instead of home.
set viminfo+=n~/.local/share/vim/.viminfo

" Plugins configuration
let g:ackprg = 'ag --vimgrep --smart-case'

let g:fzf_command_prefix = 'Fzf'
let g:fzf_layout = { 'down': '~20%' }

nmap <C-f> :FzfFiles<cr>
imap <C-f> <esc>:<C-u>FzfFiles<cr>

nmap <C-b> :FzfBuffers<cr>
imap <C-b> <esc>:<C-u>FzfBuffers<cr>

let g:rg_command = '
  \ rg --column --line-number --no-heading --fixed-strings --ignore-case --no-ignore --hidden --follow --color "always"
  \ -g "*.{js,json,php,md,styl,jade,html,config,py,cpp,c,go,hs,rb,conf}"
  \ -g "!{.git,node_modules,vendor}/*" '

augroup filetypedetect
  autocmd BufNewFile,BufRead .tmux.conf*,tmux.conf* setf tmux
  autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4
  autocmd BufNewFile,BufRead *.md setlocal noet tabstop=4 shiftwidth=4
  autocmd BufNewFile,BufRead *.sh setlocal expandtab shiftwidth=2 tabstop=2
  autocmd BufNewFile,BufRead *.proto setlocal expandtab shiftwidth=2 tabstop=2

  autocmd FileType json setlocal expandtab shiftwidth=2 tabstop=2
  autocmd FileType ruby setlocal expandtab shiftwidth=2 tabstop=2
augroup END

" Local additions and overrides
let $LOCALVIMRC = expand('~/.vimrc.local')
if filereadable($LOCALVIMRC) | source $LOCALVIMRC | endif