Skip to content

Completion trigger chars don't work with YAML grammar extension languages #230277

Closed

Description

@BoykoAlex

The issue is that if trigger chars are all alphabetic chars for instance only a few of them do trigger completion proposal computations. The only trigger char that works is 'y' bringing up 3 completions starting with `y'. If you try 's', 'd', 'm' which also have 3 completion proposals starting with these chars the completion proposal computation (completion provider) is never invoked. Seems random really.

Here the repo demonstrating the issue: https://github.com/BoykoAlex/vscode-extension-samples/tree/triggerchars-yaml-completions. It is a fork of VSCode's extension samples. The completions-sample is the one modified. The branch is triggerchars-yaml-completions

Essentially the extension contributes a new language sample-properties-yaml and the grammar for the language which is really the YAML grammar.

The grammar piece seems to be critical.
Snippet from package.json

	"contributes": {
		"languages": [
		  {
			"id": "sample-properties-yaml",
			"aliases": [
			  "Sample Properties Yaml"
			],
			"filenamePatterns": [
			  "sample*.yml",
			  "sample*.yaml",
			  "sample*.yml",
			  "sample*.yaml"
			],
			"configuration": "./yaml-support/language-configuration.json"
		  }
		],
		"grammars": [
			{
			  "language": "sample-properties-yaml",
			  "scopeName": "source.sample-properties-yaml",
			  "path": "./yaml-support/sample-properties-yaml.tmLanguage.json"
			}
		]
	},

The sample-properties-yaml.tmLanguage.json:

{
  "name": "Sample Properties YAML",
  "scopeName": "source.sample-properties-yaml",
  "patterns": [
    {
      "comment": "source.yaml is defined in vscode core",
      "include": "source.yaml"
    }
  ]
}

If the grammar is not defined for the language then completion proposals show up fine for all trigger chars. The syntax highlighting is lost however. Feels, therefore, that the issue is related to the grammar definition of the yaml based language.

Activity

  1. RedCMD commented on Oct 2, 2024

    @RedCMD
    Contributor

    You prob need to enable "strings": true under "editor.quickSuggestions" in package.json
    This will enable completion triggers within strings based on your "wordPattern" in language-configuration.json

    "configurationDefaults": {
    	"[sample-properties-yaml]": {
    		"editor.quickSuggestions": {
    			"strings": true
    		}
    	}
    }

    idk why some letters work but not others

  2. BoykoAlex commented on Oct 2, 2024

    @BoykoAlex
    ContributorAuthor

    Wow... thanks a lot. I would never be able to guess that :-) It did help and I think this can be resolved now - thanks again!

  3. locked and limited conversation to collaborators on Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

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