Fix execution of the Angular language server for HTML files

This commit is contained in:
w0rp 2022-01-05 11:34:30 +00:00
parent ac0495df6e
commit 11a90ad0ff
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
2 changed files with 11 additions and 23 deletions

View File

@ -11,10 +11,7 @@ function! ale_linters#html#angular#GetProjectRoot(buffer) abort
endfunction
function! ale_linters#html#angular#GetExecutable(buffer) abort
return ale#path#FindExecutable(a:buffer, 'html_angular', [
\ 'node_modules/@angular/language-server/bin/ngserver',
\ 'node_modules/@angular/language-server/index.js',
\])
return 'node'
endfunction
function! ale_linters#html#angular#GetCommand(buffer) abort
@ -34,9 +31,16 @@ function! ale_linters#html#angular#GetCommand(buffer) abort
\ fnamemodify(l:language_service_dir, ':h:h')
\ . '/typescript'
\)
let l:executable = ale_linters#html#angular#GetExecutable(a:buffer)
let l:script = ale#path#FindExecutable(a:buffer, 'html_angular', [
\ 'node_modules/@angular/language-server/bin/ngserver',
\ 'node_modules/@angular/language-server/index.js',
\])
return ale#node#Executable(a:buffer, l:executable)
if !filereadable(l:script)
return ''
endif
return ale#Escape('node') . ' ' . ale#Escape(l:script)
\ . ' --ngProbeLocations ' . ale#Escape(l:language_service_dir)
\ . ' --tsProbeLocations ' . ale#Escape(l:typescript_dir)
\ . ' --stdio'

View File

@ -22,23 +22,7 @@ Execute(The default command for Angular should be correct):
AssertLSPLanguage 'html'
AssertLSPProject ale#test#GetFilename('../test-files/angular')
AssertLinter g:paths.ngserver, ale#Escape(g:paths.ngserver)
\ . ' --ngProbeLocations ' . ale#Escape(g:paths.service)
\ . ' --tsProbeLocations ' . ale#Escape(g:paths.typescript)
\ . ' --stdio'
Execute(It should be possible to use the global ngserver):
let b:ale_html_angular_use_global = 1
call ale#test#SetFilename('../test-files/angular/test.html')
let g:paths = {
\ 'service': ale#test#GetFilename('../test-files/angular/node_modules/@angular/language-service'),
\ 'typescript': ale#test#GetFilename('../test-files/angular/node_modules/typescript'),
\}
AssertLSPLanguage 'html'
AssertLSPProject ale#test#GetFilename('../test-files/angular')
AssertLinter 'ngserver', ale#Escape('ngserver')
AssertLinter 'node', ale#Escape('node') . ' ' . ale#Escape(g:paths.ngserver)
\ . ' --ngProbeLocations ' . ale#Escape(g:paths.service)
\ . ' --tsProbeLocations ' . ale#Escape(g:paths.typescript)
\ . ' --stdio'