redhat-developer / redhat-developer/yaml-language-server

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

Open
#1,084 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.5k
Forks
352
Avg merge
2d 7h
Merged PRs (30d)
11

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading src/languageserver/handlers/languageHandlers.ts, especially onDidChangeWatchedFiles and watchedFilesHandler, and compare it with the registration in src/extension.ts. Trace server startup and LSP settings to determine how default YAML/JSON watchers and customized extensions should be registered; done means schema changes are handled without restarting the server.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, yaml
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.