darkelf
darkelf2mo ago

VIM - ALE - import-prefix-missing: Relative import path

on vim with ALE config for Deno. got this error with commando "deno task dev" or "deno lint" do not have erro. vimrc call plug#begin('~/.vim/plugged') Plug 'preservim/nerdtree' Plug 'psf/black', { 'branch': 'stable' } Plug 'dense-analysis/ale' call plug#end() filetype indent plugin on autocmd FileType typescript source ~/.vim/ftplugin/typescript-style.vim autocmd FileType javascript source ~/.vim/ftplugin/typescript-style.vim autocmd FileType typescriptreact source ~/.vim/ftplugin/typescript-style.vim let g:ale_linters = { \ 'typescript': ['deno'], \ 'javascript': ['deno'] } let g:ale_fixer = { \ 'typescript': ['deno'], } let g:ale_lint_on_save = 1 let g:ale_lint_on_text_changed = 'never' let g:ale_linters_explicit = 1 let g:ale_deno_unstable = 1 " Formatar automaticamente com denofmt ao salvar um arquivo TypeScript " " nmap <C-a> :NERDTreeToggle<CR> " Shortcuts for split navigation map <C-h> <C-w>h map <C-j> <C-w>j map <C-k> <C-w>k map <C-l> <C-w>l deno.json { "tasks": { "dev": "deno run --watch --allow-env --allow-read --allow-write --allow-net main.ts" }, "imports": { "@std/assert": "jsr:@std/assert@1", "@std/dotenv": "jsr:@std/dotenv@^0.225.2" } }
main.ts import "@std/dotenv/load"; const ano = 2015; const dia = 19; const sessionCookie = Deno.env.get("SESSION_COOKIE"); console.log(sessionCookie); const url = https://adventofcode.com/${ano}/day/${dia}/input; const res = await fetch(url, { headers: { Cookie: session=${sessionCookie} }, }); console.log(res); //console.log(await res.text());
1 Reply
aaaaaaaaaa
aaaaaaaaaa3w ago
Hi, I think I was having the same issue as you. For me, ALE was not finding deno imports in vim. I noticed that you may have a syntax error in your vimrc here:
let g:ale_linters = {
\ 'typescript': ['deno'],
\ 'javascript': ['deno']
}

let g:ale_fixer = {
\ 'typescript': ['deno'],
}
let g:ale_linters = {
\ 'typescript': ['deno'],
\ 'javascript': ['deno']
}

let g:ale_fixer = {
\ 'typescript': ['deno'],
}
The trailing comma was giving me errors (in vim 9), so I changed it to this and it worked:
let g:ale_linters = { 'typescript': ['deno'], 'javascript': ['deno'] }
let g:ale_fixer = { 'typescript': ['deno'] }
let g:ale_linters = { 'typescript': ['deno'], 'javascript': ['deno'] }
let g:ale_fixer = { 'typescript': ['deno'] }
This fixed the problem for me. When I used the command :ALEInfo, it said that I was using tsserver and not deno. When I added your snippet, ALE correctly uses deno now. Hope this helps!

Did you find this page helpful?