-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc_old
295 lines (222 loc) · 8.13 KB
/
.vimrc_old
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
"#Set things up for vundle
" git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
" :PluginInstall
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'vim-scripts/taglist.vim'
" requred in bash for ctrl+s: stty stop undef # to unmap ctrl-s
" open ipython qtconsole
" run :IPython
Plugin 'ivanov/vim-ipython'
" toggles comments with gc
Plugin 'tpope/vim-commentary.git'
" switches between header and source
Plugin 'vim-scripts/a.vim.git'
" syntax
Plugin 'vim-scripts/scons.vim.git'
Plugin 'vim-scripts/SWIG-syntax.git'
" opening companion files
" might be better than a.vim?
Plugin 'derekwyatt/vim-fswitch'
" settings are in .vim/after/plugin/fswitch.vim
" awesome motion commands
Plugin 'Lokaltog/vim-easymotion'
Bundle 'majutsushi/tagbar'
" shows multiple files nicely
" <F1> for help doesn't work
" doesn't show vim leader (taglist does)
" required for vim-clang-format
Bundle 'kana/vim-operator-user.git'
" formatting for c, c++ files
Bundle 'rhysd/vim-clang-format'
" python lint, lots of other stuff
Bundle 'klen/python-mode'
call vundle#end()
filetype plugin indent on
" end vundle stuff
" TODO: move this to c files stuff?
""" clang format options ---------------------------------
let g:clang_format#command = "clang-format-3.6"
let g:clang_format#style_options = {
\ "AccessModifierOffset" : -4,
\ "AllowShortIfStatementsOnASingleLine" : "true",
\ "AlwaysBreakTemplateDeclarations" : "true",
\ "ColumnLimit" : 110,
\ "Standard" : "C++11"}
" map to <Leader>cf in C++ code
autocmd FileType c,cpp,objc nnoremap <buffer><Leader>f :<C-u>ClangFormat<CR>
autocmd FileType c,cpp,objc vnoremap <buffer><Leader>f :ClangFormat<CR>
" if you install vim-operator-user
autocmd FileType c,cpp,objc map <buffer><Leader>x <Plug>(operator-clang-format)
" Toggle auto formatting:
nmap <Leader>C :ClangFormatAutoToggle<CR>
" "--------- YouCompleteMe options ------------------------
" let g:ycm_register_as_syntastic_checker = 1 "default 1
" let g:Show_diagnostics_ui = 1 "default 1
" "will put icons in Vim's gutter on lines that have a diagnostic set.
" "Turning this off will also turn off the YcmErrorLine and YcmWarningLine
" "highlighting
" let g:ycm_enable_diagnostic_signs = 1 " signs in gutter
" let g:ycm_enable_diagnostic_highlighting = 1
" let g:ycm_always_populate_location_list = 1 "default 0
" let g:ycm_open_loclist_on_ycm_diags = 1 "default 1
" let g:ycm_complete_in_strings = 1 "default 1
" let g:ycm_collect_identifiers_from_tags_files = 1 "default 0
" let g:ycm_global_ycm_extra_conf="~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py"
" let g:ycm_confirm_extra_conf = 0 "ask before loading, security issue
" let g:ycm_goto_buffer_command = 'same-buffer' "[ 'same-buffer', 'horizontal-split', 'vertical-split', 'new-tab' ]
" let g:ycm_filetype_whitelist = { '*': 1 } " only work on certain filetypes?
" let g:ycm_key_invoke_completion = '<C-Space>'
" " fixed unreadable #include errors in YCM
" highlight link YcmErrorSection Error
" nnoremap <F11> :YcmForceCompileAndDiagnostics <CR>
" "--------- END YouCompleteMe options ------------------------
set backspace=2 "make it work like other aps(?)
set shiftwidth=4
set tabstop=4
set softtabstop=4
set smarttab
set expandtab
" autocompletion of file browsing
set wildmenu
set wildmode=longest:list
set title " show name of file in tab
" show white space?
set list
set listchars=tab:>.,trail:.,extends:#,nbsp:.
" avoid hitting Esc so much
inoremap jk <C-[>
" inoremap kj <C-[>
" inoremap Jk <C-[>
" inoremap Kj <C-[>
" inoremap jK <C-[>
" inoremap kJ <C-[>
" inoremap JK <C-[>
" inoremap KJ <C-[>
" C-[ is better than Esc, not clear why
imap <silent> <Down> <C-o>gj
imap <silent> <Up> <C-o>gk
nmap <silent> <Down> gj
nmap <silent> <Up> gk
set number
nnoremap <F2> :set nonumber!<CR>
set pastetoggle=<F2>
" tab movement
nnoremap <C-I> :tabprev<CR>
nnoremap <C-O> :tabnext<CR>
inoremap <C-I> <Esc>:tabprev<CR>
inoremap <C-O> <Esc>:tabnext<CR>
" split movement
nmap <C-K> <C-w><Up>
nmap <C-J> <C-w><Down>
nmap <C-L> <C-w><Right>
nmap <C-H> <C-w><Left>
set splitbelow
set splitright
" window resizing
nnoremap <silent> + :exe "resize " . (winheight(0) * 3/2)<CR>
nnoremap <silent> - :exe "resize " . (winheight(0) * 2/3)<CR>
""" MOVE THIS TO PYTHON FILE -------------------
""" python-mode mappings ----------------------------
let g:pymode_doc_key = 'K'
let g:pymode_rope_completion = 0
let g:pymode_rope_lookup_project = 0
" syntax highlighting
let g:pymode_syntax = 1
let g:pymode_syntax_all = 1
let g:pymode_syntax_indent_errors = g:pymode_syntax_all
let g:pymode_syntax_space_errors = g:pymode_syntax_all
" let g:pymode_folding = 0 " comletely disable folding
set foldlevelstart=2
" "Lint
let g:pymode_lint = 1
" let g:pymode_lint_checker = "pylint, pep8" " mccabe, pyflakes, others?
let g:pymode_lint_checker = "flake8" " mccabe, pyflakes, others?
let g:pymode_lint_write = 1 " auto check on save
let g:pymode_lint_config = '$HOME/.vim/pylint.rc'
let g:pymode_lint_options_pep8 = {'max_line_length': 110} " if no config file
" then draw the line in the right place
let g:pymode_options_max_line_length = g:pymode_lint_options_pep8['max_line_length']
highlight ColorColumn term=reverse cterm=reverse gui=reverse " gray
""" easymotion mappings -----------------------------
" let g:EasyMotion_do_mapping = 1 " Disable default mappings
" Jump to anywhere you want with minimal keystrokes, with just one key binding
nmap <Space> <Plug>(easymotion-s)
" s2 also an option
let g:EasyMotion_smartcase = 1
" JK motions: Line motions
" somehow these get over written
nmap <Leader>j <Plug>(easymotion-j)
nmap <Leader>k <Plug>(easymotion-k)
" easy way to make vertical splits bigger
nnoremap <C-n> <C-w>>
" for some reason <C-n> doesn't work
" for interaction with ipython, needs running ipython qtconsole and :IPython
nnoremap <silent> <F4> :silent w <CR>:silent python run_this_file()<CR>
inoremap <F4> <ESC>:w <CR>:python run_this_file()<CR>
" search options
set incsearch
set hlsearch
" get rid of highlighting
nnoremap <silent><CR> :nohlsearch<CR><CR>
" not sure if these are needed
" highlight NonText guibg=#060606
" highlight Folded guibg=#0A0A0A guifg=#9090D0
" complete options (what does this set?)
set completeopt=menu,menuone
" leader key
let mapleader=","
" Spellcheck trigger
nmap <silent> <leader>sp :set spell!<CR>
" Key mapping for simple .vimrc editing
nmap <silent> <leader>ev :tabe $MYVIMRC<CR>
" Source .vimrc file
map <leader>sv :source $MYVIMRC<CR>
" Open tag bar
map <silent> <leader>l :TagbarToggle<CR>
" Open taglist, does multiple buffers
map <silent> <leader>; :TlistToggle<CR>
" Run ctags - read by YCM
map <leader>tg :! ctags -R .<CR>
map <leader>fp :PymodeLintAuto<CR>
" file types to recognize
au BufNewFile,BufRead SCons* set filetype=scons
au BufNewFile,BufRead CMake* set filetype=cmake
au BufNewFile,BufRead *.i set filetype=swig
au BufNewFile,BufRead *.swig set filetype=swig
au bufnewfile,bufread *.ino set filetype=c " arduino files
autocmd BufRead,BufNewFile *.launch setfiletype roslaunch
autocmd FileType scons set commentstring=#\ %s
autocmd FileType cmake set commentstring=#\ %s
autocmd FileType cpp set commentstring=//\ %s
autocmd FileType swig set commentstring=//\ %s
autocmd FileType c set commentstring=//\ %s
" a.vim settings
" prevent opening file if not found
let g:alternateNoDefaultAlternate=1
" allow sudo write
cmap w!! w !sudo tee > /dev/null %
" close menu (doesn't work on everything)
autocmd CursorMovedI * if pumvisible() == 0|silent! pclose|endif
autocmd InsertLeave * if pumvisible() == 0|silent! pclose|endif
" Execution
nnoremap fd :exec 'w' <cr> :exec '! python %' <cr>
nnoremap <buffer> ! :exec '! python %' <cr>
nnoremap <buffer> @ :exec 'w' <cr>
nnoremap <buffer> > <C-w>>
nnoremap <buffer> < <C-w><
command R !./%
map <leader>a oassert(False)<ESC>
map <leader>p oprint<ESC>
map <leader>w oraw_input("break")<ESC>
command! -nargs=1 SS let @/ = '\V'.escape(<q-args>, '\')
syntax enable
colorscheme monokai
" Maps change window keys to ctrl+h,j,k,l
map <C-J> <C-W>j<C-W>_
map <C-K> <C-W>k<C-W>_
nmap <c-h> <c-w>h<c-w><Bar>
nmap <c-l> <c-w>l<c-w><Bar>