]> git.madduck.net Git - etc/vim.git/blob - ale_linters/html/angular.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / ale_linters / html / angular.vim
1 " Author: w0rp <devw0rp@gmail.com>
2 " Description: tsserver integration for ALE
3
4 call ale#Set('html_angular_executable', 'ngserver')
5 call ale#Set('html_angular_use_global', get(g:, 'ale_use_global_executables', 0))
6
7 function! ale_linters#html#angular#GetProjectRoot(buffer) abort
8     return ale#path#Dirname(
9     \   ale#path#FindNearestDirectory(a:buffer, 'node_modules')
10     \)
11 endfunction
12
13 function! ale_linters#html#angular#GetExecutable(buffer) abort
14     return 'node'
15 endfunction
16
17 function! ale_linters#html#angular#GetCommand(buffer) abort
18     let l:language_service_dir = ale#path#Simplify(
19     \   ale#path#FindNearestDirectory(
20     \       a:buffer,
21     \       'node_modules/@angular/language-service'
22     \   )
23     \)
24
25     if empty(l:language_service_dir)
26         return ''
27     endif
28
29     let l:language_service_dir = fnamemodify(l:language_service_dir, ':h')
30     let l:typescript_dir = ale#path#Simplify(
31     \   fnamemodify(l:language_service_dir, ':h:h')
32     \   . '/typescript'
33     \)
34     let l:script = ale#path#FindExecutable(a:buffer, 'html_angular', [
35     \   'node_modules/@angular/language-server/bin/ngserver',
36     \   'node_modules/@angular/language-server/index.js',
37     \])
38
39     if !filereadable(l:script)
40         return ''
41     endif
42
43     return ale#Escape('node') . ' ' . ale#Escape(l:script)
44     \ . ' --ngProbeLocations ' . ale#Escape(l:language_service_dir)
45     \ . ' --tsProbeLocations ' . ale#Escape(l:typescript_dir)
46     \ . ' --stdio'
47 endfunction
48
49 call ale#linter#Define('html', {
50 \   'name': 'angular',
51 \   'aliases': ['angular-language-server', 'angularls'],
52 \   'lsp': 'stdio',
53 \   'executable': function('ale_linters#html#angular#GetExecutable'),
54 \   'command': function('ale_linters#html#angular#GetCommand'),
55 \   'project_root': function('ale_linters#html#angular#GetProjectRoot'),
56 \})