-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc
182 lines (141 loc) · 4.31 KB
/
vimrc
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
set nocompatible
filetype off
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
set rtp+=/usr/local/opt/fzf
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'junegunn/goyo.vim'
Plugin 'w0rp/ale'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'altercation/vim-colors-solarized'
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-sensible'
Plugin 'plasticboy/vim-markdown'
Plugin 'tpope/vim-surround'
Plugin 'junegunn/fzf.vim'
Plugin 'pangloss/vim-javascript'
Plugin 'mxw/vim-jsx'
Plugin 'junegunn/vim-easy-align'
Plugin 'nathangrigg/vim-beancount'
Plugin 'StanAngeloff/php.vim'
Plugin 'tpope/vim-rhubarb'
Plugin 'rodjek/vim-puppet'
Plugin 'rizzatti/dash.vim'
Plugin 'fatih/vim-go'
call vundle#end()
" Set leader to comma
let mapleader=","
" Enable syntax highlighting
syntax on
" Enable filetype detection. Disabled by default on some Linux distros.
filetype plugin indent on
" Enable Airline (statusbar)
let g:airline#extensions#tabline#enabled=1
" Display line numbers
set number
" Set a visual indicator for line wrap
set colorcolumn=80
" To enable the full solarized colorscheme, touch this file.
" Otherwise, smart default to the reduced colorscheme.
if empty(glob("~/.vim/solarized"))
let g:solarized_termcolors=256
endif
" Set up solarized colorscheme
let &background = $VIMBG
silent! colorscheme solarized
" Move around buffers
nmap <leader>. :bprevious<cr>
nmap <leader>/ :bnext<cr>
" Map a shortcut to delete trailing whitespace
nmap <leader>ws :%s/\s\+$//e<cr>
" Set document width to 80 characters, but don't autowrap
set textwidth=80
set nowrap
" Show 7 lines above/below the cursor
set scrolloff=7
" Case insensitive search for lowercase query, case sensitive for mixed case
set ignorecase
set smartcase
" Highlight search results
set hlsearch
" Turn off backups/swap files, I find them useless/annoying.
set nobackup
set nowritebackup
set noswapfile
" Switch buffers without saving
set hidden
" Use 4 spaces instead of 1 tab
set shiftwidth=4
set tabstop=4
set expandtab
" Use spacebar to search
nmap <space> /
" Disable highlights from search via ,<enter>
nmap <silent> <leader><cr> :noh<cr>
" Return to last edit position when opening files
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Pressing ,ss will toggle and untoggle spell checking
nmap <leader>ss :setlocal spell!<cr>
" Fast edit vimrc
nmap <leader>e :e ~/.vimrc<cr>
" Goyo (distraction free editing) shortcut
nmap <silent> <leader>zz :Goyo<cr>
" Disable obnoxious error bells
set noerrorbells visualbell t_vb=
" Copy/paste to system clipboard
nmap <leader>yy "*yy
vmap <leader>yy "*y
nmap <leader>dd "*dd
vmap <leader>dd "*d
map <leader>PP "*P
map <leader>pp "*p
" Fast saving
nmap <leader>w :w<cr>
imap <leader>ww <esc>:w<cr>
" Change working directory to current file path
nmap <leader>cd :cd %:p:h<cr>
" Configure certain filetypes to indent two spaces instead of 4
autocmd Filetype ruby setlocal ts=2 sts=2 sw=2
autocmd Filetype javascript setlocal ts=2 sts=2 sw=2
autocmd Filetype json setlocal ts=2 sts=2 sw=2
autocmd Filetype beancount setlocal ts=2 sts=2 sw=2
autocmd Filetype yaml setlocal ts=2 sts=2 sw=2
" Switch 0 and ^
nnoremap 0 ^
nnoremap ^ 0
" Stop vim-markdown and vim-beancount from folding
let g:vim_markdown_folding_disabled = 1
let g:vim_beancount_folding_disabled = 1
" Remap Y to be consistent with D, C, etc
nmap Y y$
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
" Highlight php @params, etc. inside docblocks
function! PhpSyntaxOverride()
hi! def link phpDocTags phpDefine
hi! def link phpDocParam phpType
endfunction
augroup phpSyntaxOverride
autocmd!
autocmd FileType php call PhpSyntaxOverride()
augroup END
" Q normally drops you into Ex mode. Nobody wants that.
map Q <Nop>
" allow setting a light background via env variable
if !empty($LIGHT_COLORS)
set bg=light
endif
" Used to use Ctrl-P but switched to fzf for better days
nmap <c-p> :GFiles<cr>
" For speed on large files, don't lint on text change or on fopen
let g:ale_lint_on_text_changed = 'never'
let g:ale_lint_on_enter = 0
let g:ale_linters = {'javascript': ['eslint']}