Kate LSP Configuration not Working

I’ve spent much more time than I could afford trying to make Kate autocomplete PHP/HTML/JS/CSS code. I want tag-closing and indentation to be automatic, like in many other text editors.

Here is proof that I have successfully installed the appropriate language servers:

someone@SOMETHING:~$ which intelephense vscode-html-language-server typescript-language-server vscode-css-language-server 
/usr/local/bin/intelephense
/usr/local/bin/vscode-html-language-server
/usr/local/bin/typescript-language-server
/usr/local/bin/vscode-css-language-server
someone@SOMETHING:~$

Here is my user server settings file (which I edited through Kate to make sure that the latter was aware of it):

{
    "servers": {

        "php": {
            "command": ["intelephense", "--stdio"],
            "url": "https://github.com/bmewburn/intelephense-docs",
            "highlightingModeRegex": "^PHP$"
        },

        "html": {
	            "command": ["vscode-html-language-server", "--stdio"],
	            "url": "https://github.com/Microsoft/vscode/tree/main/extensions/html-language-features/server",
	            "highlightingModeRegex": "^HTML$"
	        }
    }
}

As you can see, I’m sticking to PHP and HTML for now, and I’ll deal with pure CSS and JS files after. Right now I’m just trying to make it work when I open files ending in HTML and PHP extensions. (Does the PHP language server also take care of HTML files, though? That would be nice.)

My LSP plugin is enabled in Kate, I ran “restart all LSP servers” from the “LSP server” menu, but it still doesn’t work, even after restarting Kate.

Any suggestions on what I’m doing wrong? I honestly don’t remember much from the tens of different things I tried to fix the issue.

Whatever I do, there is no information in the “diagnostics” tab.

Thank you.

1 Like

Is there anything logged into the “Output” tab?

Your JSON seems fine, if there are any failures on starting any LSP services, Kate should log them out on the “Output” tab.

1 Like

Thank you for your reply!

There is nothing showing up within the output tab either, unfortunately. Even after doing “restart all LSP servers.”

The output tab should always show something, if the LSP client is running. For example - on my setup when I open a PHP file I get this:

[18:25:11  LSP Client Log] Started server php@/home/odeda/Documents/Projects/isrp/isrp-api: /home/odeda/.local/bin/phpactor language-server
[18:25:11  LSP Server Log] php@/home/odeda/Documents/Projects/isrp/isrp-api
Starting language server, use -vvv for verbose output
[18:26:01  LSP Server Info] Indexing workspace Done indexing (48.84s, 120/∞ mb), watching with pattern matching find (BSD/GNU)

if you have no output, then it means that the LSP client didn’t understand that your current file needs a language server.

You can also see that problem by opening the “LSP Client” menu - if the option to “Restart LSP Server” is grayed out (as opposed to “Restart All LSP Servers”, that is always available) - that means that Kate did not understand that this file should use an LSP.

1 Like

Oh, that’s a step forward!

How do I make Kate understand that I want the respective server to be launched when I open a file? Because this issue happens with all the file types I’ve tried, including PHP, HTML, CSS and JS.

Thank you.

Do you have different result when launching Kate from terminal? Sometimes Kate doesn’t find the correct path, but if those language servers can be found when using the terminal, then it should find them.

Seems the highlightingModeRegex for php is
"highlightingModeRegex": "^PHP \\(HTML\\)$" by default, you could try that.

html part seems to be correct. Make sure you have also the server listed in “Allowed and blocked servers” tab and enabled.

2 Likes

Check that in Kate’s settings, under Open/SaveModes & Filetypes [sic], you have PHP set up with the correct file extensions and MIME types:

2 Likes

Correcting the highlightingModeRegex did the trick, and apparently fixed the issue for all my language servers. Not sure how that works, but my problem is now solved. Many thanks to you and everyone who contributed their help.

Cheers.

1 Like

Huh, that’s interesting. But I am glad you got it to work!

LSP configurations can be quite annoying, so I definitely understand the frustration!