From d95a465b4399c3c10b83925935ec5f4807d65b60 Mon Sep 17 00:00:00 2001 From: Tony Chen Date: Mon, 30 Nov 2020 08:33:52 -0500 Subject: Don't show entire context when completing --- src/nvim/lua/vim.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/nvim/lua/vim.lua') diff --git a/src/nvim/lua/vim.lua b/src/nvim/lua/vim.lua index 3e601586ea..49c34c5b89 100644 --- a/src/nvim/lua/vim.lua +++ b/src/nvim/lua/vim.lua @@ -547,7 +547,7 @@ function vim._expand_pat(pat, env) if pat == '' then local result = vim.tbl_keys(env) table.sort(result) - return result + return result, 0 end -- TODO: We can handle spaces in [] ONLY. @@ -558,7 +558,7 @@ function vim._expand_pat(pat, env) -- Get the last part of the pattern local last_part = pat:match("[%w.:_%[%]'\"]+$") - if not last_part then return {} end + if not last_part then return {}, 0 end local parts, search_index = vim._expand_pat_get_parts(last_part) @@ -568,11 +568,11 @@ function vim._expand_pat(pat, env) local final_env = env for _, part in ipairs(parts) do if type(final_env) ~= 'table' then - return {} + return {}, 0 end -- Normally, we just have a string - -- Just attempt to get the string directly from the environment + -- Just attempt to get the string directly from the environment if type(part) == "string" then final_env = rawget(final_env, part) else @@ -584,32 +584,32 @@ function vim._expand_pat(pat, env) -- -> _G[MY_VAR] -> "api" local result_key = part[1] if not result_key then - return {} + return {}, 0 end local result = rawget(env, result_key) if result == nil then - return {} + return {}, 0 end final_env = rawget(final_env, result) end if not final_env then - return {} + return {}, 0 end end local result = vim.tbl_map(function(v) - return prefix_match_pat .. v + return v end, vim.tbl_filter(function(name) return string.find(name, match_pat) ~= nil end, vim.tbl_keys(final_env))) table.sort(result) - return result + return result, #prefix_match_pat end vim._expand_pat_get_parts = function(lua_string) -- cgit