@databutton/codemirror-languageserver
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -34,3 +34,3 @@ import { EditorView, Tooltip, ViewUpdate, PluginValue } from "@codemirror/view"; | ||
textDocumentFormatting(params: LSP.DocumentFormattingParams): Promise<LSP.TextEdit[]>; | ||
textDocumentDiagnostic(params: LSP.DocumentDiagnosticParams): Promise<LSP.DocumentDiagnosticReport>; | ||
textDocumentLinting(params: LSP.DidChangeTextDocumentParams): Promise<PublishDiagnosticsParams>; | ||
textDocumentHover(params: LSP.HoverParams): Promise<LSP.Hover>; | ||
@@ -62,3 +62,8 @@ textDocumentCompletion(params: LSP.CompletionParams): Promise<LSP.CompletionList | LSP.CompletionItem[]>; | ||
format(): Promise<void>; | ||
requestDiagnostics(_view: EditorView): Promise<any[]>; | ||
requestDiagnostics(view: EditorView): Promise<{ | ||
from: number; | ||
to: number; | ||
severity: "error" | "warning" | "info"; | ||
message: string; | ||
}[]>; | ||
requestHoverTooltip(view: EditorView, { line, character }: { | ||
@@ -65,0 +70,0 @@ line: number; |
@@ -124,4 +124,4 @@ import { autocompletion } from '@codemirror/autocomplete'; | ||
} | ||
async textDocumentDiagnostic(params) { | ||
return this.request("textDocument/diagnostic", params, timeout); | ||
async textDocumentLinting(params) { | ||
return this.request("textDocument/didChange", params, timeout); | ||
} | ||
@@ -249,3 +249,3 @@ async textDocumentHover(params) { | ||
} | ||
async requestDiagnostics(_view) { | ||
async requestDiagnostics(view) { | ||
console.debug(`Requesting diagnostics for ${this.documentUri}`); | ||
@@ -255,41 +255,38 @@ if (!this.client.ready) { | ||
} | ||
const result = await this.client.textDocumentDiagnostic({ | ||
const result = await this.client.textDocumentLinting({ | ||
textDocument: { | ||
uri: this.documentUri, | ||
version: this.documentVersion++, | ||
}, | ||
contentChanges: [{ text: view.state.doc.toString() }], | ||
}); | ||
console.debug(`Diagnostics for ${this.documentUri}:`, result); | ||
return []; | ||
// if (result.uri !== this.documentUri) return; | ||
// const diagnostics = result.diagnostics | ||
// .map(({ range, message, severity }) => ({ | ||
// from: posToOffset(this.view.state.doc, range.start), | ||
// to: posToOffset(this.view.state.doc, range.end), | ||
// severity: ( | ||
// { | ||
// [DiagnosticSeverity.Error]: "error", | ||
// [DiagnosticSeverity.Warning]: "warning", | ||
// [DiagnosticSeverity.Information]: "info", | ||
// [DiagnosticSeverity.Hint]: "info", | ||
// } as const | ||
// )[severity], | ||
// message, | ||
// })) | ||
// .filter( | ||
// ({ from, to }) => | ||
// from !== null && | ||
// to !== null && | ||
// from !== undefined && | ||
// to !== undefined, | ||
// ) | ||
// .sort((a, b) => { | ||
// switch (true) { | ||
// case a.from < b.from: | ||
// return -1; | ||
// case a.from > b.from: | ||
// return 1; | ||
// } | ||
// return 0; | ||
// }); | ||
// return diagnostics; | ||
if (result.uri !== this.documentUri) | ||
return; | ||
const diagnostics = result.diagnostics | ||
.map(({ range, message, severity }) => ({ | ||
from: posToOffset(this.view.state.doc, range.start), | ||
to: posToOffset(this.view.state.doc, range.end), | ||
severity: { | ||
[DiagnosticSeverity.Error]: "error", | ||
[DiagnosticSeverity.Warning]: "warning", | ||
[DiagnosticSeverity.Information]: "info", | ||
[DiagnosticSeverity.Hint]: "info", | ||
}[severity], | ||
message, | ||
})) | ||
.filter(({ from, to }) => from !== null && | ||
to !== null && | ||
from !== undefined && | ||
to !== undefined) | ||
.sort((a, b) => { | ||
switch (true) { | ||
case a.from < b.from: | ||
return -1; | ||
case a.from > b.from: | ||
return 1; | ||
} | ||
return 0; | ||
}); | ||
return diagnostics; | ||
} | ||
@@ -305,4 +302,5 @@ async requestHoverTooltip(view, { line, character }) { | ||
}); | ||
if (!result) | ||
if (!result.contents) { | ||
return null; | ||
} | ||
const { contents, range } = result; | ||
@@ -309,0 +307,0 @@ let pos = posToOffset(view.state.doc, { line, character }); |
{ | ||
"name": "@databutton/codemirror-languageserver", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Language Server Plugin for CodeMirror 6", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28840
657