Configuring Vim/Neovim ALE plugin to support :ALEGoToDefinition in JavaScript files - vim

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.

Related

Atom editor not showing suggestions or importing node modules

I have been using VSCode for several years, but I recently decided to move to Atom. VSCode has built-in a ton of features, including a very well-built auto-suggestion system. Whenever I started typing something in VSCode, I got a suggestion. Unfortunately, this is not the case in Atom.
I have tried autocomplete-modules, autocomplete-paths, and atom-ternjs, but with no luck. What I want is a proper, working autosuggestion system that also imports on select.
I work with Material-UI and Material Design Icons and both of these were automatically suggested and imported in VSCode. I mostly write JavaScript for React.js and Node.js for the backend.
you have to install for language https://github.com/atom/autocomplete-plus/wiki/Autocomplete-Providers
read this https://atom.io/packages/autocomplete-plus

Neovim Rust LSP diagnostics no longer working in buffers

Something has caused my Rust language tools to stop working as expected recently. I hadn't been in a Rust file for about 2 weeks, came back and I no longer have all the diagnostic info from the language server in the buffer. No gutter hints, no underlines, no LSP-Saga goodness. Oddly I still have some inlay hints. ?? I could use some help troubleshooting where to dig on this.
Nvim version:
NVIM v0.8.0-1210-gd367ed9b2
LuaJIT 2.1.0-beta3
Packer installs related to rust:
nvim-lspconfig (though not using it to configure rust, see tools below)
Mason and mason-lspconfig
simrat39/rust-tools
Rust-Analyzer and codelldb installed through Mason and updated
So far I have tried removing rust-tools and and configuring through lspconfigs. No luck. I also confirmed with :LspInfo that the language server is running and attached with both config options. I removed LSPSaga, combed through everything touching vim.diagnostic and turned things off / back on, no love there either.
The strange thing is I still have my Typescript, Lua, Svelte and Go support, full featured and totally unchanged, so it's more than likely something specific to Rust. I did run PackerSync a few times because I was playing with themes and saw some updates on other plugins that I didn't pay a lot of attention to. No new issues on any of the github repos related to Rust either, at least not with this issue. Something changed somewhere, but I could definitely use some direction tracking it down.
Any thoughts?
Edit
I was able to get partial support back. I did this by uninstalling the language server with Mason, then installing an older version directly within linux and adding it to $PATH. At this point things some of the things turned back on, but not all. I then removed the binary from $PATH and reinstalled the latest version with Mason, and the things that started working again kept working.
This one has me stumped, but I got enough functionality back to work comfortably again.

How to enable Node.js code autocompletion in VSCode?

I have installed Visual Studio Code and Node.js and both basically work, but autocomplete is not (completely) working. If I type 'console.' I do indeed see a list popup. Likewise if I do:
const http = require("http");
http.
But if I simply type 'process.' I don't see anything. In fact as soon as I type '.' Code autocompletes 'process' to 'ProcessingInstruction'. I was expecting to see argv pop up, along with all the other stuff you see if you type 'process' at a Node prompt.
Here's what I see when I type 'console.':
Yay -- it works!
But here's what I see when I type 'process.' (I have to change the autocompleted 'ProcessingInstruction' back to 'process'):
Boo -- it doesn't know 'process'! :(
You will need to tell VS Code about the types in Node JS (as you hit at yourself in the comment). To do this you can install the types for node running the following command (assuming you have already run npm init):
npm install --save-dev #types/node
It will install the types for Node JS, which VS Code automatically picks up and you'll be auto-completing all Node JS-specific things going forward. You don't even have to restart VS Code.
As you are adding more dependencies to your project (if you will be doing so). Many of them have a #types/X package as well (if they don't have the already included in the package), which will allow autocomplete as well.
Per Microsoft's Documentation: https://code.visualstudio.com/docs/nodejs/working-with-javascript
IntelliSense for JavaScript libraries and frameworks is powered by TypeScript type declaration (typings) files.
Automatic type acquisition requires npmjs, the Node.js package manager, which is included with the Node.js runtime.
In my situation, I do not have npmjs installed and that's why automatic type acquisition fails.
*Edit, that is, after installing npm, my autocomplete starting working successfully for node related hints.
If you are using pure javascript for your node app, when including the required modules, they should be defined with single quotes instead of double-quotes. If you were using a code formatter extension like "Prettier" for instance, it adds it by default before the IntelliSense, then you would have to update your settings to use single quote.

Moodle Atto 'plugin not found'

I've been trying to use the Atto plugin template (https://github.com/justinhunt/moodle-atto_newtemplate) to try and create my own Atto plugin. I've made the changes outlined in the README, and got shifter to run via npm. It appears to generate the build folder that matches the other plugins.
I'm able to see the plugin in configuration, and it's showing up in the Atto Toolbar Settings, but, when I pop open a text editor, I don't get an icon, and the console logs moodle-editor_atto-editor: Plugin 'testplugin' could not be found - skipping initialisation
I've found a few references in the docs that shifter is no longer used, and grunt is the new way to go, but I can't find any actual docs on this, and no gruntfile seems to exist anywhere.
Has anyone come across this before? What am I missing?
You will need to run shifter on your YUI code for it to work - the usual way of doing that, for Moodle 2.9 and above is to use grunt - see https://docs.moodle.org/dev/Grunt for more details.
Not sure if this was ever resolved. The template is really helpful and it also comes with lib, db, and version PHP scripts. The string that you use as the plugin name has to be consistent throughout these scripts, as well as in your JS file. By default, it is set to atto_NEWTEMPLATE. Did you perhaps change this string to atto_testplugin in one place but not in all the others?

Server side programming language/framework that support hot-reload

Is there any other server side language (with or without frameworks) that support hot-reload or live-coding, so when we develop, all we need is:
Start the web server
Edit the source code
Try on the browser (without having to restart the server)
Similar to PHP
Some other language that I know able to do this:
ruby/sinatra
sinatra-reloader gem (sometimes not working)
rerun (*
nodejs
nodules module
node-supervisor module
nodemon (*
(* automatically restart server when there are changes, not really hot-reload
Is there any other language that are able to do this? and if possible, showing the error (filename and line number, or the full stack trace) on the browser (not in the terminal/console), so I don't have to switch from code-editor then to browser and then to console to see the error.
You can try Perl with the Mojolicious framework: http://mojolicio.us/ (using the morbo server).
Can also be achived with Groovy/Java using the Grails framework: http://grails.org
You can use Erlang to work as a web server, which is designed to allow you to hot swap whole modules of code while the program is up and running. Though, the functional programming paradigm does take a little while to get used to...
How to write a simple webserver in Erlang?
I hope this helps...
I think what you ask for is actually called live-reload, hot-reload is something I believe only Erlang can truly accomplish.
By configuring and adding plugins to Grunt or Gulp, you can watch for changes in any list / kinds of files and describe any action to be initiated. Here is a plugin for Grunt. With this method, any language can gain such ability.
As a side note, Django (Python) has auto-restart as well. But that does not mean Python language has it built-in, Django uses a Grunt-like trick to restart its dev-server.
Revel for Go could do this, or Beego, the difference is Revel only recompile when there are changes on the source code and on new request (so it's more efficient), Beego recompile every time there are source code changes.
EDIT: Beego 1.3.0 remove its hot reload feature T__T

Resources