Skip to content

bug: not working in blink.cmp #310

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

Closed
2 tasks done
nfwyst opened this issue Jan 28, 2025 · 1 comment
Closed
2 tasks done

bug: not working in blink.cmp #310

nfwyst opened this issue Jan 28, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@nfwyst
Copy link

nfwyst commented Jan 28, 2025

Neovim version (nvim -v)

0.10.3

Neovim distribution

LazyVim

Operating system

MacOS

Terminal emulator / GUI

WezTerm

Describe the bug

when use markdown source in blink.cmp it show error: failed to get completions with error: .../neovim/0.10.3/share/nvim/runtime/lua/vim/treesitter.lua:382: Invalid position: row and col must be non-negative

Expected behavior

show not show error notify

Healthcheck output

render-markdown: require("render-markdown.health").check()

render-markdown.nvim [version] ~
- OK plugin 7.8.9
- OK neovim >= 0.10

render-markdown.nvim [configuration] ~
- OK valid

render-markdown.nvim [nvim-treesitter] ~
- OK installed
- OK markdown: parser installed
- OK markdown: highlight enabled
- OK markdown_inline: parser installed
- OK markdown_inline: highlight enabled
- OK latex: parser installed

render-markdown.nvim [icons] ~
- OK using: mini.icons

render-markdown.nvim [executables] ~
- WARNING latex2text: not installed
  - ADVICE:
    - Disable LaTeX support to avoid this warning by setting { latex = { enabled = false } }

render-markdown.nvim [conflicts] ~
- OK headlines: not installed
- OK obsidian: installed but should not conflict

Plugin configuration

local ft = { "markdown", "Avante", "codecompanion", "octo" }
local anti_conceal = { enabled = false }

return {
  "MeanderingProgrammer/render-markdown.nvim",
  ft = ft,
  dependencies = {
    {
      "saghen/blink.cmp",
      module = false,
      opts = function(_, opts)
        PUSH(opts.sources.default, "markdown")
        opts.sources.providers.markdown = {
          name = "RenderMarkdown",
          module = "render-markdown.integ.blink",
        }
      end,
    },
  },
  opts = {
    render_modes = { "n", "i", "no", "c", "t", "v", "V", "" },
    file_types = ft,
    latex = {
      render_modes = true,
    },
    heading = {
      sign = true,
      render_modes = true,
      icons = { "󰎥 ", "󰎨 ", "󰎫 ", "󰎲 ", "󰎯 ", "󰎴 " },
    },
    paragraph = {
      render_modes = true,
      left_margin = 2,
    },
    code = {
      sign = true,
      width = "full",
      render_modes = true,
    },
    dash = {
      render_modes = true,
    },
    bullet = {
      render_modes = true,
    },
    checkbox = {
      enabled = true,
      render_modes = true,
    },
    quote = {
      render_modes = true,
    },
    pipe_table = {
      render_modes = true,
    },
    link = {
      render_modes = true,
    },
    inline_highlight = {
      render_modes = true,
    },
    html = {
      render_modes = true,
    },
    overrides = {
      buflisted = {
        [false] = { anti_conceal = anti_conceal },
      },
      buftype = {
        nofile = { anti_conceal = anti_conceal },
      },
    },
    win_options = {
      concealcursor = {
        rendered = "nvic",
      },
    },
  },
}

Plugin error log

N/A

Confirmations

  • I have updated this plugin to the latest version using my plugin manager
  • I have provided the text contained in all screenshots as raw text in this issue. This means if there is a screenshot below it is the copy pasted contents of the file in the screenshot. I understand that my issue will be closed if I have not.

Additional information

No response

@nfwyst nfwyst added the bug Something isn't working label Jan 28, 2025
MeanderingProgrammer added a commit that referenced this issue Jan 28, 2025
## Details

Issue: #310

`nvim-cmp` passes the cursor position as a (1,1)-indexed value by
adjusting the column output of `nvim_win_get_cursor`.

`blink.cmp` does not make this adjustment and directly passes the
(1,0)-indexed value from `nvim_win_get_cursor`.

Previously we did not handle this difference and would subtract 1 from
the column resulting in an exception due to negative values. The fix is
to account for this difference when adjusting the values to treesitter's
(0,0)-indexed APIs.

I'm not 100% sure why this did not crop up before while testing but
likely related to this note from the `0.11.0` release:

> [!IMPORTANT]
> Blink.cmp now fetches the completion items immediately upon entering
> insert mode by default. More ideas for prefetching are being explored!

So we still had the off by 1 column issue but since items were not being
pre-fetched and due to the trigger characters configuration the column
would always be > 0, so it would not error.
@MeanderingProgrammer
Copy link
Owner

Thanks for letting me know! I don't currently use blink.cmp as my main completion engine so didn't catch this.

Fixed the issue here: c85d682

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

2 participants