简体   繁体   中英

How to enable yaml language server in Kate editor

There is a yaml language server

I would like to use it in the Kate Editor . The Kate documentation for the language server plugin suggest configuration examples like:

{
    "servers": {
        ...
        "python": {
            "command": ["python3", "-m", "pyls", "--check-parent-process"],
            "url": "https://github.com/palantir/python-language-server",
            "highlightingModeRegex": "^Python$"
        }
        ...
    }
}

The python language server works for me out of the box (confirming there's no problem with the plugin in general).

The yaml language server suggests command:

docker run -it quay.io/redhat-developer/yaml-language-server:latest

When I run this from bash I see the docker is up:

CONTAINER ID   IMAGE                                                  COMMAND                  CREATED          STATUS          PORTS     NAMES
fac9a04e2bf0   quay.io/redhat-developer/yaml-language-server:latest   "node ./out/server/s…"   12 seconds ago   Up 11 seconds             practical_euclid

(I added my user to a docker group so I can run docker in a non-root mode. Kate also runs under my user. So I assume the LSP does as well and runs its commands under my user too.)

I created Kate LSP plugin configuration:

        ...
        "yaml": {
            "command": ["docker", "run", "-it", "quay.io/redhat-developer/yaml-language-server:latest"],
            "url": "https://github.com/redhat-developer/yaml-language-server",
            "highlightingModeRegex": "^YAML$"
        },
        ...

The Kate configuration editor reports it is a valid JSON.

When I open yaml file in Kate I receive messages:

10:24:14 LSP Client Log Started server yaml@/home/i314691: /usr/bin/docker run -it quay.io/redhat-developer/yaml-language-server:latest
10:24:14 LSP Client Warning Server terminated unexpectedly ... NOT Restarting [/usr/bin/docker run -it quay.io/redhat-developer/yaml-language-server:latest] [homepage: https://github.com/redhat-developer/yaml-language-server]

Indeed the docker terminates immediately, so I don't know how to use docker log , because docker ps doesn't show it.

The Kate documentation for the language server plugin suggest enabling further debug in the language server.

Unfortunately my knowledge of node.js is very limited. Can you please suggest how to troubleshot node.js docker? How to troubleshoot the yaml language server? Any other suggestion for troubleshooting between the language server and Kate?

Kate editor version information:

||/ Name                 Version                             Architecture Description
+++-====================-===================================-============-============================================
ii  kate                 4:22.04.2-0ubuntu1~ubuntu22.04~ppa1 amd64        powerful text editor
ii  kate5-data           4:22.04.2-0ubuntu1~ubuntu22.04~ppa1 all          shared data files for Kate text editor
ii  ktexteditor-katepart 5.94.0-0ubuntu1~ubuntu22.04~ppa1    amd64        provide advanced plain text editing services

From some reason the docker did not work, but when I installed via

sudo snap install yaml-language-server

the language server works in Kate.

Edit: The

sudo npm i -g yaml-language-server

works for me as well.
You only have to choose the lesser evil between snap and having installed nodejs that you don't use. (I recently uninstalled snap, because it was messing up with Firefox.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM