Skip to content

Commit 94c7274

Browse files
committed
Move highlight autocmds from plugin/ to ftplugin/
This results in simpler code (we don't need all the compatibility checks) and faster launch for vim, as the highlighting autocmds are not created until a .cs file is opened.
1 parent 1ceae02 commit 94c7274

File tree

3 files changed

+24
-40
lines changed

3 files changed

+24
-40
lines changed

autoload/OmniSharp/util.vim

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ function! OmniSharp#util#CheckCapabilities() abort
123123
endif
124124

125125
if !s:capable
126-
" Clear BufEnter and InsertLeave autocmds
127-
silent! autocmd! OmniSharp_HighlightTypes
128126
" Clear plugin integration autocmds
129127
silent! autocmd! OmniSharp_Integrations
130128
endif

ftplugin/cs/OmniSharp.vim

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,43 @@ if !OmniSharp#util#CheckCapabilities() | finish | endif
33
if get(b:, 'OmniSharp_ftplugin_loaded', 0) | finish | endif
44
let b:OmniSharp_ftplugin_loaded = 1
55

6+
if get(g:, 'OmniSharp_start_server', 0)
7+
call OmniSharp#StartServerIfNotRunning()
8+
endif
9+
10+
call OmniSharp#actions#buffer#Update()
11+
if g:OmniSharp_highlighting
12+
call OmniSharp#actions#highlight#Buffer()
13+
endif
14+
615
augroup OmniSharp_FileType
716
autocmd! * <buffer>
817

9-
autocmd BufLeave <buffer>
18+
autocmd BufEnter,BufLeave <buffer>
1019
\ if !pumvisible() |
1120
\ call OmniSharp#actions#buffer#Update() |
1221
\ endif
1322

1423
autocmd CompleteDone <buffer> call OmniSharp#actions#complete#ExpandSnippet()
1524

1625
autocmd TextChanged <buffer> call OmniSharp#actions#buffer#Update()
17-
augroup END
1826

19-
setlocal omnifunc=OmniSharp#Complete
27+
if g:OmniSharp_highlighting
28+
autocmd BufEnter <buffer> call OmniSharp#actions#highlight#Buffer()
29+
endif
30+
if g:OmniSharp_highlighting >= 2
31+
autocmd InsertLeave,TextChanged <buffer> call OmniSharp#actions#highlight#Buffer()
32+
endif
33+
if g:OmniSharp_highlighting >= 3
34+
autocmd TextChangedI <buffer> call OmniSharp#actions#highlight#Buffer()
35+
if exists('##TextChangedP')
36+
autocmd TextChangedP <buffer> call OmniSharp#actions#highlight#Buffer()
37+
endif
38+
endif
2039

21-
if get(g:, 'OmniSharp_start_server', 0)
22-
call OmniSharp#StartServerIfNotRunning()
23-
endif
40+
augroup END
2441

25-
call OmniSharp#actions#buffer#Update()
42+
setlocal omnifunc=OmniSharp#Complete
2643

2744
command! -buffer -bar OmniSharpRestartAllServers call OmniSharp#RestartAllServers()
2845
command! -buffer -bar OmniSharpRestartServer call OmniSharp#RestartServer()

plugin/OmniSharp.vim

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -50,39 +50,8 @@ command! -bar -nargs=? OmniSharpInstall call OmniSharp#Install(<f-args>)
5050
command! -bar -nargs=? OmniSharpOpenLog call OmniSharp#log#Open(<q-args>)
5151
command! -bar -bang OmniSharpStatus call OmniSharp#Status(<bang>0)
5252

53-
" Initialise automatic type and interface highlighting
5453
" Preserve backwards compatibility with older version g:OmniSharp_highlight_types
5554
let g:OmniSharp_highlighting = get(g:, 'OmniSharp_highlighting', get(g:, 'OmniSharp_highlight_types', 2))
56-
if g:OmniSharp_highlighting
57-
augroup OmniSharp_HighlightTypes
58-
autocmd!
59-
autocmd BufEnter *.cs,*.csx
60-
\ if !pumvisible() && OmniSharp#util#CheckCapabilities() |
61-
\ call OmniSharp#actions#highlight#Buffer() |
62-
\ endif
63-
64-
if g:OmniSharp_highlighting >= 2
65-
autocmd InsertLeave,TextChanged *.cs,*.csx
66-
\ if OmniSharp#util#CheckCapabilities() |
67-
\ call OmniSharp#actions#highlight#Buffer() |
68-
\ endif
69-
endif
70-
71-
if g:OmniSharp_highlighting >= 3
72-
autocmd TextChangedI *.cs,*.csx
73-
\ if OmniSharp#util#CheckCapabilities() |
74-
\ call OmniSharp#actions#highlight#Buffer() |
75-
\ endif
76-
77-
if exists('##TextChangedP')
78-
autocmd TextChangedP *.cs,*.csx
79-
\ if OmniSharp#util#CheckCapabilities() |
80-
\ call OmniSharp#actions#highlight#Buffer() |
81-
\ endif
82-
endif
83-
endif
84-
augroup END
85-
endif
8655

8756
function! s:ALEWantResults() abort
8857
if !g:OmniSharp_server_stdio | return | endif

0 commit comments

Comments
 (0)