Skip to content

Commit

Permalink
[Code] Enabgle go language of the monaco editor. (#33476)
Browse files Browse the repository at this point in the history
This change will make the code plugin have the ability in the
development mode to highlight the go source code and send
the go-to definition request to the lang server.
  • Loading branch information
Henry Wong authored and zfy0701 committed Mar 21, 2019
1 parent b9389f5 commit 03db103
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/code/public/monaco/monaco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import lightTheme from '@elastic/eui/dist/eui_theme_light.json';
// import 'monaco-editor/esm/vs/basic-languages/css/css.contribution.js';
// import 'monaco-editor/esm/vs/basic-languages/dockerfile/dockerfile.contribution.js';
// import 'monaco-editor/esm/vs/basic-languages/fsharp/fsharp.contribution.js';
// import 'monaco-editor/esm/vs/basic-languages/go/go.contribution.js';
import 'monaco-editor/esm/vs/basic-languages/go/go.contribution.js';
// import 'monaco-editor/esm/vs/basic-languages/handlebars/handlebars.contribution.js';
// import 'monaco-editor/esm/vs/basic-languages/html/html.contribution.js';
// import 'monaco-editor/esm/vs/basic-languages/ini/ini.contribution.js';
Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugins/code/public/monaco/monaco_helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { editor } from 'monaco-editor';
import chrome from 'ui/chrome';
import { ResizeChecker } from 'ui/resize_checker';
import { EditorActions } from '../components/editor/editor';
import { provideDefinition } from './definition/definition_provider';
Expand Down Expand Up @@ -43,6 +44,9 @@ export class MonacoHelper {
this.monaco.languages.registerDefinitionProvider('java', definitionProvider);
this.monaco.languages.registerDefinitionProvider('typescript', definitionProvider);
this.monaco.languages.registerDefinitionProvider('javascript', definitionProvider);
if (chrome.getInjected('enableLangserversDeveloping', false) === true) {
this.monaco.languages.registerDefinitionProvider('go', definitionProvider);
}
const codeEditorService = new EditorService();
codeEditorService.setMonacoHelper(this);
this.editor = monaco.editor.create(
Expand Down
6 changes: 5 additions & 1 deletion x-pack/plugins/code/server/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,18 @@ async function initCodeNode(server: Server, serverOptions: ServerOptions, log: L
log.info('Initializing Code plugin as code-node.');
const queueIndex: string = server.config().get('xpack.code.queueIndex');
const queueTimeout: number = server.config().get('xpack.code.queueTimeout');
const devMode: boolean = server.config().get('env.dev');
const adminCluster = server.plugins.elasticsearch.getCluster('admin');

// @ts-ignore
const esClient: EsClient = adminCluster.clusterClient.client;
const repoConfigController = new RepositoryConfigController(esClient);

server.injectUiAppVars('code', () => ({
enableLangserversDeveloping: devMode,
}));
// Enable the developing language servers in development mode.
if (server.config().get('env.dev') === true) {
if (devMode === true) {
LanguageServers.push(...LanguageServersDeveloping);
}

Expand Down

0 comments on commit 03db103

Please sign in to comment.