-
Notifications
You must be signed in to change notification settings - Fork 6
/
.vimrc
200 lines (171 loc) · 7.39 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
syntax on
filetype plugin on
filetype plugin indent on
""" ---- Settings ----
set autoindent " always set autoindenting on
set autoread
set autowriteall
set copyindent " copy the previous indentation on autoindenting
set expandtab
set hidden
set hlsearch " highlight search terms
set ignorecase " ignore case when searching
set incsearch " show search matches as you type
set number " always show line numbers
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set showmatch " set show matching parenthesis
set smartcase " ignore case if search pattern is all lowercase, case-sensitive otherwise
set nobackup
set nocompatible
set noic
set noswapfile
set nowrap " don't wrap lines
set softtabstop =4
set tabstop =4 " a tab is four spaces
set backspace =indent,eol,start " allow backspacing over everything in insert mode
set shiftwidth =4 " number of spaces to use for autoindenting
set pastetoggle =<F2>
set t_Co =256
set wildignore =*.py[co]
set wildmode =full
set wildmenu
set clipboard =unnamedplus
set tags +=~/.tags/django.tags
set path +=templates
set includeexpr =substitute(v:fname,'\\.','/','g')
set suffixesadd =.py
set laststatus =2
set completeopt =menu
set runtimepath +=~/.vim/bundle/vundle/
call vundle#rc()
let g:closetag_default_xml =1
let g:surround_{char2nr("r")} ="_(u\r)"
let g:syntastic_python_flake8_args ='--ignore=E501,E128,E225'
let g:syntastic_mode_map ={ 'mode': 'passive' }
let g:go_bin_path = expand("~/.bin")
let g:go_snippet_engine = "neosnippet"
let g:go_doc_keywordprg_enabled = 0
colorscheme herald
if filereadable(".lvimrc")
source .lvimrc
endif
autocmd FileType html set ft =htmldjango.html
autocmd FileType htmldjango set ft =htmldjango.html
autocmd FileType coffee setlocal ts =2 sts=2 sw=2 et
autocmd FileType jade setlocal ts =2 sts=2 sw=2 et
autocmd FileType python compiler pyunit
autocmd FileType modula2 set ft =markdown
autocmd FileType go setlocal noexpandtab
au BufNewFile *.go setlocal filetype=go fileencoding=utf-8 fileformat=unix
au BufRead *.go setlocal filetype=go fileencoding=utf-8 fileformat=unix
au BufReadPost *.go setlocal filetype=go fileencoding=utf-8 fileformat=unix
autocmd BufWrite *.go :GoImports
""" ---- Plugins ------
Plugin 'fatih/vim-go'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-ragtag'
Plugin 'tpope/vim-dispatch'
Plugin 'tpope/vim-unimpaired'
Plugin 'tpope/vim-abolish'
Plugin 'majutsushi/tagbar'
Plugin 'scrooloose/nerdcommenter'
Plugin 'Shougo/neocomplete.vim'
Plugin 'Shougo/neosnippet'
Plugin 'Shougo/neosnippet-snippets'
Plugin 'kien/ctrlp.vim'
Plugin 'scrooloose/syntastic'
Plugin 'dhruvasagar/vim-table-mode'
Plugin 'bling/vim-airline'
Plugin 'Chiel92/vim-autoformat'
Plugin 'skwp/greplace.vim'
""" ---- Keybindings ----
" toggle fugitive status
map <silent><leader>s :Gstatus<CR>
" toggle fugitive diff
map <silent><leader>d :Gdiff<CR>
" insert newline but dont enter insert mode
map <silent><leader><Enter> o<Esc>k
" tabbing
map <silent>K :tabnext<CR>
map <silent>J :tabprevious<CR>
" new tab
map <Leader>T :tabnew<CR>
" Project search
map <leader>g :Ggrep <cword>
" remove trailing whitespace
map <leader>w :FixWhitespace<CR>
nmap <F6> :SyntasticToggleMode<CR>
nmap <leader>fp :Git push<CR>
nmap <leader>fm :Git pull<CR>
nmap <leader>fc :Gread<CR>
nmap <leader>fw :Gwrite<CR>
nmap <C-s> :wa<CR>
nmap <leader>x :x<CR>
nmap <F9> :Dispatch<CR>
nnoremap !d :.!date +\%Y-\%m-\%d\ \%H:\%M<CR>
" clear search highlight
nnoremap <leader><space> :noh<CR>
" shortcuts
nnoremap ; :
" open gf in new tab
nnoremap gf <C-W>gf
nnoremap Q gqap
nnoremap <leader>= ea<C-X><C-S>
" clear ^M messup
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
" prevent cursor jumping
noremap <S-Up> <Up>
noremap <S-Down> <Down>
" move between splits
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
"noremap q :close<CR>
" Plugin key-mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: pumvisible() ? "\<C-n>" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: "\<TAB>"
" For snippet_complete marker.
if has('conceal')
set conceallevel=2 concealcursor=i
endif
"Show a list of interfaces which is implemented by the type under your cursor with <leader>s
au FileType go nmap <Leader>f <Plug>(go-implements)
"Show type info for the word under your cursor with <leader>i (useful if you have disabled auto showing type info via g:go_auto_type_info)
au FileType go nmap <Leader>i <Plug>(go-info)
"Open the relevant Godoc for the word under the cursor with <leader>gd or open it vertically with <leader>gv
au FileType go nmap <Leader>gd <Plug>(go-doc)
au FileType go nmap <Leader>gv <Plug>(go-doc-vertical)
"Or open the Godoc in browser
au FileType go nmap <Leader>gb <Plug>(go-doc-browser)
"Run commands, such as go run with <leader>r for the current file or go build and go test for the current package with <leader>b and <leader>t. Display a beautiful annotated source code to see which functions are covered with <leader>c.
au FileType go nmap <leader>r <Plug>(go-run)
au FileType go nmap <leader>b <Plug>(go-build)
au FileType go nmap <leader>t <Plug>(go-test)
au FileType go nmap <leader>c <Plug>(go-coverage)
au FileType go nmap <leader>i <Plug>(go-install)
au FileType go nmap <leader>k <Plug>(go-imports)
"Replace gd (Goto Declaration) for the word under your cursor (replaces current buffer):
au FileType go nmap gd <Plug>(go-def)
"Or open the definition/declaration in a new vertical, horizontal or tab for the word under your cursor:
au FileType go nmap <Leader>ds <Plug>(go-def-split)
au FileType go nmap <Leader>dv <Plug>(go-def-vertical)
au FileType go nmap <Leader>dt <Plug>(go-def-tab)
" modify selected text using combining diacritics
command! -range -nargs=0 Overline call s:CombineSelection(<line1>, <line2>, '0305')
command! -range -nargs=0 Underline call s:CombineSelection(<line1>, <line2>, '0332')
command! -range -nargs=0 DoubleUnderline call s:CombineSelection(<line1>, <line2>, '0333')
command! -range -nargs=0 Strikethrough call s:CombineSelection(<line1>, <line2>, '0336')
function! s:CombineSelection(line1, line2, cp)
execute 'let char = "\u'.a:cp.'"'
execute a:line1.','.a:line2.'s/\%V[^[:cntrl:]]/&'.char.'/ge'
endfunction