harper icon indicating copy to clipboard operation
harper copied to clipboard

LaTeX Support

Open grantlemons opened this issue 2 years ago • 13 comments

grantlemons avatar Mar 08 '24 22:03 grantlemons

Just a reminder that we'll eventually have to make changes to the Mason Registry, nvim-lspconfig and mason-lspconfig.nvim for this to work properly once it's merged.

elijah-potter avatar Aug 07 '24 23:08 elijah-potter

For anyone wondering, progress on this stalled because of how weird LaTeX is as a language, but if anyone wants to take it on, feel free to. Here's the old draft pr for this feature: https://github.com/elijah-potter/harper/pull/100

grantlemons avatar Nov 29 '24 18:11 grantlemons

Hi @grantlemons I understand that there is not much one can do because TeX is a substitution based language. However, LTeX somehow gets it working. One does not need a perfect solution, but a good enough one. For instance, just extracting the text and using it, considering all formulae like jsut single numbers would be a start. It is a bit sad to see the depelopment stopped. How can I help?

mocenigo avatar Dec 22 '24 15:12 mocenigo

I am also interested in making this work for LaTeX. It seems to me that LTeX ignores some user-defined macros, which results in some false positives, but is nonetheless very useful. Would that be an option here?

I tried installing the harper-ls version in the branch #100 but due to my limited rust skills, I would either need to move harper-latex and the tree-sitter inside harper-core to avoid a circular import :(

gdahia avatar Jan 07 '25 18:01 gdahia

I echo the support and interest in this feature. I've been looking for an integrated grammar checker after the VS Code Grammarly Extension was sunset. Is the current work now in the latex-parsing branch? What are the current blockers?

Reading the PR and this thread, it appears the issues were around:

  • How to handle macros in the middle of paragraphs, i.e. macro expansion
  • How to consider the inputs to macros
  • Giving lints about capitalisation
  • And linting the package import configuration (which probably produces false negatives external to the actual text/document/file?)

Is there more behind the scenes that hasn't been discussed? Perhaps we can task up some of this so others can chip. Or at least restart discussion on some of these more fundamental issues. Without knowing the scope of work required to get this over the line, it's a hard ask for someone to pick this up.

Personally, I'm not too fussed if the parsing is imperfect or limited and fails around complex macros. I'm a C++ developer by trade, I'm used to Visual Studio falling over and giving up when handling macros. Developers write terribly complex and convoluted macros all the time, and there's a limit to how far intellisense-like parsing can go before it's basically just reimplementing the compiler.

Markyparky56 avatar Apr 23 '25 13:04 Markyparky56

The latex-parsing branch is extremely out of date.

The main blocker is just that parsing LaTeX sucks. I did find a project called unified-latex, which has (unofficial?) Rust bindings in the unlatex crate.

The unified-latex folks explain that it will never be perfect:

Though parsing LaTeX isn't possible since it effectively has no grammar, unified-latex makes some practical assumptions. It should work on your code, unless you do complicated things like redefine control sequences or embed complicated TeX-style macros.

grantlemons avatar Apr 23 '25 17:04 grantlemons

I don't know any technical details, but TexLab's parser might provide some aid (If you haven't looked into it before). It is an LSP for LaTeX written in Rust.

https://github.com/latex-lsp/texlab/tree/master/crates/parser

zefr0x avatar Apr 23 '25 18:04 zefr0x

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 14 days. Thank you for your contribution!

github-actions[bot] avatar Jan 04 '26 02:01 github-actions[bot]

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 14 days. Thank you for your contribution!

Progress is chugging along. #2073 is almost feature-complete, and I'll mark it as 'ready for review' after some refactoring.

shreyasminocha avatar Jan 16 '26 01:01 shreyasminocha

Progress is chugging along. #2073 is almost feature-complete, and I'll mark it as 'ready for review' after some refactoring.

加油!화이팅!がんばって!ສຸກດີ!

hippietrail avatar Jan 16 '26 04:01 hippietrail

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 14 days. Thank you for your contribution!

Progress is chugging along. #2073 is almost feature-complete, and I'll mark it as 'ready for review' after some refactoring.

YAY \o/ I will have a look and see how I can help.

mocenigo avatar Jan 16 '26 13:01 mocenigo

Quick update:

It looks like #2073 is infeasible because it relies on an incompatibly-licensed dependency. However, I've drafted #2689, which includes a parser build from scratch for LaTeX documents. Since it's quite customized to our setup, we'll be able to ship it in harper.js and then downstream in our Chrome extension. From there, we can add support to Overleaf, the most popular LaTeX editor there is.

elijah-potter avatar Feb 13 '26 21:02 elijah-potter

This issue was solved with #2689. Any further work needed is out of the scope of this issue and should be filed separately.

elijah-potter avatar Feb 20 '26 15:02 elijah-potter