vim-lsp-settings icon indicating copy to clipboard operation
vim-lsp-settings copied to clipboard

customTags for yaml-language-server

Open alexvoss opened this issue 1 year ago • 2 comments

Hi,

I am looking for a way to define customTags for yaml-language-server. I am editing ~/.local/share/vim-lsp-settings/settings.json and have:

{
  "yaml-language-server": {
    "schemas": [
      {
        "fileMatch": ["mkdocs.yaml", "mkdocs.yml"],
        "url": "file:///Users/avoss/src/mkdocs-material/mkdocs-material-fork/docs/schema.json"
      }
    ],
    "customTags": [
      "!ENV scalar",
      "!ENV sequence",
      "tag:yaml.org,2002:python/name:material.extensions.emoji.to_svg",
      "tag:yaml.org,2002:python/name:material.extensions.emoji.twemoji"
    ]
  }     
}

The schemas part comes from vim-lsp-settings.txt in the help. I assumed that I could add the customTags attribute in the same way but it does not seem to have any effect. The tags I am trying to define come from Material for MkDocs.

What confuses me is that the format for the schema configuration is different from that shown in the documentation for the language server? Is there even a way to configure customTags in the global settings?

alexvoss avatar Jan 05 '24 21:01 alexvoss

For me setting the following in my vimrc worked:

let g:lsp_settings = {     
\   "yaml-language-server": { 
\     "workspace_config": {         
\       "yaml": {                 
\         "customTags": [                
\           "!reference sequence"
\         ]                             
\       }                                                                                                             
\     }
\   }                                                                                                                 
\ }

Based on that I assume, you need to move customTags into workspace_config>yaml, e.g.:

{
  "yaml-language-server": {
    "schemas": [
      {
        "fileMatch": ["mkdocs.yaml", "mkdocs.yml"],
        "url": "file:///Users/avoss/src/mkdocs-material/mkdocs-material-fork/docs/schema.json"
      }
    ],
    "workspace_config": {
      "yaml": {
        "customTags": [
          "!ENV scalar",
          "!ENV sequence",
          "tag:yaml.org,2002:python/name:material.extensions.emoji.to_svg",
          "tag:yaml.org,2002:python/name:material.extensions.emoji.twemoji"
        ]
      }
    }
  }
}

Andrwe avatar Jan 22 '24 17:01 Andrwe

Thanks, that did the trick!

alexvoss avatar Jan 22 '24 20:01 alexvoss