diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-26 21:28:33 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-26 21:28:33 +0800 |
commit | 32f85a5757c6fca2529e287a58d358da54a422e4 (patch) | |
tree | 2291611aed343480e51fde73a84eee6eaaf71736 /script/core | |
parent | eb0735fd4cb9530dfa6534d7424d08155e4fb619 (diff) | |
download | lua-language-server-32f85a5757c6fca2529e287a58d358da54a422e4.zip |
fix #1092
Diffstat (limited to 'script/core')
-rw-r--r-- | script/core/completion/completion.lua | 17 | ||||
-rw-r--r-- | script/core/hover/init.lua | 17 |
2 files changed, 32 insertions, 2 deletions
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua index 8b50f8af..d4c20c60 100644 --- a/script/core/completion/completion.lua +++ b/script/core/completion/completion.lua @@ -303,7 +303,22 @@ local function checkLocal(state, word, position, results) goto CONTINUE end if vm.getInfer(source):hasFunction() then - for _, def in ipairs(vm.getDefs(source)) do + local defs = vm.getDefs(source) + -- make sure `function` is before `doc.type.function` + local orders = {} + for i, def in ipairs(defs) do + if def.type == 'function' then + orders[def] = i - 20000 + elseif def.type == 'doc.type.function' then + orders[def] = i - 10000 + else + orders[def] = i + end + end + table.sort(defs, function (a, b) + return orders[a] < orders[b] + end) + for _, def in ipairs(defs) do if def.type == 'function' or def.type == 'doc.type.function' then local funcLabel = name .. getParams(def, false) diff --git a/script/core/hover/init.lua b/script/core/hover/init.lua index 9d855894..7231944a 100644 --- a/script/core/hover/init.lua +++ b/script/core/hover/init.lua @@ -40,8 +40,23 @@ local function getHover(source) local oop if vm.getInfer(source):view() == 'function' then + local defs = vm.getDefs(source) + -- make sure `function` is before `doc.type.function` + local orders = {} + for i, def in ipairs(defs) do + if def.type == 'function' then + orders[def] = i - 20000 + elseif def.type == 'doc.type.function' then + orders[def] = i - 10000 + else + orders[def] = i + end + end + table.sort(defs, function (a, b) + return orders[a] < orders[b] + end) local hasFunc - for _, def in ipairs(vm.getDefs(source)) do + for _, def in ipairs(defs) do if guide.isOOP(def) then oop = true end |