Skip to content

Commit 6398305

Browse files
authored
Use GetVar instead of get in HasCommand (#1136)
1 parent c8e0fc0 commit 6398305

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

autoload/LanguageClient.vim

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -786,12 +786,15 @@ function! s:SkipSendingMessage() abort
786786
return v:false
787787
endif
788788

789-
let l:commands = get(g:, 'LanguageClient_serverCommands', {})
790-
let l:has_command = has_key(l:commands, &filetype)
791-
789+
let l:has_command = LanguageClient#HasCommand(&filetype)
792790
return !l:has_command || &buftype !=# '' || &filetype ==# '' || expand('%') ==# ''
793791
endfunction
794792

793+
function! LanguageClient#HasCommand(filetype) abort
794+
let l:commands = s:GetVar('LanguageClient_serverCommands', {})
795+
return has_key(l:commands, a:filetype)
796+
endfunction
797+
795798
function! LanguageClient#Call(method, params, callback, ...) abort
796799
if s:SkipSendingMessage()
797800
echo '[LC] Server not configured for filetype ' . &filetype

plugin/LanguageClient.vim

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ command! -nargs=* LanguageClientStart :call LanguageClient#startServer(<f-args>)
154154
command! LanguageClientStop call LanguageClient#shutdown()
155155

156156
function! s:OnBufEnter()
157-
if !s:HasCommand()
157+
if !LanguageClient#HasCommand(&filetype)
158158
return
159159
endif
160160

@@ -163,19 +163,14 @@ function! s:OnBufEnter()
163163
endfunction
164164

165165
function! s:OnFileType()
166-
if !s:HasCommand()
166+
if !LanguageClient#HasCommand(&filetype)
167167
return
168168
endif
169169

170170
call LanguageClient#handleFileType()
171171
call s:ConfigureAutocmds()
172172
endfunction
173173

174-
function! s:HasCommand()
175-
let l:commands = get(g:, 'LanguageClient_serverCommands', {})
176-
return has_key(l:commands, &filetype)
177-
endfunction
178-
179174
function! s:ConfigureAutocmds()
180175
augroup languageClient
181176
autocmd!

0 commit comments

Comments
 (0)