-
Notifications
You must be signed in to change notification settings - Fork 3
/
.vimrc
225 lines (188 loc) · 7.03 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
""""""""""""""""""""""
" Plug Setup "
""""""""""""""""""""""
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
call plug#begin()
Plug 'fatih/vim-go'
Plug 'fatih/molokai'
Plug 'AndrewRadev/splitjoin.vim'
Plug 'SirVer/ultisnips'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'scrooloose/nerdtree'
Plug 'scrooloose/nerdcommenter'
Plug 'mileszs/ack.vim'
Plug 'ap/vim-css-color'
call plug#end()
""""""""""""""""""""""
" Settings "
""""""""""""""""""""""
set nocompatible " Enables us Vim specific features
filetype off " Reset filetype detection first ...
filetype plugin indent on " ... and enable filetype detection
syntax on " enable syntax
set ttyfast " Indicate fast terminal conn for faster redraw
set ttymouse=xterm2 " Indicate terminal type for mouse codes
set ttyscroll=3 " Speedup scrolling
set laststatus=2 " Show status line always
set encoding=utf-8 " Set default encoding to UTF-8
set autoread " Automatically read changed files
set autoindent " Enabile Autoindent
set backspace=indent,eol,start " Makes backspace key more powerful.
set incsearch " Shows the match while typing
set hlsearch " Highlight found searches
set noerrorbells " No beeps
set number " Show line numbers
set showcmd " Show me what I'm typing
set noswapfile " Don't use swapfile
set nobackup " Don't create annoying backup files
set splitright " Vertical windows should be split to right
set splitbelow " Horizontal windows should split to bottom
set autowrite " Automatically save before :next, :make etc.
set hidden " Buffer should still exist if window is closed
set noshowmatch " Do not show matching brackets by flickering
set noshowmode " We show the mode with airline or lightline
set ignorecase " Search case insensitive...
set smartcase " ... but not if it begins with upper case
set completeopt=menu,menuone " Show popup menu, even if there is one entry
set pumheight=10 " Completion window max size
set nocursorcolumn " Do not highlight column (speeds up highlighting)
set nocursorline " Do not highlight cursor (speeds up highlighting)
set lazyredraw " Wait to redraw
set number " display line number
set tabstop=4 " spaces for tabs
set shiftwidth=4 " spaces for shifts
set expandtab " convert tabs into spaces
set wrap! " disable text wrap
set synmaxcol=200 " set line max count
set clipboard^=unnamed " copy to clipboard
set clipboard^=unnamedplus
" This enables us to undo files even if you exit Vim.
if has('persistent_undo')
set undofile
set undodir=~/.config/vim/tmp/undo//
endif
" Colorscheme
syntax enable
set t_Co=256
let g:rehash256 = 1
let g:molokai_original = 1
colorscheme molokai
"Bottom bar settings
set noruler
set laststatus=2
set statusline=%<\ %f\ %m%y%=%-35.(Line:\ %l\ of\ %L,\ Col:\ %c%V\ (%P)%)
"""""""""""""""""""""
" Mapping "
"""""""""""""""""""""
let mapleader="\<Space>"
" find and replace
function! VisualFindAndReplace()
:OverCommandLine%s/
endfunction
function! VisualFindAndReplaceWithSelection() range
:'<,'>OverCommandLine s/
endfunction
nnoremap <Leader>fr :call VisualFindAndReplace()<CR>
xnoremap <Leader>fr :call VisualFindAndReplaceWithSelection()<CR>
"Spell check
nnoremap <leader>sc :set spell spelllang=en_us<CR>
nnoremap <leader>ns :set nospell<CR>
"Productivity
inoremap jj <ESC>
nnoremap d "_d
nnoremap x "_x
noremap <leader>s :w<CR>
noremap <leader>q :q<CR>
nnoremap <leader>w :wq<CR>
nnoremap <leader>fq :q!<CR>
nnoremap <leader>gg gg=G``<CR>
nnoremap <C-b> :b#<CR>
nnoremap <leader>u <C-r>
nnoremap <leader>o :noh<CR>
" Tab Buffers
nnoremap [ gT
nnoremap ] gt
" Quick Left and Right
nnoremap <C-h> ^
nnoremap <C-l> $
" Easy toggle
nnoremap <leader>\ :NERDTreeToggle<CR>
" Center n
nnoremap n nzzzv
nnoremap N Nzzzv
" Ack
nnoremap <Leader>F :tabnew <Bar> Ack<Space>
" " And/or abbreviation
abbr TAck tabnew <Bar> Ack
" Split rightward so as not to displace a left NERDTree
"""""""""""""""""""""
" Plugins "
"""""""""""""""""""""
" autocmd VimEnter * NERDTree " open nerdtree automatically
" commenter
let g:NERDSpaceDelims = 1
let g:NERDCompactSexyComs = 1
let g:NERDDefaultAlign = 'left'
let g:NERDCustomDelimiters = {
\ 'jsx': { 'left': '{/*','right': '*/}' },
\ 'typescript.tsx': { 'left': '{/*','right': '*/}' }
\ }
let g:NERDCommentEmptyLines = 1
let g:NERDTrimTrailingWhitespace = 1
" CSS Colors
let g:cssColorVimDoNotMessMyUpdatetime = 1
" vim-go
let g:go_fmt_command = "goimports"
let g:go_autodetect_gopath = 1
let g:go_list_type = "quickfix"
let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_generate_tags = 1
" Open :GoDeclsDir with ctrl-g
nmap <C-g> :GoDeclsDir<cr>
imap <C-g> <esc>:<C-u>GoDeclsDir<cr>
augroup go
autocmd!
" Show by default 4 spaces for a tab
autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4
" :GoBuild and :GoTestCompile
autocmd FileType go nmap <leader>b :<C-u>call <SID>build_go_files()<CR>
" :GoTest
autocmd FileType go nmap <leader>t <Plug>(go-test)
" :GoRun
autocmd FileType go nmap <leader>r <Plug>(go-run)
" :GoDoc
autocmd FileType go nmap <Leader>d <Plug>(go-doc)
" :GoCoverageToggle
autocmd FileType go nmap <Leader>c <Plug>(go-coverage-toggle)
" :GoInfo
autocmd FileType go nmap <Leader>i <Plug>(go-info)
" :GoMetaLinter
autocmd FileType go nmap <Leader>l <Plug>(go-metalinter)
" :GoDef but opens in a vertical split
autocmd FileType go nmap <Leader>v <Plug>(go-def-vertical)
" :GoDef but opens in a horizontal split
autocmd FileType go nmap <Leader>s <Plug>(go-def-split)
" :GoAlternate commands :A, :AV, :AS and :AT
autocmd Filetype go command! -bang A call go#alternate#Switch(<bang>0, 'edit')
autocmd Filetype go command! -bang AV call go#alternate#Switch(<bang>0, 'vsplit')
autocmd Filetype go command! -bang AS call go#alternate#Switch(<bang>0, 'split')
autocmd Filetype go command! -bang AT call go#alternate#Switch(<bang>0, 'tabe')
augroup END
" build_go_files is a custom function that builds or compiles the test file.
" It calls :GoBuild if its a Go file, or :GoTestCompile if it's a test file
function! s:build_go_files()
let l:file = expand('%')
if l:file =~# '^\f\+_test\.go$'
call go#test#Test(0, 1)
elseif l:file =~# '^\f\+\.go$'
call go#cmd#Build(0)
endif
endfunction