fannheyward / coc-texlab

TexLab extension for coc.nvim
MIT License
121 stars 3 forks source link

Wrong suggestions/errors when using non-standard/Unicode (`[^a-zA-Z]`) macro names #250

Closed Andrew15-5 closed 1 year ago

Andrew15-5 commented 1 year ago

Issue https://github.com/latex-lsp/texlab/issues/857 (https://github.com/fannheyward/coc-texlab/issues/249) has been resolved and server now provides suggestions with any macro names, hurray! But now there are some bugs with coc-texlab (I'm pretty sure). Below I paste Neovim config, LaTeX file/document and some tests. Only the 3rd test is passed because macro/command name consists of non-special characters ([a-z]). But of course ideally all 7 must be passed (support of 99% any name).

There are some notes:

init.vim ```vim call plug#begin($HOME . '/.config/nvim/autoload/plugged') Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'joshdick/onedark.vim' Plug 'tpope/vim-commentary' call plug#end() colorscheme onedark " Comment lines noremap :Commentary inoremap :Commentary " Use to trigger completion. if has('nvim') inoremap coc#refresh() else inoremap coc#refresh() endif " coc-texlab let g:tex_flavor = 'latex' " Select auto completion option inoremap \ coc#pum#visible() ? coc#pum#next(1) : \ CheckBackspace() ? "\" : \ coc#refresh() inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" ```
bug.tex ```latex \documentclass{article} % \newcommand{\ö}{} % No error % \newcommand{\öö}{} % Error: Unexpected "}" (texlab 1) % \newcommand{\ööabc}{} % Error: Unexpected "}" (texlab 1) \newcommand\ööabc{} \def\öabc{} \def\123{123} \def\abc{} \begin{document} \end{document} ```
Tests Step 0: `\`, `` ![image](https://user-images.githubusercontent.com/37143421/224181824-7e05bb39-51c6-4d74-99dd-782f6085c8f4.png)
Test #Step 1Step 2
1🔴 `1` ![image](https://user-images.githubusercontent.com/37143421/224181110-eef0f733-c087-44d4-a57d-fe2fae853062.png) (macro `\1` is undefined, shown otherwise) `` ![image](https://user-images.githubusercontent.com/37143421/224181231-49af3a1d-1daa-46df-a82d-ad3f744ed8ec.png)
2🔴 `123`, `` ![image](https://user-images.githubusercontent.com/37143421/224181315-d04c67e7-a2a3-4fa9-a437-328b7a44171a.png) (macro `\123` is defined, shown otherwise)
3🟢 `abc`, `` ![image](https://user-images.githubusercontent.com/37143421/224181450-8d51e698-8711-49b6-9481-7e9d637af66d.png) (macro `\abc` is defined, the same is shown)
4🔴 `ö`, `` ![image](https://user-images.githubusercontent.com/37143421/224181578-ca44ec82-7a5e-4d73-b8c6-e0c801a9a81b.png) (macro `\ö` is undefined, shown otherwise) `` ![image](https://user-images.githubusercontent.com/37143421/224181609-218d22e9-150f-4377-bdaf-81156b3a761f.png)
5🔴 `öabc`, `` ![image](https://user-images.githubusercontent.com/37143421/224184414-0db0907b-59ef-4edc-8798-2a5d4d905007.png) (macro `\öabc` is defined, shown otherwise)
6🔴 `öö` ![image](https://user-images.githubusercontent.com/37143421/224184732-badb8a47-feeb-4b30-ba4d-8e857da6b5ae.png) (macro `\ööabc` is defined, but no suggestions are shown unless `` is pressed again) `abc`, `` ![image](https://user-images.githubusercontent.com/37143421/224184901-ab23ec91-9cd1-47b4-8fbe-af9adc799237.png) (macro `\ööabc` is defined, shown otherwise)
7🔴 `öö`, `` ![image](https://user-images.githubusercontent.com/37143421/224185116-a35d3b4b-4636-42b3-ba1c-892def7be885.png) \*Uncommented 1 line with the extension error* (macros `\ööabc` and `\öö` are defined, but only **word** and **not a macro** `ööabc` is suggested)
\newcommand{} Meaningless errors are shown which say that the `}` character is inserted in the unexpected/wrong place, but the syntax is correct. Maybe it's only shown when the macro's name have anything appended after the Unicode character (a hunch from just looking at the places where the errors occur). ![image](https://user-images.githubusercontent.com/37143421/224190462-2e6af06c-2ba3-4408-892b-af9218b9b29d.png) ![image](https://user-images.githubusercontent.com/37143421/224190515-5d36cf47-00c1-40da-8a97-64281a5124a4.png) Output (from `lualatex bug.tex`): ![image](https://user-images.githubusercontent.com/37143421/224190741-8098910b-3ac1-4654-adcd-6f5ad55f59a6.png) Source code: ```latex \documentclass{article} \newcommand{\ö}{ö} % No error \newcommand{\öö}{öö} % Error: Unexpected "}" (texlab 1) \newcommand{\ööabc}{ööabc} % Error: Unexpected "}" (texlab 1) \renewcommand\ööabc{ööabc} % No error \def\öabc{öabc} \def\123{123} \def\abc{abc} \def\a0{a0} \def\0a{0a} % \def\1a{1a} % OK if no macro starting with \1 is used \begin{document} \ö, \öö, \ööabc, \öabc, \123, \abc, \a0, \0a \end{document} ```

Updated test results (checked means no issues):


Update: main conversation/issue is now here: https://github.com/latex-lsp/texlab/issues/864. This issue will be closed with the main issue because the issue is related to both projects.

fannheyward commented 1 year ago

Thank you for your report. Do you have tested with the lasted texlab with that fix patch?

Andrew15-5 commented 1 year ago

Yes, of course. Just git clone, cd, cargo build and mv texlab /path/to/bin dir/. Works like a charm.

Andrew15-5 commented 1 year ago

Updated the comment:

fannheyward commented 1 year ago

Very detailed reproduce steps, will follow up on this issue.

pfoerster commented 1 year ago

@fannheyward It looks like all of the tests are bugs in the server and not in coc-texlab.

@Andrew15-5 Can you try out the latest changes on the texlab master branch, please? The tests should pass now :)

Andrew15-5 commented 1 year ago

But now there are some bugs with coc-texlab (I'm pretty sure)

Yay, I'm glad I put this I'm pretty sure.

@pfoerster, let me "transfer" the issue to https://github.com/latex-lsp/texlab, and then we can talk tests. ;)