summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/svelte/svelteserver.vim21
-rw-r--r--autoload/ale/fix/registry.vim2
-rw-r--r--autoload/ale/fixers/prettier.vim1
-rw-r--r--doc/ale-supported-languages-and-tools.txt3
-rw-r--r--doc/ale-svelte.txt31
-rw-r--r--doc/ale.txt5
-rw-r--r--supported-tools.md3
-rw-r--r--test/command_callback/test_svelteserver_command_callback.vader8
8 files changed, 73 insertions, 1 deletions
diff --git a/ale_linters/svelte/svelteserver.vim b/ale_linters/svelte/svelteserver.vim
new file mode 100644
index 00000000..bcd10be8
--- /dev/null
+++ b/ale_linters/svelte/svelteserver.vim
@@ -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'),
+\})
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index bb26573b..d82e2778 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -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': {
diff --git a/autoload/ale/fixers/prettier.vim b/autoload/ale/fixers/prettier.vim
index 43806e8e..a080d880 100644
--- a/autoload/ale/fixers/prettier.vim
+++ b/autoload/ale/fixers/prettier.vim
@@ -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',
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index 26e91e5c..fde158fe 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -489,6 +489,9 @@ Notes:
* `stylelint`
* SugarSS
* `stylelint`
+* Svelte
+ * `prettier`
+ * `svelteserver`
* Swift
* Apple `swift-format`
* `sourcekit-lsp`
diff --git a/doc/ale-svelte.txt b/doc/ale-svelte.txt
new file mode 100644
index 00000000..92f109f7
--- /dev/null
+++ b/doc/ale-svelte.txt
@@ -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:
diff --git a/doc/ale.txt b/doc/ale.txt
index 63086611..cb11226d 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -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|
diff --git a/supported-tools.md b/supported-tools.md
index 4c65a324..1bcbe686 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -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)
diff --git a/test/command_callback/test_svelteserver_command_callback.vader b/test/command_callback/test_svelteserver_command_callback.vader
new file mode 100644
index 00000000..c09f1682
--- /dev/null
+++ b/test/command_callback/test_svelteserver_command_callback.vader
@@ -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'