Skip to content

Commit d539858

Browse files
committed
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.
1 parent 53ce343 commit d539858

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

script/provider/completion.lua

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ local ws = require 'workspace'
77
local isEnable = false
88

99
local function allWords()
10-
local str = '\t\n.:(\'"[,#*@|=-{/\\ +?'
10+
local str = '\t\n.:(\'"[,#*@|=-{ +?'
1111
local mark = {}
1212
local list = {}
1313
for c in str:gmatch '.' do
@@ -20,6 +20,11 @@ local function allWords()
2020
list[#list+1] = postfix
2121
mark[postfix] = true
2222
end
23+
local separator = config.get(scp.uri, 'Lua.completion.requireSeparator')
24+
if not mark[separator] then
25+
list[#list+1] = separator
26+
mark[separator] = true
27+
end
2328
end
2429
return list
2530
end

0 commit comments

Comments
 (0)