amarakon / nvim-cmp-buffer-lines

nvim-cmp completion source for buffer lines

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fails on lines with indentation.

jihedmastouri opened this issue · comments

I am trying to use this plugin to replace the default .

In this example, the plugin does not give any suggestions. (This is also my config)
image

At the beginning of the line, it works like a charm.
image

I think It would be better to ignore whitespaces/indetations at the start of the line.

Unfortunately, I do not think this is possible with the way nvim-cmp works. The code that governs the suggestions is this:

function source.get_keyword_pattern()
	return ".*"
end

I can change ".*" to "\\\\[^[:blank:]]*" to make it work on lines with indentation, but that will also mean that you won't be able to complete entries with whitespace in them. If you think I am wrong, and that it is indeed possible to do this, please submit a pull request.

I'm facing the same issue and find it very annoying. Thats I'd love to solve the problem but I don't quite understand the keyword_patterns. The README of cmp is also very bad and does not tell me anything. Could you explain me how this keyword_patterns are meant to work? I know how lua regexs work, but i don't know against what i'm matching and whats the idea in the first place

Ok I think I get it, never mind. It's first of all not LUA regex but POSIX. And the the regex matches against the longest char sequence before the cursor and compares it to the completion items. Isn't "[^[:blank:]].*" a regex that should solve the problem? We simply start at the first non-blank but then everything is allowed (also blanks).