add support for svelte via svelteserver language server (#3644)

* add support for svelte via svelteserver language server
* svelte: fix Vint error and add a `svelteserver` simple test.

Co-authored-by: Joakim Repomaa <mail@j.repomaa.com>
Co-authored-by: Joakim Repomaa <mail@jreinert.com>
This commit is contained in:
fiatjaf 2021-03-20 19:23:27 -03:00 committed by GitHub
parent b1d833417b
commit 4411b4d751
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 73 additions and 1 deletions

View File

@ -0,0 +1,21 @@
" Author: Joakim Repomaa <joakim@repomaa.com>
" Description: Svelte Language Server integration for ALE
call ale#Set('svelte_svelteserver_executable', 'svelteserver')
call ale#Set('svelte_svelteserver_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#svelte#svelteserver#GetProjectRoot(buffer) abort
let l:package_path = ale#path#FindNearestFile(a:buffer, 'package.json')
return !empty(l:package_path) ? fnamemodify(l:package_path, ':h') : ''
endfunction
call ale#linter#Define('svelte', {
\ 'name': 'svelteserver',
\ 'lsp': 'stdio',
\ 'executable': {b -> ale#node#FindExecutable(b, 'svelte_svelteserver', [
\ 'node_modules/.bin/svelteserver',
\ ])},
\ 'command': '%e --stdio',
\ 'project_root': function('ale_linters#svelte#svelteserver#GetProjectRoot'),
\})

View File

@ -112,7 +112,7 @@ let s:default_registry = {
\ },
\ 'prettier': {
\ 'function': 'ale#fixers#prettier#Fix',
\ 'suggested_filetypes': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue', 'html', 'yaml', 'openapi', 'ruby'],
\ 'suggested_filetypes': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue', 'svelte', 'html', 'yaml', 'openapi', 'ruby'],
\ 'description': 'Apply prettier to a file.',
\ },
\ 'prettier_eslint': {

View File

@ -74,6 +74,7 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort
\ 'graphql': 'graphql',
\ 'markdown': 'markdown',
\ 'vue': 'vue',
\ 'svelte': 'svelte',
\ 'yaml': 'yaml',
\ 'openapi': 'yaml',
\ 'html': 'html',

View File

@ -489,6 +489,9 @@ Notes:
* `stylelint`
* SugarSS
* `stylelint`
* Svelte
* `prettier`
* `svelteserver`
* Swift
* Apple `swift-format`
* `sourcekit-lsp`

31
doc/ale-svelte.txt Normal file
View File

@ -0,0 +1,31 @@
===============================================================================
ALE Svelte Integration *ale-svelte-options*
===============================================================================
prettier *ale-svelte-prettier*
See |ale-javascript-prettier| for information about the available options.
===============================================================================
svelteserver *ale-svelte-svelteserver*
g:ale_svelte_svelteserver_executable *g:ale_svelte_svelteserver_executable*
*b:ale_svelte_svelteserver_executable*
Type: |String|
Default: `'svelteserver'`
See |ale-integrations-local-executables|
g:ale_svelte_svelteserver_use_global *g:ale_svelte_svelteserver_use_global*
*b:ale_svelte_svelteserver_use_global*
Type: |Number|
Default: `get(g:, 'ale_use_global_executables', 0)`
See |ale-integrations-local-executables|
===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View File

@ -1438,6 +1438,7 @@ g:ale_linter_aliases *g:ale_linter_aliases*
\ 'ps1': 'powershell',
\ 'rmarkdown': 'r',
\ 'rmd': 'r',
\ 'svelte': ['svelte', 'javascript'],
\ 'systemverilog': 'verilog',
\ 'typescriptreact': ['typescript', 'tsx'],
\ 'verilog_systemverilog': ['verilog_systemverilog', 'verilog'],
@ -1588,6 +1589,7 @@ g:ale_linters *g:ale_linters*
\ 'python': ['flake8', 'mypy', 'pylint', 'pyright'],
\ 'rust': ['cargo', 'rls'],
\ 'spec': [],
\ 'svelte': ['eslint', 'svelteserver'],
\ 'text': [],
\ 'vue': ['eslint', 'vls'],
\ 'zsh': ['shell'],
@ -3010,6 +3012,9 @@ documented in additional help files.
stylelint.............................|ale-stylus-stylelint|
sugarss.................................|ale-sugarss-options|
stylelint.............................|ale-sugarss-stylelint|
svelte..................................|ale-svelte-options|
prettier..............................|ale-svelte-prettier|
svelteserver..........................|ale-svelte-svelteserver|
swift...................................|ale-swift-options|
sourcekitlsp..........................|ale-swift-sourcekitlsp|
systemd.................................|ale-systemd-options|

View File

@ -498,6 +498,9 @@ formatting.
* [stylelint](https://github.com/stylelint/stylelint)
* SugarSS
* [stylelint](https://github.com/stylelint/stylelint)
* Svelte
* [prettier](https://github.com/prettier/prettier)
* [svelteserver](https://github.com/sveltejs/language-tools/tree/master/packages/language-server)
* Swift
* [Apple swift-format](https://github.com/apple/swift-format)
* [sourcekit-lsp](https://github.com/apple/sourcekit-lsp)

View File

@ -0,0 +1,8 @@
Before:
call ale#assert#SetUpLinterTest('svelte', 'svelteserver')
After:
call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
AssertLinter 'svelteserver', ale#Escape('svelteserver') . ' --stdio'