-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
330 lines (272 loc) · 9.96 KB
/
vimrc
File metadata and controls
330 lines (272 loc) · 9.96 KB
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
" install Plug if it's not already
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
"""""
""""""Plugins
call plug#begin('~/.vim/plugged')
"NERDTree setup
Plug 'scrooloose/nerdtree', {'on': 'NERDTreeToggle'}
"""
"asthetics
Plug 'ryanoasis/vim-devicons'
Plug 'flazz/vim-colorschemes'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
""""""
"editor
Plug 'editorconfig/editorconfig-vim'
Plug 'christoomey/vim-tmux-navigator'
Plug 'junegunn/fzf'
"git
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-fugitive'
Plug 'Xuyuanp/nerdtree-git-plugin'
""""""
"development
" autocomplete
" Plug 'Shougo/neocomplete'
Plug 'nholik/deoplete.nvim'
Plug 'roxma/nvim-yarp'
" Plug 'roxma/vim-hug-neovim-rpc'
"
"Plug 'Shougo/deoplete.nvim', { 'do' : ':UpdateRemotePlugins'}
" syntax checking
Plug 'w0rp/ale'
"csharp
Plug 'OmniSharp/omnisharp-vim'
Plug 'OrangeT/vim-csharp'
Plug 'tpope/vim-commentary'
call plug#end()
""""""Plugins
" For conceal markers.
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
"general setup
colorscheme molokai
syntax enable
set encoding=utf8
set tabstop=4
set softtabstop=4
set expandtab
set shiftwidth=4
set number
set showcmd
set cursorline
filetype indent on
set wildmenu
set lazyredraw
set showmatch
set ruler
set visualbell
set ttyfast
let mapleader = "\\"
set laststatus=2
set noswapfile
set hidden
" clipboard shortcuts allow yanking/putting text into system clipboard
noremap <Leader>y "*y
noremap <Leader>p "*p
noremap <Leader>Y "+y
noremap <Leader>P "+p
" set cursor for modes
" 1 is the blinky block cursor
" 2 is the default (non-blinky) block cursor
" 3 is blinky underscore
" 4 fixed underscore
" 5 pipe bar (blinking)
" 6 fixed pipe bar
let &t_SI = "\<esc>[5 q"
let &t_SR = "\<esc>[3 q"
let &t_EI = "\<esc>[2 q"
" let g:python_host_prog = '/usr/bin/python2'
let g:python_host_prog = '/usr/bin/python2'
let g:python3_host_prog = '/usr/bin/python3'
"set timeoutlen=1000 ttimeoutlen=0 "get rid of delay when hitting esc to leave insert mode
map <C-e> :NERDTreeToggle<CR>
let g:airline_theme='simple'
let g:airline_powerline_fonts = 1
let g:ale_sign_error= '⚠️'
"deoplete setup
let g:deoplete#enable_at_startup = 1
" call deoplete#custom#option('sources', {
" \ 'cs': ['omni'],
" \})
let g:deoplete#sources = {}
let g:deoplete#sources#syntax#min_keyword_length = 3
let g:deoplete#sources._=['buffer', 'file']
let g:deoplete#sources.cs = ['omni' ]
let g:deoplete#keyword_patterns = {}
let g:deoplete#keyword_patterns['default'] = '\h\w*'
if !exists('g:deoplete#omni#input_patterns')
let g:deoplete#omni#input_patterns = {}
endif
let g:deoplete#omni#input_patterns.cs = '.*[^=\);]'
"let g:deoplete#omni#input_patterns.cs = ['\w*']
" Use smartcase.
let g:deoplete#enable_smart_case = 1
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
"inoremap <expr><C-h> deoplete#smart_close_popup()."\<C-h>"
"inoremap <expr><BS> deoplete#smart_close_popup()."\<C-h>"
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function() abort
return deoplete#close_popup() . "\<CR>"
endfunction
"OmniSharpSetup
"let g:syntastic_cs_checkers = ['code_checker'] " use syntastic with omnisharp
let g:OmniSharp_selector_ui = 'fzf' " Use fzf.vim
let g:OmniSharp_server_stdio = 1
" based on defaults provided in docs
" Don't autoselect first omnicomplete option, show options even if there is only
" one (so the preview documentation is accessible). Remove 'preview' if you
" don't want to see any documentation whatsoever.
set completeopt=longest,menuone
",preview
" Fetch full documentation during omnicomplete requests.
" By default, only Type/Method signatures are fetched. Full documentation can
" still be fetched when you need it with the :OmniSharpDocumentation command.
let g:omnicomplete_fetch_full_documentation = 1
" Set desired preview window height for viewing documentation.
" You might also want to look at the echodoc plugin.
"set previewheight=5
" Tell ALE to use OmniSharp for linting C# files, and no other linters.
let g:ale_linters = { 'cs': ['OmniSharp'] }
" Enable snippet completion
" let g:OmniSharp_want_snippet=1
" Fetch semantic type/interface/identifier names on BufEnter and highlight them
let g:OmniSharp_highlight_types = 1
augroup omnisharp_commands
autocmd!
" When Syntastic is available but not ALE, automatic syntax check on events
" (TextChanged requires Vim 7.4)
" autocmd BufEnter,TextChanged,InsertLeave *.cs SyntasticCheck
" Show type information automatically when the cursor stops moving
autocmd CursorHold *.cs call OmniSharp#TypeLookupWithoutDocumentation()
" Update the highlighting whenever leaving insert mode
autocmd InsertLeave *.cs call OmniSharp#HighlightBuffer()
" Alternatively, use a mapping to refresh highlighting for the current buffer
autocmd FileType cs nnoremap <buffer> <Leader>th :OmniSharpHighlightTypes<CR>
" The following commands are contextual, based on the cursor position.
autocmd FileType cs nnoremap <buffer> gd :OmniSharpGotoDefinition<CR>
autocmd FileType cs nnoremap <buffer> <Leader>fi :OmniSharpFindImplementations<CR>
autocmd FileType cs nnoremap <buffer> <Leader>fs :OmniSharpFindSymbol<CR>
autocmd FileType cs nnoremap <buffer> <Leader>fu :OmniSharpFindUsages<CR>
" Finds members in the current buffer
autocmd FileType cs nnoremap <buffer> <Leader>fm :OmniSharpFindMembers<CR>
autocmd FileType cs nnoremap <buffer> <Leader>fx :OmniSharpFixUsings<CR>
autocmd FileType cs nnoremap <buffer> <Leader>tt :OmniSharpTypeLookup<CR>
autocmd FileType cs nnoremap <buffer> <Leader>dc :OmniSharpDocumentation<CR>
autocmd FileType cs nnoremap <buffer> <C-\> :OmniSharpSignatureHelp<CR>
autocmd FileType cs inoremap <buffer> <C-\> <C-o>:OmniSharpSignatureHelp<CR>
" Navigate up and down by method/property/field
autocmd FileType cs nnoremap <buffer> <C-k> :OmniSharpNavigateUp<CR>
autocmd FileType cs nnoremap <buffer> <C-j> :OmniSharpNavigateDown<CR>
" Find all code errors/warnings for the current solution and populate the quickfix window
autocmd FileType cs nnoremap <buffer> <Leader>cc :OmniSharpGlobalCodeCheck<CR>
augroup END
" Contextual code actions (uses fzf, CtrlP or unite.vim when available)
nnoremap <Leader>ca :OmniSharpGetCodeActions<CR>
" Run code actions with text selected in visual mode to extract method
xnoremap <Leader>ca :call OmniSharp#GetCodeActions('visual')<CR>
" Rename with dialog
nnoremap <Leader>nm :OmniSharpRename<CR>
nnoremap <F2> :OmniSharpRename<CR>
" Rename without dialog - with cursor on the symbol to rename: `:Rename newname`
command! -nargs=1 Rename :call OmniSharp#RenameTo("<args>")
nnoremap <Leader>cf :OmniSharpCodeFormat<CR>
" Start the omnisharp server for the current solution
nnoremap <Leader>ss :OmniSharpStartServer<CR>
nnoremap <Leader>sp :OmniSharpStopServer<CR>
" show code actions lightbulb
set updatetime=500
sign define OmniSharpCodeActions text=💡
augroup OSCountCodeActions
autocmd!
autocmd FileType cs set signcolumn=yes
autocmd CursorHold *.cs call OSCountCodeActions()
augroup END
function! OSCountCodeActions() abort
if bufname('%') ==# '' || OmniSharp#FugitiveCheck() | return | endif
if !OmniSharp#IsServerRunning() | return | endif
let opts = {
\ 'CallbackCount': function('s:CBReturnCount'),
\ 'CallbackCleanup': {-> execute('sign unplace 99')}
\}
call OmniSharp#CountCodeActions(opts)
endfunction
function! s:CBReturnCount(count) abort
if a:count
let l = getpos('.')[1]
let f = expand('%:p')
execute ':sign place 99 line='.l.' name=OmniSharpCodeActions file='.f
endif
endfunction
" let g:vimspector_enable_mappings = 'HUMAN'
" packadd! vimspector
"debugging
" function! MicrosoftDocs()
" let type = OmniSharp#py#eval('getFullType()')['type']
" execute "!xdg-open 'https://docs.microsoft.com/en-us/dotnet/api/".type."?view=netcore-2.2'"
" endfunction
" function! SourceLookup()
" let type = OmniSharp#py#eval('getFullType()')['type']
" silent execute '!xdg-open "https://source.dot.net/\#q='.type.'"'
" endfunction
" function! DebugTest()
" call InitDebugger("debugTest", {'name': OmniSharp#py#eval('getFullType()')['type']})
" endfunction
" function! RunTest()
" let ch = ch_open('localhost:4321', { "mode": "json" })
" let obj = { "command": "runTest" }
" let obj["name"] = OmniSharp#py#eval('getFullType()')['type']
" let obj["filename"] = expand('%:p')
" call ch_sendexpr(ch, obj)
" endfunction
" function! StartDebugger()
" call InitDebugger("debugProgram", {})
" endfunction
" function! InitDebugger(command, obj)
" let g:db_files = []
" let ch = ch_open('localhost:4321', { "mode": "json", "callback": "DebuggerHandle", "close_cb": "DebuggerCloseHandle" })
" let obj = a:obj
" let obj["command"] = a:command
" let obj["filename"] = fnamemodify(expand("%"), ":p")
" let breakpoints = sign_getplaced()
" for i in breakpoints
" let inner = i['signs']
" let i['filename'] = fnamemodify(bufname(i['bufnr']), ":p")
" endfor
" let obj["breakpoints"] = breakpoints
" call ch_sendexpr(ch, obj, { "callback": "DebuggerHandle" })
" endfunction
" function! DebuggerHandle(ch, msg)
" " echo "received"
" let cmd = a:msg["command"]
" if cmd == "highlight"
" call add(g:db_files, a:msg["file"])
" execute 'e '.a:msg["file"]
" match
" execute 'match Search /\%'.a:msg["lineNumber"].'l/'
" execute 'normal! '.a:msg["lineNumber"].'G'
" execute 'normal! zz'
"" endif
" if cmd == "clearHighlights"
" match
" endif
" endfunction
" function! DebuggerCloseHandle(ch)
" " echo "closed"
" for db_file in g:db_files
" execute 'e '.db_file
" execute 'match'
" match
" endfor
" endfunction
" nnoremap <F5> :call StartDebugger()