Last active
June 2, 2024 19:13
-
-
Save brianmed/a3226fdf33cb92212c9a1fc6d34ef776 to your computer and use it in GitHub Desktop.
Some vim setup for omnisharp and c#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" remove any unwanted vi behavior as soon as possible | |
" must be first because actually has a great number of side effects | |
" | |
" is probably redundant, but I'm paranoid | |
set nocompatible | |
if !exists("g:source_base") | |
let g:source_base = "~bpm/.vim" | |
endif | |
if v:progname != "vi" | |
exe "set rtp+=" . g:source_base | |
exe "set rtp+=" . g:source_base . "/after" | |
" exe "set rtp+=/usr/local/opt/fzf" | |
exe "source " . g:source_base . "/vimrc_autocmds" | |
exe "source " . g:source_base . "/vimrc_options" | |
exe "source " . g:source_base . "/vimrc_functions" | |
exe "source " . g:source_base . "/vimrc_mappings" | |
exe "source " . g:source_base . "/vimrc_terminaloptions" | |
exe "source " . g:source_base . "/vimrc_plugins" | |
exe "source " . g:source_base . "/vimrc_omnisharp" | |
endif | |
if -1 != match(expand("%:p"), "/tmp/.*crontab.*") | |
set compatible | |
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let g:OmniSharp_server_stdio = 1 | |
let g:OmniSharp_server_use_net6 = 1 | |
let g:OmniSharp_start_without_solution = 1 | |
" let g:OmniSharp_loglevel = 'debug' | |
let g:ale_linters = { | |
\ 'cs': ['OmniSharp'] | |
\} | |
" let g:ale_enabled = 0 | |
" let g:ale_set_balloons = 0 | |
" let g:ale_set_highlights = 0 | |
" let g:ale_set_loclist = 0 | |
" let g:ale_set_signs = 0 | |
" let g:ale_set_highlights = 0 | |
let g:ale_virtualtext_cursor = 'disabled' | |
let g:asyncomplete_auto_popup = 1 | |
let g:asyncomplete_auto_completeopt = 0 | |
let g:syntastic_cs_checkers = ['syntax'] | |
" let g:OmniSharp_popup_position = 'peek' | |
let g:OmniSharp_popup_position = 'atcursor' | |
if has('nvim') | |
let g:OmniSharp_popup_options = { | |
\ 'winhl': 'Normal:NormalFloat' | |
\} | |
else | |
let g:OmniSharp_popup_options = { | |
\ 'highlight': 'Normal', | |
\ 'padding': [0, 0, 0, 0], | |
\ 'border': [1] | |
\} | |
endif | |
let g:OmniSharp_popup_mappings = { | |
\ 'sigNext': '<C-n>', | |
\ 'sigPrev': '<C-p>', | |
\ 'pageDown': ['<C-f>', '<PageDown>'], | |
\ 'pageUp': ['<C-b>', '<PageUp>'] | |
\} | |
let g:sharpenup_map_prefix = '<Space>os' | |
let g:sharpenup_statusline_opts = { 'Text': '%s (%p/%P)' } | |
let g:sharpenup_statusline_opts.Highlight = 1 | |
let g:OmniSharp_selector_ui = 'fzf' | |
let g:OmniSharp_selector_findusages = 'fzf' | |
function! MakeSolution() abort | |
let sln = shellescape(fnamemodify(OmniSharp#FindSolutionOrDir(), ':.')) | |
call feedkeys(':make' . sln) | |
endfunction | |
" " automatically open quickfix window after build is completed | |
" autocmd QuickFixCmdPost [^l]* nested cwindow | |
" autocmd QuickFixCmdPost l* nested lwindow | |
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) | |
" if v:version >= 704 | |
" autocmd BufEnter,TextChanged,InsertLeave *.cs SyntasticCheck | |
" endif | |
" " 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 <leader>fk :call MakeSolution()<CR> | |
autocmd FileType cs nnoremap <leader>fd :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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set hidden | |
set history=4096 | |
set mousehide | |
set path+=~/.vim | |
set scrolloff=5 | |
set sidescroll=2 | |
set statusline=%F\ %y\ %r%m\ %=%l/%L\ %{virtcol(\".\")}\ (%p%%) | |
set viminfo=!,\"1000,%,'50,h,n~/.vim/viminfo | |
" will save file when jumping to a tag in another file (and other times) | |
set autowrite | |
" gets rid of about 80% of the 'hit-return' prompts | |
set cmdheight=2 | |
" don't change alternate files for :reads | |
set cpoptions-=a | |
" don't break long lines if they're already long when you start | |
" format numbered lists | |
set formatoptions+=ln | |
" remove the toolbar | |
set guioptions-=T | |
" add bottom scrollbar | |
set guioptions+=b | |
" always show a status line | |
set laststatus=2 | |
" give hints, so we know if in insert, replace, visual, select, or normal mode | |
set showmode | |
" when highlighting stuff I can go anywhere | |
set virtualedit=block | |
" i hate the PC speaker | |
set visualbell | |
" control how wildcard matching behaves | |
set wildmenu | |
set wildmode=longest:full | |
" set mouse and selection to how I like it | |
behave xterm | |
" | |
" Setup Completions | |
" | |
set completeopt=menuone,noinsert,noselect,popuphidden | |
set completepopup=highlight:Pmenu,border:off | |
" use dictionary for 'i_ctrl-[pn]' | |
set complete+=k | |
set dictionary+=/usr/share/dict/words | |
set infercase | |
" | |
" Defaults for editing and displaying text. | |
" | |
" basic formatting | |
set autoindent | |
" bs behaves like in most editors | |
set backspace=indent,eol,start | |
" advanced formatting will be in ftplugins | |
set nocindent | |
" helpful for textfiles - actually not really | |
" set textwidth=78 | |
" not useful for regular text. will be turned on by ftplugins | |
set noshowmatch | |
" more easily identify strange lines | |
set nowrap | |
set listchars=eol:$,tab:\|\ ,trail:¿ | |
" tabs are evil | |
set expandtab | |
set shiftwidth=4 | |
set tabstop=4 | |
set softtabstop=4 | |
" | |
" Setup Searching | |
" | |
" default is visual feedback and to disregard case, unless there is a *typed* | |
" uppercase char in the text to search for | |
set ignorecase | |
set incsearch | |
set smartcase | |
exe "set backupdir=" . g:source_base . "/tmp//" | |
exe "set directory=" . g:source_base . "/tmp//" | |
exe "set undodir=" . g:source_base . "/tmp//" | |
set backup | |
set undofile | |
set nofoldenable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment