All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Mohammed Chelouti - https://github.com/motato1
2 " Arnold Chand <creativenull@outlook.com>
3 " Description: Handler functions for Deno.
5 call ale#Set('deno_executable', 'deno')
6 call ale#Set('deno_unstable', 0)
7 call ale#Set('deno_import_map', 'import_map.json')
8 call ale#Set('deno_lsp_project_root', '')
10 function! ale#handlers#deno#GetExecutable(buffer) abort
11 return ale#Var(a:buffer, 'deno_executable')
14 " Find project root for Deno's language server.
16 " Deno projects do not require a project or configuration file at the project root.
17 " This means the root directory has to be guessed,
18 " unless it is explicitly specified by the user.
20 " The project root is determined by ...
21 " 1. using a user-specified value from deno_lsp_project_root
22 " 2. looking for common top-level files/dirs
23 " 3. using the buffer's directory
24 function! ale#handlers#deno#GetProjectRoot(buffer) abort
25 let l:project_root = ale#Var(a:buffer, 'deno_lsp_project_root')
27 if !empty(l:project_root)
31 let l:possible_project_roots = [
39 for l:possible_root in l:possible_project_roots
40 let l:project_root = ale#path#FindNearestFile(a:buffer, l:possible_root)
42 if empty(l:project_root)
43 let l:project_root = ale#path#FindNearestDirectory(a:buffer, l:possible_root)
46 if !empty(l:project_root)
47 " dir:p expands to /full/path/to/dir/ whereas
48 " file:p expands to /full/path/to/file (no trailing slash)
49 " Appending '/' ensures that :h:h removes the path's last segment
50 " regardless of whether it is a directory or not.
51 return fnamemodify(l:project_root . '/', ':p:h:h')
58 " Initialization Options for deno, for javascript and typescript
59 function! ale#handlers#deno#GetInitializationOptions(buffer) abort
63 \ 'unstable': v:false,
64 \ 'importMap': ale#path#FindNearestFile(a:buffer, 'import_map.json'),
67 if ale#Var(a:buffer, 'deno_unstable')
68 let l:options.unstable = v:true
71 " Look for a value set using the historical option name.
72 let l:import_map = getbufvar(
74 \ 'ale_deno_importMap',
75 \ get(g:, 'ale_deno_importMap', '')
78 if empty(l:import_map)
79 let l:import_map = ale#Var(a:buffer, 'deno_import_map')
82 if !empty(l:import_map)
83 let l:options.importMap = ale#path#FindNearestFile(a:buffer, l:import_map)