Setting up an LSP server for php

In php, variables start with $ — in vim that is not part of a word by default. A small hole in the abstraction: you think you are holding a word, but in fact you are poking your finger into the void between signs.

You can fix this by adding vim.opt.iskeyword:append("$") to init.lua.

LSP is the "rules of communication" between a development environment and a language server, the standard by which these two programs exchange information. In essence it is a contract between two living processes that pass knowledge about your code to each other, so the editor can look under the hood and show not just the text but its meaning. The protocol can be implemented for practically any language. All you need is a language server with support for it. More on why it is needed (article on habr)

Popular php servers:

PS: I bought an intelephense license. To connect it, it was enough to create the directory ~/.intelephense/ and drop in the licence.txt received by email. But I did not see or understand the "goodies" of the purchased license. Twenty-five euros exchanged for a promise — a trade typical of the industry, where the output always has more hype than bytes.

intelephense documentation

The config used in vscode (it is also given in the documentation)

The official documentation gives the setup — I settled on that.

For the Laravel framework they recommend installing Laravel Ide Helper

To generate classes, interfaces, traits and so on you can use the easy-php package plus a quick snippet set.

You can see the list of what it does in the documentation or simply by pressing - in a php file.

Enable inlay hints — type hints right in the code, without pop-up windows:

Видео «inlay-hints» не найдено (урок не готов или slug неверный).