yaml-language-server icon indicating copy to clipboard operation
yaml-language-server copied to clipboard

register file watchers (workspace/didChangeWatchedFiles) instead of relying on redhat.vscode-yaml

Open notpeter opened this issue 6 months ago • 0 comments

Is your enhancement related to a problem? Please describe.

In non-vscode editors yaml-language-server needs to be restarted when local json schemas change.

I believe this is because yaml-language-server is not being notified of changes to those schema files via workspace/didChangeWatchedFiles. I believe this works in VSCode, because the YAML Extension handles registration here src/extension.ts at initialization:"

    synchronize: {
      // Notify the server about file changes to YAML and JSON files contained in the workspace
      fileEvents: [workspace.createFileSystemWatcher('**/*.?(e)y?(a)ml'), workspace.createFileSystemWatcher('**/*.json')],
    },

And so yaml-language-server receives the workspace/didChangeWatchedFiles events via onDidChangeWatchedFiles and routes them to watchedFilesHandler function -- but only for vscode.

Describe the solution you would like

Ideally yaml-language-server would explicitly register those same file watchers itself at startup.

Describe alternatives you have considered

Rather than hard-coding watchers for **/*.{yaml,yml,eyml,eyaml,json} it would be nice if yaml-language-server use those as a default and allowed customized watching via LSP settings, just in case the user has their own extensions they want to watch: e.g. *.jsonschema.

Additional context

notpeter avatar Jun 20 '25 22:06 notpeter