Coder Social home page Coder Social logo

lsp-yaml's Introduction

LSP-yaml

YAML support for Sublime's LSP plugin. Basically a fork of sublimelsp/LSP-json.

Uses yaml-language-server to provide validation, formatting and other features for YAML files. See linked repository for more information.

By default, schemas are automatically retrieved from schemastore.org.

Install

  1. Open the command palette and run Package Control: Install Package, then select LSP
  2. Install LSP-yaml from Package Control
  3. Restart Sublime

Configuration

Open configuration file using command palette with Preferences: LSP-yaml Settings command or opening it from the Sublime menu (Preferences > Package Settings > LSP > Servers > LSP-yaml).

Development

Clone this repository into your Packages directory. Open the command palette and run Package Control: Satisfy Dependencies.

lsp-yaml's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar jfcherng avatar predragnikolic avatar randombyte avatar rchl avatar rwols avatar

Stargazers

 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

Forkers

nugged

lsp-yaml's Issues

Suggestions not working

To Reproduce

  1. Close ST3, rename away your ~/.config/sublime-text-3` directory, and reopen ST3
  2. Install Package control from the command palette
  3. Install LSP and LSP-yaml packages; restart ST3
  4. Open or create a yaml file with a $schema: declaration at the top (see example below); restart ST3 again for good measure
  5. Place your cursor in any place where a fixed set of keys are expected and start writing

Expected behavior
The available keys according to the schema should be shown in the suggestion menu.

Actual behaviour
Either nothing is shown, or ST3's default menu based on the other words present in the file.

Example
Here is a yaml file with a valid schema:

$schema: https://vega.github.io/schema/vega-lite/v4.json
description: A simple bar chart
data:
  values:
    - { a: A, b: 28 }
    - { a: B, b: 55 }
    - { a: C, b: 43 }
mark: bar
encoding:
  x: 
    field: a
    type: nominal
    axis: 
      labelAngle: 0
  y: 
    field: b
    type: quantitative
  # <- here

If you place your cursor where the comment is shown, aligned with y:, and start typing col... it should suggest color, but instead nothing is suggested.

LSP-yaml: Notification handler 'workspace/didChangeConfiguration' failed with message: Cannot read property 'length' of undefined

I was under the impression that the yaml-language-server supports formatting. However, in my case this seem to not work (i.e. LSP format file grayed out).
image

Moreover, it seems to not do anything at all. I did see an error for a notification handler. Maybe that is causing this, or am I misunderstanding something else?

My LSP-yaml.sublime-settings

// Settings in here override those in "LSP-yaml/LSP-yaml.sublime-settings"
{
	"settings": {
		"yaml.format.enable": true,
		"yaml.format.singleQuote": true,
		"yaml.format.printWidth": 88,
		"yaml.schemas": {
			"Ansible Role": "task/*.yml"
		}
	}
}

Full debug log

:: --> LSP-yaml initialize(1): {'rootUri': 'file:///C:/.../Ansible', 'initializationOptions': {}, 'processId': 12448, 'rootPath': 'C:\\...\\Ansible', 'workspaceFolders': [{'name': 'Ansible', 'uri': 'file:///C:/.../Ansible'}], 'clientInfo': {'name': 'Sublime Text LSP', 'version': '1.4.0'}, 'capabilities': {'textDocument': {'documentHighlight': {'dynamicRegistration': True}, 'typeDefinition': {'dynamicRegistration': True, 'linkSupport': True}, 'signatureHelp': {'signatureInformation': {'documentationFormat': ['markdown', 'plaintext'], 'parameterInformation': {'labelOffsetSupport': True}}, 'dynamicRegistration': True}, 'declaration': {'dynamicRegistration': True, 'linkSupport': True}, 'rangeFormatting': {'dynamicRegistration': True}, 'colorProvider': {'dynamicRegistration': True}, 'rename': {'dynamicRegistration': True, 'prepareSupport': True}, 'formatting': {'dynamicRegistration': True}, 'codeAction': {'dynamicRegistration': True, 'resolveSupport': {'properties': ['edit']}, 'dataSupport': True, 'codeActionLiteralSupport': {'codeActionKind': {'valueSet': ['quickfix', 'refactor', 'refactor.extract', 'refactor.inline', 'refactor.rewrite', 'source.organizeImports']}}}, 'references': {'dynamicRegistration': True}, 'synchronization': {'dynamicRegistration': True, 'willSaveWaitUntil': True, 'willSave': True, 'didSave': True}, 'selectionRange': {'dynamicRegistration': True}, 'definition': {'dynamicRegistration': True, 'linkSupport': True}, 'hover': {'dynamicRegistration': True, 'contentFormat': ['markdown', 'plaintext']}, 'implementation': {'dynamicRegistration': True, 'linkSupport': True}, 'codeLens': {'dynamicRegistration': True}, 'completion': {'dynamicRegistration': True, 'completionItemKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]}, 'completionItem': {'documentationFormat': ['markdown', 'plaintext'], 'snippetSupport': True, 'resolveSupport': {'properties': ['detail', 'documentation', 'additionalTextEdits']}, 'deprecatedSupport': True, 'tagSupport': {'valueSet': [1]}}}, 'documentSymbol': {'symbolKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}, 'dynamicRegistration': True, 'hierarchicalDocumentSymbolSupport': True, 'tagSupport': {'valueSet': [1]}}, 'publishDiagnostics': {'versionSupport': True, 'codeDescriptionSupport': True, 'relatedInformation': True, 'dataSupport': True, 'tagSupport': {'valueSet': [2, 1]}}}, 'experimental': {}, 'window': {'workDoneProgress': True, 'showDocument': {'support': True}, 'showMessage': {'messageActionItem': {'additionalPropertiesSupport': True}}}, 'workspace': {'executeCommand': {}, 'configuration': True, 'applyEdit': True, 'symbol': {'symbolKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}, 'dynamicRegistration': True, 'tagSupport': {'valueSet': [1]}}, 'didChangeConfiguration': {'dynamicRegistration': True}, 'workspaceFolders': True, 'workspaceEdit': {'documentChanges': True, 'failureHandling': 'abort'}}, 'general': {'markdown': {'version': '3.2.2', 'parser': 'Python-Markdown'}, 'regularExpressions': {'engine': 'ECMAScript'}}}}
:: <<< LSP-yaml 1: {'capabilities': {'documentSymbolProvider': True, 'codeLensProvider': {'resolveProvider': False}, 'documentFormattingProvider': False, 'executeCommandProvider': {'commands': ['jumpToSchema']}, 'documentRangeFormattingProvider': False, 'documentOnTypeFormattingProvider': {'firstTriggerCharacter': '\n'}, 'hoverProvider': True, 'foldingRangeProvider': False, 'completionProvider': {'resolveProvider': False}, 'documentLinkProvider': {}, 'workspace': {'workspaceFolders': {'changeNotifications': True, 'supported': True}}, 'textDocumentSync': {'didOpen': {}, 'didClose': {}, 'change': {'syncKind': 2}, 'save': {}}, 'codeActionProvider': True}}
::  -> LSP-yaml initialized: {}
::  -> LSP-yaml workspace/didChangeConfiguration: {'settings': {'yaml': {'editor': {'tabSize': 2}, 'maxItemsComputed': 5000, 'schemas': {'Ansible Role': 'task/*.yml'}, 'schemaStore': {'enable': True}, 'hover': True, 'customTags': [], 'validate': True, 'format': {'printWidth': 88, 'enable': True, 'proseWrap': 'preserve', 'bracketSpacing': True, 'singleQuote': True}, 'completion': True, 'disableAdditionalProperties': False}, 'http': {'proxy': None, 'proxyStrictSSL': False}}}
::  -> LSP-yaml textDocument/didOpen: {'textDocument': {'uri': 'file:///C:/.../Ansible/test.yml', 'languageId': 'yaml', 'version': 0, 'text': "---\n## Process all hosts\n- hosts: 'scaleway'\n  force_handlers: yes\n  become: yes\n\n  # Roles\n  tasks:\n    - name: 'removing transparent huge pages'\n      file:\n        state: 'absent'\n        path: '/etc/systemd/system/disable-thp.service'\n\n    - name: 'starting the service to disable transparent huge pages'\n      systemd:\n        name: 'disable-thp'\n        daemon_reload: 'yes'\n        enabled: no\n\n    - name: 'test'\n      debug:\n        msg: 'we are alive'\n"}}
LSP-yaml: Notification handler 'workspace/didChangeConfiguration' failed with message: Cannot read property 'length' of undefined
:: --> LSP-yaml textDocument/codeLens(2): {'textDocument': {'uri': 'file:///C:/.../Ansible/test.yml'}}
:: <-- LSP-yaml client/registerCapability(0): {'registrations': [{'id': 'f9fe16b4-f7ff-4dd7-b674-a25dcc9962ec', 'registerOptions': {}, 'method': 'workspace/didChangeWorkspaceFolders'}]}
:: >>> LSP-yaml 0: None
:: <-  LSP-yaml window/logMessage: {'message': "Notification handler 'workspace/didChangeConfiguration' failed with message: Cannot read property 'length' of undefined", 'type': 1}
:: <<< LSP-yaml 2: []
:: <-  LSP-yaml textDocument/publishDiagnostics: {'uri': 'file:///C:/.../Ansible/test.yml', 'diagnostics': []}
:: --> LSP-yaml textDocument/codeAction(3): {'textDocument': {'uri': 'file:///C:/.../Ansible/test.yml'}, 'context': {'diagnostics': []}, 'range': {'end': {'character': 0, 'line': 0}, 'start': {'character': 0, 'line': 0}}}
:: <<< LSP-yaml 3: []
:: --> LSP-yaml textDocument/codeAction(4): {'textDocument': {'uri': 'file:///C:/.../Ansible/test.yml'}, 'context': {'diagnostics': []}, 'range': {'end': {'character': 12, 'line': 20}, 'start': {'character': 12, 'line': 20}}}
:: <<< LSP-yaml 4: []

Custom Tags have no effect

Hello,

I have followed the example here for setting custom tags, however I still see signed them as an error in a Yaml file.

I'm working on Windows 10, Sublime Stable Channel, Build 4143

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.