cmake-tools.nvim
cmake-tools.nvim copied to clipboard
Error during the lazy initialization, when it is triggered by pressing hotkeys
Bug description Hello! Thank you for the great plugin. I encountered a problem when lazy initializing the plugin with keys. Here's the error log
Failed to run `config` for cmake-tools.nvim
...pro/plugins/cmake-tools.nvim/lua/cmake-tools/scratch.lua:9: Failed to save undo information
# stacktrace:
- /cmake-tools.nvim/lua/cmake-tools/scratch.lua:9 _in_ **create**
- /cmake-tools.nvim/lua/cmake-tools/init.lua:1625 _in_ **register_scratch_buffer**
- /cmake-tools.nvim/lua/cmake-tools/init.lua:83 _in_ **setup**_
if I call lazy initialization through cmd by calling any available function, no error occurs (like :CMakeSettings
from Minimal configuration)
Minimal configuration
local root = vim.fn.fnamemodify("./.repro", ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
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 = {
"folke/tokyonight.nvim",
"nvim-lua/plenary.nvim",
{
"Civitasv/cmake-tools.nvim",
lazy = true,
cmd = {
"CMakeSettings"
},
keys = {
{ "cs", "<cmd>CMakeSettings<cr>", desc = "Cmake Settings" },
},
opts = {},
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.cmd.colorscheme("tokyonight")
Steps to reproduce with minimal configuration
- run
nvim -u <Minimal configuration>
(you also need empty CMakeLists.txt) - press
cs
Environment
NVIM v0.9.5 Build type: Release LuaJIT 2.1.1710088188
LazyVim uses this init function and it seems to fix the issue:
init = function()
local loaded = false
local function check()
local cwd = vim.uv.cwd()
if vim.fn.filereadable(cwd .. "/CMakeLists.txt") == 1 then
require("lazy").load({ plugins = { "cmake-tools.nvim" } })
loaded = true
end
end
check()
vim.api.nvim_create_autocmd("DirChanged", {
callback = function()
if not loaded then
check()
end
end,
})
end,
it might help with fixing the underlying issue or just be added to a readme
Use the latest commit, I've fixed it.
It seems that the behavior has now changed, when the plugin is initialized, the *cmake-tools* buffer appears. It looks like the current fix broke the commit https://github.com/Civitasv/cmake-tools.nvim/commit/a4cd0b3a2c8a166a54b36bc00579954426748959
Yes, do you know how to find the buffer whose buflisted is false?
It should disappear now.
I updated to the latest commit, the buffer no longer displays in bufferline but the original problem with lazy still remains
Weird, are you sure that you have updated to the latest commit? Cause I previously had this problem, but now it disappears.
Yes, it doesn't reproduce on the attached repro, but it still reproduces on my configuration, I'll check now
It seems that the problem now occurs not during initialization but when trying to write something into it. Attaching the error log
CMakeBuild Error executing Lua callback: .../share/nvim/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:48: Vim:Error executing Lua callback: ...e/nvim/lazy/cmake-tools.nvim/lua/cmake-tools/scratch.lua:17: Expected Lua number
stack traceback:
[C]: in function 'nvim_buf_set_lines'
...e/nvim/lazy/cmake-tools.nvim/lua/cmake-tools/scratch.lua:17: in function 'append'
...are/nvim/lazy/cmake-tools.nvim/lua/cmake-tools/utils.lua:237: in function <...are/nvim/lazy/cmake-tools.nvim/lua/cmake-tools/utils.lua:220>
[C]: in function 'cmd'
.../share/nvim/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:48: in function <.../share/nvim/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:16>
stack traceback:
[C]: in function 'cmd'
.../share/nvim/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:48: in function <.../share/nvim/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:16>
Check the latest commit.
The issue has been resolved and is no longer occurring. Thank you very much!