mirror of
https://github.com/amix/vimrc
synced 2025-07-12 22:24:59 +08:00
Update ui_glue.vim, lightline.txt, and 333 more files...
This commit is contained in:
52
sources_non_forked/ale/ale_linters/html/angular.vim
Normal file
52
sources_non_forked/ale/ale_linters/html/angular.vim
Normal file
@ -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#path#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'),
|
||||
\})
|
@ -24,7 +24,7 @@ endfunction
|
||||
|
||||
call ale#linter#Define('html', {
|
||||
\ 'name': 'htmlhint',
|
||||
\ 'executable': {b -> ale#node#FindExecutable(b, 'html_htmlhint', [
|
||||
\ 'executable': {b -> ale#path#FindExecutable(b, 'html_htmlhint', [
|
||||
\ 'node_modules/.bin/htmlhint',
|
||||
\ ])},
|
||||
\ 'command': function('ale_linters#html#htmlhint#GetCommand'),
|
||||
|
@ -5,7 +5,7 @@ call ale#Set('html_stylelint_options', '')
|
||||
call ale#Set('html_stylelint_use_global', 0)
|
||||
|
||||
function! ale_linters#html#stylelint#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'html_stylelint', [
|
||||
return ale#path#FindExecutable(a:buffer, 'html_stylelint', [
|
||||
\ 'node_modules/.bin/stylelint',
|
||||
\])
|
||||
endfunction
|
||||
|
Reference in New Issue
Block a user