latex-lsp / texlab

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

Does not work with `jsarticle`, `jsbook`. #793

Closed ryota2357 closed 2 years ago

ryota2357 commented 2 years ago

I'm using neovim and nvim-lsp.

As in the title, texlab will detach (clash?) with documentclass{jsarticle}. article and jarticle works well.

How to reproduce

Use this init.vim.

init.vim ```vim if has('vim_starting') set encoding=utf-8 endif scriptencoding utf-8 if &compatible set nocompatible endif let s:plug_dir = expand('/tmp/plugged/vim-plug') if !filereadable(s:plug_dir .. '/plug.vim') execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir) end execute 'set runtimepath+=' . s:plug_dir call plug#begin(s:plug_dir) Plug 'hrsh7th/nvim-cmp' Plug 'hrsh7th/cmp-buffer' Plug 'hrsh7th/cmp-nvim-lsp' Plug 'hrsh7th/vim-vsnip' Plug 'neovim/nvim-lspconfig' call plug#end() PlugInstall | quit let g:tex_flavor = 'latex' lua << EOF local cmp = require "cmp" cmp.setup { snippet = { expand = function(args) vim.fn["vsnip#anonymous"](args.body) end, }, mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.confirm({ select = true }), }), sources = cmp.config.sources({ { name = "nvim_lsp" }, { name = "buffer" }, }), } EOF lua << EOF local capabilities = require('cmp_nvim_lsp').default_capabilities() require('lspconfig').texlab.setup { capabilities = capabilities } EOF ```
  1. Start neovim.
  2. :LspInfo, you can see that texlab is started.
  3. Type \documentclass{jsarticle} in the first line. (You can also get completion.)
  4. Go to the next line, and type \begin. (You can't get completion.)
  5. :LspInfo, you can see that texlab is detached.

Also, the diagnostic does not work well.

Open the following tex file.

\documentclass{jarticle}
\begin{document}
\begin{equation}
  x^2 + y^2 = z^2
\end{equation}
\end{document}
  1. Change \begin{equation} to \begin{equation (remove })
  2. You can see the diagnostic error.
  3. Continue to write something and save it. (don't fix })
  4. You can't see the error.

Note: In this init.vim, I used nvim-cmp for completion. The same thing is occurs in ddc.vim

Expected

If you do the above with jarticle or article instead of jsarticle, the input completion and errors will continue to display correctly.

Environment

neovim

:version
NVIM v0.8.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@HMBRW-A-001-M1-004.local

texlab

$ texlab --version
texlab 4.3.0

If this bug originates from nevoim or nvim-lsp, I apologize.

ryota2357 commented 2 years ago

In VSCode, the same(?) things occur. I installed texlab extension. (not installed LaTeX Workshop.)

With jsarticle, TexLab language server output is this.

[Info  - 15:12:47] Connection to server got closed. Server will restart.
[Info  - 15:12:50] Connection to server got closed. Server will restart.
[Info  - 15:12:54] Connection to server got closed. Server will restart.
[Info  - 15:13:07] Connection to server got closed. Server will restart.
[Error - 15:13:08] The texlab server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

This is not reproduced with jarticle and so on.

pfoerster commented 2 years ago

@ryota2357 Thanks for the detailed report! Can you give 7fd82cc5885fb6e180823ce7715eb173283facfe a try? It should fix the issue.

ryota2357 commented 2 years ago

Thank you!! It works! I can get both diagnostic and completion.

ryota2357 commented 2 years ago

@pfoerster Today, I tested 7fd82cc5885fb6e180823ce7715eb173283facfe in other PC, it dose not fix the issue.

vimrc-dev (almost same as first init.vim) ```vim if has('vim_starting') set encoding=utf-8 endif scriptencoding utf-8 if &compatible set nocompatible endif let s:plug_dir = expand('/tmp/plugged/vim-plug') if !filereadable(s:plug_dir .. '/plug.vim') execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir) end execute 'set runtimepath+=' . s:plug_dir call plug#begin(s:plug_dir) Plug 'hrsh7th/nvim-cmp' Plug 'hrsh7th/cmp-nvim-lsp' Plug 'hrsh7th/vim-vsnip' Plug 'neovim/nvim-lspconfig' call plug#end() PlugInstall | quit let g:tex_flavor = 'latex' lua << EOF local cmp = require "cmp" cmp.setup { snippet = { expand = function(args) vim.fn["vsnip#anonymous"](args.body) end, }, mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.confirm({ select = true }), }), sources = cmp.config.sources({ { name = "nvim_lsp" }, }), } EOF lua << EOF local capabilities = require('cmp_nvim_lsp').default_capabilities() require('lspconfig').texlab.setup { capabilities = capabilities } vim.lsp.set_log_level("debug") EOF ```

https://user-images.githubusercontent.com/61523777/197152206-d3e5dfbf-6907-4505-8dd8-3c95d178cc59.mov

neovim version is same(0.8), macOS version is same(12.6). This PC is MacBook Pro 2018 (intel i5). But in MacBook Pro 2021 (M1-Pro), this issue is fixed.

ryota2357 commented 2 years ago

I want to fix the issue, but I don't have the skills. What information should I provide?

pfoerster commented 2 years ago

@ryota2357

What information should I provide?

Thanks to your video, I was able to narrow down the issue. Can you try e353156, please?

ryota2357 commented 2 years ago

Thank you! It works on both PC.

pfoerster commented 2 years ago

Released with 4.3.1