ltls

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2024 License: EUPL-1.2 Imports: 8 Imported by: 0

README

ltls

builds.sr.ht status

About

A language server that read Latex files and provides LanguageTool diagnostics.

Features

  • Spell checking through LSP Diagnostics
  • Corrections propositions in the form of code actions (not implemented)
  • Support for the premium LanguageTool API
  • Rate limiting and smart querying (not implemented)
  • Can reach the LanguageTool API even behind a HTTP proxy server
  • Custom matches to prevent false positive due to markup (not implemented)

Credits

The code is strongly inspired by efm-langserver (because it is fairly easy to read and written in Go so I can copy paste here and there).

I have not been reading the code from ltex-ls, while writing this tool (mostly because Java and Kotlin are completely alien to me), but I'd like to credit the author of ltex-ls because I used ltex-ls for a long time (I wrote my PhD with it because this project was not usable yet) and was inspired by it to use the LSP approach.

If this does not fit your need, consider using ltex-ls instead, it is a great tool.

Differences with ltex-ls

  • ltex-ls provides completion, ltls does not
  • ltex-ls works for Markdown and other markup language, ltls focuses on latex (although that one may change depending on my own needs, it shouldn't even be difficult)
  • ltex-ls focuses on the local server, it handles downloading and running it
  • ltls focuses on the premium API: it will handle proxy server and it will ensure the queries and their frequencies are compliant with what LanguageTool allows. It will also try to only query for what recently changed to avoid using you limited number of queries too quickly

Installation

From source:

git clone https://git.sr.ht/~lattay/ltls
cd ltls
go build
cp ltls ~/.local/bin

or if $GOPATH/bin is in your $PATH

git clone https://git.sr.ht/~lattay/ltls
cd ltls
go install

Usage

ltls has only been tested on Neovim, but I suppose it should work with any other standard compliant LSP client.

This is the parameters that can be configured at runtime:

{
	"settings": {
		"ltls": {
			"apiEndpoint": string?,  // "https://api.languagetoolplus.com/v2"
			"apiKey": string?,  // $LT_API_KEY
			"username": string?,  // $LT_API_USERNAME
			"language": string?,  // "en"
			"motherTongue": string?,  // "en"
			"disabledCategories": string?,  // []
			"disabledRules": string?,  // []
			"debug": string?  // false
		}
	}
}

And here is an example of configuring the server with Neovim:

vim.lsp.start {
	name = "ltls",
	cmd = { "ltls" },
	root_dir = vim.fs.dirname(vim.uv.cwd()),
	settings = {
		ltls = {
			language = vim.o.spelllang,
			motherTongue = "fr",
			disabledRules = { "TYPOGRAPHY/WHITESPACE_RULE" },
			debug = true,
		},
	},
}

If you have a premium account, you can find your token at https://languagetool.org/editor/settings/access-tokens.

TODO

  • Split Latex code into markup/regular text
  • Basic LSP events handling
    • respond/do something on initialize
    • respond to initialized
    • do something on initialized
    • respond to didSave
    • send checks on didSave
    • respond to didOpen
    • send checks on didOpen
    • respond didChangeConfiguration
    • respond to shutdown
    • respond to exit
  • Move language settings to a file-specific context
  • Handle LT API
    • get checks from LanguageTool
    • send new words to dictionnary
  • Implement smart rules to replace markup with text
    • all the math with 1+1=2
    • \`and''with"`
    • \emph, \text* with the parameter text
    • user defined matches?
  • Expose code actions
    • Propose to add to dict on typos
    • Propose to apply the replacements
  • Rate limiting
    • Fragment large queries in several HTTP requests
    • debounce to avoid redundant queries
    • hold a state of the document to patch and identify changed regions
    • use the patches to send shorter non redundant requests
  • Full testing suite
    • unit testing elements of the LT client
    • more testing of the server
    • more testing of the slicer

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL