diff --git a/.vimrc b/.vimrc index e2091f4..542f681 100644 --- a/.vimrc +++ b/.vimrc @@ -59,7 +59,9 @@ set smartcase Bundle 'Chiel92/vim-autoformat' Bundle 'gmarik/vundle' Bundle 'scrooloose/nerdtree' +Bundle 'scrooloose/syntastic' Bundle 'leafgarland/typescript-vim' +Bundle 'SirVer/ultisnips' " My Bundles here: " @@ -73,6 +75,8 @@ Bundle 'https://github.com/klen/python-mode.git' Bundle 'https://github.com/godlygeek/tabular.git' Bundle 'taglist.vim' Bundle 'mattn/emmet-vim' +Bundle 'tpope/vim-dispatch' +Bundle 'OmniSharp/omnisharp-vim' let g:JSHintHighlightErrorLine = 0 let g:miniBufExplForceSyntaxEnable = 1 @@ -176,3 +180,124 @@ filetype plugin indent on set tags+=/home/fergalm/.vim/tags autocmd Filetype java setlocal omnifunc=javacomplete#Complete let g:SuperTabDefaultCompletionType = 'context' + +"OmniSharp stuff + +let g:UltiSnipsListSnippets ="" +let g:UltiSnipsJumpForwardTrigger="" +let g:UltiSnipsJumpBackwardTrigger="" + +"This is the default value, setting it isn't actually necessary +let g:OmniSharp_host = "http://localhost:2000" + +"Set the type lookup function to use the preview window instead of the status line +"let g:OmniSharp_typeLookupInPreview = 1 + +"Timeout in seconds to wait for a response from the server +let g:OmniSharp_timeout = 1 + +"Showmatch significantly slows down omnicomplete +"when the first match contains parentheses. +set noshowmatch + +"Super tab settings - uncomment the next 4 lines +"let g:SuperTabDefaultCompletionType = 'context' +"let g:SuperTabContextDefaultCompletionType = "" +"let g:SuperTabDefaultCompletionTypeDiscovery = ["&omnifunc:","&completefunc:"] +"let g:SuperTabClosePreviewOnPopupClose = 1 + +"don't autoselect first item in omnicomplete, show if only one item (for preview) +"remove preview if you don't want to see any documentation whatsoever. +set completeopt=longest,menuone,preview +" Fetch full documentation during omnicomplete requests. +" There is a performance penalty with this (especially on Mono) +" 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_documentation=1 + +"Move the preview window (code documentation) to the bottom of the screen, so it doesn't move the code! +"You might also want to look at the echodoc plugin +set splitbelow + +" Get Code Issues and syntax errors +let g:syntastic_cs_checkers = ['syntax', 'semantic', 'issues'] +" If you are using the omnisharp-roslyn backend, use the following +" let g:syntastic_cs_checkers = ['code_checker'] +augroup omnisharp_commands + autocmd! + + "Set autocomplete function to OmniSharp (if not using YouCompleteMe completion plugin) + autocmd FileType cs setlocal omnifunc=OmniSharp#Complete + + " Synchronous build (blocks Vim) + "autocmd FileType cs nnoremap :wa!:OmniSharpBuild + " Builds can also run asynchronously with vim-dispatch installed + autocmd FileType cs nnoremap b :wa!:OmniSharpBuildAsync + " automatic syntax check on events (TextChanged requires Vim 7.4) + autocmd BufEnter,TextChanged,InsertLeave *.cs SyntasticCheck + + " Automatically add new cs files to the nearest project on save + autocmd BufWritePost *.cs call OmniSharp#AddToProject() + + "show type information automatically when the cursor stops moving + autocmd CursorHold *.cs call OmniSharp#TypeLookupWithoutDocumentation() + + "The following commands are contextual, based on the current cursor position. + + autocmd FileType cs nnoremap gd :OmniSharpGotoDefinition + autocmd FileType cs nnoremap fi :OmniSharpFindImplementations + autocmd FileType cs nnoremap ft :OmniSharpFindType + autocmd FileType cs nnoremap fs :OmniSharpFindSymbol + autocmd FileType cs nnoremap fu :OmniSharpFindUsages + "finds members in the current buffer + autocmd FileType cs nnoremap fm :OmniSharpFindMembers + " cursor can be anywhere on the line containing an issue + autocmd FileType cs nnoremap x :OmniSharpFixIssue + autocmd FileType cs nnoremap fx :OmniSharpFixUsings + autocmd FileType cs nnoremap tt :OmniSharpTypeLookup + autocmd FileType cs nnoremap dc :OmniSharpDocumentation + "navigate up by method/property/field + autocmd FileType cs nnoremap :OmniSharpNavigateUp + "navigate down by method/property/field + autocmd FileType cs nnoremap :OmniSharpNavigateDown + +augroup END + + +" this setting controls how long to wait (in ms) before fetching type / symbol information. +set updatetime=500 +" Remove 'Press Enter to continue' message when type information is longer than one line. +set cmdheight=2 + +" Contextual code actions (requires CtrlP or unite.vim) +nnoremap :OmniSharpGetCodeActions +" Run code actions with text selected in visual mode to extract method +vnoremap :call OmniSharp#GetCodeActions('visual') + +" rename with dialog +nnoremap nm :OmniSharpRename +nnoremap :OmniSharpRename +" rename without dialog - with cursor on the symbol to rename... ':Rename newname' +command! -nargs=1 Rename :call OmniSharp#RenameTo("") + +" Force OmniSharp to reload the solution. Useful when switching branches etc. +nnoremap rl :OmniSharpReloadSolution +nnoremap cf :OmniSharpCodeFormat +" Load the current .cs file to the nearest project +nnoremap tp :OmniSharpAddToProject + +" (Experimental - uses vim-dispatch or vimproc plugin) - Start the omnisharp server for the current solution +nnoremap ss :OmniSharpStartServer +nnoremap sp :OmniSharpStopServer + +" Add syntax highlighting for types and interfaces +nnoremap th :OmniSharpHighlightTypes +"Don't ask to save when changing buffers (i.e. when jumping to a type definition) +set hidden + +" Enable snippet completion, requires completeopt-=preview +let g:OmniSharp_want_snippet=1 + + + +"End OmniSharp stuff