5 ms·
I’m fighting with it right now. LSP specifies several configuration mechanisms but there isn’t a “blessed” one. This is a pain point because: I want to write P
by kstrauser 3y ago
I’m fighting with it right now. LSP specifies several configuration mechanisms but there isn’t a “blessed” one. This is a pain point because:
I want to write Python.
There’s one FOSS language server (pylsp) that’s a better fit for my needs than the other Python servers.
I want to use a certain commercial editor.
The editor and the language server don’t share a common configuration method.
Ergo, I can’t use the editor I’d like to write Python the way I want. It’s no one’s fault. The editor works just fine with other servers, for Python and for lots of other languages. The server is also operating within spec, and plenty of editors support its configuration method. However, they don’t play well with each other. I can still use the editor with that server as long as I’m ok with the default settings, but I’m not.
It would’ve been spiffy to have a preferred baseline method that all editors and language servers spoke, but they went the enterprisey “here are a hundred options - pick a few!” overly configurable direction.
Bummer. I really, really like that editor.
- foota 3y agoWhat is configuration in this case?
- kstrauser 3y agoIn this specific case, enabling specific plugins, configuring their behavior, adjusting maximum line lengths, that sort of thing.
- duped 3y agoThat seems out of scope of what LSP deals with
- kstrauser 3y agoThat’s exactly the kind of thing LSP deals with. You have to get those settings into the server somehow, and the main methods are for the editor to send them to the server, or for the server to load them from somewhere in the filesystem or similar. A lot of those settings (like line length) are configured in the editor by the user. It makes a lot more sense to have a mechanism to communicate them over the same protocol than to use a janky method like writing to a file with a specific name, or some other out-of-band method.
- the_mitsuhiko 3y agoLSP assumes that there is a higher level editor integration that handles configuration. That’s not ideal but it’s somewhat sensible as different editors will want to expose different ways to configure them.
- kstrauser 3y agoTrue, but there are also a slew of methods like workspace/didChangeConfiguration for passing config around in-band.
- lozenge 3y agoIdeally, adding an LSP would just be adding a file path to your editor config. This file could contain standard info like supported file extensions, the executable of the LSP, and the parameters to pass the executable. You could also disable/ignore certain features. And, this file would have a common format across all IDEs.
- duped 3y agoLSP is a protocol for answering queries about the language model behind the text, not controlling anything about the text itself (expect for auto formatting, but that's a bit special). Those configurations seem to be in scope for the text editor, not the language server. In fact LSP is mostly configuration agnostic. It might use configuration for a particular query like autoformatting, but it's still request/response in terms of text edits.
- kstrauser 3y agoYou have to tell the server how to interpret the code somehow. I mentioned line length. In Python, you may want one configurable max for code and another for comments. If you can pass those to the server, it can tell you which lines are too long using the standard mechanism for identifying errors and warnings. Otherwise, the editor would have to know how to parse the code so it could know whether a given line is code or comment. That’s the sort of thing LSP can do better. That’s just one example, not the lone thing users would likely configure. Edit: More concretely, here are some of the config knobs you can twiddle via LSP for the particular server I’ve been discussing: https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md https://github.com/python-lsp/python-lsp-server/blob/develop... There are other plugins around with settings that aren’t documented there, but are still configured through the same mechanism.
- smacke 3y agoHave you opened an issue against https://github.com/python-lsp/python-lsp-server https://github.com/python-lsp/python-lsp-server? I'm an occasional contributor for easy fixes; if your fix is easy chances are it would get picked up.
- kstrauser 3y agoI came in at the tail end of https://github.com/python-lsp/python-lsp-server/issues/195 https://github.com/python-lsp/python-lsp-server/issues/195. The possibility of me sponsoring a fix came up, and I’m on board with it, but the other contributor never replied.
- pydry 3y agoPerhaps unrelated but Ive been meaning to ask and I couldn't find - what's the deal with python-lsp-server and virtualenvs? It seems like it has to be installed in the virtualenv to provide completions, etc. Is that right?
- kstrauser 3y agoNo. The editor sends information about the environment to the server. That was a mystery to me, too, for a while.
- deleted 3y ago[deleted]
- BaculumMeumEst 3y agopeople actually like their editor? blasphemy. you must be using either sublime or kakoune
- gilcot 3y agosupreme blasphemy. Emacs
- BaculumMeumEst 3y agoyou just have a call to (stockholm-syndrome) buried somewhere in your 1200 line init file
- froh 3y ago(xkcd-get 297) https://xkcd.com/297/ https://xkcd.com/297/ https://github.com/vibhavp/emacs-xkcd https://github.com/vibhavp/emacs-xkcd
- gilcot 3y agoParenthesis are flying like god's edition… ;D
- vidarh 3y agoThe amount of Emacs configuration I had was what drove me to the insanity of writing my own editor....
- kstrauser 3y agoI do! The one here is BBEdit which you can extend by writing - ready for this? - command line programs. It didn’t come with a built-in JavaScript formatted, so I wrote a shell script that runs Prettier on its input, and told BBEdit to run that script when I hit F1. Voila. JavaScript formatting. It’s also incredibly fast and responsive. If I can’t get it working to write Python the way I want, I’m going back to Emacs. It’s not a “native” Mac app, but doesn’t fall into the uncanny valley the way things like VSCode do.