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

Selecting prev/next in cmdline removes line range markers (<,>) #1092

Open
2 tasks done
Davidyz opened this issue Jan 26, 2025 · 3 comments · May be fixed by #1155
Open
2 tasks done

Selecting prev/next in cmdline removes line range markers (<,>) #1092

Davidyz opened this issue Jan 26, 2025 · 3 comments · May be fixed by #1155
Labels
bug Something isn't working

Comments

@Davidyz
Copy link

Davidyz commented Jan 26, 2025

Make sure you have done the following

  • Updated to the latest version of blink.cmp
  • Searched for existing issues and documentation (try <C-k> on https://cmp.saghen.dev)

Bug Description

After visually selecting some lines and trying to type a command, for example :<,>s/foo/bar/ (<,> is automatically added by neovim as the selection range markers), when you just finished typing s and press <Up> (binded to "select_prev" when using enter preset), the completion menu will erase the <,> markers. The completion only works as intended if there is a space before s, for example: :<,> s/foo/bar/. Similar behaviour was observed when manually typing the line ranges, like :3,5s/foo/bar/ won't work, but :3,5 s/foo/bar/ will.

Relevant configuration

-- Run with `nvim -u repro.lua`

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

---@diagnostic disable-next-line: missing-fields
require('lazy.minit').repro({
  spec = {
    {
      'saghen/blink.cmp',
      -- please test on `main` if possible
      -- otherwise, remove this line and set `version = '*'`
      build = 'cargo build --release',
      opts = {
        keymap = { cmdline = { preset='enter' }},
      },
    },
    {
      'neovim/nvim-lspconfig',
      opts = {
        servers = {
          lua_ls = {},
        },
      },
      config = function(_, opts)
        local lspconfig = require('lspconfig')
        for server, config in pairs(opts.servers) do
          -- passing config.capabilities to blink.cmp merges with the capabilities in your
          -- `opts[server].capabilities, if you've defined it
          config.capabilities = require('blink.cmp').get_lsp_capabilities()
          lspconfig[server].setup(config)
        end
      end,
    },
  },
})

neovim version

v0.10.3

blink.cmp version

main

@Davidyz Davidyz added the bug Something isn't working label Jan 26, 2025
@solidtesting
Copy link

I've submitted a fix for this issue in PR #1155 .

@Davidyz
Copy link
Author

Davidyz commented Feb 5, 2025

Hi, thanks for the fix! It works for visual range selection (:'<,'>), but for line number ranges (:3,5) it doesn't seem to be working. Is it possible to fix this as well?

@ranjithshegde
Copy link

Thank you for working on the fix!!!
I think the parsing has to be extended for a general list of special characters as well. doing :echo &buf<completion_key> inserts the selection and removes &

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

Successfully merging a pull request may close this issue.

3 participants