summaryrefslogtreecommitdiff
path: root/ale_linters/svelte
diff options
context:
space:
mode:
authorfiatjaf <fiatjaf@gmail.com>2021-03-20 19:23:27 -0300
committerGitHub <noreply@github.com>2021-03-20 22:23:27 +0000
commit4411b4d751f944892c7d5c17a503a9a55fd9ddd1 (patch)
tree660ee195988bf08cc5e4f44807b5fc916691fbe4 /ale_linters/svelte
parentb1d833417bcb57e265e0d01df07b28f463529d4b (diff)
downloadale-4411b4d751f944892c7d5c17a503a9a55fd9ddd1.zip
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>
Diffstat (limited to 'ale_linters/svelte')
-rw-r--r--ale_linters/svelte/svelteserver.vim21
1 files changed, 21 insertions, 0 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'),
+\})