Skip to content

Commit 9a57044

Browse files
committed
Update README.md
1 parent f430697 commit 9a57044

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,28 @@ This sets up all built-in features: completion, hover, diagnostics, go-to-defini
6767
| `synchronizationMethod` | `SynchronizationMethod` | `'full'` or `'incremental'` document sync (default: `'full'`) |
6868
| `client` | `LanguageServerClient` | Share a client across multiple editor instances |
6969
| `onCapabilities` | `(capabilities) => void` | Called when server capabilities are available |
70+
| `onError` | `(error: Error) => void` | Called when the connection encounters an error |
71+
| `onClose` | `() => void` | Called when the connection is closed |
72+
73+
## Error Handling
74+
75+
The plugin does not crash on connection failures. Use `onError` and `onClose` to handle disconnections:
76+
77+
```js
78+
languageServer({
79+
serverUri: 'ws://localhost:8080',
80+
rootUri: 'file:///',
81+
documentUri: `file:///${filename}`,
82+
languageId: 'cpp',
83+
onError(error) {
84+
console.error('LSP error:', error);
85+
},
86+
onClose() {
87+
console.log('LSP connection closed');
88+
// Recreate the editor extensions to reconnect
89+
},
90+
})
91+
```
7092

7193
## Shared Client
7294

0 commit comments

Comments
 (0)