-
Notifications
You must be signed in to change notification settings - Fork 374
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Language-Understanding LSP (#1711)
* Add LSP of LG * change folder name * change folder location * seperate server and client demo * add completion and hover for builtin-functions * change file names * change dependency * refactor the package * update demo readme * make some refine * remove npm lock file * add demos to workspace and run test in 1 command * remove declaration files * change tsc outDir to dist, simplify test command * add syntax highlight in demo and new API * change naming of the project and move the demo * remove package.json in demo * change the content in readme * fix lg-lsp package publish problem * fix build command and redundent d.ts files * integrate LG LSP server to composer server * change api in demo * change the order of commands in build:prod * delete redundent files generated from build * change lg-lsp-server api to attachLSPServer * remove gitignore in lg-lsp-server demo * remove attachLSPServer in server * fix token rules and suggestion context awareness * init of LU LSP * add diagnostic in LSP * add auto suggestions * fix * remove redundent in client * add doc on type config * fix * modify doc type format * fix * change version of bf-lu * fix diagnostic * refactor getRangeAtPosition method * fix tokens * remove black line * fix tokens * add roles suggestions * add regex entity seperated line definition * add suggestions for ml entity * matching only ML entities * fix * update documents * fix * integrate lu-lsp to composer * upgrade botbuilder-expressions * clean up * update sample * add test * add syntax highlight * add token rule for {@ expr * add a case in token * fix import statement token * fix composite entity auto complete * fix entity suggestion and tokens * add labeling experience of add unlabeled entity * fix typos * fix lint * fix redundent edits * fix unnecessary space * fix naming and role suggestions * fix labeling and error postion * fix insert text in wrong line, intent usesFeature * update bf-lu version * change find a valid luisJson and suggest composite * add unit test for LU lsp basic funcionalities Co-authored-by: Hongyang Du (hond) <hond@microsoft.com> Co-authored-by: Dong Lei <donglei@microsoft.com> Co-authored-by: Zhixiang Zhan <zhixzhan@microsoft.com>
- Loading branch information
Showing
32 changed files
with
2,166 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
// Licensed under the MIT License. | ||
|
||
export * from './lg'; | ||
export * from './lu'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import * as monacoEditor from '@bfcomposer/monaco-editor/esm/vs/editor/editor.api'; | ||
|
||
export function registerLULanguage(monaco: typeof monacoEditor) { | ||
monaco.languages.setMonarchTokensProvider('lu', { | ||
tokenizer: { | ||
root: [ | ||
[/^\s*#/, { token: 'intent', next: '@intent' }], | ||
[/^\s*@/, { token: 'entity-identifier', goBack: 1, next: '@entityMode' }], | ||
[/^\s*>\s*[\s\S]*$/, { token: 'comments' }], | ||
], | ||
|
||
intent: [ | ||
[/^\s*#/, { token: 'intent', next: '@intent' }], | ||
[/^\s*-/, { token: 'utterrance-indentifier', next: '@utterrance' }], | ||
[/^\s*>\s*[\s\S]*$/, { token: 'comments' }], | ||
[/^\s*@/, { token: 'entity-identifier', goBack: 1, next: '@entityMode' }], | ||
[/.*$/, 'intent'], | ||
], | ||
utterrance: [ | ||
[/^\s*#/, { token: 'intent', next: '@intent' }], | ||
[/^\s*>\s*[\s\S]*$/, { token: 'comments' }], | ||
[/^\s*-/, { token: 'utterrance-indentifier', next: 'utterrance' }], | ||
[/^\s*@/, { token: 'entity-identifier', goBack: 1, next: '@entityMode' }], | ||
[/({)(\s*[\w.@:\s]*\s*)(=)(\s*[\w.]*\s*)(})/, ['lb', 'pattern', 'equal', 'entity-name', 'rb']], | ||
[/({\s*@)(\s*[\w.]*\s*)(})/, ['lb', 'entity-name', 'rb']], | ||
// eslint-disable-next-line security/detect-unsafe-regex | ||
[/\s*\[[\w\s.]+\]\(.{1,2}\/[\w.*]+(#[\w.?]+)?\)/, 'import-desc'], | ||
[/./, 'utterance-other'], | ||
], | ||
entityMode: [ | ||
[/^\s*#/, { token: 'intent', next: '@intent' }], | ||
[/^\s*>\s*[\s\S]*$/, { token: 'comments' }], | ||
[/^\s*-/, { token: 'utterrance-indentifier', next: 'utterrance' }], | ||
[ | ||
/(@\s*)(ml|prebuilt|regex|list|composite|patternany|phraselist)(\s*\w*)/, | ||
['intent-indentifier', 'entity-type', 'entity-name'], | ||
], | ||
[/(@\s*)(\s*\w*)/, ['intent-indentifier', 'entity-name']], | ||
[/\s*(hasRoles|useFeature)\s*/, 'keywords'], | ||
[/.*$/, 'entity-other', '@pop'], | ||
], | ||
}, | ||
}); | ||
|
||
monaco.languages.register({ | ||
id: 'lu', | ||
extensions: ['.lu'], | ||
aliases: ['LU', 'language-understanding'], | ||
mimetypes: ['application/lu'], | ||
}); | ||
|
||
monaco.languages.setLanguageConfiguration('lu', { | ||
autoClosingPairs: [ | ||
{ open: '{', close: '}' }, | ||
{ open: '[', close: ']' }, | ||
{ open: '(', close: ')' }, | ||
], | ||
}); | ||
|
||
monaco.editor.defineTheme('lu', { | ||
base: 'vs', | ||
inherit: false, | ||
colors: {}, | ||
rules: [ | ||
{ token: 'intent', foreground: '0000FF' }, | ||
{ token: 'pattern', foreground: '00B7C3' }, | ||
{ token: 'entity-name', foreground: '038387' }, | ||
{ token: 'comments', foreground: '7A7A7A' }, | ||
{ token: 'import-desc', foreground: '00A32B' }, | ||
{ token: 'entity-type', foreground: 'DF2C2C' }, | ||
{ token: 'keywords', foreground: '0078D7' }, | ||
], | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
Composer/packages/tools/language-servers/language-understanding/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/lib | ||
/demo/lib | ||
/demo/dist |
27 changes: 27 additions & 0 deletions
27
Composer/packages/tools/language-servers/language-understanding/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Language-understanding language server demo | ||
|
||
|
||
|
||
## goto language-understanding directory, install packages, run | ||
``` | ||
npm install | ||
``` | ||
|
||
## How to start the demo | ||
|
||
#### 1. under language-understanding directory, run | ||
``` | ||
yarn start | ||
``` | ||
|
||
### 2. go to code-editor directory | ||
|
||
start luEditor demo, connect :5003/lu-language-server | ||
|
||
## Features | ||
|
||
### 1.Auto-suggestions for entity types and defined entities | ||
|
||
### 2.Syntax and semantic diagonostics | ||
|
||
### Auto-copletion for ml entities and list entities |
Oops, something went wrong.