Coder Social home page Coder Social logo

adamvoss / vscode-yaml Goto Github PK

View Code? Open in Web Editor NEW
27.0 3.0 5.0 309 KB

YAML language support, including JSON Schema validation, for Visual Studio Code

Home Page: https://marketplace.visualstudio.com/items?itemName=adamvoss.yaml

License: MIT License

TypeScript 100.00%

vscode-yaml's Introduction

YAML for Visual Studio Code

Features

  • JSON Schema validation
  • Quick Navigation (Ctrl + Shift + O)
  • Document formatting
  • Hover data descriptions (when provided by active schemas)

How to associate schemas

Schemas are handled exactly same way they are with JSON in Visual Studio Code and your schema file must still be written in JSON. This means you can:

Known Issues

  • No support has been implemented for include references. (relevant code)
  • Formatter strips comments and --- yaml marker. see issues/#9
  • Formatter renames anchors/references in the style &ref12/*ref12

Acknowledgments

This extension would not have been possible without numerous open source projects. Please see ACKNOWLEDGMENTS.md.

Contributing

Contributions are welcome! To install dependencies and begin work, run:

npm install

This was forked from https://github.com/Microsoft/vscode/tree/master/extensions/json, to prepare the latest commits from upstream, use:

git clone https://github.com/Microsoft/vscode.git
cd vscode
git checkout -b vscode-json
git filter-branch --prune-empty --subdirectory-filter extensions/json/ vscode-json

vscode-yaml's People

Contributors

adamvoss avatar aeschli avatar alexdima avatar alrra avatar bpasero avatar dbaeumer avatar dstorey avatar golf1052 avatar ikuyadeu avatar isidorn avatar joaomoreno avatar jrieken avatar kieferrm avatar marvinhagemeister avatar mjbvz avatar philoserf avatar ramya-rao-a avatar weinand 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

Watchers

 avatar  avatar  avatar

vscode-yaml's Issues

Stacktrace when using aws cloud formation templates

Hi

I'm trying to use this project for AWS Cloud Formation templates, but I get this stacktrace:

c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:219
        errors.forEach(e => _doc.errors.push(e));
                                       ^

TypeError: Cannot read property 'push' of undefined
    at errors.forEach.e (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:219:40)
    at Array.forEach (native)
    at createJSONDocument (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:219:16)
    at yamlDocs.map.doc (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:255:53)
    at Array.map (native)
    at Object.parse (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:255:42)
    at Object.parseYAMLDocument (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\yamlLanguageService.js:65:59)
    at c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\out\yamlServerMain.js:232:117
    at Object.get (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\out\languageModelCache.js:34:33)
    at getJSONDocument (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\out\yamlServerMain.js:240:26)
[Info  - 07:45:14] Connection to server got closed. Server will restart.
c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:219
        errors.forEach(e => _doc.errors.push(e));
                                       ^

TypeError: Cannot read property 'push' of undefined
    at errors.forEach.e (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:219:40)
    at Array.forEach (native)
    at createJSONDocument (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:219:16)
    at yamlDocs.map.doc (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:255:53)
    at Array.map (native)
    at Object.parse (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:255:42)
    at Object.parseYAMLDocument (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\yamlLanguageService.js:65:59)
    at c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\out\yamlServerMain.js:232:117
    at Object.get (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\out\languageModelCache.js:34:33)
    at getJSONDocument (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\out\yamlServerMain.js:240:26)
[Info  - 07:45:14] Connection to server got closed. Server will restart.
c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:219
        errors.forEach(e => _doc.errors.push(e));
                                       ^

TypeError: Cannot read property 'push' of undefined
    at errors.forEach.e (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:219:40)
    at Array.forEach (native)
    at createJSONDocument (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:219:16)
    at yamlDocs.map.doc (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:255:53)
    at Array.map (native)
    at Object.parse (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:255:42)
    at Object.parseYAMLDocument (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\yamlLanguageService.js:65:59)
    at c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\out\yamlServerMain.js:232:117
    at Object.get (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\out\languageModelCache.js:34:33)
    at getJSONDocument (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\out\yamlServerMain.js:240:26)
[Info  - 07:45:15] Connection to server got closed. Server will restart.
c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:219
        errors.forEach(e => _doc.errors.push(e));
                                       ^

TypeError: Cannot read property 'push' of undefined
    at errors.forEach.e (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:219:40)
    at Array.forEach (native)
    at createJSONDocument (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:219:16)
    at yamlDocs.map.doc (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:255:53)
    at Array.map (native)
    at Object.parse (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:255:42)
    at Object.parseYAMLDocument (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\yamlLanguageService.js:65:59)
    at c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\out\yamlServerMain.js:232:117
    at Object.get (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\out\languageModelCache.js:34:33)
    at getJSONDocument (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\out\yamlServerMain.js:240:26)
[Info  - 07:45:16] Connection to server got closed. Server will restart.
c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:219
        errors.forEach(e => _doc.errors.push(e));
                                       ^

TypeError: Cannot read property 'push' of undefined
    at errors.forEach.e (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:219:40)
    at Array.forEach (native)
    at createJSONDocument (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:219:16)
    at yamlDocs.map.doc (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:255:53)
    at Array.map (native)
    at Object.parse (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\parser\yamlParser.js:255:42)
    at Object.parseYAMLDocument (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\node_modules\vscode-yaml-languageservice\lib\yamlLanguageService.js:65:59)
    at c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\out\yamlServerMain.js:232:117
    at Object.get (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\out\languageModelCache.js:34:33)
    at getJSONDocument (c:\Users\montao\.vscode\extensions\adamvoss.yaml-0.0.10\server\out\yamlServerMain.js:240:26)

Option to disable validation

I have some Symfony config files that currently do not fit into valid yaml, meaning some properties start with % and no ' or " before that.
Is there a way to disable the validation for valid yaml but keep the highlighting.

YAML syntax errors crash vscode

Running latest vscode and your plugin

When i make some syntax mistakes in yaml files, and vscode correctly tries to highlight those the whole vscode will eventually crash

  • The error is highlighted, along with every line in the file (seems wrong?)
  • Not sure where to look for logs, but eventually the window crashes

yaml server crashing

Running vscode on osx. Tried re-installing the plugin but no luck.

TypeError: Cannot read property 'forEach' of undefined
    at JSONValidation.doValidation (/Users/brandon/.vscode/extensions/adamvoss.yaml-0.0.10/server/node_modules/vscode-json-languageservice/lib/services/jsonValidation.js:47:38)
    at yamlDocument.documents.map.d (/Users/brandon/.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 (/Users/brandon/.vscode/extensions/adamvoss.yaml-0.0.10/server/node_modules/vscode-yaml-languageservice/lib/yamlLanguageService.js:48:62)
    at validateTextDocument (/Users/brandon/.vscode/extensions/adamvoss.yaml-0.0.10/server/out/yamlServerMain.js:215:21)
    at Timeout._onTimeout (/Users/brandon/.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)
[Error - 9:03:17 AM] Connection to server got closed. Server will not be restarted.

Auto-completion when using JSON Schema

I noticed auto-completion doesn't work when using a JSON schema, although the validation works fine. Is expected to be working? If it is, then would this be a bug in the vscode-yaml extension or in VS Code?Whatever the case, congrats for this excellent extension - it saved me and my team countless hours.

Merging in multiple anchors results in validation error

When using anchors and merging multiple anchors into the same object Visual Studio Code complains about invlid document.

Document:

.numbers: &numbers
  one: "1"
  two: "2"

.countries: &countries
  us: "United States"
  uk: "United Kingdom"

instance1:
  <<: *numbers
  <<: *countries
  something: "else"

Expected result: The document is valid

Actual result: Error in validating document

JS-YAML: duplicate key at line 10, column 3
JS-YAML: duplicate key at line 11, column 3

2017-12-21 16_36_32

The server crashes

VSCode said the server crashed 5 times in 3 minutes. It won't be started again.

clientSnippetSupport field in yamlServerMain.ts is unused

The clientSnippetSupport field is assigned but never actually used. Should it be removed instead?

let clientSnippetSupport = false;
let clientDynamicRegisterSupport = false;
// After the server has started the client sends an initilize request. The server receives
// in the passed params the rootPath of the workspace plus the client capabilities.
let workspaceRoot: URI;
connection.onInitialize((params: InitializeParams): InitializeResult => {
workspaceRoot = URI.parse(params.rootPath);
function hasClientCapability(...keys: string[]) {
let c = params.capabilities;
for (let i = 0; c && i < keys.length; i++) {
c = c[keys[i]];
}
return !!c;
}
clientSnippetSupport = hasClientCapability('textDocument', 'completion', 'completionItem', 'snippetSupport');
clientDynamicRegisterSupport = hasClientCapability('workspace', 'symbol', 'dynamicRegistration');
return {
capabilities: {
// Tell the client that the server works in FULL text document sync mode
textDocumentSync: documents.syncKind,
// Disabled because too JSON centric
// completionProvider: { resolveProvider: false },
hoverProvider: true,
documentSymbolProvider: true,
documentFormattingProvider: false
}
};
});

Include support for JSON Schema in YAML format

JSON is already unnecessarily verbose, and JSON Schema definitions don't make it any better. I would like to see support for JSON Schema validation against definitions in YAML format instead of JSON, so we can forget about the format entirely.

feature request: jinja support?

Thanks for this plugin, very useful.

Not sure how this might be done, but I'll ask anyway 😄 ... is it possible to somehow enable jinja2 support for validation? I guess this might be a wider issue for vscode too, not only for this plugin. But I have a yaml file with some jinja2 tags that looks like this:

screen shot 2017-12-12 at 11 15 09

The errors/warnings I get are:

screen shot 2017-12-12 at 11 20 31

It'd be great if this could look a bit nicer somehow.

FYI, these yaml files are from openstack rally

Thanks!

Possible to disable linting onChange?

I’d prefer the linting to occur only when I save, or trigger it manually. I apologize if this is obvious; I’m new to VS Code and couldn’t figure this out after ~15 minutes of searching.

JS-YAML: unknown tag <!Join>

Hi,

Unfortunately I have some problems to validate yaml documents for AWS CloudFormation.
I have following line in my Template:
TemplateURL: !Join ["/", [ !FindInMap [CFNBucket, !Ref "AWS::Region", !Ref "Environment" ], "cfn-generic/s3_single.yaml"]]

Starting with !Join I get following error:
JS-YAML: unknown tag <!Join> at line 37, column 20

Is there a solution to workaround with this, so that I can validate my templates. E.g. CustomTags that are ignored.

Auto-completion by context

Would it be possible to have auto-completion based on the YAML context. For example, if I'm typing a key in an associative array, it would complete based on other keys, if I'm typing a value, other values, etc?

unknown tag <tag:yaml.org,2002:str>

"yes as a boolean": yes
"yes as a string": "yes"
"yes as a string with tag": !!str yes

The third line causes the error in the title of the issue. Is there currently no support for the recommended schemas? If so, there should be at least some documentation on how to add this support locally.

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.