emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Elisp LSP Server


From: Daniel Brooks
Subject: Re: Elisp LSP Server
Date: Thu, 04 Nov 2021 22:55:00 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Richard Stallman <rms@gnu.org> writes:

>   > An LSP-server is actually software running on your own machine,
>   > but in a different process. And it’s very often free software too!
>
> I understand about having Emacs invoke a language server.
> (Is an "LSP server" the same thing as a language server?
> It isn't obvious.)

It is. LSP stands for “language–server protocol”. It’s a protocol for an
editor and a language compiler or runtime to exchange information. The
editor sends queries that generally correspond to the user’s actions,
and the server sends back information the editor can use to complete
that action.

For example, if I am editing a C program in Emacs, I can call
`xref-find-definitions' and it will find the identifier at point,
consult my TAGS file, and jump to the definition of that identifier.

With an LSP server, Emacs instead sends the filename and the location of
point to the server, and the server sends back a list of filenames and
locations where the definition(s) are. This frees Emacs from having to
know very much about the specific language, and frees language designers
from having to teach every text editor in the world about their new
language.

> But we were talking about having a web browser invoke Emacs.
> How does the language server relate to that?

I admit I wasn’t following the discussion, but I think that it is
becoming more common for people to run large applications inside the
browser. Specifically, GitHub is doing something with VSCode. By running
VSCode in the browser, GitHub can provide an IDE for any project hosted
there, which is hoped to be a powerful feature for attracting new
developers to submit code to those projects that use it. I haven’t tried
it myself, but I see no technical obstacles to this. I myself helped in
some small ways to get MAME emulated arcade machines and consoles
running in the browser for https://archive.org/.

Anyway, VSCode tries to make it as easy as possible for their users to
get started programming in their favorite languages. The VSCode user can
generally go to a list of plugins inside of VSCode, find one for their
language, check the checkbox next to it, and more or less immediately
start programming in that language, complete with LSP integration. (This
is not much different from running `package-install', for example, except
that it can and does install binaries on your system).

Within Emacs, `lsp-mode' offers integration with LSP servers, and it has
a function `lsp-install-server' which can automatically install some of
them.

If Emacs were to act as an LSP server, then in principle VSCode could
offer an Elisp extension which would download Emacs for the user. It
wouldn’t be for use as an editor, but just for use as the LSP server for
the elisp code that the user is editing in VSCode.

Incidentally, Microsoft owns GitHub and VSCode, and they started the LSP
protocol specification specifically for use with VSCode back in 2016
(although the direct inspiration, I suspect, comes from a post by Steve
Yegge at Google a few years prior).

>From the point of view of most developers of text editors, and most
language designers, the LSP protocol makes sense. It reduces the amount
of work that they all have to do to support each other. On the other
hand, the specification is quite closely tied to the needs of VSCode. It
is called an open standard, but having taken a look at it I can see that
it is just whatever VSCode happened to support at the time it was
published, plus some extensions since then. Perhaps it can grow from
there.

I don’t see any particular need for Emacs to be a language server for
Elisp, but there is nevertheless an argument for it. For example, it is
not much different than allowing users to export word–processor
documents in formats that can be read by your competitors. As far as I
know, Microsoft Office does not give the user the option of exporting
their document as an OpenOffice file, but OpenOffice does allow
exporting documents as Microsoft Office files. Microsoft Office tries to
keep people from straying from Microsoft products, while OpenOffice does
not.

Even so, I think it would be significant work for not much benefit.

I hope something in that ramble was helpful!

db48x



reply via email to

[Prev in Thread] Current Thread [Next in Thread]