zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
47.33k stars 2.75k forks source link

Yaml custom tags, unresolved tags #18013

Open elvishp2006 opened 3 days ago

elvishp2006 commented 3 days ago

Check for existing issues

Describe the bug / provide steps to reproduce it

I had configured my editor to work with a custom lsp config to yaml files, but it keep saying that my custom tags are Unresolved

Environment

Zed: v0.153.5 (Zed Preview) OS: macOS 14.6.1 Memory: 16 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

  "lsp": {
    "yaml-language-server": {
      "initialization_options": {
        "yaml": {
          "customTags": [
            "!And scalar",
            "!And mapping",
            "!And sequence",
            "!If scalar",
            "!If mapping",
            "!If sequence",
            "!Not scalar",
            "!Not mapping",
            "!Not sequence",
            "!Equals scalar",
            "!Equals mapping",
            "!Equals sequence",
            "!Or scalar",
            "!Or mapping",
            "!Or sequence",
            "!FindInMap scalar",
            "!FindInMap mappping",
            "!FindInMap sequence",
            "!Base64 scalar",
            "!Base64 mapping",
            "!Base64 sequence",
            "!Cidr scalar",
            "!Cidr mapping",
            "!Cidr sequence",
            "!Ref scalar",
            "!Ref mapping",
            "!Ref sequence",
            "!Sub scalar",
            "!Sub mapping",
            "!Sub sequence",
            "!GetAtt scalar",
            "!GetAtt mapping",
            "!GetAtt sequence",
            "!GetAZs scalar",
            "!GetAZs mapping",
            "!GetAZs sequence",
            "!ImportValue scalar",
            "!ImportValue mapping",
            "!ImportValue sequence",
            "!Select scalar",
            "!Select mapping",
            "!Select sequence",
            "!Split scalar",
            "!Split mapping",
            "!Split sequence",
            "!Join scalar",
            "!Join mapping",
            "!Join sequence",
            "!Condition scalar",
            "!Condition mapping",
            "!Condition sequence"
          ],
          "schemas": {
            "https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json": "template.yml"
          }
        }
      }
    }
  }
Captura de Tela 2024-09-18 às 12 15 41

If applicable, attach your Zed.log file to this issue.

Zed.log


notpeter commented 3 days ago

Can you provide an minimal example YAML file so I can see if I can reproduce?

elvishp2006 commented 2 days ago

Can you provide an minimal example YAML file so I can see if I can reproduce?

AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
  api-example: API Example

Parameters:
  Stage:
    Type: String
    Default: development
    AllowedValues:
      - development
      - staging
      - production

Conditions:
  IsProductionStage: !Equals [!Ref Stage, production]

Resources:
  HttpApi:
    Type: AWS::Serverless::HttpApi
    Properties:
      DefaultRouteSettings:
        DetailedMetricsEnabled: true
      Domain:
        CertificateArn: arn:aws:acm:us-east-1:000000000000:certificate/be8e5595-4771-4408-9ec2-547a2230bdfds
        DomainName: !Ref DomainName
        EndpointConfiguration: REGIONAL
        Route53:
          HostedZoneId: Z1OLBJHSKHIU98
notpeter commented 2 days ago

I can reproduce. You config works correctly in 2d06d5c906 following this PR:

But is broken in current Stable/Preview.

After running the bisect the offending commit that introduced the regression is 02d5f320ad621e92cafaa7075f61e6496e12cd98 which is the following PR:

Thanks for reporting.

notpeter commented 2 days ago

Change initialization_options to settings and it should work. I'll work on updating the docs to reflect this.

elvishp2006 commented 2 days ago

I had changed the configs to this:

  "lsp": {
    "yaml-language-server": {
      "settings": {
        "yaml": {
          "customTags": [
            "!And scalar",
            "!And mapping",
            "!And sequence",
            "!If scalar",
            "!If mapping",
            "!If sequence",
            "!Not scalar",
            "!Not mapping",
            "!Not sequence",
            "!Equals scalar",
            "!Equals mapping",
            "!Equals sequence",
            "!Or scalar",
            "!Or mapping",
            "!Or sequence",
            "!FindInMap scalar",
            "!FindInMap mappping",
            "!FindInMap sequence",
            "!Base64 scalar",
            "!Base64 mapping",
            "!Base64 sequence",
            "!Cidr scalar",
            "!Cidr mapping",
            "!Cidr sequence",
            "!Ref scalar",
            "!Ref mapping",
            "!Ref sequence",
            "!Sub scalar",
            "!Sub mapping",
            "!Sub sequence",
            "!GetAtt scalar",
            "!GetAtt mapping",
            "!GetAtt sequence",
            "!GetAZs scalar",
            "!GetAZs mapping",
            "!GetAZs sequence",
            "!ImportValue scalar",
            "!ImportValue mapping",
            "!ImportValue sequence",
            "!Select scalar",
            "!Select mapping",
            "!Select sequence",
            "!Split scalar",
            "!Split mapping",
            "!Split sequence",
            "!Join scalar",
            "!Join mapping",
            "!Join sequence",
            "!Condition scalar",
            "!Condition mapping",
            "!Condition sequence"
          ],
          "schemas": {
            "https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json": "template.yml"
          }
        }
      }
    }
  }

But it's not working yet

Captura de Tela 2024-09-19 às 14 14 24
Zed: v0.154.0 (Zed Preview)
OS: macOS 15.0.0
Memory: 16 GiB
Architecture: aarch64
notpeter commented 2 days ago

Here is an example project that works for me Zed Preview v0.154.0 https://github.com/notpeter2/zed-yaml-example

Unrelated, there's a typo in your settings: s/"!FindInMap mappping",/"!FindInMap mapping",/ (three p's).

elvishp2006 commented 2 days ago

Here is an example project that works for me Zed Preview v0.154.0 https://github.com/notpeter2/zed-yaml-example

Unrelated, there's a typo in your settings: s/"!FindInMap mappping",/"!FindInMap mapping",/ (three p's).

I think this repo is private

notpeter commented 2 days ago

Whoops. Fixed.

elvishp2006 commented 2 days ago

I don't know what is happening here:

https://www.youtube.com/watch?v=TuvBA4FqeyI

notpeter commented 2 days ago

Can you look in your Zed log ~/Library/Logs/Zed/Zed.log and see if there's anything of note?

It's a little baroque, but from the Command Palette (cmd-shift-p) there's also debug: open language server logs and then you can select "yaml-language-server" and [x] "RPC Messages"

Screenshot 2024-09-19 at 14 19 10

Then if you open the .zed/settings.json and make a change (e.g. add a space and save) you can see the log of communication between Zed and the LSP. Similarly, any actions you perform in the file (edit, hover diagnostics, etc) should show up there too.

I don't have any great ideas about what to look for, but maybe something will pop out at you.

Also worth commenting out any lines in your Zed user settings (`~/.config/zed/settings.json) related to this in case there's some conflict between the user settings and the workspace settings in the repo.

elvishp2006 commented 2 days ago

I did commented the section lsp from user settings, and here are the logs:

// Send:
{"jsonrpc":"2.0","method":"textDocument/didSave","params":{"textDocument":{"uri":"file:///private/tmp/zed-yaml-example/.zed/settings.json"}}}
// Send:
{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"[yaml]":{"editor.tabSize":2},"yaml":{"customTags":["!And scalar","!And mapping","!And sequence","!If scalar","!If mapping","!If sequence","!Not scalar","!Not mapping","!Not sequence","!Equals scalar","!Equals mapping","!Equals sequence","!Or scalar","!Or mapping","!Or sequence","!FindInMap scalar","!FindInMap mapping","!FindInMap sequence","!Base64 scalar","!Base64 mapping","!Base64 sequence","!Cidr scalar","!Cidr mapping","!Cidr sequence","!Ref scalar","!Ref mapping","!Ref sequence","!Sub scalar","!Sub mapping","!Sub sequence","!GetAtt scalar","!GetAtt mapping","!GetAtt sequence","!GetAZs scalar","!GetAZs mapping","!GetAZs sequence","!ImportValue scalar","!ImportValue mapping","!ImportValue sequence","!Select scalar","!Select mapping","!Select sequence","!Split scalar","!Split mapping","!Split sequence","!Join scalar","!Join mapping","!Join sequence","!Condition scalar","!Condition mapping","!Condition sequence"],"schemas":{"https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json":"template.yml"}}}}}
// Receive:
{"jsonrpc":"2.0","id":3,"method":"workspace/configuration","params":{"items":[{"section":"yaml"},{"section":"http"},{"section":"[yaml]"},{"section":"editor"},{"section":"files"}]}}
// Send:
{"jsonrpc":"2.0","id":3,"result":[{"customTags":["!And scalar","!And mapping","!And sequence","!If scalar","!If mapping","!If sequence","!Not scalar","!Not mapping","!Not sequence","!Equals scalar","!Equals mapping","!Equals sequence","!Or scalar","!Or mapping","!Or sequence","!FindInMap scalar","!FindInMap mapping","!FindInMap sequence","!Base64 scalar","!Base64 mapping","!Base64 sequence","!Cidr scalar","!Cidr mapping","!Cidr sequence","!Ref scalar","!Ref mapping","!Ref sequence","!Sub scalar","!Sub mapping","!Sub sequence","!GetAtt scalar","!GetAtt mapping","!GetAtt sequence","!GetAZs scalar","!GetAZs mapping","!GetAZs sequence","!ImportValue scalar","!ImportValue mapping","!ImportValue sequence","!Select scalar","!Select mapping","!Select sequence","!Split scalar","!Split mapping","!Split sequence","!Join scalar","!Join mapping","!Join sequence","!Condition scalar","!Condition mapping","!Condition sequence"],"schemas":{"https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json":"template.yml"}},null,{"editor.tabSize":2},null,null]}
// Receive:
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///private/tmp/zed-yaml-example/template.yml","diagnostics":[{"range":{"start":{"line":15,"character":29},"end":{"line":15,"character":53}},"message":"Incorrect type. Expected \"object(AWS CloudFormation Serverless Application Model (SAM))\".","severity":1,"code":0,"source":"yaml-schema: AWS CloudFormation Serverless Application Model (SAM)","data":{"schemaUri":["https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json"]}}]}}
// Send:
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///private/tmp/zed-yaml-example/template.yml","version":2},"contentChanges":[{"range":{"start":{"line":12,"character":18},"end":{"line":12,"character":18}},"text":" "}]}}
// Send:
{"jsonrpc":"2.0","id":6,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///private/tmp/zed-yaml-example/template.yml"},"position":{"line":12,"character":19},"context":{"triggerKind":2,"triggerCharacter":" "}}}
// Receive:
{"jsonrpc":"2.0","id":6,"result":{"items":[{"kind":12,"label":"!And","insertText":"!And ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!And "}},{"kind":12,"label":"!If","insertText":"!If ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!If "}},{"kind":12,"label":"!Not","insertText":"!Not ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Not "}},{"kind":12,"label":"!Equals","insertText":"!Equals ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Equals "}},{"kind":12,"label":"!Or","insertText":"!Or ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Or "}},{"kind":12,"label":"!FindInMap","insertText":"!FindInMap ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!FindInMap "}},{"kind":12,"label":"!Base64","insertText":"!Base64 ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Base64 "}},{"kind":12,"label":"!Cidr","insertText":"!Cidr ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Cidr "}},{"kind":12,"label":"!Ref","insertText":"!Ref ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Ref "}},{"kind":12,"label":"!Sub","insertText":"!Sub ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Sub "}},{"kind":12,"label":"!GetAtt","insertText":"!GetAtt ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!GetAtt "}},{"kind":12,"label":"!GetAZs","insertText":"!GetAZs ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!GetAZs "}},{"kind":12,"label":"!ImportValue","insertText":"!ImportValue ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!ImportValue "}},{"kind":12,"label":"!Select","insertText":"!Select ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Select "}},{"kind":12,"label":"!Split","insertText":"!Split ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Split "}},{"kind":12,"label":"!Join","insertText":"!Join ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Join "}},{"kind":12,"label":"!Condition","insertText":"!Condition ","insertTextFormat":2,"documentation":"","textEdit":{"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"newText":"!Condition "}}],"isIncomplete":false}}
// Receive:
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///private/tmp/zed-yaml-example/template.yml","diagnostics":[{"range":{"start":{"line":15,"character":29},"end":{"line":15,"character":53}},"message":"Incorrect type. Expected \"object(AWS CloudFormation Serverless Application Model (SAM))\".","severity":1,"code":0,"source":"yaml-schema: AWS CloudFormation Serverless Application Model (SAM)","data":{"schemaUri":["https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json"]}}]}}
// Send:
{"jsonrpc":"2.0","id":7,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///private/tmp/zed-yaml-example/template.yml"},"range":{"start":{"line":12,"character":19},"end":{"line":12,"character":19}},"context":{"diagnostics":[],"only":["","quickfix","refactor","refactor.extract","source"]}}}
// Receive:
{"jsonrpc":"2.0","id":7,"result":[]}
// Send:
{"jsonrpc":"2.0","method":"textDocument/didSave","params":{"textDocument":{"uri":"file:///private/tmp/zed-yaml-example/template.yml"}}}
// Send:
{"jsonrpc":"2.0","id":8,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///private/tmp/zed-yaml-example/template.yml"},"range":{"start":{"line":7,"character":16},"end":{"line":7,"character":16}},"context":{"diagnostics":[],"only":["","quickfix","refactor","refactor.extract","source"]}}}
// Receive:
{"jsonrpc":"2.0","id":8,"result":[]}
notpeter commented 2 days ago

For anyone we attempts to reproduce this, I still get a single squiggle (which I think is legit) but the youtube video above shows the previous broken behavior.

Screenshot 2024-09-19 at 17 16 28 Screenshot 2024-09-19 at 17 19 19