latex-lsp / texlab

An implementation of the Language Server Protocol for LaTeX
GNU General Public License v3.0
1.55k stars 53 forks source link

Parser error #602

Closed motorto closed 2 years ago

motorto commented 2 years ago

Hey guys the following code:

\newcommand{\CVSubHeadingListStart}{\begin{itemize}[leftmargin=0.5cm, label={}]}
\newcommand{\CVSubHeadingListEnd}{\end{itemize}}
\newcommand{\CVItemListStart}{\begin{itemize}}
\newcommand{\CVItemListEnd}{\end{itemize}\vspace{-5pt}}

Returns the following errors about missing parenthesis ? image

I don't know what else to provide, but to me it seems that is a parser error (or I am doing something stupid in my end)

Happy Easter !

clason commented 2 years ago

Works for me; but the diagnostics sometimes need a bit of time to "catch up". Try editing (or reloading) the buffer to force a sync.

motorto commented 2 years ago

hum weird ...

here is a minimal tex file but it gives me the same error. ```latex \documentclass[A4,11pt]{article} \usepackage{latexsym} \usepackage[empty]{fullpage} \usepackage{titlesec} \usepackage{marvosym} \usepackage[usenames,dvipsnames]{color} \usepackage{verbatim} \usepackage{enumitem} \usepackage[hidelinks]{hyperref} \usepackage[english]{babel} \usepackage{tabularx} \usepackage{tikz} \input{glyphtounicode} \usepackage{palatino} \addtolength{\oddsidemargin}{-1cm} \addtolength{\evensidemargin}{-1cm} \addtolength{\textwidth}{2cm} \addtolength{\topmargin}{-1cm} \addtolength{\textheight}{2cm} \urlstyle{same} \raggedbottom \raggedright \setlength{\tabcolsep}{0cm} % Sections formatting \titleformat{\section}{ \vspace{-4pt}\scshape\raggedright\large }{}{0em}{}[\color{black}\titlerule \vspace{-5pt}] % Ensure that .pdf is machine readable/ATS parsable \pdfgentounicode=1 %-----CUSTOM COMMANDS FOR FORMATTING SECTIONS---------------------------------- \newcommand{\CVItem}[1]{ \item\small{ {#1 \vspace{-2pt}} } } \newcommand{\CVSubheading}[4]{ \vspace{-2pt}\item \begin{tabular*}{0.97\textwidth}[t]{l@{\extracolsep{\fill}}r} \textbf{#1} & #2 \\ \small#3 & \small #4 \\ \end{tabular*}\vspace{-7pt} } \newcommand{\CVSubSubheading}[2]{ \item \begin{tabular*}{0.97\textwidth}{l@{\extracolsep{\fill}}r} \text{\small#1} & \text{\small #2} \\ \end{tabular*}\vspace{-7pt} } \newcommand{\CVSubItem}[1]{\CVItem{#1}\vspace{-4pt}} \renewcommand\labelitemii{$\vcenter{\hbox{\tiny$\bullet$}}$} \newcommand{\CVSubHeadingListStart}{\begin{itemize}[leftmargin=0.5cm, label={}]} \newcommand{\CVSubHeadingListEnd}{\end{itemize}} \newcommand{\CVItemListStart}{\begin{itemize}} \newcommand{\CVItemListEnd}{\end{itemize}\vspace{-5pt}} \begin{document} \section{Education} \CVSubHeadingListStart % \CVSubheading % Example % {Degree Achieved}{Years of Study} % {Institution of Study}{Where it is located} \CVSubheading {{School $|$ \emph{\small{Formation centered in Computer Science}}}}{2018-Ongoing} {University of Europe}{Europe} \CVSubHeadingListEnd \section{Skills} \begin{itemize}[leftmargin=0.5cm, label={}] \small{\item{ \textbf{Languages}{: Portuguese (Native), English (B1), Spanish (A2) } \\ \textbf{Programming}{: C, Shell Scripting, Java, Assembly } \\ \textbf{Document Creation}{: Microsoft Office Suite, LaTeX , Markdown} \\ \textbf{Operating Systems}{: Unix based(Linux and BSD), Windows} }} \end{itemize} \end{document} ```

image

clason commented 2 years ago

OK, in that context, I get the same errors.

(Ah, I see my error -- Neovim's LSP client still doesn't fully work when opening an empty file and then setting the filetype... 😠 )

pfoerster commented 2 years ago

Thanks for the report. This happens with VSCode as well. This bug stems from the parser; it tries to complete the itemize environment, which causes the error about the unexpected }. I think we should handle this case the same way that we do in the tree-sitter grammar.

motorto commented 2 years ago

Neovim's LSP client still doesn't fully work when opening an empty file and then setting the filetype...

The client doesn't seem to attach to the buffer after setting the filetype :)

This bug stems from the parser; it tries to complete the itemize environment, which causes the error about the unexpected }

Should I change the name of the issue then since it's not an error on the parser ?

pfoerster commented 2 years ago

Should I change the name of the issue then since it's not an error on the parser ?

The title is fine. It is an error of the parser (we do not use the tree-sitter grammar in the server).

pfoerster commented 2 years ago

Can you give eec02390716fcf4fbf01de9afa975853e9267082 a try, please?

motorto commented 2 years ago

Sure, it seems to be working fine. In that use case the error seems to be fixed.

On Sat, Apr 16 2022 at 04:33:05 -0700, Patrick Förster @.***> wrote:

Can you give eec0239 https://github.com/latex-lsp/texlab/commit/eec02390716fcf4fbf01de9afa975853e9267082 a try, please?

— Reply to this email directly, view it on GitHub https://github.com/latex-lsp/texlab/issues/602#issuecomment-1100645083, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMRTQPN6LFZT3NZ45QTNXSLVFKQPDANCNFSM5TSFRDEQ. You are receiving this because you authored the thread.Message ID: @.***>

motorto commented 2 years ago

Did find a new one I think \usepackage{amsmath} package


\begin{pmatrix}
1 & 2 & 3\\
a & b & c
\end{pmatrix}

image

clason commented 2 years ago

Is that inside a math environment? (It's not legal outside.)

motorto commented 2 years ago

Is that inside a math environment? (It's not legal outside.)

Yup my error.

Probably should close this issue, but I am not sure if there was a new release since

pfoerster commented 2 years ago

Did find a new one I think \usepackage{amsmath} package

This error is actually reported by latex itself and not texlab ;)

but I am not sure if there was a new release since

texlab 4.0.0 is now released 🚀