From 3dc92d1d5b13d4ff9c49bbf92a362d6787baaf01 Mon Sep 17 00:00:00 2001 From: cscherr Date: Mon, 23 Jun 2025 15:43:26 +0200 Subject: [PATCH] ltex again --- lua/custom/plugins/configs/lsp.lua | 1 + lua/custom/plugins/ltex.lua | 85 ++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 lua/custom/plugins/ltex.lua diff --git a/lua/custom/plugins/configs/lsp.lua b/lua/custom/plugins/configs/lsp.lua index 9f09cf5..3d6622e 100644 --- a/lua/custom/plugins/configs/lsp.lua +++ b/lua/custom/plugins/configs/lsp.lua @@ -195,6 +195,7 @@ local servers = { }, }, }, + ltex_plus = LTEX_SETTINGS, } -- Ensure the servers and tools above are installed diff --git a/lua/custom/plugins/ltex.lua b/lua/custom/plugins/ltex.lua new file mode 100644 index 0000000..eecb691 --- /dev/null +++ b/lua/custom/plugins/ltex.lua @@ -0,0 +1,85 @@ +local utils = require 'custom.utils' + +local ltex_fts = { + 'bibtex', + 'bib', + 'tex', + 'typst', + 'latex', + 'gitcommit', + 'markdown', + 'org', + 'restructuredtext', + 'rsweave', + 'quarto', + 'rmd', + 'context', + 'text', + 'html', + 'pandoc', + 'xhtml', + 'plaintex', + 'quarto', + 'mail', + 'mdx', + 'rmd', + 'rnoweb', + 'rst', +} + +LTEX_SETTINGS = { + use_spellfile = true, + autostart = false, + filetypes = ltex_fts, + settings = { + ltex = { + checkFrequency = 'save', -- shut up while i'm just editing, see + -- specific language (such as en-GB or de-DE is recommended, but I + -- want multilingual) + language = 'auto', + enabled = ltex_fts, + additionalRules = { + enablePickyRules = true, + -- thats cool, but often adds diagnostics in + -- places where a german might confuse words that are similar + -- between english and german REGARDLESS of context. I seem to use the + -- english words only in the proper contexts, so leaving this on + -- just adds annoying hints like 'Hinweis: "list/NN.*" (English) bedeutet "Liste", + -- "Verzeichnis" (German). Meinten Sie vielleicht 'cunning', 'trick'?' + -- everytime I use the word "list". I liked that this makes the hints be + -- in german regardless of the language I'm working in through... + --motherTongue = "de", + }, + }, + }, +} + +-- load token and additional languagetool items later if specified +local has_api_key, apiKey = utils.try_require 'custom.secret.languagetool' +if has_api_key and apiKey ~= '' then + print(string.format('apiKey for ltex found: %s' % apiKey)) + LTEX_SETTINGS = vim.tbl_deep_extend('keep', LTEX_SETTINGS, { + settings = { + languageToolOrg = { + apiKey = apiKey, + username = 'accounts@cscherr.de', + languageToolHttpServerUrl = 'https://api.languagetoolplus.com/v2/', + }, + languageToolHttpServerUrl = 'https://api.languagetoolplus.com/v2/', + }, + }) +else + print 'apiKey for ltex/languagetool is not specified' +end + +return { + { + 'vigoux/ltex-ls.nvim', + enabled = false, + requires = 'neovim/nvim-lspconfig', + filetypes = { 'latex', 'tex', 'bib', 'markdown', 'gitcommit', 'text', 'typst' }, + config = function() + require('ltex-ls').setup { LTEX_SETTINGS } + end, + }, +}