mirror of https://github.com/dense-analysis/ale
Add importMap option to deno Initialization Options (#3827)
* feat(deno): move init options to handlers * feat(deno): add deno lsp support for js files * feat(deno): use default map option * feat(docs): add deno import map option * feat(deno): add tests for importMap option * fix(deno): use full path in importMap * feat(deno): remove deno as linter for js, separate PR * fix(deno): test for executable * fix(deno-test): include filename to simplify function
This commit is contained in:
parent
7d8fb2ba17
commit
8c591996a8
|
@ -1,4 +1,5 @@
|
|||
" Author: Mohammed Chelouti - https://github.com/motato1
|
||||
" Arnold Chand <creativenull@outlook.com>
|
||||
" Description: Deno lsp linter for TypeScript files.
|
||||
|
||||
call ale#linter#Define('typescript', {
|
||||
|
@ -7,19 +8,5 @@ call ale#linter#Define('typescript', {
|
|||
\ 'executable': function('ale#handlers#deno#GetExecutable'),
|
||||
\ 'command': '%e lsp',
|
||||
\ 'project_root': function('ale#handlers#deno#GetProjectRoot'),
|
||||
\ 'initialization_options': function('ale_linters#typescript#deno#GetInitializationOptions'),
|
||||
\ 'initialization_options': function('ale#handlers#deno#GetInitializationOptions'),
|
||||
\})
|
||||
|
||||
function! ale_linters#typescript#deno#GetInitializationOptions(buffer) abort
|
||||
let l:options = {
|
||||
\ 'enable': v:true,
|
||||
\ 'lint': v:true,
|
||||
\ 'unstable': v:false,
|
||||
\ }
|
||||
|
||||
if ale#Var(a:buffer, 'deno_unstable')
|
||||
let l:options.unstable = v:true
|
||||
endif
|
||||
|
||||
return l:options
|
||||
endfunction
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
" Author: Mohammed Chelouti - https://github.com/motato1
|
||||
" Arnold Chand <creativenull@outlook.com>
|
||||
" Description: Handler functions for Deno.
|
||||
|
||||
call ale#Set('deno_executable', 'deno')
|
||||
call ale#Set('deno_unstable', 0)
|
||||
call ale#Set('deno_importMap', 'import_map.json')
|
||||
call ale#Set('deno_lsp_project_root', '')
|
||||
|
||||
function! ale#handlers#deno#GetExecutable(buffer) abort
|
||||
|
@ -50,3 +52,23 @@ function! ale#handlers#deno#GetProjectRoot(buffer) abort
|
|||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" Initialization Options for deno, for javascript and typescript
|
||||
function! ale#handlers#deno#GetInitializationOptions(buffer) abort
|
||||
let l:options = {
|
||||
\ 'enable': v:true,
|
||||
\ 'lint': v:true,
|
||||
\ 'unstable': v:false,
|
||||
\ 'importMap': ale#path#FindNearestFile(a:buffer, 'import_map.json'),
|
||||
\ }
|
||||
|
||||
if ale#Var(a:buffer, 'deno_unstable')
|
||||
let l:options.unstable = v:true
|
||||
endif
|
||||
|
||||
if ale#Var(a:buffer, 'deno_importMap') isnot# ''
|
||||
let l:options.importMap = ale#path#FindNearestFile(a:buffer, ale#Var(a:buffer, 'deno_importMap'))
|
||||
endif
|
||||
|
||||
return l:options
|
||||
endfunction
|
||||
|
|
|
@ -34,6 +34,12 @@ g:ale_deno_unstable *g:ale_deno_unstable*
|
|||
|
||||
Enable or disable unstable Deno features and APIs.
|
||||
|
||||
g:ale_deno_importMap *g:ale_deno_importMap*
|
||||
*b:ale_deno_importMap*
|
||||
Type: |String|
|
||||
Default: `'import_map.json'`
|
||||
|
||||
Specify the import map filename to load url maps in a deno project.
|
||||
|
||||
===============================================================================
|
||||
eslint *ale-typescript-eslint*
|
||||
|
|
|
@ -178,6 +178,9 @@ let g:ale_python_auto_poetry = get(g:, 'ale_python_auto_poetry', 0)
|
|||
" This variable can be overridden to set the GO111MODULE environment variable.
|
||||
let g:ale_go_go111module = get(g:, 'ale_go_go111module', '')
|
||||
|
||||
" Default executable for deno, needed set before plugin start
|
||||
let g:ale_deno_executable = get(g:, 'ale_deno_executable', 'deno')
|
||||
|
||||
" If 1, enable a popup menu for commands.
|
||||
let g:ale_popup_menu_enabled = get(g:, 'ale_popup_menu_enabled', has('gui_running'))
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Before:
|
||||
let g:ale_deno_importMap = 'import_map.json'
|
||||
let g:ale_deno_unstable = 0
|
||||
let g:ale_deno_executable = 'deno'
|
||||
let g:ale_deno_lsp_project_root = ''
|
||||
|
@ -13,7 +14,8 @@ Execute(Should set deno lsp for TypeScript projects using stable Deno API):
|
|||
AssertLSPOptions {
|
||||
\ 'enable': v:true,
|
||||
\ 'lint': v:true,
|
||||
\ 'unstable': v:false
|
||||
\ 'unstable': v:false,
|
||||
\ 'importMap': ''
|
||||
\}
|
||||
|
||||
Execute(Should set deno lsp using unstable Deno API if enabled by user):
|
||||
|
@ -22,7 +24,41 @@ Execute(Should set deno lsp using unstable Deno API if enabled by user):
|
|||
AssertLSPOptions {
|
||||
\ 'enable': v:true,
|
||||
\ 'lint': v:true,
|
||||
\ 'unstable': v:true
|
||||
\ 'unstable': v:true,
|
||||
\ 'importMap': ''
|
||||
\}
|
||||
|
||||
Execute(Should set the default importMap filepath):
|
||||
call ale#test#SetFilename('../test-files/typescript/test.ts')
|
||||
|
||||
AssertLSPOptions {
|
||||
\ 'enable': v:true,
|
||||
\ 'lint': v:true,
|
||||
\ 'unstable': v:false,
|
||||
\ 'importMap': ale#path#Simplify(g:dir . '/../test-files/typescript/import_map.json')
|
||||
\}
|
||||
|
||||
Execute(Should set the importMap filepath from user defined importMap):
|
||||
let g:ale_deno_importMap = 'custom_import_map.json'
|
||||
call ale#test#SetFilename('../test-files/typescript/test.ts')
|
||||
|
||||
AssertLSPOptions {
|
||||
\ 'enable': v:true,
|
||||
\ 'lint': v:true,
|
||||
\ 'unstable': v:false,
|
||||
\ 'importMap': ale#path#Simplify(g:dir . '/../test-files/typescript/custom_import_map.json')
|
||||
\}
|
||||
|
||||
Execute(Should set the importMap filepath from user defined importMap with unstable API):
|
||||
let g:ale_deno_importMap = 'custom_import_map.json'
|
||||
let g:ale_deno_unstable = 1
|
||||
call ale#test#SetFilename('../test-files/typescript/test.ts')
|
||||
|
||||
AssertLSPOptions {
|
||||
\ 'enable': v:true,
|
||||
\ 'lint': v:true,
|
||||
\ 'unstable': v:true,
|
||||
\ 'importMap': ale#path#Simplify(g:dir . '/../test-files/typescript/custom_import_map.json')
|
||||
\}
|
||||
|
||||
Execute(Should find project root containing tsconfig.json):
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
Before:
|
||||
Save g:ale_deno_executable
|
||||
runtime autoload/ale/handlers/deno.vim
|
||||
|
||||
After:
|
||||
unlet! g:ale_deno_executable
|
||||
unlet! b:ale_deno_executable
|
||||
|
||||
call ale#linter#Reset()
|
||||
|
||||
|
|
Loading…
Reference in New Issue