@codemirror/lsp-client
Advanced tools
+10
-0
@@ -0,1 +1,11 @@ | ||
| ## 6.2.4 (2026-05-15) | ||
| ### Bug fixes | ||
| Tell the server we prefer Markdown docs over plain text. | ||
| Support completion-set-wide `insertTextFormat` options. | ||
| Support separate filter and display names for completions. | ||
| ## 6.2.3 (2026-04-15) | ||
@@ -2,0 +12,0 @@ |
+1
-1
| { | ||
| "name": "@codemirror/lsp-client", | ||
| "version": "6.2.3", | ||
| "version": "6.2.4", | ||
| "description": "Language server protocol client for CodeMirror", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
+1
-1
@@ -37,3 +37,3 @@ import type * as lsp from "vscode-languageserver-protocol" | ||
| snippetSupport: true, | ||
| documentationFormat: ["plaintext", "markdown"], | ||
| documentationFormat: ["markdown", "plaintext"], | ||
| insertReplaceSupport: false, | ||
@@ -40,0 +40,0 @@ }, |
+21
-14
@@ -65,2 +65,9 @@ import type * as lsp from "vscode-languageserver-protocol" | ||
| function shouldTriggerCompletion(plugin: LSPPlugin, character: string) : "identifier" | "triggerCharacter" | null { | ||
| let triggers = plugin.client.serverCapabilities?.completionProvider?.triggerCharacters | ||
| if (triggers && triggers.indexOf(character) > -1) return "triggerCharacter" | ||
| if (/[a-zA-Z_]/.test(character)) return "identifier" | ||
| return null | ||
| } | ||
| /// A completion source that requests completions from a language | ||
@@ -71,12 +78,9 @@ /// server. | ||
| if (!plugin) return null | ||
| let triggerChar = "" | ||
| if (!context.explicit) { | ||
| triggerChar = context.view.state.sliceDoc(context.pos - 1, context.pos) | ||
| let triggers = plugin.client.serverCapabilities?.completionProvider?.triggerCharacters | ||
| if (!/[a-zA-Z_]/.test(triggerChar) && !(triggers && triggers.indexOf(triggerChar) > -1)) return null | ||
| } | ||
| return getCompletions(plugin, context.pos, { | ||
| triggerCharacter: triggerChar, | ||
| triggerKind: context.explicit ? 1 /* Invoked */ : 2 /* TriggerCharacter */ | ||
| }, context).then(result => { | ||
| let triggerChar = context.state.sliceDoc(context.pos - 1, context.pos) | ||
| let triggerReason = context.explicit ? "invoked" : shouldTriggerCompletion(plugin, triggerChar) | ||
| if (!triggerReason) return null | ||
| let completionContext: lsp.CompletionContext = triggerReason == "triggerCharacter" | ||
| ? {triggerKind: 2 /* TriggerCharacter */, triggerCharacter: triggerChar} | ||
| : {triggerKind: 1 /* Invoked */} | ||
| return getCompletions(plugin, context.pos, completionContext, context).then(result => { | ||
| if (!result) return null | ||
@@ -93,5 +97,7 @@ if (Array.isArray(result)) result = {items: result} as lsp.CompletionList | ||
| let option: Completion = { | ||
| label: text, | ||
| label: item.filterText || item.label, | ||
| displayLabel: item.label, | ||
| type: item.kind && kindToType[item.kind], | ||
| } | ||
| let insertTextFormat = item.insertTextFormat ?? result.itemDefaults?.insertTextFormat | ||
| if (item.commitCharacters && item.commitCharacters != defaultCommitChars) | ||
@@ -101,5 +107,6 @@ option.commitCharacters = item.commitCharacters | ||
| if (item.sortText) option.sortText = item.sortText | ||
| if (item.insertTextFormat == 2 /* Snippet */) { | ||
| if (insertTextFormat == 2 /* Snippet */) { | ||
| option.apply = (view, c, from, to) => snippet(text.replace(/\$(\d+)/g, "${$1}"))(view, c, from, to) | ||
| option.label = item.label | ||
| } else if (option.label != text) { | ||
| option.apply = text | ||
| } | ||
@@ -110,3 +117,3 @@ if (item.documentation) option.info = () => renderDocInfo(plugin, item.documentation!) | ||
| commitCharacters: defaultCommitChars, | ||
| validFor: config.validFor ?? prefixRegexp(result.items), | ||
| validFor: result.isIncomplete ? undefined : (config.validFor ?? prefixRegexp(result.items)), | ||
| map: (result, changes) => ({...result, from: changes.mapPos(result.from)}), | ||
@@ -113,0 +120,0 @@ } |
+1
-1
@@ -57,3 +57,3 @@ import type * as lsp from "vscode-languageserver-protocol" | ||
| {label: "one", kind: 14, commitCharacters: ["."], textEdit: {newText: "one!", range: {start: before, end: params.position}}}, | ||
| {label: "okay", kind: 7, documentation: "`code` stuff", insertText: "ookay"}, | ||
| {label: "ookay", kind: 7, documentation: "`code` stuff", insertText: "okay"}, | ||
| ] | ||
@@ -60,0 +60,0 @@ } |
@@ -271,3 +271,3 @@ import type * as lsp from "vscode-languageserver-protocol" | ||
| ist(cs.length, 2) | ||
| ist(cs[0].label, "one!") | ||
| ist(cs[0].label, "one") | ||
| ist(cs[1].label, "ookay") | ||
@@ -283,3 +283,3 @@ acceptCompletion(cm) | ||
| acceptCompletion(cm) | ||
| ist(cm.state.sliceDoc(), "..one!\nookay") | ||
| ist(cm.state.sliceDoc(), "..one!\nokay") | ||
| }) | ||
@@ -286,0 +286,0 @@ }) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
280879
0.72%6457
0.37%