简体   繁体   中英

JavaScript autocomplete on imported modules in GitHub's Atom

I'm trying to get familiar with GitHub's Atom and working with JavaScript on a large-scale project. I've been working with tutorials, and the biggest complaint I'm having with Atom is that I can't find a way to get the out of the box autocomplete to work consistently.

For example, I'm following a relatively simple Node.js tutorial, using ES6 syntax, and I have the following code in a core.js file:

export function logMe(message) {
  console.log('message: ' + message);
}

In main.js file, I have the following:

import {logMe} from '../src/core'

logMe('Hello, world!');

However, when typing in main.js , I get no autocomplete suggestions for logMe or anything in my core.js file. I feel like there should be either some existing functionality in autocomplete-plus , or another plugin, that allows autocomplete to work across import statements.

Have you tried using atom-ternjs it is Atom integration with the excellent TernJS . You will need to spend a bit of time generating your .tern-project file by going to the Packages menu → Atom TernjsConfigure Project , but once you have it setup it works very well.

If you don't want to go down the TernJS route, then there is a setting for the autocomplete-plus package called Include Completions from All Buffers :

包括所有缓冲区的完成

In my experience it can create a lot of noise and is dependent upon a the other files being open which doesn't scale well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM