diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-01-04 11:10:55 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-01-04 11:10:55 +0800 |
commit | 83975e739d6ed07fee0bf64f7cbf0be00d5afcc7 (patch) | |
tree | 65047896839cb4b1831a1df1b83048d5d7a9c452 /script/core | |
parent | 50a1df60f0916ff2a1cd68a37d501851b10d1da3 (diff) | |
download | lua-language-server-83975e739d6ed07fee0bf64f7cbf0be00d5afcc7.zip |
workspace: supports `.dll`(`.so`) in `require`
Diffstat (limited to 'script/core')
-rw-r--r-- | script/core/completion.lua | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua index 4ffcfcd3..e9564df3 100644 --- a/script/core/completion.lua +++ b/script/core/completion.lua @@ -625,6 +625,20 @@ local function checkCommon(word, text, offset, results) end end end + for uri in files.eachDll() do + local words = files.getDllWords(uri) or {} + for _, str in ipairs(words) do + if not used[str] and str ~= word then + used[str] = true + if matchKey(word, str) then + results[#results+1] = { + label = str, + kind = define.CompletionItemKind.Text, + } + end + end + end + end else for str in text:gmatch '([%a_][%w_]*)' do if not used[str] and str ~= word then @@ -848,6 +862,27 @@ local function checkUri(ast, text, offset, results) end ::CONTINUE:: end + for uri in files.eachDll() do + local opens = files.getDllOpens(uri) or {} + local path = workspace.getRelativePath(uri) + for _, open in ipairs(opens) do + if matchKey(literal, open) then + if not collect[open] then + collect[open] = { + textEdit = { + start = source.start + #source[2], + finish = source.finish - #source[2], + newText = open, + } + } + end + collect[open][#collect[open]+1] = ([=[* [%s](%s)]=]):format( + path, + uri + ) + end + end + end elseif libName == 'dofile' or libName == 'loadfile' then for uri in files.eachFile() do |