Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@codemirror/lsp-client

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemirror/lsp-client - npm Package Compare versions

Comparing version
6.1.2
to
6.2.0
+6
-0
CHANGELOG.md

@@ -0,1 +1,7 @@

## 6.2.0 (2025-10-27)
### New features
`serverCompletion` now takes an option `validFor` that can be used to configure the regexp used in the result.
## 6.1.2 (2025-09-10)

@@ -2,0 +8,0 @@

@@ -472,2 +472,10 @@ import * as lsp from 'vscode-languageserver-protocol';

override?: boolean;
/**
Set a custom
[`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor) expression
to use in the completion results. By default, the library uses an
expression that accepts word characters, optionally prefixed by
any non-word prefixes found in the results.
*/
validFor?: RegExp;
}): Extension;

@@ -474,0 +482,0 @@ /**

@@ -472,2 +472,10 @@ import * as lsp from 'vscode-languageserver-protocol';

override?: boolean;
/**
Set a custom
[`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor) expression
to use in the completion results. By default, the library uses an
expression that accepts word characters, optionally prefixed by
any non-word prefixes found in the results.
*/
validFor?: RegExp;
}): Extension;

@@ -474,0 +482,0 @@ /**

+1
-1
{
"name": "@codemirror/lsp-client",
"version": "6.1.2",
"version": "6.2.0",
"description": "Language server protocol client for CodeMirror",

@@ -5,0 +5,0 @@ "keywords": [

import type * as lsp from "vscode-languageserver-protocol"
import {EditorState, Extension} from "@codemirror/state"
import {EditorState, Extension, Facet} from "@codemirror/state"
import {CompletionSource, Completion, CompletionContext, snippet, autocompletion} from "@codemirror/autocomplete"

@@ -15,11 +15,24 @@ import {LSPPlugin} from "./plugin"

override?: boolean
/// Set a custom
/// [`validFor`](#autocomplete.CompletionResult.validFor) expression
/// to use in the completion results. By default, the library uses an
/// expression that accepts word characters, optionally prefixed by
/// any non-word prefixes found in the results.
validFor?: RegExp
} = {}): Extension {
let result: Extension[]
if (config.override) {
return autocompletion({override: [serverCompletionSource]})
result = [autocompletion({override: [serverCompletionSource]})]
} else {
let data = [{autocomplete: serverCompletionSource}]
return [autocompletion(), EditorState.languageData.of(() => data)]
result = [autocompletion(), EditorState.languageData.of(() => data)]
}
if (config.validFor) result.push(completionConfig.of({validFor: config.validFor}))
return result
}
const completionConfig = Facet.define<{validFor: RegExp}, {validFor: RegExp | null}>({
combine: results => results.length ? results[0] : {validFor: null}
})
function getCompletions(plugin: LSPPlugin, pos: number, context: lsp.CompletionContext, abort?: CompletionContext) {

@@ -72,2 +85,3 @@ if (plugin.client.hasCapability("completionProvider") === false) return Promise.resolve(null)

let defaultCommitChars = result.itemDefaults?.commitCharacters
let config = context.state.facet(completionConfig)

@@ -93,3 +107,3 @@ return {

commitCharacters: defaultCommitChars,
validFor: prefixRegexp(result.items),
validFor: config.validFor ?? prefixRegexp(result.items),
map: (result, changes) => ({...result, from: changes.mapPos(result.from)}),

@@ -96,0 +110,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display