Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with jsarticle, jsbook. #793

Closed
ryota2357 opened this issue Oct 18, 2022 · 8 comments
Closed

Does not work with jsarticle, jsbook. #793

ryota2357 opened this issue Oct 18, 2022 · 8 comments
Labels
bug Something isn't working

Comments

@ryota2357
Copy link

ryota2357 commented Oct 18, 2022

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
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({
    ['<CR>'] = 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 ryota2357 changed the title Dose not work with jsarticle, jsbook. Does not work with jsarticle, jsbook. Oct 18, 2022
@ryota2357
Copy link
Author

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 added a commit that referenced this issue Oct 19, 2022
Do not parse packages that are part of the TeX distro and not available
in the completion database unless the package is a local user package.

See #793.
@pfoerster
Copy link
Member

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

@pfoerster pfoerster added the bug Something isn't working label Oct 19, 2022
@ryota2357
Copy link
Author

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

@ryota2357
Copy link
Author

ryota2357 commented Oct 21, 2022

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

vimrc-dev (almost same as first init.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({
    ['<CR>'] = 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
2022-10-21.17.33.15.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
Copy link
Author

ryota2357 commented Oct 21, 2022

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

pfoerster added a commit that referenced this issue Oct 21, 2022
Do not treat /usr/local/texlive... paths as local packages.

See #793.
@pfoerster
Copy link
Member

@ryota2357

What information should I provide?

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

@ryota2357
Copy link
Author

Thank you!
It works on both PC.

@pfoerster
Copy link
Member

Released with 4.3.1

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Apr 27, 2023
## [5.5.0] - 2023-04-16

### Added

- Allow optionally passing cursor position to `textDocument/build` request for use in forward search after building.
  Previously, the server had to guess the cursor position ([#475](latex-lsp/texlab#475))
- Add experimental `texlab.experimental.citationCommands` setting to allow extending the list of citation commands
  ([#832](latex-lsp/texlab#832))
- Add support for escaping placeholders in build arguments similar to forward search
- Allow configuring completion matching algorithm ([#872](latex-lsp/texlab#872))

### Fixed

- Fix regression introduced in `v5.4.2` involving `texlab.cleanArtifacts` command.

## [5.4.2] - 2023-04-11

### Fixed

- Fix memory leak when editing documents over a long time ([#856](latex-lsp/texlab#856))
- Fix parsing parentheses in file paths ([#874](latex-lsp/texlab#874))

## [5.4.1] - 2023-03-26

### Fixed

- Do not return symbols with empty names (e. g. sections without name) ([#870](latex-lsp/texlab#870))
- Repair `textDocument/formatting` request ([#871](latex-lsp/texlab#871))

## [5.4.0] - 2023-03-12

### Added

- Add experimental settings to allow extending the list of special environments:
  - `texlab.experimental.mathEnvironments`
  - `texlab.experimental.enumEnvironments`
  - `texlab.experimental.verbatimEnvironments`
- Add `texlab.changeEnvironment` workspace command ([#849](latex-lsp/texlab#849))
- Add `texlab.showDependencyGraph` workspace command

### Changed

- Do not show caption or section names in label inlay hints ([#858](latex-lsp/texlab#858))
- Include more user-defined commands in command completion

### Fixed

- Parse nested `\iffalse` blocks correctly ([#853](latex-lsp/texlab#853))
- Parse commands with multi-byte characters correctly ([#857](latex-lsp/texlab#857))
- Fix checking whether a document can be a root file

## [5.3.0] - 2023-02-25

### Added

- Allow filtering `textDocument/documentSymbols` using regular expressions specified via
  `texlab.symbols.allowedPatterns` and `texlab.symbols.ignoredPatterns`
  ([#851](latex-lsp/texlab#851))

### Fixed

- Do not use percent-encoded path when searching for PDF files during forward search
  ([#848](latex-lsp/texlab#848))
- Always return an empty list of code actions instead of returning "method not found" ([#850](latex-lsp/texlab#850))

## [5.2.0] - 2023-01-29

### Added

- Include line numbers in build warnings when available ([#840](latex-lsp/texlab#840))
- Add `none` formatter to `texlab.latexFormatter` and `texlab.bibtexFormatter` options
  to allow disabling formatting ([#846](latex-lsp/texlab#846))

### Fixed

- Concatenate more than two lines of maximum length in build diagnostics ([#842](latex-lsp/texlab#842))
- Apply the correct range of references to labels when renaming ([#841](latex-lsp/texlab#841))
- Use `document` environment to detect root file instead of `\documentclass` ([#845](latex-lsp/texlab#845))

## [5.1.0] - 2023-01-21

### Added

- Allow manually overriding the root directory using a `texlabroot`/`.texlabroot` marker file.
  See the wiki for more information.
  ([#826](latex-lsp/texlab#826), [#838](latex-lsp/texlab#838))

### Deprecated

- Deprecate `texlab.rootDirectory` setting in favor of `.texlabroot` files

### Fixed

- Do not use `.git`, `.chktexrc`, `.latexmkrc` files/directories to determine the root directory
  ([#826](latex-lsp/texlab#826))
- Fix building documents without an explicit root directory ([#837](latex-lsp/texlab#837))

## [5.0.0] - 2022-12-29

### Changed

- _BREAKING_: `texlab.rootDirectory` is now used as the folder path from which the compiler is executed
  relative to the main document. By default it is equal to `"."`. For more information, please visit the wiki.
- Improve performance of completion by a huge margin due to a faster filtering method used internally
- Do not discover project files beyond the provided workspace folders
- Try to guess the root directory by checking for files such as `.latexmkrc` or `Tectonic.toml` if `texlab.rootDirectory` is not set

### Fixed

- Update positions of reported build diagnostics when editing the affected line
- Do not treat links to files as bidirectional by default. This prevents issues where `texlab` ends up compiling the wrong file
  in projects with shared files ([#806](latex-lsp/texlab#806), [#757](latex-lsp/texlab#757), [#679](latex-lsp/texlab#679))
- Fix coverage of directories which need to be watched for changes ([#502](latex-lsp/texlab#502), [#491](latex-lsp/texlab#491))
- Resolve links of the `import` package correctly
- Use `filterText` of completion items when filtering internally ([#829](latex-lsp/texlab#829))

## [4.3.2] - 2022-11-20

### Fixed

- Do not try to run the TeX engine on package files and fail the build instead ([#801](latex-lsp/texlab#801))
- Handle URIs with URL-encoded drive letters on Windows ([#802](latex-lsp/texlab#802))
- Parse BibTeX entries with unbalanced quotes correctly ([#809](latex-lsp/texlab#809))
- Provide completion for more acronym commands ([#813](latex-lsp/texlab#813))
- Fix parsing acronym definitions ([#813](latex-lsp/texlab#813))

## [4.3.1] - 2022-10-22

### Fixed

- Do not crash with a stack overflow when trying to load packages with many internal dependencies ([#793](latex-lsp/texlab#793))
- Normalize drive letters of all document URIs
- Fix parsing commands that take file paths as arguments ([#789](latex-lsp/texlab#789))
- Use the correct working directory and command line arguments when calling `latexindent` ([#645](latex-lsp/texlab#645))
- Fix publishing to CTAN

## [4.3.0] - 2022-09-25

### Added

- Add inlay hints for `\label{...}` ([#753](latex-lsp/texlab#753))

### Fixed

- Improve accuracy of the error locations reported by the TeX engine ([#738](latex-lsp/texlab#738))
- Reduce number of false positive errors reported by `texlab` ([#745](latex-lsp/texlab#745))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants