|
| 1 | +" OmniSharp/omnisharp-vim: { |
| 2 | + let g:OmniSharp_popup_position = winwidth(0) >= 80 ? 'peek' : 'center' |
| 3 | + if has('nvim') |
| 4 | + let g:OmniSharp_popup_options = { |
| 5 | + \ 'winhl': 'Normal:NormalFloat' |
| 6 | + \} |
| 7 | + else |
| 8 | + let g:OmniSharp_popup_options = { |
| 9 | + \ 'highlight': 'Normal', |
| 10 | + \ 'padding': [0, 0, 0, 0], |
| 11 | + \ 'border': [1] |
| 12 | + \} |
| 13 | + endif |
| 14 | + let g:OmniSharp_popup_mappings = { |
| 15 | + \ 'pageDown': ['<C-f>', '<PageDown>'], |
| 16 | + \ 'pageUp': ['<C-b>', '<PageUp>'] |
| 17 | + \} |
| 18 | + |
| 19 | + "if s:using_snippets |
| 20 | + " let g:OmniSharp_want_snippet = 1 |
| 21 | + "endif |
| 22 | + |
| 23 | + let g:OmniSharp_highlight_groups = { |
| 24 | + \ 'ExcludedCode': 'NonText' |
| 25 | + \} |
| 26 | + "\ 'Comment': 'NonText', |
| 27 | + "\ 'XmlDocCommentName': 'Identifier', |
| 28 | + "\ 'XmlDocCommentText': 'NonText' |
| 29 | + "\} |
| 30 | + |
| 31 | + if spacevim#load('clap') |
| 32 | + let g:OmniSharp_selector_findusages = 'clap' |
| 33 | + endif |
| 34 | + let g:OmniSharp_autoselect_existing_sln = 1 |
| 35 | + let g:OmniSharp_highlighting = 3 |
| 36 | + let g:OmniSharp_diagnostic_exclude_paths = [ 'Temp[/\\]', 'obj[/\\]', '\.nuget[/\\]' ] |
| 37 | + "let g:OmniSharp_fzf_options = { 'down': '10' }']]]' ] |
| 38 | + |
| 39 | + " The following autoformats the code on write per OmniSharp |
| 40 | + " configuration when g:OmniSharp_code_format is set. |
| 41 | + " Each codebase might have different configuration. |
| 42 | + " Some codebases might be messy, where autoformat is a burden in making patches, thus this is false by default. |
| 43 | + " https://github.com/OmniSharp/omnisharp-roslyn/wiki/Configuration-Options |
| 44 | + let g:OmniSharp_code_format = v:false |
| 45 | + augroup codeformatOmniSharp |
| 46 | + autocmd! |
| 47 | + autocmd BufWritePre *.cs :if g:OmniSharp_code_format | :OmniSharpCodeFormat | :endif |
| 48 | + augroup END |
| 49 | + |
| 50 | + " Cache the 'project' data from OmniSharp-Roslyn to each cs buffer |
| 51 | + augroup cacheOmniSharpProject |
| 52 | + autocmd! |
| 53 | + autocmd FileType cs call s:CacheOmniSharpProjectInBuffer({->0}) |
| 54 | + augroup END |
| 55 | + |
| 56 | + function! s:CacheOmniSharpProjectInBuffer(callback) |
| 57 | + if &filetype ==# 'cs' |
| 58 | + let bufnr = bufnr('%') |
| 59 | + let host = OmniSharp#GetHost(bufnr) |
| 60 | + if !has_key(host, 'project') |
| 61 | + " 'project' not in cache, must query from OmniSharp-Roslyn, is async |
| 62 | + call OmniSharp#actions#project#Get(bufnr, a:callback) |
| 63 | + endif |
| 64 | + endif |
| 65 | + endfunction |
| 66 | + |
| 67 | + if spacevim#load('programming') |
| 68 | + if exists('g:vista_executive_for') && v:t_dict == type(g:vista_executive_for) |
| 69 | + call extend(g:vista_executive_for, {'cs': 'ctags'}) |
| 70 | + else |
| 71 | + let g:vista_executive_for = {'cs': 'ctags'} |
| 72 | + endif |
| 73 | + endif |
| 74 | +" } |
| 75 | + |
| 76 | +" nickspoons/vim-sharpenup: { |
| 77 | + " We want everything from vim-sharpenup but the keybindings due to integration |
| 78 | + let g:sharpenup_create_mappings = 0 |
| 79 | + let g:sharpenup_map_legacy_csproj_actions = 0 |
| 80 | + |
| 81 | + " TODO: integrate mappings better: |
| 82 | + nmap <C-\> <Plug>(omnisharp_signature_help) |
| 83 | + imap <C-\> <Plug>(omnisharp_signature_help) |
| 84 | + nmap <silent> <buffer> [[ <Plug>(omnisharp_navigate_up) |
| 85 | + nmap <silent> <buffer> ]] <Plug>(omnisharp_navigate_down) |
| 86 | + "nmap <prefix>ca <Plug>(omnisharp_code_actions) |
| 87 | + "xmap <prefix>ca <Plug>(omnisharp_code_actions) |
| 88 | + "nmap <silent> <buffer> <prefix>. <Plug>(omnisharp_code_action_repeat) |
| 89 | + "xmap <silent> <buffer> <prefix>. <Plug>(omnisharp_code_action_repeat) |
| 90 | + |
| 91 | + " A `Dictionary-function` containing vim-which-key mappings |
| 92 | + function! s:whichkey_omnisharp_integration() |
| 93 | + if &filetype ==# 'cs' |
| 94 | + let s:new_keymap = get(s:, 'new_keymap', { |
| 95 | + \ 'name': '+omnisharp', |
| 96 | + \ '.': ['<Plug>(omnisharp_code_action_repeat)', 'repeat'], |
| 97 | + \ 'a': ['<Plug>(omnisharp_code_actions)' , 'code-action'], |
| 98 | + \ 'c': ['<Plug>(omnisharp_global_code_check)' , 'global-code-check'], |
| 99 | + \ 'f': ['<Plug>(omnisharp_code_format)' , 'formatting'], |
| 100 | + \ 'h': ['<Plug>(omnisharp_signature_help)' , 'hover'], |
| 101 | + \ 'H': ['<Plug>(omnisharp_highlight)' , 'highlight'], |
| 102 | + \ 'r': ['<Plug>(omnisharp_find_usages)' , 'references'], |
| 103 | + \ 'R': ['<Plug>(omnisharp_rename)' , 'rename'], |
| 104 | + \ 's': ['<Plug>(omnisharp_documentation)' , 'document-symbol'], |
| 105 | + \ 'S': ['<Plug>(omnisharp_find_symbol)' , 'workspace-symbol'], |
| 106 | + \ 'g': { |
| 107 | + \ 'name': '+goto', |
| 108 | + \ 'd': ['<Plug>(omnisharp_go_to_definition)', 'definition'], |
| 109 | + \ 't': ['<Plug>(omnisharp_find_type)' , 'type-definition'], |
| 110 | + \ 'i': ['<Plug>(omnisharp_find_implementations)', 'implementation'], |
| 111 | + \ 's': ['<Plug>(omnisharp_find_symbol)' , 'symbol'], |
| 112 | + \ }, |
| 113 | + \ 'p': { |
| 114 | + \ 'name': '+preview', |
| 115 | + \ 'd': ['<Plug>(omnisharp_preview_definition)' , 'definition'], |
| 116 | + \ 'i': ['<Plug>(omnisharp_preview_implementations)', 'implementation'], |
| 117 | + \ }, |
| 118 | + \ 'b': { |
| 119 | + \ 'name': '+build', |
| 120 | + \ 'p': ['<Plug>(omnisharp_build_project)' , 'build-project'], |
| 121 | + \ 's': ['<Plug>(omnisharp_build_solution)' , 'build-solution'], |
| 122 | + \ 'd': ['<Plug>(omnisharp_debug_project)' , 'debug-project'], |
| 123 | + \ 'v': ['<Plug>(omnisharp_create_debug_config)', 'create-vimspector-config'], |
| 124 | + \ }, |
| 125 | + \ 't': { |
| 126 | + \ 'name': '+test', |
| 127 | + \ 't': ['<Plug>(omnisharp_run_test)' , 'run-test'], |
| 128 | + \ 'n': ['<Plug>(omnisharp_run_test_no_build)', 'run-test-no-build'], |
| 129 | + \ 'T': ['<Plug>(omnisharp_run_tests_in_file)', 'run-tests-in-file'], |
| 130 | + \ 'N': ['<Plug>(omnisharp_run_tests_in_file_no_build)', 'run-tests-in-file-no-build'], |
| 131 | + \ 'd': ['<Plug>(omnisharp_debug_test)' , 'debug-test'], |
| 132 | + \ 'D': ['<Plug>(omnisharp_debug_test_no_build)', 'debug-test-no-build'], |
| 133 | + \ }, |
| 134 | + \ 'x': { |
| 135 | + \ 'name': '+csproj-modify', |
| 136 | + \ 'a': ['<Plug>(omnisharp_add_to_csproj)' , 'add-to-csproj'], |
| 137 | + \ 'r': ['<Plug>(omnisharp_rename_in_csproj)', 'rename-in-csproj'], |
| 138 | + \ }, |
| 139 | + \ 'X': { |
| 140 | + \ 'name': '+server', |
| 141 | + \ 's': [':OmniSharpStatus!' , 'status'], |
| 142 | + \ 'S': ['<Plug>(omnisharp_start_server)' , 'start'], |
| 143 | + \ 't': ['<Plug>(omnisharp_stop_server)' , 'stop'], |
| 144 | + \ 'T': ['<Plug>(omnisharp_stop_all_servers)' , 'stop-all'], |
| 145 | + \ 'r': ['<Plug>(omnisharp_restart_server)' , 'restart'], |
| 146 | + \ 'R': ['<Plug>(omnisharp_restart_all_servers)', 'restart-all'], |
| 147 | + \ }, |
| 148 | + \ }) |
| 149 | + return s:new_keymap |
| 150 | + else |
| 151 | + return s:keep_keymap |
| 152 | + endif |
| 153 | + endfunction |
| 154 | + |
| 155 | + " Integrate OmniSharp hotkeys with vim-which-key |
| 156 | + if spacevim#load('which-key') |
| 157 | + let s:keep_keymap = get(s:, 'keep_keymap', deepcopy(g:spacevim#map#leader#desc['l'])) |
| 158 | + let g:spacevim#map#leader#desc['l'] = function('s:whichkey_omnisharp_integration') |
| 159 | + endif |
| 160 | +" } |
| 161 | + |
| 162 | +" mattn/vim-lsp-settings: { |
| 163 | + if exists('g:spacevim_lsp_engine') && g:spacevim_lsp_engine ==# 'vim_lsp' |
| 164 | + let g:lsp_settings = get(g:, 'lsp_settings', {}) |
| 165 | + if !has_key(g:lsp_settings, 'omnisharp-lsp') |
| 166 | + let g:lsp_settings['omnisharp-lsp'] = {} |
| 167 | + endif |
| 168 | + let g:lsp_settings['omnisharp-lsp'].disabled = 1 |
| 169 | + endif |
| 170 | +" } |
| 171 | + |
| 172 | +" itchyny/lightline.vim: { |
| 173 | + let g:sharpenup_statusline_opts = { 'Text': '%s (%p/%P)' } |
| 174 | + let g:sharpenup_statusline_opts.Highlight = 0 |
| 175 | +" } |
| 176 | + |
| 177 | +" As alternative to OmniSharpCodeFormat, can use different formatter |
| 178 | +" vim-autoformat/vim-autoformat: { |
| 179 | + "let g:formatdef_my_custom_cs = '"astyle --mode=cs --style=ansi -pcHs".&shiftwidth' |
| 180 | +" } |
0 commit comments