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

[Bug]: Freezes the nvim instance if used alongside Comment.nvim #209

Closed
aidigital opened this issue Dec 30, 2024 · 7 comments
Closed

[Bug]: Freezes the nvim instance if used alongside Comment.nvim #209

aidigital opened this issue Dec 30, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@aidigital
Copy link

aidigital commented Dec 30, 2024

Description

Hi,

I've noticed that when used alongside Comment.nvim, dropbar.nvim will lead to the nvim instance completely freezing.

The freeze happens mostly on opening .nix files and after V-isually selecting a 50-ish block of code/text and trying to delete it or running gcc.
However I did notice the freeze on .rs files, after deleting a single line and trying to save.
In conclusion, freezing doesn't seem related to a specific file-type or operation (sometimes it froze as soon as I tried opening a file), but rather to using dropbar alongside Comment.nvim.

nvim version

v0.10.3

dropbar.nvim version

e5f9fb9

Operating system and version

Linux 6.9.3

Minimal config

See below the config used with lazy.nvim, or with nixvim.
You'll probably use lazy.nvim as that's more common; I am a nixvim uses so that's why I included that config, plus it's very short.

Steps to reproduce

Below I have two minimal configs to reproduce this, lazy.nvim and nixvim.

lazy.nvim config

-- plugins.lua
return {
	{
	    'numToStr/Comment.nvim',
	    opts = {
		-- add any options here
	    }
	},

	{
		"Bekaboo/dropbar.nvim",
		-- optional, but required for fuzzy finder support
		dependencies = {
			"nvim-telescope/telescope-fzf-native.nvim",
			build = "make",
		},
		config = function()
			local dropbar_api = require("dropbar.api")
			vim.keymap.set("n", "<leader>j", dropbar_api.pick, { desc = "Pick symbols in winbar" })
			vim.keymap.set("n", "[;", dropbar_api.goto_context_start, { desc = "Go to start of current context" })
			vim.keymap.set("n", "];", dropbar_api.select_next_context, { desc = "Select next context" })
		end,
	},

	{ "nvim-treesitter/nvim-treesitter" }, -- added this because w/o it, dropbar doesnt seem to show up
}
-- init.lua
require("config.lazy")

lazy-lock.json:

{
  "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
  "dropbar.nvim": { "branch": "master", "commit": "e5f9fb998a54c0ec1c2d25de88a3c260c494ffe1" },
  "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" },
  "nvim-treesitter": { "branch": "master", "commit": "7e0fcf0d456fc5818da1af35b1a3f5c784fce457" },
  "telescope-fzf-native.nvim": { "branch": "main", "commit": "dae2eac9d91464448b584c7949a31df8faefec56" }
}

nixvim config

{pkgs}: let
in {
  enable = true;
  globals.mapleader = " ";

  plugins = {
    # comment.enable = true;
  };

  extraPlugins = with pkgs.vimPlugins; [
    dropbar-nvim
    comment-nvim # either use this or the above comments.enable in plugins
   # unlike with lazy.nvim, here we don't need nvim-treesitter for dropbar to work (and  freeze nvim when used alongside comment-nvim)
  ];
}

Expected behavior

No freeze.

Actual behavior

What happens exactly:

  • the nvim process freezes completely. CPU core utilization goes 100%. I have to kill the tmux tab running nvim.

If I remove either dropbar or Comment, no freeze.

Additional information

No response

@aidigital aidigital added the bug Something isn't working label Dec 30, 2024
@aidigital
Copy link
Author

aidigital commented Dec 30, 2024

For some reason, it appears that enabling treesitter highlights fixes the problem (i.e. using dropbar and Comment.nvim together no longer leads to neovim freezing).

Thankfully, this works ...
... both when managing the configuration with lazy,nvim ...

-- init.lua
require("nvim-treesitter.configs").setup({
	["highlight"] = { ["enable"] = true },
})

... or with nixvim

  # ...
  plugins = {
    treesitter = {
      enable = true; 
      gccPackage = null; 
      settings = {
          highlight.enable = true;
      };
    };
  };
}

Interesting, to say the least.

@Bekaboo
Copy link
Owner

Bekaboo commented Dec 31, 2024

Please use the minimal config provided to reproduce the bug without a package manager, or at least provide config with lazy.nvim bootstrap code, not only the plugin specs.

@aidigital
Copy link
Author

In the lazy.nvim config section I provided all the config necessary to reproduce the bug with lazy.nvim.
But as I mentioned in my second message, I managed to fix the problem with the below config.

-- init.lua
require("nvim-treesitter.configs").setup({
	["highlight"] = { ["enable"] = true },
})

Would be nice to know the root cause of the problem, but given I found a fix (or at least a workaround), and given the problem manifested itself only when dropbar is used alongside Comment.nvim, not by itself, I'm not sure it's worth your time digging deeper into this, but your call.
I'm happy if you close this bug.

@Bekaboo
Copy link
Owner

Bekaboo commented Jan 2, 2025

Cannot reproduce.

@Kuwagata
Copy link

Kuwagata commented Jan 2, 2025

I'm experiencing a similar issue with regard to freezing while editing nix files and deleting text. I haven't had enough time to locate the root cause, but while trying to sift through which plugins updated recently I disabled dropbar along with a few others. It seemed to prevent or sidestep the issue at first glance, but it could have been one of the other plugins I disabled. I'll test things further tomorrow when I get a chance in the evening.

@Kuwagata
Copy link

Kuwagata commented Jan 3, 2025

Looks like this might be a result of the neovim build in nixpkgs having a mismatched treesitter library or something, which makes sense with the behavior.

@aidigital
Copy link
Author

local tmp = vim.env.TMPDIR or vim.env.TEMPDIR or vim.env.TMP or vim.env.TEMP or "/tmp"
local data = tmp .. "/" .. (vim.env.NVIM_APPNAME or "nvim")
local packages_root = data .. "/site"
local cloned_root = packages_root .. "/pack/packages/start"

local plugins = {
	["Comment.nvim"] = "https://github.com/numToStr/Comment.nvim",
	["dropbar.nvim"] = "https://github.com/Bekaboo/dropbar.nvim",
	["nvim-treesitter"] = "https://github.com/nvim-treesitter/nvim-treesitter",
}

vim.fn.mkdir(cloned_root, "p")
vim.opt.rtp:prepend(packages_root)

vim.opt.pp = {}
vim.opt.pp:prepend(packages_root)

for plugin_name, url in pairs(plugins) do
	local plugin_path = cloned_root .. "/" .. plugin_name
	if not vim.loop.fs_stat(plugin_path) then
		vim.fn.system({ "git", "clone", url, plugin_path })
	end
end

-- This must be done once, then it can be commented out.
-- But w/o this, dropbar does not show up on in the bar in .nix files (and the dropbar.sources module doesnt get loaded).
-- require("nvim-treesitter.configs").setup({
-- 	ensure_installed = {
-- 		"nix",
-- 	},
-- 	-- ["highlight"] = { ["enable"] = true }, -- 👈 fix for nixpks#neovim
-- })

require("Comment").setup({}) --  👈 fix for nixpks#neovim

Above is the minimal.lua with which neovim v0.10.3 from nixpkgs breaks, unless one of the 👈 fixes is made, i.e. either not using Comment.nvim or enabling treesitter highlights.

As @Kuwagata was saying, neovim outside of nixpkgs won't break with the above minimal config (even without the above "fixes", i.e. if Comment.nvim is enabled and the treesitter highlights are not enabled).

This definitely doesn't look like a dropbar bug.

@Bekaboo Bekaboo closed this as not planned Won't fix, can't repro, duplicate, stale Jan 6, 2025
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

3 participants