@@ -76,15 +76,20 @@ export default class BashServer {
76
76
this . documents . listen ( this . connection )
77
77
this . documents . onDidChangeContent ( async change => {
78
78
const { uri } = change . document
79
+
80
+ // Load the tree for the modified contents into the analyzer:
81
+ const analyzeDiagnostics = this . analyzer . analyze ( uri , change . document )
82
+
83
+ // Run shellcheck diagnostics:
79
84
let diagnostics : LSP . Diagnostic [ ] = [ ]
80
85
81
- // FIXME: re-lint on workspace folder change
82
86
const folders = await connection . workspace . getWorkspaceFolders ( )
83
87
const lintDiagnostics = await this . linter . lint ( change . document , folders || [ ] )
84
88
diagnostics = diagnostics . concat ( lintDiagnostics )
85
89
90
+ // Treesitter's diagnostics can be a bit inaccurate, so we only merge the
91
+ // analyzer's diagnostics if the setting is enabled:
86
92
if ( config . getHighlightParsingError ( ) ) {
87
- const analyzeDiagnostics = this . analyzer . analyze ( uri , change . document )
88
93
diagnostics = diagnostics . concat ( analyzeDiagnostics )
89
94
}
90
95
@@ -100,6 +105,8 @@ export default class BashServer {
100
105
connection . onReferences ( this . onReferences . bind ( this ) )
101
106
connection . onCompletion ( this . onCompletion . bind ( this ) )
102
107
connection . onCompletionResolve ( this . onCompletionResolve . bind ( this ) )
108
+
109
+ // FIXME: re-lint on workspace folder change
103
110
}
104
111
105
112
/**
0 commit comments