From 0fef4c3e17f4f41c070e890dc7bee6f348983b5f Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Wed, 3 Mar 2021 11:51:44 -0500 Subject: [PATCH] fix: remove gotos because this breaks lua 5.1 (#583) --- lua/telescope/builtin/internal.lua | 14 ++++++++------ lua/telescope/builtin/lsp.lua | 3 +-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lua/telescope/builtin/internal.lua b/lua/telescope/builtin/internal.lua index f0eabc9..69903ae 100644 --- a/lua/telescope/builtin/internal.lua +++ b/lua/telescope/builtin/internal.lua @@ -725,8 +725,7 @@ internal.autocommands = function(opts) local event, group, ft_pat, cmd, source_file, source_lnum local current_event, current_group, current_ft - local cmd_output = vim.fn.execute("verb autocmd *", "silent") - for line in cmd_output:gmatch("[^\r\n]+") do + local inner_loop = function(line) -- capture group and event group, event = line:match("^(" .. pattern.GROUP .. ")%s+(" .. pattern.EVENT .. ")") -- ..or just an event @@ -740,7 +739,7 @@ internal.autocommands = function(opts) current_event = event current_group = group end - goto line_parsed + return end -- non event/group lines @@ -754,13 +753,13 @@ internal.autocommands = function(opts) -- is there a command on the same line? cmd = line:match(pattern.INDENT .. "%S+%s+(.+)") - goto line_parsed + return end if current_ft and cmd == nil then -- trim leading spaces cmd = line:gsub("^%s+", "") - goto line_parsed + return end if current_ft and cmd then @@ -778,8 +777,11 @@ internal.autocommands = function(opts) cmd = nil end end + end - ::line_parsed:: + local cmd_output = vim.fn.execute("verb autocmd *", "silent") + for line in cmd_output:gmatch("[^\r\n]+") do + inner_loop(line) end -- print(vim.inspect(autocmd_table)) diff --git a/lua/telescope/builtin/lsp.lua b/lua/telescope/builtin/lsp.lua index 28ecf60..49bc698 100644 --- a/lua/telescope/builtin/lsp.lua +++ b/lua/telescope/builtin/lsp.lua @@ -190,10 +190,9 @@ local function check_capabilities(feature) local supported_client = false for _, client in pairs(clients) do supported_client = client.resolved_capabilities[feature] - if supported_client then goto continue end + if supported_client then break end end - ::continue:: if supported_client then return true else