nvim: configure latex formatting options and completion model

This commit is contained in:
2026-05-29 03:32:58 +02:00
parent 81aef85feb
commit 6966af3229
4 changed files with 32 additions and 1 deletions
+13
View File
@@ -9,3 +9,16 @@ vim.opt_local.spelllang = { "en_gb", "de_de", "fr" }
vim.opt_local.wrap = true
vim.opt_local.linebreak = true
vim.opt_local.textwidth = 0 -- don't hard-wrap LaTeX
-- Normalize display-math delimiters: $$ … $$ → \[ … \] on every save.
-- Uses a unique augroup per buffer to avoid double-registration on :edit.
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = 0,
group = vim.api.nvim_create_augroup("user_tex_normalize_math_" .. vim.api.nvim_get_current_buf(), { clear = true }),
callback = function()
local view = vim.fn.winsaveview()
vim.cmd([[silent! keeppatterns %s/\v\$\$(\_.{-})\$\$/\\[\1\\]/g]])
vim.fn.winrestview(view)
end,
})
+4
View File
@@ -15,6 +15,10 @@ vim.lsp.config("texlab", {
formatterLineLength = 80,
bibtexFormatter = "texlab",
latexFormatter = "latexindent",
latexindent = {
["local"] = "localSettings.yaml",
modifyLineBreaks = false,
},
},
},
})
+1 -1
View File
@@ -8,7 +8,7 @@ return {
},
opts = {
backend = "ollama",
model = "qwen2.5-coder:latest",
model = "qwen2.5-coder:1.5b-base",
url = vim.env.OLLAMA_HOST or "http://localhost:11434",
tokens_to_clear = { "<|endoftext|>" },
fim = {
+14
View File
@@ -60,6 +60,20 @@ return {
tex = { "latexindent" },
["jinja.html"] = { "djlint" },
},
formatters = {
latexindent = {
-- Pass -l <localSettings.yaml> if found anywhere up the directory tree,
-- so project-local verbatimEnvironments guards are respected.
prepend_args = function(_, ctx)
local found = vim.fs.find("localSettings.yaml", {
upward = true,
path = vim.fs.dirname(ctx.filename),
type = "file",
})[1]
return found and { "-l", found } or {}
end,
},
},
format_on_save = {
timeout_ms = 2000,
lsp_fallback = true,