Giter VIP home page Giter VIP logo

vscode-yaml's Introduction

Visual Studio Marketplace Installs Build Status License OpenVSX Registry

YAML Language Support by Red Hat

Provides comprehensive YAML Language support to Visual Studio Code, via the yaml-language-server, with built-in Kubernetes syntax support.

Features

screencast

  1. YAML validation:
    • Detects whether the entire file is valid yaml
    • Detects errors such as:
      • Node is not found
      • Node has an invalid key node type
      • Node has an invalid type
      • Node is not a valid child node
  2. Document Outlining (Ctrl + Shift + O):
    • Provides the document outlining of all completed nodes in the file
  3. Auto completion (Ctrl + Space):
    • Auto completes on all commands
    • Scalar nodes autocomplete to schema's defaults if they exist
  4. Hover support:
    • Hovering over a node shows description if provided by schema
  5. Formatter:
    • Allows for formatting the current file
    • On type formatting auto indent for array items

Auto completion and hover support are provided by the schema. Please refer to Language Server Settings to setup a schema

YAML version support

Starting from 1.0.0 the extension uses eemeli/yaml as the new YAML parser, which strictly enforces the specified YAML spec version. Default YAML spec version is 1.2, it can be changed with yaml.yamlVersion setting.

Extension Settings

The following settings are supported:

  • yaml.yamlVersion: Set default YAML spec version (1.2 or 1.1)
  • yaml.format.enable: Enable/disable default YAML formatter (requires restart)
  • yaml.format.singleQuote: Use single quotes instead of double quotes
  • yaml.format.bracketSpacing: Print spaces between brackets in objects
  • yaml.format.proseWrap: Always: wrap prose if it exceeds the print width, Never: never wrap the prose, Preserve: wrap prose as-is
  • yaml.format.printWidth: Specify the line length that the printer will wrap on
  • yaml.validate: Enable/disable validation feature
  • yaml.hover: Enable/disable hover
  • yaml.completion: Enable/disable autocompletion
  • yaml.schemas: Helps you associate schemas with files in a glob pattern
  • yaml.schemaStore.enable: When set to true, the YAML language server will pull in all available schemas from JSON Schema Store
  • yaml.schemaStore.url: URL of a schema store catalog to use when downloading schemas.
  • yaml.customTags: Array of custom tags that the parser will validate against. It has two ways to be used. Either an item in the array is a custom tag such as "!Ref" and it will automatically map !Ref to a scalar, or you can specify the type of the object !Ref should be, e.g. "!Ref sequence". The type of object can be either scalar (for strings and booleans), sequence (for arrays), mapping (for objects).
  • yaml.maxItemsComputed: The maximum number of outline symbols and folding regions computed (limited for performance reasons).
  • yaml.disableDefaultProperties: Disable adding not required properties with default values into completion text (default is false).
  • yaml.suggest.parentSkeletonSelectedFirst: If true, the user must select some parent skeleton first before autocompletion starts to suggest the rest of the properties. When the YAML object is not empty, autocompletion ignores this setting and returns all properties and skeletons.
  • [yaml]: VSCode-YAML adds default configuration for all YAML files. More specifically, it converts tabs to spaces to ensure valid YAML, sets the tab size, allows live typing autocompletion and formatting, and also allows code lens. These settings can be modified via the corresponding settings inside the [yaml] section in the settings:
    • editor.tabSize
    • editor.formatOnType
    • editor.codeLens
  • http.proxy: The URL of the proxy server that will be used when attempting to download a schema. If it is not set or it is undefined no proxy server will be used.
  • http.proxyStrictSSL: If true the proxy server certificate should be verified against the list of supplied CAs. Default is false.
  • yaml.style.flowMapping : Forbids flow style mappings if set to forbid
  • yaml.style.flowSequence : Forbids flow style sequences if set to forbid
  • yaml.keyOrdering : Enforces alphabetical ordering of keys in mappings when set to true. Default is false
  • yaml.extension.recommendations : Enable extension recommendations for YAML files. Default is true

Adding custom tags

To use the custom tags in your YAML file, you need to first specify the custom tags in the setting of your code editor. For example, you can have the following custom tags:

"yaml.customTags": [
    "!Scalar-example scalar",
    "!Seq-example sequence",
    "!Mapping-example mapping"
]

The !Scalar-example would map to a scalar custom tag, the !Seq-example would map to a sequence custom tag, the !Mapping-example would map to a mapping custom tag.

You can then use the newly defined custom tags inside the YAML file:

some_key: !Scalar-example some_value
some_sequence: !Seq-example
  - some_seq_key_1: some_seq_value_1
  - some_seq_key_2: some_seq_value_2
some_mapping: !Mapping-example
  some_mapping_key_1: some_mapping_value_1
  some_mapping_key_2: some_mapping_value_2

Associating schemas

YAML Language support uses JSON Schemas to understand the shape of a YAML file, including its value sets, defaults and descriptions. The schema support is shipped with JSON Schema Draft 7.

We support schemas provided through JSON Schema Store. However, schemas can also be defined in a workspace.

The association of a YAML file to a schema can be done either in the YAML file itself using a modeline or in the User or Workspace settings under the property yaml.schemas.

Associating a schema in the YAML file

It is possible to specify a yaml schema using a modeline. Schema url can be a relative path. If a relative path is specified, it is calculated from yaml file path, not from workspace root path

# yaml-language-server: $schema=<urlToTheSchema>

Associating a schema to a glob pattern via yaml.schemas:

yaml.schemas applies a schema to a file. In other words, the schema (placed on the left) is applied to the glob pattern on the right. Your schema can be local or online. Your schema must be a relative path and not an absolute path. The entrance point for yaml.schemas is a location in user and workspace settings

When associating a schema it should follow the format below

"yaml.schemas": {
    "url": "globPattern",
    "Kubernetes": "globPattern"
}

e.g.

yaml.schemas: {
    "https://json.schemastore.org/composer": "/*"
}

e.g.

yaml.schemas: {
    "kubernetes": "/myYamlFile.yaml"
}

e.g.

yaml.schemas: {
    "https://json.schemastore.org/composer": "/*",
    "kubernetes": "/myYamlFile.yaml"
}

On Windows with full path:

yaml.schemas: {
    "C:\\Users\\user\\Documents\\custom_schema.json": "someFilePattern.yaml",
    "file:///C:/Users/user/Documents/custom_schema.json": "someFilePattern.yaml",
}

On Mac/Linux with full path:

yaml.schemas: {
    "/home/user/custom_schema.json": "someFilePattern.yaml",
}

Since 0.11.0 YAML Schemas can be used for validation:

 "/home/user/custom_schema.yaml": "someFilePattern.yaml"

A schema can be associated with multiple globs using a json array, e.g.

yaml.schemas: {
    "kubernetes": ["filePattern1.yaml", "filePattern2.yaml"]
}

e.g.

"yaml.schemas": {
    "http://json.schemastore.org/composer": ["/*"],
    "file:///home/johnd/some-schema.json": ["some.yaml"],
    "../relative/path/schema.json": ["/config*.yaml"],
    "/Users/johnd/some-schema.json": ["some.yaml"],
}

e.g.

"yaml.schemas": {
    "kubernetes": ["/myYamlFile.yaml"]
}

e.g.

"yaml.schemas": {
    "http://json.schemastore.org/composer": ["/*"],
    "kubernetes": ["/myYamlFile.yaml"]
}

Multi root schema association:

You can also use relative paths when working with multi-root workspaces.

Suppose you have a multi-root workspace that is laid out like:

My_first_project:
   test.yaml
   my_schema.json
My_second_project:
   test2.yaml
   my_schema2.json

You must then associate schemas relative to the root of the multi root workspace project.

yaml.schemas: {
    "My_first_project/my_schema.json": "test.yaml",
    "My_second_project/my_schema2.json": "test2.yaml"
}

yaml.schemas allows you to specify JSON schemas that you want to validate against the YAML you write. Kubernetes is a reserved keyword field. It does not require a URL, as the language server will provide that. You need the keyword kubernetes and a glob pattern.

Mapping a schema in an extension

  • Supports yamlValidation point, which allows you to contribute a schema for a specific type of YAML file (Similar to jsonValidation) e.g.
{
  "contributes": {
    "yamlValidation": [
      {
        "fileMatch": "yourfile.yml",
        "url": "./schema.json"
      }
    ]
  }
}

Feedback & Questions

If you discover an issue please file a bug and we will fix it as soon as possible.

License

MIT, See LICENSE for more information.

Data and Telemetry

The vscode-yaml extension collects anonymous usage data and sends it to Red Hat servers to help improve our products and services. Read our privacy statement to learn more. This extension respects the redhat.telemetry.enabled setting, which you can learn more about at https://github.com/redhat-developer/vscode-redhat-telemetry#how-to-disable-telemetry-reporting

How to contribute

The instructions are available in the contribution guide.

vscode-yaml's People

Contributors

aeschli avatar andxu avatar apupier avatar brifly avatar concaf avatar dependabot[bot] avatar dmilosz avatar evidolob avatar fbricon avatar gorkem avatar johnhillegass avatar joshuawilson avatar jpinkney avatar lostintangent avatar mickaelistria avatar mohitsuman avatar msivasubramaniaan avatar nikolaskomonen avatar odockal avatar p-spacek avatar rgrunber avatar snjeza avatar soltys avatar ssbarnea avatar tricktron avatar vidminas avatar whazor avatar willismonroe avatar zcervink avatar zmwangx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-yaml's Issues

support go templates

I'm adding some go template syntax in my YAML which is causing this linter to complain, which is a shame. For e.g somewhere inside a kubernetes pod spec:

spec:
  volumes:
  - name: fonts
    emptyDir: {}
  {{ if .development -}}
  - name: srccode
    hostPath:
      path: /Users/src
  {{- end }}

image

Any easy way to get it to ignore this go-template syntax?

'Yaml Support server crashed 5 times in the last 3 minutes' problem in VS Code

Hello,
Having an issue that was already reported, but mine differs somewhat.
After installing the Yaml extension on VS Code for Windows, I keep getting the The Yaml Support server crashed 5 times in the last 3 minutes. The server will not be restarted error. After looking in the input, I seem to be missing something:

module.js:472
    throw err;
    ^

Error: Cannot find module './languageService/utils/uri'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\apilon\.vscode\extensions\redhat.vscode-yaml-0.0.8\node_modules\yaml-language-server\out\server\src\server.js:13:15)
    at Object.<anonymous> (C:\Users\apilon\.vscode\extensions\redhat.vscode-yaml-0.0.8\node_modules\yaml-language-server\out\server\src\server.js:439:3)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
[Error - 13:39:59] Connection to server got closed. Server will not be restarted.

What is this module that is missing and/or shouldn't it come with the extension ?

Extension version: 0.0.8
VS Code version: 1.20.0
Windows version: Windows 10 Pro x64 - Fall Creator's Update

Thanks.

add a few Commands to create new files (e.g. Deployment, DeploymentConfig, Service, Route, ConfigMap, PVC)

It'd be nice to have a little 'new kubernetes file' wizard that lets you pick from these kinds:

  • Deployment
  • DeploymentConfig
  • Service
  • Route
  • ConfigMap
  • PVC

then we could pre-fill in a few values (e.g. the metadata.name could default to the file name (without the .yml extension).

e.g. the generated Deployment might look like:

metadata:
  name: ${FILE_NAME_WITHOUT_EXTENSION}
  labels:
    app: ${FILE_NAME_WITHOUT_EXTENSION}
    version: 1.0.0
spec:
  replicas: 1
  template:
    spec:
      containers:
      - name: main

False CircleCI validation on `setup_remote_docker` step with subelements

Suddenly your extension supports CircleCI's config.yml. Pretty good ๐Ÿ‘

I found this false validation error:

vscode_circleci-validation_error

(for search: setup_remote_docker step is red underlined if subelements are added. Hint shows: Value is not accepted. Valid values: "checkout", "setup_remote_docker")

What is the correct repository to report this issue?
A full text search for circleci didn't return any results neither in this repo ("vscode-yaml") nor in the underlying yaml-language-server.

Error with language server

Just after a cd server; npm install; npm run compile; cd ../client/server, I try to connect to the language server from Eclipse IDE. On opening an empty dummy.k8s file, I see:

/home/mistria/workspace/com.redhat.kubernetes.lsp.eclipse/language-servers/server.js:109
    if (yDoc.errors) {
            ^

TypeError: Cannot read property 'errors' of undefined
    at validateTextDocument (/home/mistria/workspace/com.redhat.kubernetes.lsp.eclipse/language-servers/server.js:109:13)
    at Timeout.pendingValidationRequests.(anonymous function).setTimeout [as _onTimeout] (/home/mistria/workspace/com.redhat.kubernetes.lsp.eclipse/language-servers/server.js:96:9)
    at ontimeout (timers.js:386:14)
    at tryOnTimeout (timers.js:250:5)
    at Timer.listOnTimeout (timers.js:214:5)

Yaml Support server crashed 5 times in the last 3 minutes.

I'm getting a prompt at the top of VS Code, "The Yaml Support server crashed 5 times in the last 3 minutes. The server will not be restarted." if my yaml file contains an include, e.g.

customize: !include customize.yaml

Here's the output from the Yaml Support pane:

Unsupported feature, node kind: 5
C:\Users\willh.vscode\extensions\redhat.vscode-yaml-0.0.7\node_modules\yaml-language-server\out\server\src\languageService\parser\yamlParser.js:78
valueNode.location = key.value;
^

TypeError: Cannot set property 'location' of undefined
at recursivelyBuildAst (C:\Users\willh.vscode\extensions\redhat.vscode-yaml-0.0.7\node_modules\yaml-language-server\out\server\src\languageService\parser\yamlParser.js:78:32)
at recursivelyBuildAst (C:\Users\willh.vscode\extensions\redhat.vscode-yaml-0.0.7\node_modules\yaml-language-server\out\server\src\languageService\parser\yamlParser.js:64:36)
at recursivelyBuildAst (C:\Users\willh.vscode\extensions\redhat.vscode-yaml-0.0.7\node_modules\yaml-language-server\out\server\src\languageService\parser\yamlParser.js:77:50)
at recursivelyBuildAst (C:\Users\willh.vscode\extensions\redhat.vscode-yaml-0.0.7\node_modules\yaml-language-server\out\server\src\languageService\parser\yamlParser.js:64:36)
at createJSONDocument (C:\Users\willh.vscode\extensions\redhat.vscode-yaml-0.0.7\node_modules\yaml-language-server\out\server\src\languageService\parser\yamlParser.js:153:17)
at yamlDocs.map.doc (C:\Users\willh.vscode\extensions\redhat.vscode-yaml-0.0.7\node_modules\yaml-language-server\out\server\src\languageService\parser\yamlParser.js:179:49)
at Array.map (native)
at Object.parse (C:\Users\willh.vscode\extensions\redhat.vscode-yaml-0.0.7\node_modules\yaml-language-server\out\server\src\languageService\parser\yamlParser.js:179:38)
at validateTextDocument (C:\Users\willh.vscode\extensions\redhat.vscode-yaml-0.0.7\node_modules\yaml-language-server\out\server\src\server.js:283:37)
at Timeout.pendingValidationRequests.(anonymous function).setTimeout [as _onTimeout] (C:\Users\willh.vscode\extensions\redhat.vscode-yaml-0.0.7\node_modules\yaml-language-server\out\server\src\server.js:275:9)
[Info - 9:44:15 AM] Connection to server got closed. Server will restart.

Hover support

When a property is hovered it should show its documentation

Other Schemas are being ignored

Hi,

I came to a point where I needed to create multiple schemas for each group of my YAML files. I'm not sure if this is an issue but I could not find a way to make the extension use my schemas to validate my YAML files. I got 2 types of files and each of them has it's own schema.

Here is my scenario:

In my settings.json:

"yaml.schemas": {
    "./transport.schema.json": "/*.transport",
    "./credential.schema.json": "/*.credential"
}

My YAML files are:

  1. train.transport
  2. author.credential

The extension validates my author.credential against my credential.schema.json but ignoring my train.transport. I'm assuming it only remembers the last item from the list schemas.

I downloaded and debugged the source and found out that the server.js -> configureSchemas method returns a languageSettings that is being used by server.js -> updateConfiguration which overrides the first one.

I made a temporary fix just so I can make it to use all my schemas to validate my YAML files accordingly.

server.js -> updateConfiguration()

	languageSettings.schemas = configureSchemas(uri, schema.fileMatch, schema.schema,
 languageSettings.schemas);

server.js -> configureSchemas(uri, fileMatch, schema, schemas)

	if (schema === null) {
		schemas.push({ uri, fileMatch: fileMatch });
	}
	else {
		schemas.push({ uri, fileMatch: fileMatch, schema: schema });
	}

I don't want to push my fix for I know there is more elegant way to fix the issue.

Please let me know. Thanks.

Autocompletion not triggered while typing

Currently, autocompletion is only triggered when doing ctrl+space. I'm used to being spoiled by VS Code, which triggers autocompletion on each keystroke (see Java)

More details on the model diagnostics

We need more details displayed on diagnostics for model that can hint users on how to fix the issue. We should add the name of the node for instance when we signal an incorrect child node. Another one is the possible scalar types in the case of a scalar value mismatch.

Validation does not work with kubernetes yaml

Settings:

{
    "yaml.schemas": {
        "kubernetes": "pod.yaml"
    }
}

pod.yaml:

apiVersion: v1
kind: Pod
metadata:
  name: azure-vote-back
specs:
  containers:
  - name: azure-vote-back
    image: redis
    imagePullPolicy: Always
    ports:
    - containerPort: 6379
      name: redis

Result:
image

Expected result:
image

Add more documentation

This plugin seems very promising! Would be great to have more documentation around the usage & installation in the readme.

Auto-completion does not work with Kubernetes YAML files

Settings:

{
    "yaml.schemas": {
        "kubernetes": "pod.yaml"
    }
}

pod.yaml:

apiVersion: v1
kind: Pod
metadata:
  name: azure-vote-back
spec:
  containers:
  - name: azure-vote-back
    image: redis
    imagePullPolicy: Always
    ports:
    - containerPort: 6379
      name: redis

Result:
image

Expected result:
image

Feature request: formatter

Hello,
if I select "Format document", vscode pops up "Sorry, but there is no formatter for 'yaml'-files installed."
It would be nice if this extension supported formatting :-)

Does not seem to validate objects that are part of an array property

Hi, I have been testing this but could not make it to work. I designed my schema to have locations (array) and each location has Sequence and Address.

The extension does not seem to validate the Address object against my schema. I have 2 issues.

  1. The Sequence property must be a numeric but it allows me to put string.
  2. Under my Address object, I set the additionalProperties to false but it's still allow me to add line3.

Schema:

{
    "version": "1.0.0",
    "name": "Sample",
    "type": "object",
    "additionalProperties": false,
    "required": [
        "name",
        "locations"
    ],
    "properties": {
        "name": {
            "type": "string"
        },
        "locations": {
            "type": "array",
            "required": [
                "sequence",
                "address"
            ],
            "properties": {
                "sequence": {
                    "type": "integer"
                },
                "address": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                        "line1": {
                            "type": "string"
                        },
                        "line2": {
                            "type": "string"
                        }
                    }
                }
            }
        }
    }
}

YAML file:

name: sample
locations:
- sequence: this should be an integer
  address:
    line1: a
    line2: b
    line3: this should not be permitted

Programmatically associate YAML files with schemas by other extensions

Here to request a way of specifying a schema for a YAML file programmatically by other extensions.

Scenario

When a user modifies the content of a YAML, a third party can recognize the features of the new content and tell the YAML extension what schema to use for the document.
In this way, the YAML extension can focus on generic language features but let other extensions contribute the schema knowledge.
As user types, other extensions start to recognize the contents and specifies a schema on the fly. This is super useful when a user tries to write the YAML from scratch.

Current Implementation

Currently, a user needs to specify a schema for a YAML file inside the settings.json. The users have to fill the URL of the schema and persist that association inside settings.json. When there are multiple YAML files with different schemas, this work could be time consuming and error-prone.

Proposed Implementation

Besides hard-coding the schema association, we can let other extensions contribute the logic of associating schemas with YAML files. For example, the Kubernetes extension has the manifest file schema and can tell whether a YAML file conforms to the schema. So whenever the Kubernetes extension recognizes a YAML file, it tells the YAML extension to process that YAML file with the Kubernetes schema at runtime.

Support for multiple YAML documents in single file

Some of my Kubernetes yaml files are in form of:

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: web-deployment
...
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: userdirectory-deployment
...

it looks like the autocomplete/Ctrl+space is not working when there are multiple objects in a single yaml file.

Should this be supported?

Outline support

Support for document outlining [cmd+Shift+O] and navigating the yaml.

creationTimestamp validation incorrect

When I have a value such as
creationTimestamp: 2017-06-14T14:29:37Z it is reported as incorrect value type. I think we need better handling of date type.

completion/validation on kind

I thought completion wasn't working on metadata's name/labels/annotations etc
foo_yml_-_fabric8-team-components
turns out I'd made a typo in the kind but the LSP didn't warn me or offer completion

Auto-completion on sub-objects doesn't work

First of all: Thanks a lot for your awesome progress on this plugin today!

I've just tried it and it seems to work well on the root level. However, auto-completion doesn't seem to work on a sub-level. Here is an example:

# auto-complete works for `my_field`
my_root_field: 42

my_other_root_field:
  some_dynamic_key: # this key can be chosen arbitrarily
    sub_field: 0 # this again is a concrete, pre-defined key: auto-completion doesn't work

Support for anchors/references?

Hi! First, thanks for the great plugin.

I'm having an issue with validations not respecting injected references. For example, in a Circle CI 2.0 config file, I've got the docker key in a reference:

defaults: &job_defaults
  docker:
    - image: circleci/node:8.2.1

and then use it later in a job:

jobs:
  job1: 
    <<: *job_defaults

However, I still receive a Missing property "docker". message on the job1 node.

Is this the expected behavior? Thanks in advance.

How to build the language server?

I'm trying to hack around the LS and I'm currently stuck with how to build it. It seems to me that the build instructions are only working in the scope of VSCode and that a basic npm install on the source isn't enough to get the .js files generated from the .ts ones. I also tries a simple tsc but got no js generated.
What's the process to get those .ts file compiled?

"Cannot read property 'indexOf' of undefined"

From Eclipse IDE, connecting to Language Server, I see

!ENTRY org.eclipse.lsp4e 1 0 2017-06-26 20:02:27.208
!MESSAGE RequestMessage
{
  "jsonrpc": "2.0",
  "id": "2",
  "method": "textDocument/completion",
  "params": {
    "textDocument": {
      "uri": "file:///home/mistria/sandbox/fefe/test.yaml"
    },
    "uri": "file:///home/mistria/sandbox/fefe/test.yaml",
    "position": {
      "line": 0,
      "character": 0
    }
  }
}

!ENTRY org.eclipse.lsp4e 4 0 2017-06-26 20:02:27.211
!MESSAGE Request textDocument/completion failed with message: Cannot read property 'indexOf' of undefined
!STACK 0
org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Request textDocument/completion failed with message: Cannot read property 'indexOf' of undefined
	at org.eclipse.lsp4e.ProjectSpecificLanguageServerWrapper.logMessage(ProjectSpecificLanguageServerWrapper.java:283)
	at org.eclipse.lsp4e.ProjectSpecificLanguageServerWrapper.lambda$1(ProjectSpecificLanguageServerWrapper.java:226)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:149)

Any hint?

Schema validation reports errors in valid YAML document

I have rather complex JSON schema with which YAML plugin doesn't work correctly. It reports errors in valid YAML document. But when I use this schema with equivalent JSON document it works correctly.

I tried to simplify the schema and narrow the problem but it is still long and complex because the problem is in some combination of schema constructs.

I have vscode-yaml 0.0.4 with VSCode insider build (see bellow).

Here is the YAML document which doesn't work correctly:

aaa:
  type: TypeA
  properties:
    propertyA: { stringArray: [ "abcd"] }

Here is JSON document which works:

{
    "$schema": "./test.schema.json",
    "aaa": {
        "type": "TypeA",
        "properties": {
            "propertyA": {
                "stringArray": ["abcd"]
            }
        }
    }
}

Here is test.schema.json schema:

{
  "$schema": "http://json-schema.org/schema#",
  "type": "object",
  "properties": {
    "aaa": {
      "oneOf": [
        {
          "allOf": [
            {
              "properties": {
                "type": {
                  "enum": [
                    "TypeA"
                  ]
                },
                "properties": {
                  "type": "object",
                  "properties": {
                    "propertyA": {
                      "$ref": "#/definitions/commonStructures",
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "propertyA"
                  ],
                  "additionalProperties": true
                }
              },
              "required": [
                "type"
              ]
            },
            {
              "$ref": "#/definitions/commonProperties"
            }
          ]
        },
        {
          "allOf": [
            {
              "properties": {
                "type": {
                  "enum": [
                    "TypeB"
                  ]
                },
                "properties": {
                  "type": "object",
                  "properties": {
                    "propertyB": {
                      "$ref": "#/definitions/commonStructures",
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "propertyB"
                  ],
                  "additionalProperties": true
                }
              },
              "required": [
                "type"
              ]
            },
            {
              "$ref": "#/definitions/commonProperties"
            }
          ]
        }
      ]
    }
  },
  "required": [
    "aaa"
  ],
  "additionalProperties": true,
  "definitions": {
    "commonProperties": {
      "type": "object",
      "properties": {
        "commonProperty": {
          "type": "string"
        }
      }
    },
    "commonStructures": {
      "type": "object",
      "properties": {
        "stringArray": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        }
      },
      "additionalProperties": false
    }
  }
}
  • VSCode Version: Code - Insiders 1.18.0-insider (2ab10d50163f008ada9a4aa215de8c884857ce99, 2017-11-01T05:19:21.302Z)
  • OS Version: Windows_NT x64 10.0.16299
  • Extensions:
Extension Author (truncated) Version
vscode-yaml red 0.0.4

Autocompletion doesn't work for new list item

Great work on the recent updates and fixes!

I've just discovered another issue when creating a new list item, then the auto-completion just works when writing out the second field:

do-25

Consider providing a 'yamlValidation' contribution point for registering a schema

Such a contribution point enables an extension author to contribute a YAML schema association same as is done for JSON and its jsonValidation contribution point.

https://code.visualstudio.com/docs/extensionAPI/extension-points#_contributesjsonvalidation

The corresponding code in the JSON extension for this can be found here:
https://github.com/Microsoft/vscode/blob/master/extensions/json/client/src/jsonMain.ts#L174

Yaml Support server crashed 5 times in the last 3 minutes.

Looks like a repeat of an issue from back in 0.8 in VSCode.

C:\Users\XXX\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-json-languageservice\lib\services\jsonValidation.js:47
            jsonDocument.syntaxErrors.forEach(addProblem);
                                     ^

TypeError: Cannot read property 'forEach' of undefined
    at JSONValidation.doValidation (C:\Users\XXX\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-json-languageservice\lib\services\jsonValidation.js:47:38)
    at yamlDocument.documents.map.d (C:\Users\XXX\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\yamlLanguageService.js:48:71)
    at Array.map (native)
    at Object.doValidation (C:\Users\XXX\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\yamlLanguageService.js:48:62)
    at validateTextDocument (C:\Users\XXX\.vscode\extensions\adamvoss.yaml-0.0.10\server\out\yamlServerMain.js:215:21)
    at Timeout._onTimeout (C:\Users\XXX\.vscode\extensions\adamvoss.yaml-0.0.10\server\out\yamlServerMain.js:205:9)
    at ontimeout (timers.js:386:14)
    at tryOnTimeout (timers.js:250:5)
    at Timer.listOnTimeout (timers.js:214:5)
[Info  - 10:58:14 AM] Connection to server got closed. Server will restart.```

Support Travis CI file

Currently there's a red squiggle for a valid .travis.yml fragment:

image

With a tooltip:

image

According to the docs it's valid though.

Not sure whether .travis.yml is supported by design. If it's not, then it would be great to have.

Error on code completion

I am getting the below error sporadically when invoking codeCompletion

(node:1618) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 32): TypeError: Cannot read property 'forEach' of undefined
(node:1618) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 33): TypeError: Cannot read property 'forEach' of undefined
(node:1618) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 34): TypeError: Cannot read property 'forEach' of undefined
(node:1618) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 35): TypeError: Cannot read property 'forEach' of undefined
(node:1618) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 36): TypeError: Cannot read property 'forEach' of undefined
[Error - 10:46:36 AM] Request textDocument/completion failed.
  Message: Request textDocument/completion failed with message: Cannot read property 'value' of undefined
  Code: -32603 ```

How does the LS decide which yml file to care about?

At the moment, it seems like the Language Server and the VSCode extension tries to process any .yml file. However, there are many .yml files that are not necessarily using the k8s schema. Does the language make a difference? If yes, what's the trigger?

Help user set the schema of current YAML file

Currently, a user needs to specify schemas by modifying the settings.json.
Here to propose a status bar item to show the current schema for the current YAML file. Users can tell what schema is currently used and can switch schema by clicking on it.
This is useful when the wildcard is supported when associating schemas with YAML files.
The list of available schemas is maintained by the YAML extension. It will also allow other extensions register new schemas. It can also work with the mechanism proposed in #61 to automatically associate schemas with YAML files.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.