Skip to main content

Language server for text spell and grammar check with various tools.

Project description

textLSP

Language server for text spell and grammar check with various AI tools.

This tool is in early development.

textLSP

Features

LSP features

  • Diagnostics:
    • spelling or grammatical errors
  • Code actions:
    • Fix suggestions
    • Analyze paragraph with a selected passive analyzer (if the analyzer does not check on save or change)
      Showcase
    • Only on the first character of the first line: analyze the whole document if it was not fully checked yet
      Showcase
    • Custom actions defined by a given analyzer
      E.g. OpenAI text generation
  • Context based word suggestion
    Showcase

Analyzers

Local tools

The following tools run on the local system:

  • LanguageTool: Mainly for development purposes, see ltex-ls for a more mature implementation.
  • Ollama: Run LLMs efficiently on your local machine. It supports diagnostics, code actions and prompt based text generation.
    • Ollama needs to be installed manually first.
    • Various LLMs are supported, such as Llama 3, Gemma or Mistral. Suggested model is Gemma3, due to its speed, size and accuracy.
Deprecated Analysers
  • hf_checker: Huggingface text2text-generation pipeline based analyser. See the flan-t5-large-grammar-synthesis model for an example.
    Models
    • pszemraj/grammar-synthesis-small
    • pszemraj/grammar-synthesis-large
    • pszemraj/flan-t5-large-grammar-synthesis
    • pszemraj/flan-t5-xl-grammar-synthesis
    • pszemraj/bart-base-grammar-synthesis
  • hf_instruction_checker: Huggingface text2text-generation pipeline based analyser using instruction tuned models. See the Grammarly's CoEdIT model for an example. Supports error checking and text generation, such as paraphrasing, through the %HF% magic command (see the OpenAI analyser below).
    Models
    • grammarly/coedit-large
    • grammarly/coedit-xl
    • grammarly/coedit-xl-composite
    • grammarly/coedit-xxl
    • jbochi/coedit-base
    • jbochi/coedit-small
    • jbochi/candle-coedit-quantized
  • hf_completion: Huggingface fill-mask pipeline based text completion.

Tools using remote services

DISCLAIMER: THE RELATED APIS REQUIRE REGISTRATION AND ARE NOT FREE TO USE! USE THESE ANALYZERS ON YOUR OWN RESPONSIBILITY! THE AUTHORS OF TEXTLSP DO NOT ASSUME ANY RESPONSIBILITY FOR THE COSTS INCURRED!

The following tools use remote text APIs. Due to potential costs turning off automatic analysis if suggested.

  • OpenAI: Supports text correction as well as text generation through a magic command in the text file.
    • A custom URL can be set to use an OpenAI-compatible server. See the example configuration below.
      Generation showcase
Deprecated Analysers
  • GrammarBot: The GrammarBot API provides spelling and grammar checking.

Supported File Types

  • latex
  • org
  • markdown
  • any other file types as plain text

Setup

Install

pip install textLSP

For the latest version:

pip install git+https://github.com/hangyav/textLSP

Additional dependencies

Some analyzers need additional dependencies!

  • hf_checker, hf_instruction_checker and hf_completion:
pip install textLSP[transformers]

Running

Simply run:

textlsp

Since some analyzers are computation intensive, consider running it on a server using the TCP interface:

textlsp --address 0.0.0.0 --port 1234

or simply over ssh (with ssh key) if the client doesn't support it:

ssh <server> textlsp

Configuration

Using textLSP within an editor depends on the editor of choice. For a few examples how to set up language servers in general in some of the popular editors see here or take a look at the related documentation of your editor.

By default, all analyzers are disabled in textLSP, they have to be turned on in the settings. Example configuration in lua for nvim (other editors should be set up accordingly):

textLSP = {
    analysers = {
        languagetool = {
            enabled = true,
            check_text = {
                on_open = true,
                on_save = true,
                on_change = false,
            }
        },
        ollama = {
          enabled = true,
          check_text = {
            on_open = false,
            on_save = true,
            on_change = false,
          },
          model = "gemma3:4b",  -- more accurate
          -- model = "gemma3:1b",  -- smaller but faster model
          max_token = 50,
        },
        openai = {
            enabled = false,
            api_key = '<MY_API_KEY>',
            -- url = '<CUSTOM_URL>'  -- optional to use an OpenAI-compatible server
            check_text = {
                on_open = false,
                on_save = false,
                on_change = false,
            },
            model = 'gpt-5-nano',
            max_token = 100,
        },
    },
    documents = {
        -- the language of the documents, could be set to `auto` of `auto:<fallback>`
        -- to detect automatically, default: auto:en
        language = "auto:en",
        -- do not autodetect documents with fewer characters
        min_length_language_detect = 20,
        org = {
            org_todo_keywords = {
                'TODO',
                'IN_PROGRESS',
                'DONE'
            },
        },
        txt = {
            parse = true,
        },
    },
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

textlsp-0.4.0.tar.gz (53.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

textlsp-0.4.0-py3-none-any.whl (66.0 kB view details)

Uploaded Python 3

File details

Details for the file textlsp-0.4.0.tar.gz.

File metadata

  • Download URL: textlsp-0.4.0.tar.gz
  • Upload date:
  • Size: 53.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for textlsp-0.4.0.tar.gz
Algorithm Hash digest
SHA256 5867275812f9314c3c9e21c63b33a07a1acfa6ef58db04e461f7160ae98029b3
MD5 4dcb3c2836fcee5eafc2ccf2a8785496
BLAKE2b-256 c167b385039bf0faada3ec4d43d9da47c5c05cb09ba74dba06c3a0d76211c266

See more details on using hashes here.

File details

Details for the file textlsp-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: textlsp-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 66.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for textlsp-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c95a65508ef1ecfa179401664864837a495f74f8ebf8f30b013ba675abde21da
MD5 0bc7fe4248bf9b8a6ae93453ad998044
BLAKE2b-256 5bc0ced4af96cb7a16708e32ef938ad5b2fd377d462757729581287a642eb285

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page