-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
237 lines (192 loc) · 5.27 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
237
" Removes vi compatibility
set nocompatible
" Vundle
filetype off
set encoding=utf-8
set rtp+=~/.dotfiles/bundle/Vundle.vim
call vundle#begin()
" Essentials
Plugin 'gmarik/Vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'itchyny/lightline.vim'
Plugin 'editorconfig/editorconfig-vim'
Plugin 'fholgado/minibufexpl.vim'
Plugin 'tpope/vim-surround'
Plugin 'terryma/vim-expand-region'
Plugin 'elzr/vim-json'
Plugin 'godlygeek/tabular'
Plugin 'BufOnly.vim'
Plugin 'mileszs/ack.vim'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'kshenoy/vim-signature'
Plugin 'unblevable/quick-scope'
Plugin 'sheerun/vim-polyglot'
Plugin 'Valloric/YouCompleteMe'
Plugin 'tpope/vim-commentary'
Plugin 'w0rp/ale'
" Theme
Plugin 'altercation/vim-colors-solarized'
" Python
Plugin 'nvie/vim-flake8'
" Go
Plugin 'fatih/vim-go'
" Clojure
Plugin 'guns/vim-sexp'
Plugin 'tpope/vim-sexp-mappings-for-regular-people'
Plugin 'tpope/vim-fireplace'
Plugin 'raymond-w-ko/vim-niji'
call vundle#end()
runtime macros/matchit.vim
filetype plugin indent on
" Load theme
syntax enable
set background=dark
let g:solarized_termcolors = 16
let g:solarized_termtrans = 1
colorscheme solarized
" Visual stuff
set number
set relativenumber
set title
set laststatus=2
set list
set listchars=tab:>.,trail:.,extends:#,nbsp:.
autocmd filetype html,xml set listchars-=tab:>.
autocmd filetype go set nolist
" Buffer
set hidden
" Indentation
set nowrap
set tabstop=4
set shiftwidth=4
set shiftround
set shiftwidth=4
set smarttab
set expandtab
set smartindent
set pastetoggle=<F2>
filetype indent plugin on
" Searching
set showmatch
set smartcase
set hlsearch
set incsearch
" Alerts
set noerrorbells
set visualbell
" Backups and history
set nobackup
set undolevels=1000
set noswapfile
" Ignore
set wildignore+=node_modules/,__pycache__
" Mouse
set mouse=a
" Keyboard
set backspace=indent,eol,start
" Tabs
nmap <F7> :tabp<CR>
nmap <F8> :tabn<CR>
" NERDTree
nmap <F5> :NERDTreeToggle<CR>
let NERDTreeIgnore=['\.pyc$', '\.rbc$', '\~$', '\.DS_Store$']
let NERDTreeShowHidden=1
" Code completion
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
" Highlighting for various file types
au BufRead,BufNewFile *.twig set filetype=jinja
au BufRead,BufNewFile *.twig set filetype=htmljinja
au BufRead,BufNewFile *.html set filetype=jinja
au BufRead,BufNewFile *.html set filetype=htmljinja
au BufRead,BufNewFile Vagrantfile set filetype=ruby
" Command aliases
cnoreabbrev nt NERDTree
" Fix for syntax highlighting to appear correctly
autocmd BufEnter * :syntax sync fromstart
autocmd BufEnter * :syntax sync minlines=99999
" Disabled arrows
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
imap <up> <nop>
imap <down> <nop>
imap <left> <nop>
imap <right> <nop>
" Remapped split pane movement bindings
nmap <silent> <c-k> :wincmd k<CR>
nmap <silent> <c-j> :wincmd j<CR>
nmap <silent> <c-h> :wincmd h<CR>
nmap <silent> <c-l> :wincmd l<CR>
" Remapped save to Ctrl+s
map <C-s> <esc>:w<CR>
imap <C-s> <esc>:w<CR>
" CtrlP
let g:ctrlp_user_command = 'ag %s -l --hidden --nocolor --ignore .git -g ""'
set runtimepath^=~/.dotfiles/bundle/ctrlp
nnoremap <silent> <c-p> :ClearCtrlPCache<cr>\|:CtrlP<cr>
" ack.vim
let g:ackprg = 'ag --vimgrep --smart-case'
" vim-go
let go_highlight_space_tab_error = 0
let go_highlight_trailing_whitespace_error = 0
let g:go_fmt_command = "goimports"
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
" vim-markdown
let g:vim_markdown_folding_disabled = 1
" vim-json
let g:vim_json_syntax_conceal = 0
" quick-scope
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
" lightline
" Prefixes filenames in tabs with folder in case there are multiple tabs with
" the same name open at once.
"
" Taken from https://github.com/itchyny/lightline.vim/issues/43
function! MyTabFilename(n)
let buflist = tabpagebuflist(a:n)
let winnr = tabpagewinnr(a:n)
let bufnum = buflist[winnr - 1]
let bufname = expand('#'.bufnum.':t')
let buffullname = expand('#'.bufnum.':p')
let buffullnames = []
let bufnames = []
for i in range(1, tabpagenr('$'))
if i != a:n
let num = tabpagebuflist(i)[tabpagewinnr(i) - 1]
call add(buffullnames, expand('#' . num . ':p'))
call add(bufnames, expand('#' . num . ':t'))
endif
endfor
let i = index(bufnames, bufname)
if strlen(bufname) && i >= 0 && buffullnames[i] != buffullname
return substitute(buffullname, '.*/\([^/]\+/\)', '\1', '')
else
return strlen(bufname) ? bufname : '[No Name]'
endif
endfunction
function! LightLineFilename()
return expand('%')
endfunction
let g:lightline = {
\ 'colorscheme': 'solarized',
\ 'tab_component_function': {
\ 'filename': 'MyTabFilename',
\ },
\ 'component_function': {
\ 'filename': 'LightLineFilename'
\ }
\ }
" ALE
let g:ale_lint_on_text_changed = 'never'