-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add LSP for Markdown #2182
Add LSP for Markdown #2182
Conversation
While this is cool, I think a superior default LSP for Markdown would be https://github.com/valentjn/ltex-ls , it has advanced grammar and spell checking from https://languagetool.org/ built in. It also works for text and latex docs. The problem is that Formatting Markdown documents often requires being able to also format all code blocks with different languages too, and only Prettier can do that at the moment. Prettier could take care of a lot of formatting needs in Helix and would make the best default when it can be integrated with LSP. |
Hmm this LS does seem a bit green (only a handful of stars so far and 3mo old) but I suppose I don't have an objection to it. Though if jalentjn/ltex-ls is more advanced we may want to plug that in instead. Even if the code actions aren't working it might be nice to have for formatting (if it provides that) and lints |
@David-Else Oh yeah I'd love prettier as the default formatter for anything supported. |
@David-Else @the-mikedavis - ltex-ls is just grammar and spell check right? That's pretty cool and I could see how it helps with markdown and text. Remark is more like a linter for things like using inconsistent bullet point styles etc. I need to check if remark has plugins for suggesting links to internal headers or other files/github. |
Oh actually I haven't tried either yet, I'm not sure 😅 I would probably prefer the LS that does more syntactic than spelling/grammar checks. I think a spelling/grammar system would be nice to have outside of language-specific LSP stuff. Multiple LSs (#1396) might be a good way to tackle it but maybe an aspell-like plugin would be a better approach. |
Stop press! Since updating Helix now
Now you can use code actions and correct spelling/grammar. I don't think the 'add to dictionary' works yet, but in Neovim it needed a little extra code. Prettier SO nearly works with the
The problem is it needs to recognise the language, the above command only works for I have been doing a lot of technical writing lately, and having My main problem with remark lint is I think the majority of rules are redundant when you are using a formatter like Prettier, and I think that in the near future everyone will be using Prettier, it has become the industry standard. I look at the rules: https://github.com/remarkjs/remark-lint#rules Many (most?) of the lints here are automatically corrected by Prettier. Also there are rules like Basically, to sum up, there is nothing wrong with using |
I just had a quick look into ltex-ls and it apparently requires Java. Isn’t that a huge dependency to require for default markdown language intelligence? (On Ubuntu, for example, the JRE is a 179MB download. And ltex-ls is another 200MB. I’m also worried about how taxing it will be on my system. I love Helix because it’s not Electron but I’m not sure if Java is going to be any better.) About to try it out and document the required steps but just thought I’d document my initial misgivings before I forget them. It might be that the advantages outweigh the 400MB download + system resource usage but my gut feeling is that it won‘t. |
@aral If you have the Java runtime installed then you can use the version that does not include it, https://github.com/valentjn/ltex-ls/releases/download/15.2.0/ltex-ls-15.2.0.tar.gz I get what you are saying, but it really is the best grammar and spelling setup. You only need the Java runtime, not the entire language. Have a look at the language tool demo and see what it can do, it is very powerful https://languagetool.org/ |
@David-Else Just installed it; it definitely is very powerful. (And thank you for suggesting it and providing the configuration info.) :) Running htop, while typing several of its processes did hit 100% CPU though and typing does seem laggy with it active. Beyond that, it doesn’t seem to understand front-matter… … and HTML in Markdown. That said, it found that I had the wrong day for the date in my text. That’s quite cool. I still do believe that the default language server should be one that is less resource/dependency heavy but this is likely an issue that needs more of a general conversation. Helix core might be light and performant but add a few heavy LSPs and it starts to slow down and require more resources. It will likely be a good idea to adopt a policy of trying to support lightweight LSPs whenever possible by default. |
For anyone else who wants to install ltex-ls (and potentially for the LSP documentation page on the Helix Editor site):
|
That’s the one I downloaded, yes. It’s ~200MB :) |
@aral Thanks for checking it out!
Currently it only understands some front matter, for example you can set the language in the front matter and it changes immediately. This is great for switching between US and UK English.
There are a lot of settings, in Helix we are of course currently using all the defaults. https://valentjn.github.io/ltex/settings.html I found it only slows things down once the initial analysis is done, then it allows the editor to go back to full speed. |
Just putting the information here since I was unable to find it anywhere else : in order for this to work, ltex-ls needs to understand that the document's language ID is "markdown". However, helix sends it the "md" language id, and you can see in the logs that it will only interpret the document as plaintext ( Fortunately, this is configurable : language-server = { command = "ltex-ls", language-id = "markdown" } Hope this helps. |
@David-Else @the-mikedavis @aral @lazytanuki - I agree that the Markdown server I hooked up here mostly focuses on things that a formatter like Prettier should cover. Shall we close this in favor of something like ltex-ls? |
Yeah I'd say let's shoot for ltex-ls, it looks pretty sweet |
Closing in favor of adding ltex-ls |
Requires installing
remark-language-server
, adding a.remarkrc.yaml
which defines the list of filters to enforce.Example
.remarkrc.yaml
:These plugins need to be installed separately too: