diff options
author | Arnold Chand <creativenull@outlook.com> | 2021-11-21 07:02:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-21 20:02:09 +0900 |
commit | de67f4743d9ffd1694d15b1b91fedfaa0a5cda70 (patch) | |
tree | 462600fd76a8cc608a519ef40dd6b4c27f53097a /ale_linters/vue | |
parent | 072750137f752c0a09fd1ff493da2bea6519b7ef (diff) | |
download | ale-de67f4743d9ffd1694d15b1b91fedfaa0a5cda70.zip |
Add volar support for vue (#3992)
* feat-draft: inital volar setup
* feat(volar): add documentation
* feat(volar): include default init opts
* feat(volar): add initial tests
* fix(volar): add possible project roots
* fix(volar): tests - use empty files
Diffstat (limited to 'ale_linters/vue')
-rw-r--r-- | ale_linters/vue/volar.vim | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/ale_linters/vue/volar.vim b/ale_linters/vue/volar.vim new file mode 100644 index 00000000..360b1aa5 --- /dev/null +++ b/ale_linters/vue/volar.vim @@ -0,0 +1,80 @@ +" Author: Arnold Chand <creativenull@outlook.com> +" Description: Volar Language Server integration for ALE adopted from +" nvim-lspconfig and volar/packages/shared/src/types.ts + +call ale#Set('vue_volar_executable', 'volar-server') +call ale#Set('vue_volar_use_global', get(g:, 'ale_use_global_executables', 0)) +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, +\ }, +\}) + +function! ale_linters#vue#volar#GetProjectRoot(buffer) abort + let l:project_roots = ['package.json', 'vite.config.js', '.git', bufname(a:buffer)] + + for l:project_root in l:project_roots + let l:nearest_filepath = ale#path#FindNearestFile(a:buffer, l:project_root) + + if !empty(l:nearest_filepath) + return fnamemodify(l:nearest_filepath, ':h') + endif + endfor + + return '' +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:init_options = ale#Var(a:buffer, 'vue_volar_init_options') + let l:init_options.typescript.serverPath = l:tsserver_path + + return l:init_options +endfunction + +call ale#linter#Define('vue', { +\ 'name': 'volar', +\ 'language': 'vue', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#path#FindExecutable(b, 'vue_volar', ['node_modules/.bin/volar-server'])}, +\ 'command': '%e --stdio', +\ 'project_root': function('ale_linters#vue#volar#GetProjectRoot'), +\ 'initialization_options': function('ale_linters#vue#volar#GetInitializationOptions'), +\}) |