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

Added Tex Language Support #569

Open
wants to merge 47 commits into
base: main
Choose a base branch
from

Conversation

isaacST08
Copy link

Added support for the tex language.
Added the texlab LSP along with config options for build/compiling:

  • Compiling package option
  • Compiling executable option
  • Compiling executable args option
  • PDF preview using your PDF viewer of choice
  • PDF preview update on save option

Not implemented (yet):

  • Support for other LSPs
  • Formatting support via nvf options
  • Texlab options (There is however an extraLuaSettings option for texlab that allows setting these options in the meantime):
    • chktex
    • diagnosticsDelay
    • diagnostics
    • symbols
    • formatterLineLength
    • bibtexFormatter
    • latexFormatter
    • latexindent
    • completion
    • inlayHints
    • experimental

Defaults mostly follow the texlab defaults with some exceptions such as the default compiler being tectonic and the default file viewer being okular.

(I also alphabetically sorted the language imports in the modules/plugins/languages/default.nix)

@isaacST08 isaacST08 requested a review from NotAShelf as a code owner January 19, 2025 04:08
@isaacST08 isaacST08 mentioned this pull request Jan 19, 2025
1 task
@isaacST08
Copy link
Author

This should satisfy #525

github-actions bot pushed a commit that referenced this pull request Jan 19, 2025
Copy link

github-actions bot commented Jan 19, 2025

🚀 Live preview deployed from e5f6aa2

View it here:

Debug Information

Triggered by: isaacST08

HEAD at: feature-language-tex

Reruns: 155

@NotAShelf NotAShelf linked an issue Jan 19, 2025 that may be closed by this pull request
1 task
@isaacST08 isaacST08 marked this pull request as draft January 19, 2025 22:45
github-actions bot pushed a commit that referenced this pull request Jan 19, 2025
…lates.nvim dependency so created fork to fix it and redirected flake url there
github-actions bot pushed a commit that referenced this pull request Jan 23, 2025
flake.nix Show resolved Hide resolved
github-actions bot pushed a commit that referenced this pull request Jan 25, 2025
github-actions bot pushed a commit that referenced this pull request Jan 30, 2025
@isaacST08 isaacST08 marked this pull request as ready for review January 31, 2025 02:20
@isaacST08
Copy link
Author

Feature essentially done.

Implemented:

  • Lsp
    • Texlab (Recommended)
      • All features currently provided as documented by texlab
  • Builders/Compilers
    • Tectonic (Recommended)
    • latexmk
  • PDF Viewers
    • okular
    • zathura
    • sioyek
    • qpdfview
  • Forward search
  • Formatter

Not implemented:

  • Inverse search
    • Not planned as widely different between pdf viewers and configuring through nix might not even be possible for some (at least not easily) (okular...).
    • Sioyek does have inverse search support via cli args and (should) be working properly with default values.

Due to the scale that this language implementation ended up being I organized it differently compared to the other languages; it is in multiple files and modules, all called by a default.nix in a tex directory. The implementation of the second largest language is more that 5 times smaller and I felt like a single 1500 line file wasn't ideal and the current implementation was a more appropriate approach.

I have not tested every single combination of options as that would take forever. I have tested many of the more relevant ones but I have not tested the texlab experimental settings for instance.

The config I am currently using is as follows:

settings.vim.languages.tex = {
  enable = true;
  lsp.texlab = {
    forwardSearch.enable = true;
  };
  build = {
    builders.tectonic.enable = true;
    forwardSearchAfter = true;
    onSave = true;
  };
  pdfViewer.zathura.enable = true;
  extraOpts.texFlavor = {
    enable = true;
    flavor = "tex";
  };
};

I have created frameworks for easily adding both new pdf viewers and new tex builders/compilers. Adding other LSP servers should be not too complicated if texlab proves to be fundamentally inadequate.

Overall, this implementation will cover all of my needs for tex and includes many other features I will likely not use but have been implemented to achieve near feature parity with many of the implemented programs which will hopefully cover most of what anyone else requires. If not, in a few places I added methods to be able to add custom configuration just in case.

There are no other features I plan to add for the time being, but I will try to fix bugs as they come up on my side.

@NotAShelf
Copy link
Owner

NotAShelf commented Jan 31, 2025

Looks good from a first glance. Thank you for your hard work.

I'm too tired to review in full at the moment, but I'll properly review tomorrow when I wake up. One thing that comes to mid is that mkEnableTreesitterOption could probably be put into the extended library, so that other modules can use it as well.

@NotAShelf
Copy link
Owner

If you could also fix the Cı errors by then, that'd be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add texlab, language server for Latex
2 participants