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

Vue completion items contain hyphen("-") or start with at("@") can not be matched properly. #808

Closed
2 tasks done
YaQia opened this issue Dec 28, 2024 · 2 comments
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@YaQia
Copy link

YaQia commented Dec 28, 2024

Make sure you have done the following

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

Bug Description

I tried to modify

  exclude_from_prefix_regex = '[\\-]',

into

  exclude_from_prefix_regex = '',

but it breaks my completion, failing to sort the most relevant item first.
If I restores the config to the default one, items started with @ can not be sorted properly as well, and when I type the hypen("-"), all completions are gone.

Relevant configuration

return {
	"saghen/blink.cmp",
	-- optional: provides snippets for the snippet source
	dependencies = "rafamadriz/friendly-snippets",
	-- event = { "InsertEnter", "CmdlineEnter" },
	lazy = true,

	-- use a release tag to download pre-built binaries
	version = "*",
	-- AND/OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust
	-- build = 'cargo build --release',
	-- If you use nix, you can build from source using latest nightly rust with:
	-- build = 'nix run .#build-plugin',

	---@module 'blink.cmp'
	---@type blink.cmp.Config
	opts = {
		-- 'default' for mappings similar to built-in completion
		-- 'super-tab' for mappings similar to vscode (tab to accept, arrow keys to navigate)
		-- 'enter' for mappings similar to 'super-tab' but with 'enter' to accept
		-- See the full "keymap" documentation for information on defining your own keymap.
		keymap = {
			-- set to 'none' to disable the 'default' preset
			preset = "super-tab",

			["<Tab>"] = {
				"select_next",
				"snippet_forward",
				"fallback",
			},
			["<S-Tab>"] = {
				"select_prev",
				"snippet_backward",
				"fallback",
			},
			["<CR>"] = { "accept", "fallback" },
			-- disable a keymap from the preset
			["<C-e>"] = { "hide", "fallback" },
			["<C-space>"] = { "hide", "show" },

			-- show with a list of providers
			-- ["<C-space>"] = {
			-- 	function(cmp)
			-- 		cmp.show({ providers = { "snippets" } })
			-- 	end,
			-- },

			-- control whether the next command will be run when using a function
			-- ["<C-n>"] = {
			-- 	function(cmp)
			-- 		if some_condition then
			-- 			return
			-- 		end -- runs the next command
			-- 		return true -- doesn't run the next command
			-- 	end,
			-- 	"select_next",
			-- },

			-- optionally, separate cmdline keymaps
			cmdline = {
				preset = "super-tab",

				["<Tab>"] = {
					"select_next",
					"fallback",
				},
				["<S-Tab>"] = {
					"select_prev",
					"fallback",
				},
				-- ["<CR>"] = { "accept", "fallback" },
				-- disable a keymap from the preset
				["<C-e>"] = { "hide", "fallback" },
				["<C-space>"] = { "hide", "show" },

				["<CR>"] = {
					function(cmp)
						cmp.accept({
							callback = function()
								vim.api.nvim_feedkeys("\n", "n", true)
							end,
						})
					end,
					"accept",
					"fallback",
				},
			},
		},

		appearance = {
			-- Sets the fallback highlight groups to nvim-cmp's highlight groups
			-- Useful for when your theme doesn't support blink.cmp
			-- Will be removed in a future release
			use_nvim_cmp_as_default = true,
			-- Set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
			-- Adjusts spacing to ensure icons are aligned
			nerd_font_variant = "mono",
		},

		-- Default list of enabled providers defined so that you can extend it
		-- elsewhere in your config, without redefining it, due to `opts_extend`
		sources = {
			default = { "lsp", "path", "snippets", "buffer" },
		},

		completion = {
			list = { selection = "auto_insert" },
			menu = {
				border = "rounded",
			},
			documentation = {
				auto_show = true,
				auto_show_delay_ms = 0,
				window = {
					border = "rounded",
				},
			},
			ghost_text = { enabled = false },
			-- keyword = {
			-- 	range = 'prefix',
			-- 	regex = '[-_@]\\|\\k',
			-- 	exclude_from_prefix_regex = '',
			-- },
		},

		signature = { window = { border = "rounded" } },
	},
	opts_extend = { "sources.default" },
}

neovim version

NVIM v0.10.3 Build type: RelWithDebInfo LuaJIT 2.1.1731601260

blink.cmp version: branch, tag, or commit

v0.8.2 commit 5f44268

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

Saghen commented Dec 29, 2024

Duplicate of #657

@Saghen Saghen marked this as a duplicate of #657 Dec 29, 2024
@Saghen Saghen closed this as not planned Won't fix, can't repro, duplicate, stale Dec 29, 2024
@YaQia
Copy link
Author

YaQia commented Dec 29, 2024

Thanks, I will follow that issue.

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