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

Add allowComments Support

Open
#529 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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.

Sometimes comments aren’t supported. I.e. a tool might strip comments.

Describe the solution you would like

From the language service it probably makes sense to add a new option for doValidation.

interface LanguageService {
  doValidation(document: TextDocument, isKubernetes: boolean, allowComments: boolean): Promise<Diagnostic[]>
}

If this setting is true, any comment nodes will be reported.

For the language server it makes sense to add an option yaml.allowComments.

Describe alternatives you have considered

doValidation could accept an object with named properties instead.

interface DoValidationOptions {
  allowComments?: boolean;
  isKubernetes?: boolean;
}

interface LanguageService {
  doValidation(document: TextDocument, options?: DoValidationOptions): Promise<Diagnostic[]>
}

Instead of reporting every comment node, only the first or last comment in a group of comments will be reported.

# This comment will be reported
# This comment will not be reported
# This comment will not be reported

foo: bar

# This comment will be reported
# This comment will not be reported
# This comment will not be reported

Or only one comment could be reported

# This comment will be reported
# This comment will not be reported
# This comment will not be reported

foo: bar

# This comment will not be reported
# This comment will not be reported
# This comment will not be reported
Additional context

This is a downstream request from remcohaszing/monaco-yaml#28

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 with the LanguageService.doValidation interface and the language server’s yaml.allowComments option described in the issue. Review the downstream request at remcohaszing/monaco-yaml#28 and resolve whether validation takes positional or named options and how comment groups are reported. Done means the option is exposed and comment diagnostics follow an agreed grouping behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.