How to use the yaml-language-server/out/server/src/languageservice/services/jsonSchemaService.JSONSchemaService function in yaml-language-server

To help you get started, we’ve selected a few yaml-language-server examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keesschollaart81 / vscode-home-assistant / src / server / yamlLanguageServiceWrapper.ts View on Github external
constructor(completionContributions: JSONWorkerContribution[]) {
        this.jsonSchemaService = new JSONSchemaService(null, {
            resolveRelativePath: (relativePath: string, resource: string) => {
                return path.resolve(resource, relativePath);
            }
        }, null);


        this.yamlValidation = new YAMLValidation(this.jsonSchemaService);
        this.yamlValidation.configure({ validate: true });
        this.yamlDocumentSymbols = new YAMLDocumentSymbols();
        this.yamlCompletion = new YAMLCompletion(this.jsonSchemaService, completionContributions);
        // enables auto completion suggestions for tags like !include ()
        // commeted because they end up at the top of the list which does not look nice :-)
        // this.yamlCompletion.configure(null, this.getValidYamlTags()); 
        this.yamlHover = new YAMLHover(this.jsonSchemaService);
        this.yamlFormatter = new YAMLFormatter();
    }
github keesschollaart81 / vscode-home-assistant / src / server / yamlLanguageService.ts View on Github external
export function getLanguageService(workspaceContext, promiseConstructor?): LanguageService {
    let promise = promiseConstructor || Promise;

    let jsonSchemaService = new JSONSchemaService(null, workspaceContext, null);

    var jsonPath = path.join(__dirname, '..', 'lovelace-schema', 'ui-lovelace.json');
    var sc = fs.readFileSync(jsonPath,"utf-8");
    var schema = JSON.parse(sc);

    jsonSchemaService.setSchemaContributions({
        schemas: {
            "http://schema.ha.com/lovelace": schema
        },
        schemaAssociations:{ 
            "**/ui-lovelace.yaml": ["http://schema.ha.com/lovelace"]
        }
    });
   
    let yamlvalidation = new YAMLValidation(jsonSchemaService, promise);
    yamlvalidation.configure({