neoclide / coc-html

Html language server extension for coc.nvim.
208 stars 6 forks source link

[coc.nvim]: UnhandledRejection: TypeError: Cannot destructure property 'start' of 'range' as it is undefined. #57

Open samhed opened 1 year ago

samhed commented 1 year ago

I get the following message for every single line I type in a HTML file when coc-html is installed:

[coc.nvim]: UnhandledRejection: TypeError: Cannot destructure property 'start' of 'range' as it is undefined.

Doing CocDisable doesn't help, but if I uninstall coc-html the error goes away.

init.vim: Same configuration for CoC as suggested here: https://github.com/neoclide/coc.nvim#example-lua-configuration

coc-settings:

{
  "diagnostic.errorSign": "✗",
  "diagnostic.warningSign": "⚠",
  "diagnostic.hintSign": "‼",
  "python.linting.pylintEnabled": true,
  "python.linting.pycodestyleEnabled": true,
  "colors.filetypes": [
    "*"
  ],
  "clangd.path": "~/.local/share/nvim/coc-clangd-data/install/15.0.1/clangd_15.0.1/bin/clangd"
}

neovim version:

$ nvim --version
NVIM v0.8.3
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/builddir/build/BUILD/neovim-0.8.3/redhat-linux-build/cmake.config -I/builddir/build/BUILD/neovim-0.8.3/src -I/usr/include -I/usr/include/luajit-2.1 -I/builddir/build/BUILD/neovim-0.8.3/redhat-linux-build/src/nvim/auto -I/builddir/build/BUILD/neovim-0.8.3/redhat-linux-build/include
Compiled by mockbuild@koji

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info
d-mitrofanov-v commented 1 year ago

@samhed I had the same problem, but the culprit turned out to be not the coc-html, but coc-nav. The solution was some autocmds to turn it off, when entering html buffer and turn it on when leaving. You can add this to your coc.lua:

vim.api.nvim_create_augroup("CocNavToggle", { clear = true })

vim.api.nvim_create_autocmd("BufEnter", {
    group = "CocNavToggle",
    pattern = "*.html",
    command = "call CocActionAsync('deactivateExtension', 'coc-nav')",
    desc = "Turn off coc-nav for html"
})

vim.api.nvim_create_autocmd("BufLeave", {
    group = "CocNavToggle",
    pattern = "*.html",
    command = "call CocActionAsync('toggleExtension', 'coc-nav')",
    desc = "Turn on coc-nav for other files"
})
samhed commented 10 months ago

I can no longer reproduce this issue. I have both coc-html and coc-nav installed, and I did not add the autocmd's you suggested. @d-mitrofanov-v can you reproduce the issue if you remove those autocmd's?

samhed commented 10 months ago

Scratch that. I still see the bug if I open an HTML file in a split window. Can confirm that your autocmd's works.