micro
micro copied to clipboard
[Feature Request] Add support for Language Server Protocol servers
As noted in https://github.com/zyedidia/micro/issues/174#issuecomment-367855348
It would be nice if Micro had an inbuilt LSP client. This means we could then use Micro to talk to a whole bunch of LSP servers and then get more advanced support for autocomplete and hover support.
Ref - https://microsoft.github.io/language-server-protocol/
Langserver.org is a community-driven site, maintained by Sourcegraph, to track development progress of LSP-compatible language servers and clients. It will be great if micro could be a LSP client!
Came here because I wanted to suggest the same. LSP would be so awesome. All of a sudden micro would get access to IDE level tooling for a vast amount of languages <3
Yes, Yes, Yes :hugs:
@ShalokShalom Please don't bump issues without contributing significant new information; use the :+1: reaction button on the first post instead.
I have the feeling it would get forgotten then. :smirk:
Yes, Yes, Yes :hugs:
Hi, is there any progress on this? The issue is almost 1.5 years old by now. Or is there no implementation planned as of yet?
This is very important!
I guess this will never happen. As an alternative, Kate can LSP now and is lightweight, while no command-line tool, obviously.
I wouldn’t say this will never happen. I think it will be next on the list of things to do after a better keybinding system. So hopefully we can have LSP support by the fall or the end of the year.
Making a plugin for micro that adds LSP support should be possible, however it should certainly be possible, albeit a better autocompletion integration might be needed
Thank you for the great editor, Zyedidia!
Some LSP servers provide a CLI in addition to JSON-RPC. In this case, using some features is easy.
Go function definition tool gopls is one such tool. While waiting for / dreaming of full LSP support, gopls can be used with quickfix plugin
Ctrl-E, plugin install quickfix. Add to bindings.json:
{ "F3": "command: fexec gopls definition {f}:#{o}" }
Now you can press F3 to define word under cursor.
As far as I know, gopls is also the only function definition tool that works correctly with golang modules, so having such intermediate fix is convenient.
Any update to this?
It's very needed
Particular on Termux/Nix-on-droid, this could be the default solution to mobile coding.
I just stumbled over micro last week and found it great, but lacking an LSP client. So over the weekend I started working on an LSP client plugin here: https://github.com/AndCake/micro-plugin-lsp - by no means is it finished or even particularily nice. I have no background in LUA coding (nor did I implement anything LSP related before), so this is all kind of new to me. As a proof of concept, I implemented the hover and definition lookup functions. Maybe someone finds this useful in some way.
Just tested AndCake's LSP plugin. The key features already work nicely with Go.
I had gopls command on my path already. I added the plugin to .config/micro/plug and two lines to settings.json (from installation instructions). Opened a Go file, moved cursor over fmt.Println("Tero"), pressed alt-K. Function signature was shown in the bottom status line. Pressed alt-d jump to definition, and the correct file opened as a micro tab. Completion was not yet useful for me. Formatting alt-f seems to work. For formatting go imports, needed to put an empty line between built-in and third party libs so they don't get mixed, but the same is required for gofmt.
Show function signature (alt-k) and jump to definition (alt-d) are the key features for me, and they work today. The UI is nice, no popups jumping on your face, but the features are just a keypress away.
Well done!
Updated: I now tried it with Python, too. It worked! It had a lot more fiddling than Go, but that's just because the Python language server PyLSP requires more fiddling. The packages had to be installed with Pip. The maintained fork is PyLSP (ends with a "P"), which differs from the sample settings provided by AndCakes plugin. I wrote long and detailed notes on installing micro LSP plugin with Python support. PyLSP is tedious to use with default settings, I recommend installing it without automatic formatting and the most annoying linter plugins. Static type checking with MyPy worked, and this makes it much easier to capture errors.
The plugin would be much easier to install if it had sensible defaults, and did not require user to modify settings.json just to get started. (Update: it now works out of the box without modifying settings.) As alt-D and alt-K work, this offers most of the benefit LSP has to offer (for me).
If you want to try it out, it's now easy to install it with Go support:
$ sudo apt-get update
$ sudo apt-get -y install gopls micro golang-go
$ micro --plugin install lsp
@AndCake added support for show references (alt-R) - thanks for that and the whole plugin! It already supported showing function signatures (alt-K) and jump to definition (alt-D). I added help and default settings, so that it works out-of-the-box with 'micro --plugin install lsp'.
@zyedidia Are there any chances that this gets delivered by default?
@ShalokShalom do you mean including the current LSP plugin? It's still pretty early days. There is a lot to do to help it: testing LSP and writing about your experiences, reporting (and even fixing) bugs... I wrote installation instructions for Go and Python. It would be nice to have instructions for Javascript, Lua and Rust, too.
You can already install LSP plugin easily (see my comment above). Including it in Micro would not install the language servers, which are needed to make any use of LSP support. For some language servers, such as Python's, there is a lot more fiddling required than the Go gopls.
Oh. I think its simply "installing the lsp plugin" and that`s it. I would be interested in Nim.
Suggestions :-
-
do not confirm completion on pressing arrow keys, its very annoying, half of time i am fighting with the autocompletion. Instead use TAB key to confirm like most editors do.
-
maybe also add a dropdown completion instead of in-place
Hi @Tanishq-Banyal,
I like Linux/Bash style tab completion, too. Were discussing it in the plugin's Feature Request: Linux/Bash Style Tab Completion #16.
It seems that the bug you discovered with clangd is also related to AndCake / micro-plugin-lsp. May suggest that you file your bug in the plugin's issues?
I also think you could simplify your example by removing the part about "importMap", unless you're using it to provide additional initialization options.
I also think you could simplify your example by removing the part about "importMap", unless you're using it to provide additional initialization options.
I don't even know what that import map option does, i just copied the whole example line from README to settings.json and then modified it for c/c++
EDIT: removing the import map part, fixed the bug for me
Happy to hear that. So did you get LSP support for C and C++ to work? If so, you're the first, well done!
What works with C and C++?
Would you like to report your findings to micro-plugin-lsp? You could write a bug to add C / C++ installation instructions to help/lsp.md, or even submit a pull request.
What works with C and C++?
Everything works as advertised.
Although there are some issues :-
-
Since c++ parameters are usually long, alt-k output never fits on screen no matter how much i zoom out.
-
When i am editing some function argument in middle of line and autocompletion triggers, it deletes everything in that line after that argument and replaces with suggestions. Instead it should only edit the current argument, not whole line.
-
Dont force autocompletion, it triggers at odd moments and ruins everything. There should be a setting to get suggestions only when i press ctrl-space/tab/some other key.
-
Also LSP is causing performance issues in micro when pressing "backspace" key, it deletes like 3 characters/second.
-
Micro's inbuilt completion bar could be reused by LSP instead of adding one more bar.
I tested with Zig language server and it works (all the below features work)
Alt-k for hover Alt-d for definition lookup Alt-f for formatting Alt-r for looking up references
Only Ctrl-space for completion throws an error
What are the requirements for the lsp plugin to become an offical part of micro?
Lsp plugin might get a temp buffer for showing autocomplete, same as VSCode or Vim, Helix, instead of the bottom bar of the term?
Are people no longer interested to have LSPs in micro? Looks like the micro-plugin-lsp development also stopped last year.