Indent lines problem with tex files #2005
-
I've noticed that snacks.indent is generating too many indent lines in my .tex documents. What's confusing is that indent lines appear correctly in other filetypes I've tested, like .lua and .cpp. The issue seems isolated to LaTeX. For context: I use latexindent to autoformat my .tex files, but .lua and .cpp files are also autoformatted — and don't show this problem. What's strange is that everything worked perfectly when I first installed it a few weeks ago. Am I missing something? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 17 replies
-
Can you provide a minimal -- nvim -u repro.lua <file>.tex
-- repro.lua
vim.env.LAZY_STDPATH = '.repro'
load(vim.fn.system 'curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua')()
require('lazy.minit').repro {
spec = {
{
'folke/snacks.nvim',
opts = {
indent = {},
},
},
},
} Note Generated by ChatGPT. \documentclass{article}
\usepackage{amsmath}
\usepackage{enumitem}
\title{Deeply Nested Structures in \LaTeX}
\author{Sample Author}
\date{\today}
\begin{document}
\maketitle
\section{Introduction}
This document demonstrates deep nesting with consistent indentation.
\section{Nested Lists and Environments}
\begin{itemize}
\item First level item
\begin{itemize}
\item Second level item
\begin{itemize}
\item Third level item
\begin{enumerate}
\item Numbered fourth level
\begin{enumerate}
\item Numbered fifth level
\begin{description}
\item[Key] Description at sixth level
\begin{itemize}
\item Seventh level (back to bullets)
\end{itemize}
\end{description}
\end{enumerate}
\end{enumerate}
\end{itemize}
\end{itemize}
\end{itemize}
\section{Nested Math Environments}
\begin{equation}
\left[
\begin{array}{cc}
a & b \\
\left(
\begin{array}{c}
x \\
y
\end{array}
\right) &
\left\{
\begin{array}{l}
x + y \\
x - y
\end{array}
\right.
\end{array}
\right]
\end{equation}
\section{Custom Environment Example}
\newenvironment{deepblock}[1]
{
\begin{quote}
\textbf{#1}
\begin{itemize}
}
{
\end{itemize}
\end{quote}
}
\begin{deepblock}{Block Title}
\item First
\item Second
\begin{itemize}
\item Nested deeper
\begin{itemize}
\item Deepest point
\end{itemize}
\end{itemize}
\end{deepblock}
\end{document} |
Beta Was this translation helpful? Give feedback.
To be precise, you simply need to match
tabstop
(ts
) andshiftwidth
(sw
) with the actual indentation used by your formatter.In your case, you had
ts=4
andsw=4
, but the actual indentation used was 5 spaces. This means that Snacks displayed an indent every 4 spaces, and when the cursor was on the current scope (5 spaces), it also highlighted that position, resulting in a double border.