diff --git a/docs/development/writing_zeppelin_interpreter.md b/docs/development/writing_zeppelin_interpreter.md index 6ba24bc44a7..9470dd7ddc8 100644 --- a/docs/development/writing_zeppelin_interpreter.md +++ b/docs/development/writing_zeppelin_interpreter.md @@ -74,7 +74,8 @@ Here is an example of `interpreter-setting.json` on your own interpreter. }, "editor": { "language": "your-syntax-highlight-language", - "editOnDblClick": false + "editOnDblClick": false, + "completionKey": "TAB" } }, { @@ -128,6 +129,19 @@ If your interpreter uses mark-up language such as markdown or HTML, set `editOnD "editOnDblClick": false } ``` + +### Completion key (Optional) +By default, `Ctrl+dot(.)` brings autocompletion list in the editor. +Through `completionKey`, each interpreter can configure autocompletion key. +Currently `TAB` is only available option. + +``` +"editor": { + "completionKey": "TAB" +} +``` + + ## Install your interpreter binary Once you have built your interpreter, you can place it under the interpreter directory with all its dependencies. diff --git a/python/src/main/resources/interpreter-setting.json b/python/src/main/resources/interpreter-setting.json index 3bc42b8d110..c14e3d9f28d 100644 --- a/python/src/main/resources/interpreter-setting.json +++ b/python/src/main/resources/interpreter-setting.json @@ -21,7 +21,8 @@ }, "editor": { "language": "python", - "editOnDblClick": false + "editOnDblClick": false, + "completionKey": "TAB" } }, { diff --git a/spark/src/main/resources/interpreter-setting.json b/spark/src/main/resources/interpreter-setting.json index e96265f00a5..bab4c72f491 100644 --- a/spark/src/main/resources/interpreter-setting.json +++ b/spark/src/main/resources/interpreter-setting.json @@ -71,7 +71,8 @@ }, "editor": { "language": "scala", - "editOnDblClick": false + "editOnDblClick": false, + "completionKey": "TAB" } }, { @@ -110,7 +111,8 @@ }, "editor": { "language": "sql", - "editOnDblClick": false + "editOnDblClick": false, + "completionKey": "TAB" } }, { @@ -135,7 +137,8 @@ }, "editor": { "language": "scala", - "editOnDblClick": false + "editOnDblClick": false, + "completionKey": "TAB" } }, { @@ -153,7 +156,8 @@ }, "editor": { "language": "python", - "editOnDblClick": false + "editOnDblClick": false, + "completionKey": "TAB" } } ] diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js index f07a1576788..9e41af92fa0 100644 --- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js +++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js @@ -185,6 +185,11 @@ function ParagraphCtrl ($scope, $rootScope, $route, $window, $routeParams, $loca } } + const isTabCompletion = function() { + const completionKey = $scope.paragraph.config.editorSetting.completionKey + return completionKey === 'TAB' + } + $scope.$on('updateParagraphOutput', function (event, data) { if ($scope.paragraph.id === data.paragraphId) { if (!$scope.paragraph.results) { @@ -843,9 +848,9 @@ function ParagraphCtrl ($scope, $rootScope, $route, $window, $routeParams, $loca let currentLine = $scope.editor.session.getLine(iCursor.row) let isAllTabs = currentLine.split('').every(function(char) { return (char === '\t' || char === ' ') }) - // If user has pressed tab on first line char or if editor mode is %md, keep existing behavior + // If user has pressed tab on first line char or if isTabCompletion() is false, keep existing behavior // If user has pressed tab anywhere in between and editor mode is not %md, show autocomplete - if (!isAllTabs && iCursor.column && $scope.paragraph.config.editorMode !== 'ace/mode/markdown') { + if (!isAllTabs && iCursor.column && isTabCompletion()) { $scope.editor.execCommand('startAutocomplete') } else { ace.config.loadModule('ace/ext/language_tools', function () {