summaryrefslogtreecommitdiff
path: root/ale_linters/html
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2021-03-14 21:10:05 +0000
committerw0rp <devw0rp@gmail.com>2021-03-14 21:10:20 +0000
commitb45ee8ec6c760089c68fb28a5436ec8275ca5381 (patch)
treeb37f356b016f3c09ac7a706ed22fa0d852b32969 /ale_linters/html
parent80a48d01be663205b92902ca3fa137706e3e88c6 (diff)
downloadale-b45ee8ec6c760089c68fb28a5436ec8275ca5381.zip
Close #2102 - Add support for the Angular language server
Diffstat (limited to 'ale_linters/html')
-rw-r--r--ale_linters/html/angular.vim52
1 files changed, 52 insertions, 0 deletions
diff --git a/ale_linters/html/angular.vim b/ale_linters/html/angular.vim
new file mode 100644
index 00000000..f550d665
--- /dev/null
+++ b/ale_linters/html/angular.vim
@@ -0,0 +1,52 @@
+" Author: w0rp <devw0rp@gmail.com>
+" Description: tsserver integration for ALE
+
+call ale#Set('html_angular_executable', 'ngserver')
+call ale#Set('html_angular_use_global', get(g:, 'ale_use_global_executables', 0))
+
+function! ale_linters#html#angular#GetProjectRoot(buffer) abort
+ return ale#path#Dirname(
+ \ ale#path#FindNearestDirectory(a:buffer, 'node_modules')
+ \)
+endfunction
+
+function! ale_linters#html#angular#GetExecutable(buffer) abort
+ return ale#node#FindExecutable(a:buffer, 'html_angular', [
+ \ 'node_modules/@angular/language-server/bin/ngserver',
+ \ 'node_modules/@angular/language-server/index.js',
+ \])
+endfunction
+
+function! ale_linters#html#angular#GetCommand(buffer) abort
+ let l:language_service_dir = ale#path#Simplify(
+ \ ale#path#FindNearestDirectory(
+ \ a:buffer,
+ \ 'node_modules/@angular/language-service'
+ \ )
+ \)
+
+ if empty(l:language_service_dir)
+ return ''
+ endif
+
+ let l:language_service_dir = fnamemodify(l:language_service_dir, ':h')
+ let l:typescript_dir = ale#path#Simplify(
+ \ fnamemodify(l:language_service_dir, ':h:h')
+ \ . '/typescript'
+ \)
+ let l:executable = ale_linters#html#angular#GetExecutable(a:buffer)
+
+ return ale#node#Executable(a:buffer, l:executable)
+ \ . ' --ngProbeLocations ' . ale#Escape(l:language_service_dir)
+ \ . ' --tsProbeLocations ' . ale#Escape(l:typescript_dir)
+ \ . ' --stdio'
+endfunction
+
+call ale#linter#Define('html', {
+\ 'name': 'angular',
+\ 'aliases': ['angular-language-server'],
+\ 'lsp': 'stdio',
+\ 'executable': function('ale_linters#html#angular#GetExecutable'),
+\ 'command': function('ale_linters#html#angular#GetCommand'),
+\ 'project_root': function('ale_linters#html#angular#GetProjectRoot'),
+\})