besser wirds licht denk ich

This commit is contained in:
cscherr 2025-06-23 17:25:07 +02:00
parent 505dd0dda0
commit 9388a41ff1
Signed by: cscherrNT
GPG key ID: 8E2B45BC51A27EA7
2 changed files with 25 additions and 19 deletions

View file

@ -27,6 +27,10 @@ local ltex_fts = {
'rst',
}
local map = function(keys, func, desc)
vim.keymap.set('n', keys, func, { buffer = vim.buf, desc = 'LSP[LTEX]: ' .. desc })
end
LTEX_SETTINGS = {
capabilities = CAPABILITIES,
on_attach = function(client, bufnr)
@ -59,31 +63,34 @@ LTEX_SETTINGS = {
}
-- load token and additional languagetool items later if specified
local do_not_use_api_key = true
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))
if not do_not_use_api_key and has_api_key and apiKey ~= '' then
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/',
languageToolHttpServerUrl = 'https://api.languagetoolplus.com/',
},
})
else
if not do_not_use_api_key then
print 'apiKey for ltex/languagetool is not specified'
end
end
return {
'barreiroleo/ltex_extra.nvim',
ft = { 'markdown', 'tex' },
ft = ltex_fts,
dependencies = { 'neovim/nvim-lspconfig' },
-- yes, you can use the opts field, just I'm showing the setup explicitly
config = function()
require('ltex_extra').setup {
server_opts = LTEX_SETTINGS,
}
map('<leader>tS', function()
vim.cmd 'LspStart ltex'
end, 'Enable spell checking with languagetool')
end,
}

View file

@ -16,14 +16,14 @@ M.tokenize_args = function(raw)
--
-- This means we're better of implementing the lexer with an algorithm.
local t = {}
local current = ""
local current = ''
local in_str = false
local str_seek
for c in string.gmatch(raw, ".") do -- iterate through all chars
if c == " " and not in_str then
for c in string.gmatch(raw, '.') do -- iterate through all chars
if c == ' ' and not in_str then
if string.len(current) > 0 then
table.insert(t, current)
current = ""
current = ''
end
elseif c == '"' and not in_str then
in_str = true
@ -34,7 +34,7 @@ M.tokenize_args = function(raw)
elseif c == str_seek and in_str then
in_str = false
table.insert(t, current)
current = ""
current = ''
else
current = current .. c
end
@ -50,18 +50,18 @@ end
--- @param t any variable
--- @return string t_dumped t dumped to string
M.dump = function(t)
if type(t) == "table" then
local s = "{ "
if type(t) == 'table' then
local s = '{ '
for k, v in pairs(t) do
if type(k) ~= "number" then
if type(k) ~= 'number' then
k = '"' .. k .. '"'
end
if k ~= 1 then
s = s .. ", "
s = s .. ', '
end
s = s .. "[" .. k .. "] = '" .. M.dump(v) .. "'"
s = s .. '[' .. k .. "] = '" .. M.dump(v) .. "'\n"
end
return s .. " }"
return s .. ' }'
else
return tostring(t)
end
@ -81,4 +81,3 @@ M.try_require = function(module)
end
return M