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

fix: cmp popupmenu position #183

Merged
merged 1 commit into from
Nov 11, 2022
Merged

fix: cmp popupmenu position #183

merged 1 commit into from
Nov 11, 2022

Conversation

wangl-cc
Copy link
Contributor

Currently, the popupmenu position of cmp is not aligned with input of smart-cmdline, because of its offset. Adjust the screen cursor position with offset should fix it. I try to access the offset directly by Cmdline.last().offset, but I'm not sure it's the right way.

Before

截屏2022-10-31 13 34 38

After

截屏2022-10-31 13 35 05

@folke
Copy link
Owner

folke commented Nov 10, 2022

Hi! I think I may have fixed this over the last couple of days, since for me at least it looks correct without this PR.

Can you check again in your config?

@wangl-cc
Copy link
Contributor Author

Hi, I can reproduce this with this minimal init.lua:

init.lua
vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.cmd([[set packpath=/tmp/nvim/site]])
local package_root = "/tmp/nvim/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
  require("packer").startup({
    {
      "wbthomason/packer.nvim",
      {
        "folke/noice.nvim",
        requires = {
          "MunifTanjim/nui.nvim",
          "rcarriga/nvim-notify",
        },
      },
      {
        "folke/tokyonight.nvim",
      },
      {
        "hrsh7th/nvim-cmp",
        requires = {
          "hrsh7th/cmp-cmdline",
        },
      }
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. "/plugin/packer_compiled.lua",
      display = { non_interactive = true },
    },
  })
end
_G.load_config = function()
  vim.opt.termguicolors = true
  vim.cmd([[colorscheme tokyonight]])
  require("noice").setup()
  -- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
  local cmp = require "cmp"
  cmp.setup {}
  cmp.setup.cmdline(":", {
    mapping = cmp.mapping.preset.cmdline(),
    sources = {
      { name = "path", max_item_count = 5 },
      { name = "cmdline", max_item_count = 10 },
    },
  })
end
if vim.fn.isdirectory(install_path) == 0 then
  print("Installing Noice and dependencies.")
  vim.fn.system({ "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path })
end
load_plugins()
require("packer").sync()
vim.cmd([[autocmd User PackerComplete ++once echo "Ready!" | lua load_config()]])
2022-11-11.11.53.00.mov

@folke folke merged commit 8db0420 into folke:main Nov 11, 2022
@folke
Copy link
Owner

folke commented Nov 11, 2022

Merged. Thank you!

@wangl-cc wangl-cc deleted the cmp-pos branch November 11, 2022 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants