-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
236 lines (183 loc) · 4.78 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
"-------------------------------"
" Set up packages with Pathogen "
"-------------------------------"
source ~/dotfiles/vim/bundle/vim-pathogen/autoload/pathogen.vim
execute pathogen#infect('bundle/{}', '~/dotfiles/vim/bundle/{}')
runtime macros/matchit.vim
set nocompatible
if has("autocmd")
filetype plugin indent on
autocmd BufNewFile,BufRead *.es6 set filetype=javascript
"autocmd FileType html,php setlocal expandtab shiftwidth=4 softtabstop=4
end
"----------"
" Settings "
"----------"
set encoding=utf-8
scriptencoding utf-8
set backspace=eol,start,indent
set display+=lastline
set guitablabel=%t
set history=100
set hlsearch
set iskeyword+=-
set laststatus=2
set magic
set number
set relativenumber
set nocursorline
set nowrap
set ruler
set showmatch
set showmode
set textwidth=0
set whichwrap+=<,>,h,l
set wildmenu
set backupdir=~/.vim/tmp/backup
set directory=~/.vim/tmp/swap
set undodir=~/.vim/tmp/undo
set nobackup
set nowritebackup
set noswapfile
"--------------"
" Code folding "
"--------------"
set foldmethod=indent
set foldnestmax=10
set nofoldenable
set foldlevel=2
"---------------------"
" Syntax Highlighting "
"---------------------"
syntax enable
let html_no_rendering=1
"let base16colorspace=256
"colorscheme base16-ocean
set background=dark
set guifont=Hack:h16
highlight Comment cterm=italic
"------------"
" Whitespace "
"------------"
set expandtab
set shiftwidth=2
set smarttab
set tabstop=2
set ai " Auto indent
set si " Smart indent
set wrap " Wrap lines
"----------"
" Mappings "
"----------"
let mapleader="\<Space>"
" Edit vimrc file
nmap <Leader>vr :sp $MYVIMRC<CR>
nmap <Leader>so :source $MYVIMRC<CR>
" Duplicate line
nmap <Leader>d yyp
" Move lines
nmap <Leader>j ddp
nmap <Leader>k kddpk
" Clear line
nmap <Leader>co cc<Esc>
" Open line under current line
nmap <Leader>o o<Esc>
" Tab/pane shortcuts
nmap <Leader>tn :tabnew<CR>
nmap <Leader>tc :tabc<CR>
nmap <Leader>pv :vsplit<CR>
nmap <Leader>ph :split<CR>
nmap <Leader>pc :close<CR>
" Moving in tabs
nmap <C-H> :tabp<CR>
nmap <C-L> :tabn<CR>
" Moving tabs
nmap <Leader>th :tabm -1<CR>
nmap <Leader>tl :tabm +1<CR>
" Exit modes more easily
imap jk <Esc>
imap kj <Esc>
" Quick jump to start/end of lines
nmap <Leader>l $
nmap <Leader>h ^
" Clear highlighted search
nmap <silent> <Leader>/ :nohlsearch<CR>
" Make splits a bit more manageable
nnoremap <Leader>1 :vs<CR><C-w>l
nnoremap <Leader>2 :split<CR><C-w>j
nnoremap <C-Up> :bn<CR>
nnoremap <C-Down> :bp<CR>
" Strip all trailing spaces
nmap <Leader>sw :StripWhitespace<CR>
" Copy/paste inside quotes
nmap <Leader>y yi"
nmap <Leader>p vi"p
cnoreabbrev w. w %:h/
"---------------------"
" Open file in Finder "
"---------------------"
function! s:RevealInFinder()
if filereadable(expand("%"))
let l:command = "open -R %"
elseif getftype(expand("%:p:h")) == "dir"
let l:command = "open %:p:h"
else
let l:command = "open ."
endif
execute ":silent! !" . l:command
" For terminal Vim not to look messed up.
redraw!
endfunction
command! Reveal call <SID>RevealInFinder()
nmap <Leader>r :Reveal<CR>
"---------"
" Plugins "
"---------"
map <C-n> :NERDTreeToggle<CR>
map <Leader>e :NERDTreeFind<CR>
let g:NERDTreeIgnore=['\~$', '^tmp$[[dir]]', '^.git$[[dir]]', '^.sass-cache$[[dir]]', '.DS_Store']
let g:NERDTreeShowHidden=1
let g:NERDSpaceDelims=1
let g:NERDCommentEmptyLines=1
let g:NERDTrimTrailingWhitespace=1
let g:ctrlp_map='<c-p>'
let g:ctrlp_cmd='CtrlP'
let g:ctrlp_switch_buffer=0
let g:ctrlp_working_path_mode=0
let g:ctrlp_use_caching=0
let g:ctrlp_show_hidden=1
if executable('ag')
let g:ackprg='ag --vimgrep --case-sensitive'
let g:ctrlp_user_command='ag %s --nocolor --nogroup --hidden
\ --ignore .git
\ --ignore .svn
\ --ignore .hg
\ --ignore .DS_Store
\ --ignore .svg
\ --ignore "**/*.pyc"
\ -g ""'
endif
cnoreabbrev Ack Ack!
nnoremap <Leader>a :Ack!<Space>
cnoreabbrev Ag Ack!
cnoreabbrev Ag! Ack!
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.map,*.svg
let g:netrw_liststyle=3
let g:airline_powerline_fonts=1
let g:airline#extensions#tabline#enabled=1
let g:airline#extensions#tabline#fnamemod=':t'
let g:airline#extensions#tabline#show_buffers=0
let g:airline#extensions#tabline#fnamecollapse=0
let g:airline#extensions#tabline#show_tab_nr=1
let g:airline#extensions#tabline#tab_nr_type=1 " tab number
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list=1
let g:syntastic_auto_loc_list=1
let g:syntastic_check_on_open=1
let g:syntastic_check_on_wq=0
let g:syntastic_ignore_files=['\.html$', '\c\.h$', '\.css$', '\.hbs', '\.scss', '\.erb']
let g:syntastic_ruby_mri_exec = '~/.rvm/rubies/ruby-2.2.4/bin/ruby'
let g:mustache_abbreviations=1
let g:markdown_fenced_languages=['html', 'python', 'ruby', 'bash=sh', 'css']