From d539858421bd550b8731cef036ff4da1e7d623c0 Mon Sep 17 00:00:00 2001 From: kevinhwang91 Date: Mon, 4 Apr 2022 23:48:08 +0800 Subject: [PATCH] fix(completion): avoid unnecessary file sep as trigger chars Language clients such as coc.nvim have multiple completion sources that may contain a file path completion source triggered by `/` or `\`. However, if users use the default requireSeparator `.` setting under lua-language-server, type `/` or `\` in a string will fire a lot of unless items whose priority is high than file path items and make file path items at the bottom of candidates. --- script/provider/completion.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/script/provider/completion.lua b/script/provider/completion.lua index 3c0c82d74..7714525ac 100644 --- a/script/provider/completion.lua +++ b/script/provider/completion.lua @@ -7,7 +7,7 @@ local ws = require 'workspace' local isEnable = false local function allWords() - local str = '\t\n.:(\'"[,#*@|=-{/\\ +?' + local str = '\t\n.:(\'"[,#*@|=-{ +?' local mark = {} local list = {} for c in str:gmatch '.' do @@ -20,6 +20,11 @@ local function allWords() list[#list+1] = postfix mark[postfix] = true end + local separator = config.get(scp.uri, 'Lua.completion.requireSeparator') + if not mark[separator] then + list[#list+1] = separator + mark[separator] = true + end end return list end