kotct / dot

A collaborative configuration for various tools.
MIT License
3 stars 2 forks source link

Add LSP support #129

Closed rye closed 4 years ago

rye commented 5 years ago

This PR adds lsp-mode (https://github.com/emacs-lsp/lsp-mode) to the project, and demonstrates adding support for LSP in a specific language.

lsp-mode is a big project but seems like a very solid companion for this project. In particular:

lsp-mode aims to provide IDE-like experience by providing optional integration with the most popular Emacs packages like company, flycheck and projectile.

How do they do it? A "language server" is implemented for each language, and the "language server protocol" (JSON+RPC-based) is implemented by these servers, allowing for tasks common to all languages (code completion, hover things, jump-to-def, workspacing, and diagnostics) to be implemented once by those who know the language well.

This means that rather than write bindings for each editor for each language, (with M editors and N languages, that's M*N implementations) instead one ostensibly only needs to write one language server for each language and one client for each editor, reducing the number of implementations to M+N.

In reality, it's a bit closer to M*N+kN, where k is a small constant, as there is a bit of variability in how language servers are implemented, found, and selected between languages, but this is all just wiring effort and thus much easier to support in the long-run.


Some questions before I open this for merging:

Sammidysam commented 5 years ago

I'm not the right person to ask, getting notifications about this kinda just makes me sad

samontea commented 4 years ago

Every time I use a new language I feel like I spend 3 hours trying to decide which language server I want to use etc. IMHO we should just leave it up to the user's config. I don't think there's a way to save a substantial amount of time with the proposed changes.

rye commented 4 years ago

@samontea, that makes sense to me. I hadn't thought much about different language servers for the same language.

I will note that, at least on the langserver.org table, it looks like a lot of languages only have one or two language server implementations to choose from, but these are things that the user might want to configure.

Would it be safe to just add lsp-mode (also, lsp-ui?) to the dependencies, and the relevant line in the .gitignore for changes? This way, the dependencies would be installed for everyone, but not turned on.

I'm not sure about lsp-ui vs company-lsp, so maybe leaving that out and letting users decide would be better.

rye commented 4 years ago

So since this PR literally just contains the addition of lsp-mode as a dependency and one new line to the .gitignore, could we merge it? Should we?