From 1864f3950e39ab1ded1ef8ae6fb1c6d8a765c266 Mon Sep 17 00:00:00 2001 From: hrsh7th Date: Tue, 10 Aug 2021 19:25:04 +0900 Subject: [PATCH] Fix digits pattern --- lua/cmp_buffer/buffer.lua | 2 +- lua/cmp_buffer/init.lua | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/cmp_buffer/buffer.lua b/lua/cmp_buffer/buffer.lua index c333b29..478c035 100644 --- a/lua/cmp_buffer/buffer.lua +++ b/lua/cmp_buffer/buffer.lua @@ -99,7 +99,7 @@ function buffer.index_line(self, i, line) local s, e = self:matchstrpos(buf) if s then local word = string.sub(buf, s, e - 1) - if #word > 1 and string.match(word, '%a$') then + if #word > 1 and string.match(word, '[%a%d]$') then table.insert(words, word) end end diff --git a/lua/cmp_buffer/init.lua b/lua/cmp_buffer/init.lua index f0626d4..9381567 100644 --- a/lua/cmp_buffer/init.lua +++ b/lua/cmp_buffer/init.lua @@ -28,11 +28,12 @@ source.complete = function(self, request, callback) end vim.defer_fn(vim.schedule_wrap(function() + local input = string.sub(request.context.cursor_before_line, request.offset) local items = {} local words = {} for _, buf in ipairs(self:_get_buffers(request)) do for _, word in ipairs(buf:get_words()) do - if not words[word] then + if not words[word] and input ~= word then words[word] = true table.insert(items, { label = word,