LTEX+ Grammar and Spell Checker

repository·develop·Indexed 42 days ago

https://github.com/ltex-plus/vscode-ltex-plus

A VS Code extension providing offline grammar and spell checking for markup languages including LaTeX, Markdown, Typst, AsciiDoc, and others using the LanguageTool engine. Version 16.0.0-alpha features multilingual support for over 20 languages, custom dictionaries, and integration with the ltex-ls-plus Language Server (LSP).

Tokens
2.8K
Snippets
4
Records
16
Agent score
54%

What's inside LTEX+

  1. Overview of LTEX+ Grammar and Spell Checking

    develop

    LTEX+ is a Visual Studio Code extension that provides offline grammar and spell checking for various markup languages using LanguageTool (LT). Unlike standard spell checkers, it detects grammatical and stylistic errors (e.g., subject-verb agreement, improper preposition usage).

    Supported Markup Languages:

    • LaTeX, BibTeX, ConTeXt, and rsweave
    • Markdown, MDX, and Quarto
    • Typst
    • AsciiDoc
    • Org and Neorg
    • reStructuredText
    • XHTML
    • Programming language comments (optional, opt-in)

    Key Features:

    • Self-contained: Includes everything needed; no manual Java or LanguageTool installation required.
    • Offline: All checking is performed locally without uploading data to the internet.
    • Multilingual: Supports over 20 languages (e.g., English, French, German, Dutch, Chinese, Russian).
    • VS Code Integration: Provides issue highlighting with hover descriptions and replacement suggestions via Quick Fixes.
    • Customization: Supports user dictionaries and external LanguageTool servers.
  2. Requirements for LTEX+

    develop

    To use LTEX+, ensure your environment meets the following criteria:

    • OS: 64-bit Linux, macOS, or Windows.
    • VS Code: Version 1.91.0 or newer.
    • Language Support (Optional): If you are working with markup languages that VS Code does not support natively (such as LaTeX), you should install a dedicated language extension (e.g., LaTeX Workshop) alongside LTEX+.
  3. Apply Quick Fixes for LT<sub ext{E</sub>>X+ errors

    develop

    When LT<sub ext{E</sub>>X+ identifies a grammar or spelling error, you can resolve it using the Quick Fix menu.

    Using the Mouse

    1. Hover your mouse over the error in the editor to view the diagnostic message (e.g., 'speling': Possible spelling mistake found. – MORFOLOGIK_RULE_EN_US).
    2. Select Quick Fix... from the message popup.

    Using Keyboard Shortcuts

    If your cursor is currently positioned at the error, you can open the Quick Fix menu directly by pressing:

    • Ctrl+. (Control and period keys)

    Available Quick Fix Actions

    Depending on the type of error, the menu may offer several actions, such as:

    • Use '[correct word]': Replaces the error with a suggested term.
    • Add '[word]' to dictionary: Adds the term to your local dictionary to prevent future warnings.
    • Hide false positive: Suppresses the specific error instance.
    • Disable rule: Disables the specific LanguageTool rule globally.
  4. Check Markdown documents with LTEX+

    develop

    To check Markdown documents, simply open them in VS Code. LTEX+ will automatically underline spelling and grammar errors.

    If you are working with a new untitled file, ensure the language mode is set to markdown so the extension activates. You can do this by opening the Command Palette (Ctrl+Shift+P) and running the command Change Language Mode.

    markdown
    # Markdown Example
    
    This is a sentence *without any errors.*
    This is a sentence *with a speling error.*
    Finally, this is a sentence *with an grammar error.*
  5. Check LaTeX documents with LTEX+

    develop

    To enable grammar and spell checking for LaTeX documents in VS Code, you must first install a VS Code extension that provides native support for the LaTeX language.

    1. Install the LaTeX Workshop extension.
    2. Open a .tex file.
    3. LTEX+ will automatically process the document and underline errors (such as spelling or grammar mistakes) after a short period of time.
    \section{\LaTeX{} Example}
    
    This is a sentence \emph{without any errors.}
    This is a sentence \emph{with a speling error.}
    Finally, this is a sentence \emph{with an grammar error.}
  6. Explore advanced LTEX+ features

    develop

    LTEX+ supports several advanced features that can be configured or utilized within your files. Key features include:

    • External setting files: Allows you to save custom dictionaries within specific workspace folders.
    • Magic comments: Enables changing the language context in the middle of a single file.
    • LaTeX babel support: Provides support for the LaTeX babel package to handle multilingual documents.

    For detailed implementation details and configuration for these features, refer to the official LTEX+ documentation.

  7. How to use LTEX+ in VS Code

    develop

    Follow these steps to start grammar checking:

    1. Install Requirements: Ensure you have a 64-bit OS and VS Code 1.91.0+.
    2. Install Extension: Install the LTEX+ extension from the VS Code Marketplace.
    3. Reload: Reload the VS Code window if prompted.
    4. Open/Set Language Mode: Open a supported document (e.g., .tex or .md). If the file type is unrecognized, open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P) and select Change Language Mode to set it to LaTeX or Markdown.
    5. Initialization: Wait for ltex-ls to be detected. If it is not found, the extension will attempt to download it automatically. (For air-gapped environments, refer to the offline installation guide).
    6. Review Errors: Grammar and spelling errors will appear as highlights in your editor.
  8. Advanced LTeX+ usage: Magic Comments and YAML

    develop

    LTeX+ supports advanced configuration methods for specific files:

    • Magic Comments: Use special comments within your files to control LTeX+ behavior.
    • YAML Front Matter: In Markdown files, you can set the language for the document using YAML front matter.
    • Multilingual LaTeX: Support for the babel package to handle documents with multiple languages.
    • Regex False Positives: Use regular expressions to hide recurring false positives.
  9. Configure LTeX+ VS Code settings

    develop

    LTeX+ provides a wide range of configuration options via VS Code settings. Key settings include:

    • ltex.enabled: Enables or disables the extension.
    • ltex.language: Sets the primary language for checking.
    • ltex.dictionary: Path to a custom dictionary file.
    • ltex.disabledRules: List of specific rules to ignore.
    • ltex.enabledRules: List of specific rules to enforce.
    • ltex.hiddenFalsePositives: Configuration for hiding false positives.
    • ltex.languageToolHttpServerUri: URI for a remote LanguageTool HTTP server.
    • ltex.ltex-ls.path: Path to the ltex-ls executable.
    • ltex.java.path: Path to the Java runtime.
    • ltex.diagnosticSeverity: Sets the severity level of diagnostics.
    • ltex.checkFrequency: Controls how often checks are performed.

    For a full list of settings, refer to the official settings documentation.

  10. Configure LTeX language and LaTeX commands

    develop

    LTeX provides several settings to customize the checking experience. Key settings include:

    • ltex.language: Sets the language used for document checking. The default is English.
    • ltex.latex.commands: A list of custom LaTeX commands that should be ignored by the checker.

    For a complete list of available configuration options, refer to the official LTeX+ settings documentation.