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

Neovim hangs on editing cpp header #371529

Closed
kuznetsss opened this issue Jan 6, 2025 · 2 comments
Closed

Neovim hangs on editing cpp header #371529

kuznetsss opened this issue Jan 6, 2025 · 2 comments
Labels
0.kind: bug Something is broken 6.topic: vim

Comments

@kuznetsss
Copy link
Contributor

Describe the bug

Neovim from nixpkgs hangs with 100% CPU usage when editing a cpp header file. Using neovim from homebrew with the same config works fine. The issue is related to treesitter parser (see steps to reproduce below).

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create file repro.lua:
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
    vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({
        "git",
        "clone",
        "--filter=blob:none",
        "--single-branch",
        "https://github.com/folke/lazy.nvim.git",
        lazypath,
    })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
    {
        "nvim-treesitter/nvim-treesitter",
        build = ":TSUpdate",
        event = { "BufReadPre", "BufNewFile" },
        enabled = true,
        config = function()
            require("nvim-treesitter.configs").setup({
                ensure_installed = "cpp",
                highlight = { enable = true },
                indent = { enable = true },
            })
        end,
    },
}
require("lazy").setup(plugins, {
    root = root .. "/plugins",
})
  1. Create file header.hpp:
class Foo {

    std::function<void()> cb_;
public:
};
  1. nix shell nixpkgs#nvim
  2. nvim -u repro.lua header.hpp
  3. On the line 2 (the empty one after class Foo {), switch to insert mode and type util::
  4. Neovim hangs

Repeating these steps with neovim from homebrew doesn't cause any issue.

Expected behavior

Neovim works fine.

Screenshots

Additional context

➜ nvim -V1 -v
NVIM v0.10.3
Build type: Release
LuaJIT 2.1.1713773202

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/nix/store/fg597yls6lg1kj6ldj6fghgyydc3jj88-neovim-unwrapped-0.10.3/share/nvim

Metadata

  • system: "aarch64-darwin"
  • host os: Darwin 23.6.0, macOS 14.7.2
  • multi-user?: yes
  • sandbox: no
  • version: nix-env (Nix) 2.24.11
  • channels(root): "nixpkgs"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixpkgs

Notify maintainers

@manveru @rvolosatovs
Sorry if I ping wrong people here. It is quite challenging to figure out who from neovim team is maintaining the package.


Note for maintainers: Please tag this issue in your PR.


Add a 👍 reaction to issues you find important.

@kuznetsss kuznetsss added the 0.kind: bug Something is broken label Jan 6, 2025
@kuznetsss
Copy link
Contributor Author

Updating locally tree-sitter to 0.24.6 and recompiling neovim with it fixed the issue. I will create a PR to update tree-sitter.

@kuznetsss
Copy link
Contributor Author

Duplicate of #368247.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: vim
Projects
None yet
Development

No branches or pull requests

2 participants