summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold Chand <creativenull@outlook.com>2023-07-23 21:08:11 -0400
committerGitHub <noreply@github.com>2023-07-24 10:08:11 +0900
commit32e1417d985f048c1e0783dec18795173c1b4599 (patch)
treeec14be26c3a1058ee0b338d0f3c6149708dfd9db
parent1084152a117e28ed846f19e079f502ec686b6826 (diff)
downloadale-32e1417d985f048c1e0783dec18795173c1b4599.zip
fix(vue): volar v1 support (#4552)
* fix: volar v1 support * fix: volar linter errors
-rw-r--r--ale_linters/vue/volar.vim67
-rw-r--r--doc/ale-vue.txt4
-rw-r--r--test/linter/test_volar.vader4
3 files changed, 27 insertions, 48 deletions
diff --git a/ale_linters/vue/volar.vim b/ale_linters/vue/volar.vim
index bb41b883..953262b5 100644
--- a/ale_linters/vue/volar.vim
+++ b/ale_linters/vue/volar.vim
@@ -3,50 +3,21 @@
" nvim-lspconfig and volar/packages/shared/src/types.ts
call ale#Set('vue_volar_executable', 'vue-language-server')
-call ale#Set('vue_volar_use_global', get(g:, 'ale_use_global_executables', 0))
+call ale#Set('vue_volar_use_global', 1)
call ale#Set('vue_volar_init_options', {
-\ 'documentFeatures': {
-\ 'documentColor': v:false,
-\ 'documentFormatting': {
-\ 'defaultPrintWidth': 100,
-\ },
-\ 'documentSymbol': v:true,
-\ 'foldingRange': v:true,
-\ 'linkedEditingRange': v:true,
-\ 'selectionRange': v:true,
-\ },
-\ 'languageFeatures': {
-\ 'callHierarchy': v:true,
-\ 'codeAction': v:true,
-\ 'codeLens': v:true,
-\ 'completion': {
-\ 'defaultAttrNameCase': 'kebabCase',
-\ 'defaultTagNameCase': 'both',
-\ 'getDocumentNameCaseRequest': v:false,
-\ 'getDocumentSelectionRequest': v:false,
-\ },
-\ 'definition': v:true,
-\ 'diagnostics': v:true,
-\ 'documentHighlight': v:true,
-\ 'documentLink': v:true,
-\ 'hover': v:true,
-\ 'references': v:true,
-\ 'rename': v:true,
-\ 'renameFileRefactoring': v:true,
-\ 'schemaRequestService': v:true,
-\ 'semanticTokens': v:false,
-\ 'signatureHelp': v:true,
-\ 'typeDefinition': v:true,
-\ 'workspaceSymbol': v:false,
-\ },
-\ 'typescript': {
-\ 'serverPath': '',
-\ 'localizedPath': v:null,
-\ },
+\ 'typescript': { 'tsdk': '' },
\})
function! ale_linters#vue#volar#GetProjectRoot(buffer) abort
- let l:project_roots = ['package.json', 'vite.config.js', '.git', bufname(a:buffer)]
+ let l:project_roots = [
+ \ 'package.json',
+ \ 'vite.config.js',
+ \ 'vite.config.mjs',
+ \ 'vite.config.cjs',
+ \ 'vite.config.ts',
+ \ '.git',
+ \ bufname(a:buffer)
+ \]
for l:project_root in l:project_roots
let l:nearest_filepath = ale#path#FindNearestFile(a:buffer, l:project_root)
@@ -60,11 +31,19 @@ function! ale_linters#vue#volar#GetProjectRoot(buffer) abort
endfunction
function! ale_linters#vue#volar#GetInitializationOptions(buffer) abort
- let l:tsserver_path = ale#path#FindNearestExecutable(a:buffer, [
- \ 'node_modules/typescript/lib/tsserverlibrary.js'
- \ ])
+ let l:tsserver_path = ale#path#FindNearestDirectory(a:buffer, 'node_modules/typescript/lib')
+
+ if l:tsserver_path is# ''
+ " no-custom-checks
+ echohl WarningMsg
+ " no-custom-checks
+ echom '[volar] Must have typescript installed in project, please install via `npm install -D typescript`.'
+ " no-custom-checks
+ echohl None
+ endif
+
let l:init_options = ale#Var(a:buffer, 'vue_volar_init_options')
- let l:init_options.typescript.serverPath = l:tsserver_path
+ let l:init_options.typescript.tsdk = l:tsserver_path
return l:init_options
endfunction
diff --git a/doc/ale-vue.txt b/doc/ale-vue.txt
index 40106b2b..3f382e4f 100644
--- a/doc/ale-vue.txt
+++ b/doc/ale-vue.txt
@@ -50,7 +50,7 @@ g:ale_vue_volar_executable *g:ale_vue_volar_executable*
g:ale_vue_volar_use_global *g:ale_vue_volar_use_global*
*b:ale_vue_volar_use_global*
Type: |Number|
- Default: `get(g:, 'ale_use_global_executables', 0)`
+ Default: `1`
See |ale-integrations-local-executables|
@@ -58,7 +58,7 @@ g:ale_vue_volar_use_global *g:ale_vue_volar_use_global*
g:vue_volar_init_options *g:ale_vue_volar_init_options*
*b:ale_vue_volar_init_options*
Type: |Dictionary|
- Default: `{ ... }`
+ Default: `{ 'typescript': 'tsdk': '' }`
Default is too long to show here, take a look at it over
`ale_linters/vue/volar.vim`
diff --git a/test/linter/test_volar.vader b/test/linter/test_volar.vader
index bef094be..d6dc8737 100644
--- a/test/linter/test_volar.vader
+++ b/test/linter/test_volar.vader
@@ -21,7 +21,7 @@ Execute(Assert proper tsserverlibrary for Volar LSP):
call ale#test#SetFilename('../test-files/volar/src/App.vue')
let g:init_opts = ale_linters#vue#volar#GetInitializationOptions(bufnr(''))
- let g:tsserver_path = init_opts.typescript.serverPath
- let g:actual_path = ale#path#Simplify(g:dir . '/../test-files/volar/node_modules/typescript/lib/tsserverlibrary.js')
+ let g:tsserver_path = init_opts.typescript.tsdk
+ let g:actual_path = ale#path#Simplify(g:dir . '/../test-files/volar/node_modules/typescript/lib/')
AssertEqual g:tsserver_path, g:actual_path