client/atom/main.js in yoda-language-server-0.4.0 vs client/atom/main.js in yoda-language-server-0.5.0

- old
+ new

@@ -3,25 +3,35 @@ const { resolve } = require('path') class YodaClient extends AutoLanguageClient { constructor() { super() - atom.config.set('core.debugLSP', true) // Debug the hell out of this } + getGrammarScopes () { return ['source.ruby', 'source.rb', 'source.ruby.rails'] } getLanguageName () { return 'Ruby' } getServerName () { return 'Yoda' } getConnectionType() { return 'stdio' } - startServerProcess () { - const yoda = atom.inDevMode() ? spawn(resolve(__dirname, '../../exe/yoda'), ['server']) : spawn('yoda', ['server']); + getServerPath() { + const serverPath = atom.config.get('yoda.serverPath'); + return (serverPath && serverPath.length) ? serverPath : 'yoda'; + } + + startServerProcess (projectPath) { + const yoda = this._launchYoda(projectPath); yoda.stderr.on('data', (data) => { this.logger.warn(`${data}`); }); yoda.on('close', (code) => { this.logger.debug(`child process exited with code ${code}`); }); return yoda; + } + + _launchYoda(projectPath) { + const commandOptions = { cwd: projectPath }; + return spawn(this.getServerPath(), ['server'], commandOptions); } } module.exports = new YodaClient()