summaryrefslogtreecommitdiff
path: root/autoload/ale/hover.vim
diff options
context:
space:
mode:
Diffstat (limited to 'autoload/ale/hover.vim')
-rw-r--r--autoload/ale/hover.vim21
1 files changed, 17 insertions, 4 deletions
diff --git a/autoload/ale/hover.vim b/autoload/ale/hover.vim
index 0954b802..6ad43316 100644
--- a/autoload/ale/hover.vim
+++ b/autoload/ale/hover.vim
@@ -70,6 +70,18 @@ function! s:ConvertLanguageName(language) abort
return a:language
endfunction
+" Cache syntax file (non-)existence to avoid calling globpath repeatedly.
+let s:syntax_file_exists_cache = {}
+
+function! s:SyntaxFileExists(syntax_file) abort
+ if !has_key(s:syntax_file_exists_cache, a:syntax_file)
+ let s:syntax_file_exists_cache[a:syntax_file] =
+ \ !empty(globpath(&runtimepath, a:syntax_file))
+ endif
+
+ return s:syntax_file_exists_cache[a:syntax_file]
+endfunction
+
function! ale#hover#ParseLSPResult(contents) abort
let l:includes = {}
let l:highlights = []
@@ -160,10 +172,11 @@ function! ale#hover#ParseLSPResult(contents) abort
let l:language = s:ConvertLanguageName(l:language)
if !empty(l:language)
- let l:includes[l:language] = printf(
- \ 'syntax/%s.vim',
- \ l:language,
- \)
+ let l:syntax_file = printf('syntax/%s.vim', l:language)
+
+ if s:SyntaxFileExists(l:syntax_file)
+ let l:includes[l:language] = l:syntax_file
+ endif
let l:start = len(l:lines) + 1
let l:end = l:start + len(l:marked_lines)