Should use LSP-complient way to register file watcher
Currently the vscode extension watches for *.twig file changes and notifies the server - https://github.com/moetelo/twiggy/blob/1e9acaeb47e8887a69181ebe5cc418392afba3be/packages/vscode/src/extension.ts#L66-L68
Instead the server should use the client/registerCapability to register the watcher capability dynamically. VSCode will handle that automatically and it being a LSP spec compliant way, it will automatically work in many other editors also.
Could you provide an example of how this done in other language servers?
I don't know which server does this from the top of my head but eslint registers different capability here: https://github.com/microsoft/vscode-eslint/blob/f42f9e9d0455d107920019a5067811eef72c8ffa/server/src/eslint.ts#L1015-L1015
It's not much different from registering a DidChangeWatchedFiles capability. Refer to the spec at https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_didChangeWatchedFiles