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

Cmdline completion does not provide arg lead input to custom command completion #696

Closed
2 tasks done
kristijanhusak opened this issue Dec 21, 2024 · 5 comments
Closed
2 tasks done
Labels
bug Something isn't working cmdline Related to the command line

Comments

@kristijanhusak
Copy link

Make sure you have done the following

  • I have updated to the latest version of blink.cmp
  • I have read the README

Bug Description

New cmdline completion does not provide "arg_lead" to the custom command completion. Steps to reproduce:

  1. Open configuration below: nvim -u mininit.lua
  2. Type :Find something
  3. Type :messages, you will see only ARG LEAD

Expected:
To see ARG LEAD something in :messages.

Relevant configuration

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 = {
    {
      'Saghen/blink.cmp',
      version = '0.*',
      opts = {},
    },
  },
})

vim.api.nvim_create_user_command('Find', function() end, {
  force = true,
  nargs = '?',
  complete = function(arg_lead)
    print('ARG LEAD', arg_lead)
  end,
})

neovim version

0.10.2

blink.cmp version: branch, tag, or commit

0.8.0

@kristijanhusak kristijanhusak added the bug Something isn't working label Dec 21, 2024
@Saghen
Copy link
Owner

Saghen commented Dec 21, 2024

This was done intentionally to prevent the complete functions from filtering out items. If you type :Find foo=bar, it'll pass foo= as the arg lead. What's your use case for having the whole arg lead though?

@Saghen Saghen added the cmdline Related to the command line label Dec 21, 2024
@kristijanhusak
Copy link
Author

I have a custom :Find command to use as a fuzzy finder (https://github.com/kristijanhusak/neovim-config/blob/master/nvim/after/plugin/find.lua). I use ripgrep to filter down the results. If I return all results instead of slicing them on half, it works, so that part is more/less solved.

The bigger issue for me is autocompletion on input() function. In orgmode, there is an option to move a specific headline to another file. This opens up an input prompt, and allows autocompleting files where the headline should be moved. With cmdline enabled, it is not working. If I set cmdline = {'cmdline'}, it autocompletes, but not what I set in the complete function.
I'm not sure if you are an orgmode user, so here's a simple example in vimscript:

function! DoAutocomplete(A,L,P) abort
  return ['one', 'two', 'three']
endfunction

call input('test: ', '', 'customlist,DoAutocomplete')

With cmdline disabled, sourcing this file and pressing tab autocompletes "one,two,three". With cmdline with default value, or set to {'cmdline'}, it does not return anything.

@Saghen Saghen closed this as completed in 4c2744d Dec 31, 2024
@kristijanhusak
Copy link
Author

Thanks for the fix. This fixes the issue with input, but it breaks the regular completion for commands. For example, if you use telescope, try doing :Telescope f. You get an error:

Error while fetching completions: Vim:E475: Invalid argument:

That's because getcmdcompltype() returns empty string in that case.

Saghen added a commit that referenced this issue Dec 31, 2024
@Saghen
Copy link
Owner

Saghen commented Dec 31, 2024

Fixed on main, thanks!

@justicenyaga
Copy link

justicenyaga commented Jan 2, 2025

I'm still getting the following error on version 0.9.0 when I type commands such as :Telescope f

Error while fetching completions: Vim:E5108: Error executing Lua function: attempt to call a number value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cmdline Related to the command line
Projects
None yet
Development

No branches or pull requests

3 participants