You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**Text edits with ranges** - Proper replacement ranges for more accurate completions
8
11
-**Hover Information** - Documentation tooltips when hovering over functions and variables
12
+
-**Variable value previews** - Hovers on variables show a truncated JSON preview of the value
13
+
-**Nested path support** - Hovering over `user.name` resolves and shows the value at that path
9
14
-**Syntax Highlighting** - Token-based highlighting for numbers, strings, keywords, operators, etc.
10
15
11
16
## Basic Usage
@@ -58,3 +63,301 @@ The sample code is located in `samples/language-service-sample/` and shows how t
58
63
2. Connect the language service to Monaco's completion and hover providers
59
64
3. Apply syntax highlighting using decorations
60
65
4. Create an LSP-compatible text document wrapper for Monaco models
66
+
67
+
## Advanced Features
68
+
69
+
### Nested Variable Completions
70
+
71
+
The language service supports path-based completions for nested object properties. When you type a dot after a variable name, you'll get completions for its properties:
72
+
73
+
```js
74
+
constvariables= {
75
+
user: {
76
+
name:'Ada',
77
+
profile: {
78
+
email:'ada@example.com',
79
+
age:30
80
+
}
81
+
},
82
+
config: {
83
+
timeout:5000,
84
+
retries:3
85
+
}
86
+
};
87
+
88
+
// Typing "user." will show completions: user.name, user.profile
89
+
// Typing "user.profile." will show: user.profile.email, user.profile.age
90
+
```
91
+
92
+
**Monaco Editor Integration**: Add `triggerCharacters: ['.']` to your completion provider to automatically trigger completions when typing a dot:
Function completions include snippet support with tab stops for parameters. This provides a better editing experience in editors that support snippets:
106
+
107
+
```js
108
+
// When completing a function like "sum", the insertText is "sum(${1:a})"
109
+
// After selecting the completion:
110
+
// 1. The text "sum(a)" is inserted
111
+
// 2. The parameter "a" is selected, ready for editing
112
+
// 3. You can tab to the next parameter (if any)
113
+
```
114
+
115
+
**Monaco Editor Integration**: Use `insertTextRules` with `monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet` when the completion's `insertTextFormat` is 2 (snippet):
Completion items may include a `textEdit` with a specific `range` for more precise text replacement. This is especially important for path-based completions where only the partial segment after the last dot should be replaced:
134
+
135
+
```js
136
+
// When completing "user.na|" (cursor at |), only "na" should be replaced, not "user.na"
137
+
// The textEdit.range will specify the exact range to replace
138
+
```
139
+
140
+
**Monaco Editor Integration**: Check for `textEdit.range` and use it when available:
0 commit comments