Skip to content

bug: 'width' key must be a positive Integer when scrolling through completion candidates #161

@redbeardymcgee

Description

@redbeardymcgee

Prerequisites

  • I am using the latest stable or nightly neovim version
  • I am using the latest version of the plugin

Neovim Version

NVIM v0.11.5 Build type: Release LuaJIT 2.1.1741730670

care.nvim setup

require("care").setup({
        snippet_expansion = function(body)
          require("luasnip").lsp_expand(body)
        end,
        ui = {
          docs = {
            advanced_styling = true,
          },
          menu = {
            -- TODO: Add colorful-menu highlights
            -- format_entry = function(entry) end,
          },
          -- FIXME: Sometimes reports this is unavailable, maybe lazy-loading issue
          type_icons = "lspkind",
        },
      })

      local function map(keys, mapping, desc)
        vim.keymap.set("i", keys, mapping, { desc = desc })
      end

      -- Perform completion
      map("<C-Space>", function()
        require("care").api.complete()
      end, "Confirm completion")
      map("<C-y>", "<Plug>(CareConfirm)", "Confirm completion")
      map("<C-e>", "<Plug>(CareClose)", "Close completion")
      map("<C-n>", "<Plug>(CareSelectNext)", "Select next completion")
      map("<C-p>", "<Plug>(CareSelectPrev)", "Select previous completion")

      -- Documentation for current completion
      map("<C-k>", function()
        require("care").api.get_documentation()
      end)
      map("<C-f>", function()
        local care = require("care")
        if care.api.doc_is_open() then
          care.api.scroll_docs(4)
        else
          vim.api.nvim_feedkeys(vim.keycode("<c-f>"), "n", false)
        end
      end)
      map("<C-b>", function()
        local care = require("care")
        if care.api.doc_is_open() then
          care.api.scroll_docs(-4)
        else
          vim.api.nvim_feedkeys(vim.keycode("<c-b>"), "n", false)
        end
      end)
      map("<C-K>", function()
        local documentation = require("care").api.get_documentation()
        if #documentation == 0 then
          return
        end
        local old_win = vim.api.nvim_get_current_win()
        vim.cmd.wincmd("v")
        local buf = vim.api.nvim_create_buf(false, true)
        vim.bo[buf].ft = "markdown"
        vim.api.nvim_buf_set_lines(buf, 0, -1, false, documentation)
        vim.api.nvim_win_set_buf(0, buf)
        vim.api.nvim_set_current_win(old_win)
      end, "Open documentation in split")
    end,

Actual behavior

It doesn't always seem to throw the error (maybe it won't throw the error if you trigger the binding too fast?), and it does seem to scroll through the list most of the time.

E5108: Error executing lua: ...pack/myNeovimPackages/opt/care/lua/care/utils/window.lua:86: 'width' key must be a positive Integer
stack traceback:
	[C]: in function 'nvim_open_win'
	...pack/myNeovimPackages/opt/care/lua/care/utils/window.lua:86: in function 'open_cursor_relative'
	...ir/pack/myNeovimPackages/opt/care/lua/care/menu/init.lua:137: in function 'open_docs_window'
	...ir/pack/myNeovimPackages/opt/care/lua/care/menu/init.lua:162: in function 'fn'
	.../pack/myNeovimPackages/opt/care/lua/care/utils/async.lua:72: in function 'draw_docs'
	...ir/pack/myNeovimPackages/opt/care/lua/care/menu/init.lua:207: in function 'select'
	...ir/pack/myNeovimPackages/opt/care/lua/care/menu/init.lua:230: in function 'select_next'
	...ack-dir/pack/myNeovimPackages/opt/care/lua/care/init.lua:31: in function 'select_next'
	...dir/pack/myNeovimPackages/opt/care/lua/care/mappings.lua:29: in function 'callback'
	...dir/pack/myNeovimPackages/opt/care/lua/care/mappings.lua:16: in function <...dir/pack/myNeovimPackages/opt/care/lua/care/mappings.lua:14>

Expected behavior

Navigate the completion list.

Healthcheck

care:                                                                     1 ❌

care.nvim ~
- Checking configuration...
- Format entry function:
- Format entry function returns correct value
- Alignments:
- All alignments are correct
- 
- Checking dependencies...
- ❌ ERROR Critical: dependency 'fzy' not found
- Check installation instructions for you package manager in the documentation

Note: This error is a false positive. fzy --version returns fzy 1.1 © 2014-2025 John Hawthorn. Not sure why care can't find it.

Steps to reproduce

I am editing this file with https://github.com/onlyati/quadlet-lsp. Triggering completion on Network= throws the error.

## navidrome.container
[Container]
AutoUpdate=registry
ContainerName=navidrome
Environment=foo=bar
EnvironmentFile=/tmp/env
Group=1234
HostName=navidrome
Image=docker.io/deluan/navidrome
Network=host
PublishPort=4533:4533
Timezone=Etc/UTC
User=bin
UserNS=keep-id:uid=200,gid=210
Volume=navidrome-data.volume:/data:Z
Volume=/path/to/music:/music:ro,z

[Unit]
Description=Navidrome

[Install]
WantedBy=multi-user.target

[Service]
Restart=on-failure
TimeoutStartSec=900

Log

care doesn't log anything, for some reason. I suspect the error is not in care, so not caught by care, but is triggered by something care does when constructing the completion list.

Other information

The issue doesn't seem to happen unless I'm operating from a working directory that is the parent of this file. The LSP working directory, then, is one level up. This could be part of the problem, but I have also had this issue occur on another file in a different project without this quirk.

Minimal config

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    {
        "max397574/care.nvim",
        -- dependencies = {
        --     -- sources
            -- -- if you have issues with luarocks
            -- "romgrk/fzy-lua-native"
        -- },
        config = function()
            -- keymappings, `require"care.config".setup(...)`
        end
    },
  },
  -- if you have issues with luarocks
  -- pkg = { sources = { nil } },
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions