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

Falied to work with blink-cmp #48

Open
pxwg opened this issue Jan 7, 2025 · 3 comments
Open

Falied to work with blink-cmp #48

pxwg opened this issue Jan 7, 2025 · 3 comments

Comments

@pxwg
Copy link

pxwg commented Jan 7, 2025

大家好,我最近从 nvim-cmp 切换到了 blink,与 rime-ls 结合,如虎添翼感觉非常好用,非常感谢开发者为我们开发的如此流畅好用的中文输入 LSP

但是在中英文混合输入时遇到了一些问题,希望能得到帮助。我清楚这个问题应当来源于 blink,因此我同样在 blink 之中提了 issue#936 。但因为这里的朋友可能更为熟悉这方面的配置,我希望能在这里得到帮助。具体问题如下 (这个问题应当确实与 rime-ls 无关,因此如果不被允许请 feel free to close this issue):

When I input a mixed Chinese-English string like 你好\text{nihao}, I get the following error:

Error executing vim.schedule lua callback: byte index 18446744073709551612 is out of bounds of `你好\text{niha}`

Screenshot as follows:

截屏2025-01-08 01 37 19

After deleting the string, the error keeps occurring even if I type pure English:

Error executing vim.schedule lua callback: runtime error: Failed to acquire lock for frecency

Unless I restart neovim, this issue will persist. The minimal configuration could be

-- blink.lua

return {
  "saghen/blink.cmp",
  opts = {
    sources = {
      -- default = { "lsp", "path", "luasnip", "buffer", "ripgrep", "lazydev" },
      default = { "lsp", "path", "buffer" },
      cmdline = {},
      providers = {
        lsp = {
          min_keyword_length = 2,
          fallbacks = { "ripgrep", "buffer" },
          --- @param items blink.cmp.CompletionItem[]
          transform_items = function(_, items)
            -- demote snippets
            for _, item in ipairs(items) do
              if item.kind == require("blink.cmp.types").CompletionItemKind.Snippet then
                item.score_offset = item.score_offset - 3
              end
            end
            return items
          end,
        },
      },
    },
  },
}

and default rime-ls configuration (in fact, the problem would occur even if I us system Chinese input method, so I think it is not related to rime-ls)

2025-01-08.04.33.36.mov
@wlh320
Copy link
Owner

wlh320 commented Jan 11, 2025

我这边测试了一下,似乎还是跟 neovim 的 LSP 的 position encoding 相关。我发现强制要求 neovim 的 LSP 用 UTF-8 编码(我的配置是这样)时就没有这个问题。去掉相关配置后就会出现该问题。

没仔细看 blink.cmp 的实现,感觉可能是在不同编码的 range 的转换上有些问题?

顺便一提,如果用 UTF-8 编码,你的这个例子输入到 \ 的时候就会让 texlab 先崩溃掉。(这应该是 texlab 不支持不同的 position encoding)

@wlh320
Copy link
Owner

wlh320 commented Jan 12, 2025

还有就是在 neovim 0.11 版本之前,使用 rime-ls 时还是推荐强制用 UTF-8 编码,原因详见 #38

@pxwg
Copy link
Author

pxwg commented Jan 12, 2025

非常感谢!我现在使用的是nightly building,目前已经强制转换为UTF-8 编码,最近这段时间我再多实验一下看一看效果(这个问题在更新到最新版blink.cmp之后变得更隐蔽了,本issue的方式在我这边已经无法复现,但仍然可能偶然出现。我会继续观察)

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

No branches or pull requests

2 participants