Skip to content

Instantly share code, notes, and snippets.

@nidev
Created March 13, 2018 13:02
Show Gist options
  • Save nidev/c62310bcd7dd20cd5709e75d6a4b2123 to your computer and use it in GitHub Desktop.
Save nidev/c62310bcd7dd20cd5709e75d6a4b2123 to your computer and use it in GitHub Desktop.
My recent vimrc (Vundle, omnisharp-roslyn, language-server, supertab, syntastic, vim-erlang, powerline)
set nocompatible " be iMproved, required
filetype off " required
set background=dark
set ts=8
set sts=4
set sw=4
set nu
set smartindent
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
let cwd = getcwd()
let g:lsc_server_commands = {
\ 'dart': 'dart_language_server',
\ 'go': 'go-langserver -gocodecompletion',
\ 'c': "/home/nidev/.langserver/cquery/build/release/bin/cquery --init=\"{\\\"cacheDirectory\\\": \\\"/tmp/cquery\\\"}\"",
\ 'cpp': "/home/nidev/.langserver/cquery/build/release/bin/cquery --init=\"{\\\"cacheDirectory\\\": \\\"/tmp\\\"}\""
\ }
let g:lsc_enable_autocomplete = v:true
let g:lsc_auto_map = v:true " Use defaults
" ... or set only the keys you want mapped, defaults are:
"let g:lsc_auto_map = {
" \ 'GoToDefinition': '<C-]>',
" \ 'FindReferences': 'gr',
" \ 'FindCodeActions': 'ga',
" \ 'DocumentSymbol': 'go',
" \ 'ShowHover': 'K',
" \ 'Completion': '<C-L>',
" \}
" Syntastic options
let g:syntastic_go_checkers = ['go', 'gofmt', 'golint', 'gometalinter', 'govet']
let g:syntastic_cpp_compiler_options = ' -std=c++11 -stdlib=libc++'
let g:syntastic_python_checkers = ['pylin3']
" Syntastic overridden function for resizing list
" See: https://github.com/vim-syntastic/syntastic/issues/1678
function! SyntasticCheckHook(errors)
if !empty(a:errors)
let g:syntastic_loc_list_height = min([len(a:errors), 5])
endif
endfunction
" Omnisharp preconfiguration
let g:OmniSharp_selector_ui = 'unite' " Use unite.vim
" let g:OmniSharp_server_type = "roslyn"
let g:OmniSharp_host = "http://localhost:2000"
let g:OmniSharp_server_path = "/home/nidev/.langserver/omnisharp-roslyn/bin/Debug/OmniSharp.Http/net46/OmniSharp.exe"
"Disable sln detection for dotnet core projects
"NOTE: Actually, you need to patch OmniSharp.vim since it puts relative path
"for solution/csproj path. It causes critical error with OmniSharp-roslyn
let g:OmniSharp_start_without_solution = 1
"Set the type lookup function to use the preview window instead of the status line
let g:OmniSharp_typeLookupInPreview = 0
"Timeout in seconds to wait for a response from the server
let g:OmniSharp_timeout = 1
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
" Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
" Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}
" Custom Plugins
Plugin 'Heorhiy/VisualStudioDark.vim'
Plugin 'natebosch/vim-lsc'
Plugin 'dart-lang/dart-vim-plugin'
Plugin 'vim-erlang/vim-erlang-runtime'
Plugin 'vim-erlang/vim-erlang-omnicomplete'
Plugin 'vim-erlang/vim-erlang-skeletons'
Plugin 'vim-syntastic/syntastic'
Plugin 'ervandew/supertab' " required for omnisharp-vim, vim-erlang-omnicom
Plugin 'OrangeT/vim-csharp'
Plugin 'tpope/vim-dispatch'
Plugin 'Shougo/vimproc.vim'
Plugin 'Shougo/unite.vim'
Plugin 'OmniSharp/omnisharp-vim' " may need to be replaced with mine
Plugin 'SirVer/ultisnips' " required for omnisharp-vim + supertab
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'
" Powerline Bundle
Bundle 'powerline/powerline', {'rtp': 'powerline/bindings/vim/'}
" All of your Plugins must be added before the following line
call vundle#end() " required
" filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
colorscheme VisualStudioDark
" Configure powerline for Vim
python from powerline.vim import setup as powerline_setup
python powerline_setup()
python del powerline_setup
set laststatus=2 " always show
let g:syntastic_always_populate_loc_list = 0
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
" OmniSharp won't work without this setting
filetype plugin on
"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 = "<c-x><c-o>"
let g:SuperTabDefaultCompletionTypeDiscovery = ["&omnifunc:<c-x><c-o>","&completefunc:<c-x><c-n>"]
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
set completeopt=menuone
" 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_full_documentation=0
"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
" NOTE: Omitting 'semantic' will cause malfunctioning of semantic
" autocompletion on .NET core projects which does not have sln file
let g:syntastic_cs_checkers = ['semantic', '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 <F5> :wa!<cr>:OmniSharpBuild<cr>
" Builds can also run asynchronously with vim-dispatch installed
autocmd FileType cs nnoremap <leader>b :wa!<cr>:OmniSharpBuildAsync<cr>
" 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<cr>
autocmd FileType cs nnoremap <leader>fi :OmniSharpFindImplementations<cr>
autocmd FileType cs nnoremap <leader>ft :OmniSharpFindType<cr>
autocmd FileType cs nnoremap <leader>fs :OmniSharpFindSymbol<cr>
autocmd FileType cs nnoremap <leader>fu :OmniSharpFindUsages<cr>
"finds members in the current buffer
autocmd FileType cs nnoremap <leader>fm :OmniSharpFindMembers<cr>
" cursor can be anywhere on the line containing an issue
autocmd FileType cs nnoremap <leader>x :OmniSharpFixIssue<cr>
autocmd FileType cs nnoremap <leader>fx :OmniSharpFixUsings<cr>
autocmd FileType cs nnoremap <leader>tt :OmniSharpTypeLookup<cr>
autocmd FileType cs nnoremap <leader>dc :OmniSharpDocumentation<cr>
"navigate up by method/property/field
autocmd FileType cs nnoremap <C-K> :OmniSharpNavigateUp<cr>
"navigate down by method/property/field
autocmd FileType cs nnoremap <C-J> :OmniSharpNavigateDown<cr>
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 <leader><space> :OmniSharpGetCodeActions<cr>
" Run code actions with text selected in visual mode to extract method
vnoremap <leader><space> :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>")
" Force OmniSharp to reload the solution. Useful when switching branches etc.
nnoremap <leader>rl :OmniSharpReloadSolution<cr>
nnoremap <leader>cf :OmniSharpCodeFormat<cr>
" Load the current .cs file to the nearest project
nnoremap <leader>tp :OmniSharpAddToProject<cr>
" Start the omnisharp server for the current solution
nnoremap <leader>ss :OmniSharpStartServer<cr>
nnoremap <leader>sp :OmniSharpStopServer<cr>
" Add syntax highlighting for types and interfaces
nnoremap <leader>th :OmniSharpHighlightTypes<cr>
"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=0
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType cs setlocal omnifunc=OmniSharp#Complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment