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: cmp ghost text causes errors during task submission from task editor #327

Open
abhinavnatarajan opened this issue Jul 8, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@abhinavnatarajan
Copy link

Neovim version (nvim -v)

v0.10.0 release

Operating system/version

Ubuntu 23.10 on WSL2 in Windows 11

Describe the bug

If a task is submitted from the task editor while ghost text is present on the task editor form, I get hundreds of errors from nvim_cmp. These errors are not present if the autocomplete hover menu is manually closed before submitting the task.

What is the severity of this bug?

tolerable (can work around it)

Steps To Reproduce

  1. nvim -u repro.lua
  2. Setup a task template with parameters.
  3. :OverseerRun and select the template.
  4. <CR> until the last parameter in the task editor form, ensure that the autocomplete suggestion meny is open and ghost text is visible, and <CR> to submit.

Expected Behavior

The ghost text is ignored for task submission.

Minimal example file

Example main.cpp:

#include <iostream>

int main()
{
	std::cout << "Success" << std::endl;
	return 0;
}

Example CMakeLists.txt:

project(test LANGUAGES CXX)
add_executable(main main.cpp)

Minimal init.lua

-- DO NOT change the paths and don't remove the colorscheme
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 = {
  "folke/tokyonight.nvim",
  { "stevearc/dressing.nvim", config = true },
  {
    "stevearc/overseer.nvim",
    config = function()
      require("overseer").setup({
        -- add your overseer config here
      })
    end,
  },
  -- add any other plugins here
  {
    'hrsh7th/nvim-cmp',
    opts = {
      experimental = {
        ghost_text = true
      }
    }
  }
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Additional context

Example lua/overseer/template/cmake.lua:

return {
	params = function()
		return {
			build_dir = {
				name = "Build directory",
				desc = "Relative/absolute path to the build directory",
				type = "string",
				optional = false,
				default = vim.fs.joinpath(vim.fn.getcwd(), "build")
			},
			source_dir = {
				name = "Source tree",
				desc = "Relative/absolute path to the source tree",
				type = "string",
				optional = false,
				default = vim.fs.root(search.dir, { 'CMakeLists.txt', 'CMakePresets.json', 'CMakeUserPresets.json' })
			},
			cmake_args = {
				name = "CMake arguments",
				desc = "Additional arguments to pass to CMake",
				type = "string",
				optional = true,
				default = ""
			}
		}
	end,
	builder = function(params)
		return {
			cmd = "cmake",
			args = { "-S", params.source_dir, "-B", params.build_dir, params.cmake_args }
		}
	end,
	condition = {
		callback = function(search)
			if not vim.fs.root(search.dir, { 'CMakeLists.txt', 'CMakePresets.json', 'CMakeUserPresets.json' }) then
				return false, "CMakeLists.txt, CMakePresets.json or CMakeUserPresets.json not found"
			end
			if not vim.fn.executable("cmake") then
				return false, 'Command "cmake" not found'
			end
			return true
		end,
	},
}
@abhinavnatarajan abhinavnatarajan added the bug Something isn't working label Jul 8, 2024
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

1 participant