max397574 / care.nvim

care.nvim - Completion And Recommendation Engine for Neovim - WIP
https://max397574.github.io/care.nvim/
GNU General Public License v3.0
105 stars 11 forks source link

bug: Scroll bar shift + length with border = none #79

Closed benlubas closed 2 months ago

benlubas commented 2 months ago

Prerequisites

Neovim Version

NVIM v0.10.1 Build type: Release LuaJIT 2.1.1713773202 Run "nvim -V1 -v" for more info

care.nvim setup

care.setup({
  ui = {
    menu = {
      border = "none",
      max_width = 25,
      format_entry = function(entry, data)
        local deprecated = entry.completion_item.deprecated or
        vim.tbl_contains(entry.completion_item.tags or {}, 1)
        local completion_item = entry.completion_item
        local type_icons = require("care.config").defaults.ui.type_icons
        -- TODO: remove since now can only be number, or also allow custom string kinds?
        local entry_kind = type(completion_item.kind) == "string" and completion_item.kind or
        require("care.utils.lsp").get_kind_name(completion_item.kind)
        return {
          { {
            " " .. require("care.presets.utils").LabelEntries(labels)(entry, data) .. " ",
            "Comment",
          } },
          { { completion_item.label:sub(1, 26), deprecated and "@lsp.mod.deprecated" or "@care.entry" } },
          {
            {
              " " .. (type_icons[entry_kind] or type_icons.Text),
              ("@care.type.%s"):format(entry_kind),
            },
          },
        }
      end,
    },
    docs_view = {
      max_height = 10,
      max_width = 80,
      border = "none",
    },
    ghost_text = {
      enabled = false,
    },
  },
  snippet_expansion = require("luasnip").lsp_expand,
  sources = { },
  preselect = false,
})

Actual behavior

Scroll bar is shifted down one, and can become too long:

image

This appears to not happen with a rounded border.

Expected behavior

I expect that the scroll bar matches the completion menu seamlessly

Healthcheck

this doesn't exist?

Steps to reproduce

use config above, complete vim.api.nvim_

Other information

Just want to document this, I know you're aware of it

Minimal config

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 = {
    -- do not remove the colorscheme!
    { "folke/tokyonight.nvim" },
    {
        "max397574/care.nvim",
        dependencies = { "max397574/care-lsp" },
        config = function()
            care.setup({
                ui = {
                  menu = {
                    border = "rounded",
                  }
                }
            })
            vim.keymap.set("i", "<c-n>", function()
                vim.snippet.jump(1)
            end)
            vim.keymap.set("i", "<c-p>", function()
                vim.snippet.jump(-1)
            end)
            vim.keymap.set("i", "<c-space>", function()
                require("care").api.complete()
            end)

            vim.keymap.set("i", "<cr>", "<Plug>(CareConfirm)")
            vim.keymap.set("i", "<c-e>", "<Plug>(CareClose)")
            vim.keymap.set("i", "<tab>", "<Plug>(CareSelectNext)")
            vim.keymap.set("i", "<s-tab>", "<Plug>(CareSelectPrev)")

            vim.keymap.set("i", "<c-f>", function()
                if require("care").api.doc_is_open() then
                    require("care").api.scroll_docs(4)
                else
                    vim.api.nvim_feedkeys(vim.keycode("<c-f>"), "n", false)
                end
            end)

            vim.keymap.set("i", "<c-d>", function()
                if require("care").api.doc_is_open() then
                    require("care").api.scroll_docs(-4)
                else
                    vim.api.nvim_feedkeys(vim.keycode("<c-f>"), "n", false)
                end
            end)
        end,
    },
    {
        "neovim/nvim-lspconfig",
        config = function()
            require("lspconfig")["lua_ls"].setup({})
        end,
    },
    -- =========TODO=============
    -- your lspconfig stuff here
    -- =========TODO=============
    -- add any other pugins here
}
require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

-- add anything else here
vim.opt.termguicolors = true
-- do not remove the colorscheme!
vim.cmd([[colorscheme tokyonight]])
max397574 commented 2 months ago

should be fixed now works for me locally

if you still have issues please reopen