-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
268 lines (236 loc) · 7.11 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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
" Handy vanilla Vim settings
set background=dark
set wildmenu
set wildmode=longest,list
set backspace=indent,eol,start
set laststatus=2
set ruler
set scrolloff=3
set nocompatible
set noswapfile
" Search configuration
set hlsearch
set incsearch
set ignorecase
set smartcase
" Put contents of unnamed register into clipboard.
command Clip call system('xclip -i -selection clipboard', @")
" Paste contents of clipboard into buffer.
command Clop put = system('xclip -o -selection clipboard')
" Enable the Shell command. This runs shell commands and outputs to the
" scratch space.
command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>)
function! s:RunShellCommand(cmdline)
echo a:cmdline
let expanded_cmdline = a:cmdline
for part in split(a:cmdline, ' ')
if part[0] =~ '\v[%#<]'
let expanded_part = fnameescape(expand(part))
let expanded_cmdline = substitute(expanded_cmdline, part, expanded_part, '')
endif
endfor
botright new
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
call setline(1, 'You entered: ' . a:cmdline)
call setline(2, 'Expanded Form: ' .expanded_cmdline)
call setline(3,substitute(getline(2),'.','=','g'))
execute '$read !'. expanded_cmdline
setlocal nomodifiable
1
endfunction
" Ironman mode - I dare you :)
"map <Left> <Nop>
"map <Right> <Nop>
"map <Up> <Nop>
"map <Down> <Nop>
"imap <Left> <Nop>
"imap <Right> <Nop>
"imap <Up> <Nop>
"imap <Down> <Nop>
" Insert unicode ✓ and ✗!
imap <F5> <C-V>u2713
imap <F6> <C-V>u2717
" Save while in insert mode (and same shortcut for 'normal' too)
inoremap <F2> <Esc>:w<CR>
nnoremap <F2> :w<CR>
" Markdown
au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} set filetype=markdown
let g:vim_markdown_toc_autofit = 1
let g:vim_markdown_folding_level = 2
" Better controls for switching between tabs.
nnoremap th :tabfirst<CR>
nnoremap tj :tabnext<CR>
nnoremap tk :tabprev<CR>
nnoremap tl :tablast<CR>
nnoremap tt :tabedit<Space>
nnoremap tn :tabnext<Space>
nnoremap tm :tabm<Space>
nnoremap td :tabclose<CR>
" Better pane navigation
set mouse=a
map <C-Left> <C-W>j
map <C-Down> <C-W>k
map <C-Up> <C-W>h
map <C-Right> <C-W>l
" Indenting things
set autoindent
set expandtab
set smarttab
set shiftwidth=2
set tabstop=2
set cino+=(0"
" Special Python indenting
au FileType python setl sw=4
" Highlight trailing whitespace, or whitespace before a tab
highlight ExtraWhitespace ctermbg=darkred guibg=darkred
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=darkred guibg=darkred
match ExtraWhitespace /\s\+$\| \+\ze\t/
" Strip trailing whitespace on save
autocmd BufWritePre * :%s/\s\+$//e
" Line number toggling
function! NumberToggle()
if(&relativenumber != 1 && &number != 1)
set number
highlight LineNr ctermfg=gray
elseif(&relativenumber != 1 && &number == 1)
set relativenumber
highlight LineNr ctermfg=darkgray
else
set norelativenumber
set nonumber
endif
endfunc
nnoremap <C-n> :call NumberToggle()<CR>
set norelativenumber
set nonumber
" Simple plugin settings
let g:ctrlp_match_func = {'match' : 'matcher#cmatch' }
let g:rainbow_active = 1
let g:sh_no_error = 1
" PyMode settings.
let g:pymode = 1
let g:pymode_lint = 1
let g:pymode_lint_unmodified = 1
let g:pymode_lint_ignore = "E265"
let g:pymode_rope = 0
let g:pymode_doc = 1
let g:pymode_folding = 0
"let g:pymode_python = 'python3'
let g:pymode_options_max_line_length = 79
" Syntastic settings
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
" Disable GCC checking, as it's not feasible with huge codebases.
let g:syntastic_c_checkers=[]
" Go syntax highlighting and stuff.
filetype off
filetype plugin indent off
set rtp+=$GOROOT/misc/vim
filetype plugin indent on
syntax on
" Cscope options:
set csprg=gtags-cscope
set nocsverb
cs add GTAGS
set csverb
"set cscopequickfix=s-,c+,d-,i-,t-,e-
" This one replaces tags with cscope tagging.
set cst
" Cscope shortcuts.
noremap <leader>s :cs<space>f<space>s<space>
map <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
map <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
map <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
" Better navigating for references.
set cscopequickfix=s-,c-,d-,i-,t-,e-
nmap <leader>, :lprevious<CR>
nmap <leader>. :lnext<CR>
nnoremap <C-\>, :lolder<CR>
nnoremap <C-\>. :lnewer<CR>
"nmap <leader>, :lopen<CR>
"nmap <leader>. :lclose<CR>
nmap <C-\>s :lcs f s <C-r><C-w><CR> :lw<CR>
" F5 for buffers list
nmap <f5> :buffers<CR>:buffer<space>
" Ctrl-P options:
set wildignore+=*.tmp,*.swp,*.so,*.zip,*.cache,*.class
let g:ctrlp_custom_ignore = {
\ 'dir': '\v((\.git|\.svn)|/(orlandodocs|publicdocs|build|output))',
\ }
let g:ctrlp_max_files = 910000
let g:ctrlp_use_caching = 1
let g:ctrlp_clear_cache_on_exit = 0
let g:ctrlp_dotfiles = 0
let g:ctrlp_cache_dir = $HOME.'/.cache/ctrlp'
let g:ctrlp_regexp = 1
" Tag searching wth CtrlP
noremap <leader>g :CtrlPGtags<CR>
set rtp+=$HOME/.vim/bundle/CtrlPGtags
" Autocomment
nnoremap <C-\>a :ToggleAutoComment<CR>
nnoremap <leader>a :AutoComment<CR>
" Vundle options:
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" Let Vundle manage itself (required)
Bundle 'VundleVim/Vundle.vim'
" My Bundles:
"
" Github repos
Bundle 'kien/ctrlp.vim'
Bundle 'klen/python-mode'
Bundle 'JazzCore/ctrlp-cmatcher'
Bundle 'rking/ag.vim'
Bundle 'vim-scripts/VimIRC.vim'
Bundle 'derekwyatt/vim-scala'
Bundle 'scrooloose/syntastic'
Plugin 'vimwiki'
Plugin 'rodjek/vim-puppet'
Plugin 'fatih/vim-go'
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'
" status line
Plugin 'bling/vim-airline'
" If you need to change .tmux.conf.statusline, install this plugin, then run
" ':Tmuxline airline' and 'TmuxlineSnapshot! ~/.tmux.statusline.conf
Plugin 'edkolev/tmuxline.vim'
" Gitlab repos - setup an SSH key with Gitlab and run :BundleInstall to
" install these.
"Bundle 'ssh://[email protected]/vimips.git'
"Bundle 'ssh://[email protected]/autocomment.git'
"Bundle 'ssh://[email protected]/ctrlpgtags.git'
call vundle#end()
filetype plugin on " Required for Vundle
"
" Brief help
" :BundleList - list configured bundles
" :BundleInstall(!) - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
" :BundleClean(!) - confirm(or auto-approve) removal of unused bundles
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Bundle command are not allowed..
" vim-airline
let g:airline_powerline_fonts=1
set laststatus=2
set ttimeoutlen=50
let g:airline#extensions#tmuxline#enabled = 0 " Don't override Tmux theme when opening Vim
" Remember position when opening
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
" vim-go
au BufRead,BufNewFile *.go setfiletype go
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_fields = 1
let g:go_highlight_types = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
" Disable visual mode on mouse select
set mouse-=a