Skip to content

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

@notpeter

Description

@notpeter

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions