mattn / vim-lsp-settings

Auto configurations for Language Server for vim-lsp
MIT License
1.26k stars 225 forks source link

customTags for yaml-language-server #716

Open alexvoss opened 6 months ago

alexvoss commented 6 months ago

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?

Andrwe commented 5 months ago

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"
        ]
      }
    }
  }
}
alexvoss commented 5 months ago

Thanks, that did the trick!