diff --git a/dot_config/nvim/ftplugin/tex.lua b/dot_config/nvim/ftplugin/tex.lua index 08fe8fe..b679a2b 100644 --- a/dot_config/nvim/ftplugin/tex.lua +++ b/dot_config/nvim/ftplugin/tex.lua @@ -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, +}) + diff --git a/dot_config/nvim/lua/lsp/texlab.lua b/dot_config/nvim/lua/lsp/texlab.lua index d0f6062..2a07b15 100644 --- a/dot_config/nvim/lua/lsp/texlab.lua +++ b/dot_config/nvim/lua/lsp/texlab.lua @@ -15,6 +15,10 @@ vim.lsp.config("texlab", { formatterLineLength = 80, bibtexFormatter = "texlab", latexFormatter = "latexindent", + latexindent = { + ["local"] = "localSettings.yaml", + modifyLineBreaks = false, + }, }, }, }) diff --git a/dot_config/nvim/lua/plugins/ai.lua b/dot_config/nvim/lua/plugins/ai.lua index 6b4cb99..432108c 100644 --- a/dot_config/nvim/lua/plugins/ai.lua +++ b/dot_config/nvim/lua/plugins/ai.lua @@ -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 = { diff --git a/dot_config/nvim/lua/plugins/editing.lua b/dot_config/nvim/lua/plugins/editing.lua index 4cfc69f..b9f2476 100644 --- a/dot_config/nvim/lua/plugins/editing.lua +++ b/dot_config/nvim/lua/plugins/editing.lua @@ -60,6 +60,20 @@ return { tex = { "latexindent" }, ["jinja.html"] = { "djlint" }, }, + formatters = { + latexindent = { + -- Pass -l 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,