From ccae1e8ad123117ac9dffeabd8bc7d122ab0d808 Mon Sep 17 00:00:00 2001 From: Girish Palya Date: Wed, 19 Jul 2023 15:21:07 +0200 Subject: [PATCH] Optimize regex comparison in omnifunc M autoload/lsp/completion.vim --- autoload/lsp/completion.vim | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/autoload/lsp/completion.vim b/autoload/lsp/completion.vim index 70bb2ae..37690a0 100644 --- a/autoload/lsp/completion.vim +++ b/autoload/lsp/completion.vim @@ -441,15 +441,10 @@ def g:LspOmniFunc(findstart: number, base: string): any lspserver.getCompletion(1, '') # locate the start of the word - var line = getline('.') - var start = charcol('.') - 1 - var keyword: string = '' - while start > 0 && line[start - 1] =~ '\k' - keyword = line[start - 1] .. keyword - start -= 1 - endwhile + var line = getline('.')->strpart(0, col('.') - 1) + var keyword = line->matchstr('\k\+$') lspserver.omniCompleteKeyword = keyword - return line->byteidx(start) + return line->len() - keyword->len() else # Wait for the list of matches from the LSP server var count: number = 0 -- 2.48.1