vim - Configuring Vim/Neovim ALE plugin to support :ALEGoToDefinition in JavaScript files
问题描述
I installed the ALE plugin for Vim using vim-plug:
Plug 'dense-analysis/ale'
The plugin seems to have been installed correctly. I can use ALE to automatically format files with Prettier, for example. But I can't seem to get anything that uses the language server to work.
For example, in the following JavaScript file, putting my cursor over the name add
on line 5 and using the :ALEGoToDefinition
command has no effect.
function add(x, y) {
return x + y;
}
console.log(add(1, 2));
I have really made an effort to read the documentation. The ALE help file says that "ALE will do nothing" if an LSP server does not provide a location to jump to. That seems to be my problem. But the ALE documentation on GitHub also says that "ALE integrates with almost all JavaScript tools very well, and most things should work without requiring any configuration."
I must be missing something. Aside from installing ALE, is anything needed to enable features which use a language server? Should I install some kind of language server globally on my machine?
解决方案
User toupeira on Reddit answered this question for me. At the time of this writing, the only JavaScript language server that ALE supports is tsserver. It ships with TypeScript. To enable ALE's language server features, I needed to install the typescript package globally.
npm install -g typescript
I don't need to start the server manually. ALE seems to take care of that.
The only other requirement is that tsserver is enabled as a JavaScript "linter." It is by default. Run :ALEInfo
to see which linters are enabled for the current file.
推荐阅读
- angular - Angular Libraries Monorepo:是否可以为每个库使用不同的版本?
- c# - 将非DLL文件复制到其他项目的所有输出目录
- ruby-on-rails - 在 Rails 应用程序中创建 html 标签包装器
- selenium - 流利的等待不忽略异常
- solr - Solr, cast an array of strings to an array of payloads
- python - 如何从 numpy 的数组中选择特定列的值最大的行?
- c++ - 为什么在这种情况下括号不能改变 C++ 运算符的优先级?
- recaptcha - Limitations per reCaptcha (Google) account
- azure - How to escape json in dynamic content in ADF V2 in Azure?
- javascript - Calling typescript interface from commonJS function call