dlvandenberg / tree-sitter-angular

Tree Sitter Grammar for Angular
MIT License
34 stars 9 forks source link

Neovim crashing when angular and typescript parsers are installed #25

Closed JustLinuxUser closed 4 months ago

JustLinuxUser commented 4 months ago

When both angular and typescript parsers are installed, and I delete a specific line, in a special file, neovim crashes. Here is the recording asciinema

Note:

Neovim crashes when I press dd on the innermost line.

Here is the file:

@Component({
  template: `
    <section >
      <router-outlet> </router-outlet>
    </section>
`,
})

Here is a minimal neovim config to reproduce the behaviour:

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({
        "git",
        "clone",
        "--filter=blob:none",
        "https://github.com/folke/lazy.nvim.git",
        "--branch=stable", -- latest stable release
        lazypath,
    })
end
vim.opt.rtp:prepend(lazypath)

-- require("options") -- Important to go first
require("lazy").setup({
{
    "nvim-treesitter/nvim-treesitter",
    build = ":TSUpdate",
    config = function()
        local configs = require("nvim-treesitter.configs")

        configs.setup({
            sync_install = true,
            highlight = { enable = true },
            indent = { enable = false },
            incremental_selection = {
                enable = true,
                keymaps = {
                    init_selection = "<CR>", -- set to `false` to disable one of the mappings
                    node_incremental = "<CR>",
                    scope_incremental = "<TAB>",
                    node_decremental = "<S-TAB>",
                },
            },
        })
    end,
}
})
gipo355 commented 4 months ago

Can confirm, just had to disable it because it would crash neovim any time i'd enter insert mode in the html angular template. Can not pinpoint any log file.

Specifically, when i enter insert mode inside the tags.

If i type some normal text at the end of the file, it won't

dlvandenberg commented 4 months ago

I have both parsers installed:

vim.treesitter: require("vim.treesitter.health").check()

- Nvim runtime ABI version: 14
- OK Parser: angular    ABI: 14, path: /Users/dennis.vandenberg/.local/share/nvim/lazy/nvim-treesitter/parser/angular.so
- OK Parser: typescript ABI: 14, path: /Users/dennis.vandenberg/.local/share/nvim/lazy/nvim-treesitter/parser/typescript.so

And I can use dd to delete any line in the inline template. I am using nvim v0.9.5.

francisco-morales97 commented 4 months ago

I have the same problem as @gipo355, when I open the html file of an angular project and try to enter insert mode neovim crashes. I've narrowed it down to the syntax highlight option since the problem goes away when I disable that option.

EDIT: I would like to clarify that this doesn't seem to be a treesitter problem because the crashing only happens with files whose filetype is "angular" or "angular.html", typescript files work perfectly.

kedom1337 commented 4 months ago

I have exactly the same problem as described above. As soon as I uninstall the angular parser the problem is "resolved".

dlvandenberg commented 4 months ago

Which version are you on? Do you have a plugin in ~/.config/nvim/plugin/angular.lua with the following:

vim.filetype.add({
  pattern = {
    [".*%.component%.html"] = "angular.html",
  },
})

vim.api.nvim_create_autocmd("FileType", {
  pattern = "angular.html",
  callback = function()
    vim.treesitter.language.register("angular", "angular.html")
  end,
})

?

gipo355 commented 4 months ago

Yes this is exactly my configuration.

On latest version.

The file loads correctly the template shows correct highlights.

It's only when I start editing in insert mode the html that it crashes

dlvandenberg commented 4 months ago

Which version of nvim?

gipo355 commented 4 months ago

sorry, i'm on:

NVIM v0.10.0-dev-2968+g344906a08
Build type: RelWithDebInfo
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info

going to post a gif

gipo355 commented 4 months ago

Peek 2024-04-24 09-52

iurimateus commented 4 months ago

dmesg [ 1498.701484] traps: nvim[14271] general protection fault ip:7e05c2e30e3e sp:7ffcba90ba70 error:0 in libc.so.6[7e05c2db9000+15b000]

journalctl

Apr 24 iuri-Arch kernel: traps: nvim[14271] general protection fault ip:7e05c2e30e3e sp:7ffcba90ba70 error:0 in libc.so.6[7e05c2db9000+15b000]
Apr 24 iuri-Arch systemd[1]: Created slice Slice /system/systemd-coredump.
Apr 24 iuri-Arch systemd[1]: Started Process Core Dump (PID 14512/UID 0).
Apr 24 iuri-Arch systemd-coredump[14513]: [🡕] Process 14271 (nvim) of user 1000 dumped core.

                                                   Stack trace of thread 14271:
                                                   #0  0x00007e05c2e30e3e __libc_free (libc.so.6 + 0x9be3e)
                                                   #1  0x00007e05c080afa1 n/a (/home/iuri/.local/share/nvim/lazy/nvim-treesitter/parser/angular.so + 0x6fa1)
                                                   ELF object binary architecture: AMD x86-64
Apr 24 iuri-Arch systemd[1]: systemd-coredump@0-14512-0.service: Deactivated successfully.
dlvandenberg commented 4 months ago

@JustLinuxUser @francisco-morales97 @kedom1337 @iurimateus are you all using neovim 0.10.x? Maybe I can pinpoint the issue from there.

iurimateus commented 4 months ago

@JustLinuxUser @francisco-morales97 @kedom1337 @iurimateus are you all using neovim 0.10.x? Maybe I can pinpoint the issue from there.

Yes

gipo355 commented 4 months ago

am on arch(i3) too

iurimateus commented 4 months ago

I've bisected to https://github.com/neovim/neovim/commit/05f9db1c6d5ff525fecafd67f96ce064ba4c6055

v0.22.3 and v0.22.5 (current on nvim 0.10.x) also crashes

dlvandenberg commented 4 months ago

I will try to update this to the latest tree-sitter to see if that fixes it

gipo355 commented 4 months ago

dmesg [19793.572692] traps: nvim[1181103] general protection fault ip:77dc38713e3e sp:7fffc9cb6750 error:0 in libc.so.6[77dc3869c000+15b000]

journalctl

systemd-coredump[1182627]: [🡕] Process 1181103 (nvim) of user 1000 dumped core.

                                                  Stack trace of thread 1181103:
                                                  #0  0x000077dc38713e3e __libc_free (libc.so.6 + 0x9be3e)
                                                  #1  0x000077dc35a74fa1 n/a (/home/wolf/.local/share/nvim/lazy/nvim-treesitter/parser/angular.so + 0x6fa1)
                                                  ELF object binary architecture: AMD x86-64
dlvandenberg commented 4 months ago

It seems that the issue is in the scanner with the latest tree-sitter version. See related issue: https://github.com/virchau13/tree-sitter-astro/issues/26

gipo355 commented 4 months ago

just tried updating everything but it didn't help

francisco-morales97 commented 4 months ago

@JustLinuxUser @francisco-morales97 @kedom1337 @iurimateus are you all using neovim 0.10.x? Maybe I can pinpoint the issue from there.

Sorry I'm late. The version I'm using is the following: NVIM v0.9.5 Build type: Release LuaJIT 2.1.1710088188

I'm also using the configuration you suggested for ~/.config/nvim/plugins/angular.lua

kedom1337 commented 4 months ago

I am also using v0.10.x

NVIM v0.10.0-dev-2854+g49983387ff
Build type: RelWithDebInfo
LuaJIT 2.1.1710088188
Run "nvim -V1 -v" for more info