Skip to content
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

LaTeX #144

Closed
1 task done
MultisampledNight opened this issue Sep 30, 2022 · 21 comments
Closed
1 task done

LaTeX #144

MultisampledNight opened this issue Sep 30, 2022 · 21 comments
Labels
language A request to add a language extension

Comments

@MultisampledNight
Copy link

MultisampledNight commented Sep 30, 2022

Check for existing issues

  • Completed

Language

LaTeX

Tree Sitter parser link

https://github.com/latex-lsp/tree-sitter-latex

Language server link

https://github.com/latex-lsp/texlab

Misc notes

This could go a long way. Many students use LaTeX in order to take notes in lectures, and I think there these things are interesting to look at in addition to the syntax highlighting and LSP itself:

  • The ability to add snippets — sure, LaTeX has some of them itself in the form of commands, but it can be really nice to have a nice snippet for typing a table with the tabular environment, for example.
  • Have some way to look at the final result, nice for typing math equations and similar. Even if it's just the current line in an align environment.
  • Allow to fold/dim text which is not in the current paragraph/environment.
  • SyncTeX support. Part of TeXlive, it allows synchronizing the views of source code and compiled output.

(sidenote: I don't even use Zed yet, though I'd really like to see this some time in future)

@MultisampledNight MultisampledNight added the language A request to add a language extension label Sep 30, 2022
@jansol jansol mentioned this issue Apr 12, 2024
1 task
@JosephTLyons JosephTLyons transferred this issue from zed-industries/community Jan 24, 2024
@Sandybunting
Copy link

This would definitely be trickier to implement, but in the long term, including a PDF view window would make Zed extremely attractive for this workflow. I'd love to use Zed for typesetting but, even if LSP support was included, I would be reluctant to leave behind the convenient live previewing of the PDF output that VSCode achieves with the Latex Workshop package (or, for Typst, the Typst LSP package).

LaTeX Workshop VSCode screenshot

@JosephTLyons JosephTLyons changed the title LaTeX support LaTeX Feb 26, 2024
@JosephTLyons JosephTLyons transferred this issue from zed-industries/zed Feb 26, 2024
@mocenigo
Copy link

mocenigo commented Mar 5, 2024

I am very confused. I do not see LaTeX support if I open a LaTeX file into zed. If I click on "unknown" in the bottom right corner, I see a list of languages and TeX or LaTeX are not there.

Tree Sitter parser link

https://github.com/latex-lsp/tree-sitter-latex

Language server link

https://github.com/valentjn/vscode-ltex
https://github.com/latex-lsp/texlab

@Moshyfawn Moshyfawn mentioned this issue Mar 5, 2024
1 task
@Moshyfawn
Copy link
Member

If I click on "unknown" in the bottom right corner, I see a list of languages and TeX or LaTeX are not there.

Have you installed the LaTex extension from zed: extensions?

@mocenigo
Copy link

mocenigo commented Mar 6, 2024

I did not. Now I have. This is however only syntax highlighting, not compilation commands and preview <-> source sync?

@Moshyfawn
Copy link
Member

This is the extent of what the Zed language extensions can do at the moment, but there is more to come.

@mocenigo
Copy link

This is the extent of what the Zed language extensions can do at the moment, but there is more to come.

The development is happening at an astounding pace. I am amazed.

@OliCallaghan
Copy link

Opened up a PR to configure the language server here: rzukic/zed-latex#2.

Note you need texlab installed, if you're on mac, you can run brew install texlab.

@analytic-bias
Copy link

I'd mention also https://www.gnu.org/software/auctex/manual/preview-latex.html. It allows Emacs users to hit a shortcut (or automatically when file saved etc) to render configured LaTeX environments and substitute in the rendered svg in-ppace in the editor. This has been hard to be supported in vscode (James-Yu/LaTeX-Workshop#1427); don't know if you will have any luck.

@callegar
Copy link

As a LaTeX user, I'd like to add a couple of notes, in case they can be useful for the development of the LaTeX support.

  1. There are in fact two different LaTeX syntaxes: the traditional LaTeX2 syntax and the expl3 syntax. The first one is the only one document authors generally deal with. The second one is involved with the LaTeX 3 interfaces and is more and more needed by developers of new packages and classes. The second one differs from the first one as it makes a different use of some characters ('_') mainly, but the role of the space character is changed too and because it is accompanied by style guidelines that prescribe a specific way to practice indentation. Would be ideal to support both (either with automatic recognition or a switch). What is currently a benchmark for LaTeX support in a programmable editor (emacs + auctex) still has, IMHO, very poor support for expl3, all the time introducing wrong indentation.

  2. There are two major ways of doing line wrapping with LaTeX. The traditional one is hard-line-wrapping at word boundaries. It is precisely to support this type of wrapping that TeX makes a single line break in the source substantially equivalent to a space, and two subsequent line breaks significant as a paragraph break. The other possibility is soft-wrap at word boundaries. This is progressively becoming the new de facto standard, because some LaTeX editors (and prominently online ones, e.g. Overleaf, but also TeXStudio, etc.) tend to work in this way. Clearly, it would be nice to support both, since often you have the need to collaborate on a document where you cannot decide the type of wrapping. The problem is that currently no editor appears to support both wrapping styles correctly wrt indentation.

    • editors initially devised with hard word wrap in mind, typically fail to generate the correct amount of visual indentation when soft wrapping within a group. Typical case are sectioning commands If you have:

      \section{This is a section header with a very very very very very very long title}

      and the editor soft wraps, you should see

      \section{This is a section header with a
          very very very very very very  long
          title}

      but you will typically see

      \section{This is a section header with a
      very very very very very very  long
      title}

      for instance this is the case with emacs+auctex+visual-line-wrap mode. Conversely, these editors are very good at parsing the source considering multiple lines. Sow when using auto hard wrap mode, they are very good at introducing a line break at

      \section{This is a section header with a

      pushing the very on the next line with the correct amount of indentation.

    • editors devised for soft wrapping, conversely all parse LaTeX sources line by line, so when you manually introduce a hard line break they fail to see the number of open braces in the previous lines and do autoindent in the wrong way. Example, I want to define a command for sectioning:

      \newcommand \indepthsection {%
          \section{In depth: #1}%
      }

      when I press enter at the end of the first line, the editor requires me to manually do the indentation in the following lines.

So LaTeX can be tricky, because actually there are 2 syntaxes and two wrapping styles in use.

@JosephTLyons
Copy link
Collaborator

There is a LaTex extension now.

SCR-20240716-lyyl

@lnay
Copy link
Contributor

lnay commented Aug 15, 2024

This would definitely be trickier to implement, but in the long term, including a PDF view window would make Zed extremely attractive for this workflow. I'd love to use Zed for typesetting but, even if LSP support was included, I would be reluctant to leave behind the convenient live previewing of the PDF output that VSCode achieves with the Latex Workshop package (or, for Typst, the Typst LSP package).
LaTeX Workshop VSCode screenshot

I imagine the internal PDF viewer to be a distraction right now for the Zed team but it's honestly not necessary for LaTeX. You can configure texlab to use a separate pdf viewer and I plan to make some example configs in the LaTeX extension for this kind of thing.

@mocenigo
Copy link

An exrension to enable LSP support through texlab can hardly be called TeX/LaTeX support. An indispensible feature is bidirectional SyncTeX support. You click (+ some modifier, or alternatively you hit a key binding) on the source and you are transported to the corresponding place of the PDF preview, and clicking (+ some modifier) on the preview brings you to the corresponding place in the source. An integrated PDF viewer is not necessary, any external previewer that supports SyncTeX will suffice (I use skim).

Also, maybe the foundation is already there and I just do not know how to enable it, but Zed should have a sidebar that could be configurable with various panes and one could be filled with commands (similar to what latex workshop does for LaTeX in VSCode), including panels of symbols.

This, together with the speed and configurability of Zed would make it the ideal TeX/LaTeX/ConTeXt platform.

@lnay
Copy link
Contributor

lnay commented Aug 15, 2024

https://github.com/latex-lsp/texlab/wiki/Previewing
Forwards/inverse search with external pdf viewer is definitely on the table, the symbol pane is not really. Out of interest, with your desires, what do you hope to get in zed that's not in texmaker?

@lnay
Copy link
Contributor

lnay commented Aug 16, 2024

Maybe "off the table" is a bit strong, there's only a few things which extension authors can do right now. It's possible that we could see something like the webview ui toolkit from VSCode, but for Zed. But my guess is that something like that would just be more difficult to build with. People have been authoring UIs for the web for decades, nobody outside a few people have been using the "igpu" thing Zed are working on (which I'm assuming is part of their plan for future graphical extensions).

Outside of the symbol pane, and a multi-file aware outline (we only have that for individual files), I don't see much blocking the zed-latex extension from having almost every other feature you would expect. Mostly leveraging texlab with manual configuration.

@mocenigo
Copy link

https://github.com/latex-lsp/texlab/wiki/Previewing Forwards/inverse search with external pdf viewer is definitely on the table, the symbol pane is not really. Out of interest, with your desires, what do you hope to get in zed that's not in texmaker?

I do not use texmaker because it is not native, and it looks and feels very extraneous to the environment. I think snippets are already somehow implemented in Zed, correct? Then I would only need an example or an explanation of how to set them up.

@lnay
Copy link
Contributor

lnay commented Sep 21, 2024

With v0.0.7 of the latex extension, snippets should work out of the box. Try typing \begin, accept the completion and see if it adds the \end with two cursors to type in the environment name. There shouldn't be any need to install texlab yourself for this as Zed should download it automatically. Although I have only tested this myself (x64 Linux and x64 mac). If this doesn't work for you, raise an issue at rzukic/zed-latex with arch+OS and we can work from there.

@mocenigo
Copy link

mocenigo commented Sep 22, 2024

With v0.0.7 of the latex extension, snippets should work out of the box. Try typing \begin, accept the completion and see if it adds the \end with two cursors to type in the environment name. There shouldn't be any need to install texlab yourself for this as Zed should download it automatically. Although I have only tested this myself (x64 Linux and x64 mac). If this doesn't work for you, raise an issue at rzukic/zed-latex with arch+OS and we can work from there.

This works.

But there should be, for mostly textual environments, also autocompletion of words according to a dictionary. VSCode has this, so this is a feature people expect. Or maybe I do not know how to trigger it? This should be independent of the LSP.

@lnay
Copy link
Contributor

lnay commented Sep 22, 2024

Spell checking appears to be a contentious issue in Zed. There is currently a "Typos" extension however it's not very good at spotting errors.

I would personally like to see Zed run spell checking on sections of the file that the syntax grammar recognises as "spell" areas in a similar way to neovim (with @spell and @nospell queries). Alternatively, if there ever becomes a story for language servers running on language injections, that could potentially achieve a similar outcome (in this case, a spell checking language server).

@mocenigo
Copy link

Spell checking appears to be a contentious issue in Zed. There is currently a "Typos" extension however it's not very good at spotting errors.

I would personally like to see Zed run spell checking on sections of the file that the syntax grammar recognises as "spell" areas in a similar way to neovim (with @spell and @nospell queries). Alternatively, if there ever becomes a story for language servers running on language injections, that could potentially achieve a similar outcome (in this case, a spell checking language server).

However, I was not referring to spell-checking. Maybe completion was the wrong word, but maybe "suggestions"? Such as, i am typing "typing" and while I am at "ty" a menu appears with "type, types, typing, typology, tycoon" etc. and I can either continue typing, or click on one option, or select it with the up/down arrows, or get rid of the menu with ESC until the end of the word.

@lnay
Copy link
Contributor

lnay commented Sep 22, 2024

These two are usually dealt with together (the spell checking and suggestions will use the same dictionary for instance). "Spell-checking" is just the better term to search for developments elsewhere. I do agree that good spelling completions would be nice to have in Zed.

@mocenigo
Copy link

These two are usually dealt with together (the spell checking and suggestions will use the same dictionary for instance). "Spell-checking" is just the better term to search for developments elsewhere. I do agree that good spelling completions would be nice to have in Zed.

Exactly. Since one of the goals of Zed is to be adopted (of course!), when we see the marketing of other solutions, the autocompletion/suggestion popup is always a prominent feature. People expect that (like the minimap). I understand that the priorities at the moment are to support all possible AI models, but adding other important UX features should not be delayedm, otherwise there may be an adoption problem (and I am talking seriously, since I really do like Zed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language A request to add a language extension
Projects
None yet
Development

No branches or pull requests

9 participants