Skip to content

A-SunsetMkt-Forks/vscode-languagetool-linter

 
 

Repository files navigation

LanguageTool Linter for Visual Studio Code

GitHub Workflow Status (with event) Visual Studio Marketplace Installs Visual Studio Marketplace Rating (Stars)

Grammar, Style and Spell Checking in VS Code via LanguageTool. Support Markdown, MDX, HTML, and plain text files.

In memory of Adam Voss, original creator of the LanguageTool for Visual Studio Code extension.

Features

  • Issue highlighting with hover description.
  • Replacement suggestions.
  • Checks plain text, Markdown, MDX, and HTML.
  • Smart format on type to replace quotes with smart quotes, multiple consecutive hyphens with em or en-dash, and three consecutive periods with ellipses.
    • Make sure 'Editor: Format On Type' is enabled or this feature won't work. You can enable it at the document format level as well in your settings.json.
  • Allow specific rules to be ignored for markdown (pandoc) and HTML

Setup

The defaults are probably not going to work for you, but they are there to make sure using LanguageTool's Public API is done by choice. See this issue on the Atom LanguageTool Linter for an explanation why.

The defaults assume the following:

  1. You do not want to use the LanguageTool's Public API

  2. You're running LanguageTool HTTP Server on your machine using the default port of 8081.

  3. You do not want to have this extension manage your local LanguageTool HTTP Server service.

If this doesn't work for you, here are your options.

Option 1: Use an External Service

This could either be a locally running instance of LanguageTool, or the service running somewhere else.

  1. Set the URL in “LanguageTool Linter > External: URL” (i.e. http://localhost:8081).
  2. Set “LanguageTool Linter: Service Type” to external.

External URL

Option 2: Use an Extension-Managed Service

Works well if you're only using LanguageTool in Visual Studio Code.

  1. Install LanguageTool locally.
  2. Set “LanguageTool Linter > Managed: Class Path” to the location of the languagetool-server.jar file. The install doc has hints.
  3. Set “LanguageTool Linter: Service Type” to managed.

Managed Service

Option 3: Public API Service

Make sure you read and understand LanguageTool's Public API before doing this.

  1. Set “LanguageTool Linter: Service Type” to public.

Public API

Configuration Notes

Most configuration items should be safe, but there are three you should pay particular attention to:

  1. Public Api: This will use LanguageTool's Public API service. If you violate their conditions, they'll block your IP address.
  2. Lint on Change: This will make a call to the LanguageTool API on every change. If you mix this with the Public Api, you're more likely to violate their conditions and get your IP address blocked.
  3. LanguageTool: Preferred Variants: If you set this, then LanguageTool: Language must be set to auto. If it isn't, the service will throw an error.

Ignore rules inline

You have the chance to ignore specific rules inline to not bloat up your ignore list for single words:

<!-- @IGNORE:UPPERCASE_SENTENCE_START@ -->
soll heißen, dass die Nachricht von mir ist, die Koordinaten hat
ein kleiner Computer, den Sigrún mir zur Verfügung gestellt hat aus
dem irdischen
‚World Geodetic System 1984‘ <!-- @IGNORE:GERMAN_SPELLER_RULE(Geodetic)@ -->

This example will ignore the missing capital letter at the beginning (soll → Soll) and an unknown word ('Geodetic')

The optional match word is useful if the same rule is applied to several words in the sentence.

The rules can be applied to the current line (e.g. at the end) or at the line before.

Syntax:

@LT-IGNORE:<rulename>(<text-match>)@

The and the text-match is optional.

Note: Even in pandoc you have to handle the comment in html output. This can be done by using a filter.

Credits

The following projects provided excellent guidance on creating this project.

Packages

No packages published

Languages

  • TypeScript 92.1%
  • MDX 4.9%
  • HTML 1.9%
  • JavaScript 1.1%