show diagnostics of config file
This commit is contained in:
parent
ecec13ddf0
commit
59ea6999aa
3 changed files with 27 additions and 4 deletions
|
@ -110,6 +110,13 @@ export class DiagnosticsManager {
|
|||
this.scheduleDiagnosticsUpdate(uri)
|
||||
}
|
||||
|
||||
public configFileDiagnosticsReceived(
|
||||
uri: string,
|
||||
diagnostics: Diagnostic[]
|
||||
): void {
|
||||
this._currentDiagnostics.set(uri, diagnostics)
|
||||
}
|
||||
|
||||
public delete(uri: string): void {
|
||||
this._currentDiagnostics.delete(uri)
|
||||
}
|
||||
|
|
|
@ -280,8 +280,11 @@ export default class LanguageProvider {
|
|||
}
|
||||
|
||||
public handles(resource: Uri): boolean {
|
||||
let { modeIds, configFile } = this.description
|
||||
if (resource.toString().endsWith(configFile)) {
|
||||
return true
|
||||
}
|
||||
let doc = workspace.getDocument(resource.toString())
|
||||
let { modeIds } = this.description
|
||||
if (doc && modeIds.indexOf(doc.filetype) !== -1) {
|
||||
return true
|
||||
}
|
||||
|
@ -346,4 +349,8 @@ export default class LanguageProvider {
|
|||
diagnostics
|
||||
)
|
||||
}
|
||||
|
||||
public configFileDiagnosticsReceived(uri: Uri, diagnostics: Diagnostic[]): void {
|
||||
this.diagnosticsManager.configFileDiagnosticsReceived(uri.toString(), diagnostics)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { DiagnosticKind, disposeAll, workspace } from 'coc.nvim'
|
||||
import { Diagnostic, DiagnosticSeverity, Disposable } from 'vscode-languageserver-protocol'
|
||||
import { Range, Diagnostic, DiagnosticSeverity, Disposable, Position } from 'vscode-languageserver-protocol'
|
||||
import Uri from 'vscode-uri'
|
||||
import LanguageProvider from './languageProvider'
|
||||
import * as Proto from './protocol'
|
||||
|
@ -63,8 +63,17 @@ export default class TypeScriptServiceClientHost implements Disposable {
|
|||
let { body } = diag
|
||||
if (body) {
|
||||
let { configFile, diagnostics } = body
|
||||
if (diagnostics.length) {
|
||||
workspace.showMessage(`Invalid config file: ${configFile}`, 'error')
|
||||
let uri = Uri.file(configFile)
|
||||
let language = this.findLanguage(uri)
|
||||
if (!language) return
|
||||
if (diagnostics.length == 0) {
|
||||
language.configFileDiagnosticsReceived(uri, [])
|
||||
} else {
|
||||
let range = Range.create(Position.create(0, 0), Position.create(0, 1))
|
||||
let { text, code, category } = diagnostics[0]
|
||||
let severity = category == 'error' ? DiagnosticSeverity.Error : DiagnosticSeverity.Warning
|
||||
let diagnostic = Diagnostic.create(range, text, severity, code)
|
||||
language.configFileDiagnosticsReceived(uri, [diagnostic])
|
||||
}
|
||||
}
|
||||
}, null, this.disposables)
|
||||
|
|
Loading…
Add table
Reference in a new issue