Skip to content

LSP Support

USAMI Kenta edited this page Nov 7, 2022 · 5 revisions

LSP is a protocol for providing language-specific development support functions by intercommunicating with another process.

There are multiple Language Servers for PHP and LSP Clients for Emacs, so you have to make a choice.

Language Servers

There are several Language Servers for PHP. In order for you to add IDE-like functionality to PHP Mode, you must install any Language Server.

Phpactor

Phpactor is a free software, Language Server that runs on PHP 7.4+.

Intelephense

Intelephense is released as an extension of Visual Studio Code, but is available as a Language Server. It's peculiar that this server runs on the Node.js runtime instead of PHP.

This is available without payment, but please be aware that it is not free (libre) software. The EULA restricts you from modifying or reverse engineering this software.

LSP Clients

There are two known LSP Clients in Emacs. They have different characteristics. LSP Mode is generally more powerful and easier to set up.

Eglot

Eglot has a simpler implementation compared to LSP Mode, but integrates with popular completion frameworks like Company. Eglot has been merged into GNU Emacs 29 as the built-in LSP client, but is provided with online updates in GNU ELPA.

This strange name is a portmanteau word of Emacs + Polyglot.

LSP Mode

LSP Mode is a feature-rich LSP Client. It also has bundled integration with Language Servers like Intelephense by default. LSP-UI provides a rich IDE-like interface for GUI Emacs.

lsp-bridge

lsp-bridge is the fastest LSP client in Emacs. Smooth completion is achieved by bridging Python with the language server. This makes it incompatible with Emacs' built-in features. It is not yet registered with any ELPA and requires a special installation method.

Which one should I choose?

As I write this article, I advocate the combination of Phpactor and lsp-bridge. I have been backing Phpactor for a long time and it is still in active development. lsp-bridge is a recently announced latecomer LSP client implementation that achieves surprisingly fast completion. I also like the powerful AI input assistance provided by Tabnine.