Refresh generated neovim config
This commit is contained in:
@ -1176,9 +1176,22 @@ end
|
||||
---@param prompt_bufnr number: The prompt bufnr
|
||||
actions.delete_buffer = function(prompt_bufnr)
|
||||
local current_picker = action_state.get_current_picker(prompt_bufnr)
|
||||
|
||||
current_picker:delete_selection(function(selection)
|
||||
local force = vim.api.nvim_buf_get_option(selection.bufnr, "buftype") == "terminal"
|
||||
local ok = pcall(vim.api.nvim_buf_delete, selection.bufnr, { force = force })
|
||||
|
||||
-- If the current buffer is deleted, switch to the previous buffer
|
||||
-- according to bdelete behavior
|
||||
if ok and selection.bufnr == current_picker.original_bufnr then
|
||||
local jumplist = vim.fn.getjumplist(current_picker.original_win_id)[1]
|
||||
for i = #jumplist, 1, -1 do
|
||||
if jumplist[i].bufnr ~= selection.bufnr and vim.fn.bufloaded(jumplist[i].bufnr) == 1 then
|
||||
vim.api.nvim_win_set_buf(current_picker.original_win_id, jumplist[i].bufnr)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
return ok
|
||||
end)
|
||||
end
|
||||
|
||||
@ -933,7 +933,7 @@ internal.buffers = function(opts)
|
||||
|
||||
local buffers = {}
|
||||
local default_selection_idx = 1
|
||||
for _, bufnr in ipairs(bufnrs) do
|
||||
for i, bufnr in ipairs(bufnrs) do
|
||||
local flag = bufnr == vim.fn.bufnr "" and "%" or (bufnr == vim.fn.bufnr "#" and "#" or " ")
|
||||
|
||||
if opts.sort_lastused and not opts.ignore_current_buffer and flag == "#" then
|
||||
@ -951,7 +951,7 @@ internal.buffers = function(opts)
|
||||
table.insert(buffers, idx, element)
|
||||
else
|
||||
if opts.select_current and flag == "%" then
|
||||
default_selection_idx = bufnr
|
||||
default_selection_idx = i
|
||||
end
|
||||
table.insert(buffers, element)
|
||||
end
|
||||
@ -972,6 +972,10 @@ internal.buffers = function(opts)
|
||||
previewer = conf.grep_previewer(opts),
|
||||
sorter = conf.generic_sorter(opts),
|
||||
default_selection_index = default_selection_idx,
|
||||
attach_mappings = function(_, map)
|
||||
map({ "i", "n" }, "<M-d>", actions.delete_buffer)
|
||||
return true
|
||||
end,
|
||||
})
|
||||
:find()
|
||||
end
|
||||
@ -993,6 +997,19 @@ internal.colorscheme = function(opts)
|
||||
end, vim.fn.getcompletion("", "color"))
|
||||
)
|
||||
|
||||
if opts.ignore_builtins then
|
||||
-- stylua: ignore
|
||||
local builtins = {
|
||||
"blue", "darkblue", "default", "delek", "desert", "elflord", "evening",
|
||||
"habamax", "industry", "koehler", "lunaperche", "morning", "murphy",
|
||||
"pablo", "peachpuff", "quiet", "retrobox", "ron", "shine", "slate",
|
||||
"sorbet", "torte", "vim", "wildcharm", "zaibatsu", "zellner",
|
||||
}
|
||||
colors = vim.tbl_filter(function(color)
|
||||
return not vim.tbl_contains(builtins, color)
|
||||
end, colors)
|
||||
end
|
||||
|
||||
local previewer
|
||||
if opts.enable_preview then
|
||||
-- define previewer
|
||||
|
||||
@ -97,51 +97,66 @@ lsp.outgoing_calls = function(opts)
|
||||
calls(opts, "to")
|
||||
end
|
||||
|
||||
---@type { [string]: fun(results: table, items: table, opts: table): table, table }
|
||||
local action_handlers = {
|
||||
["textDocument/references"] = function(results, items, opts)
|
||||
if not opts.include_current_line then
|
||||
local retresults = {}
|
||||
local retitems = {}
|
||||
|
||||
for i, item in pairs(items) do
|
||||
if
|
||||
not (
|
||||
item.filename == vim.api.nvim_buf_get_name(opts.bufnr)
|
||||
and item.lnum == vim.api.nvim_win_get_cursor(opts.winnr)[1]
|
||||
)
|
||||
then
|
||||
table.insert(retresults, results[i])
|
||||
table.insert(retitems, items[i])
|
||||
end
|
||||
end
|
||||
|
||||
return retresults, retitems
|
||||
end
|
||||
|
||||
return results, items
|
||||
end,
|
||||
}
|
||||
|
||||
---@param action string
|
||||
---@param locations table
|
||||
---@param items table
|
||||
---@param opts table
|
||||
---@return table results, table items
|
||||
local apply_action_handler = function(action, locations, items, opts)
|
||||
local handler = action_handlers[action]
|
||||
if handler then
|
||||
return handler(locations, items, opts)
|
||||
--- convert `item` type back to something we can pass to `vim.lsp.util.jump_to_location`
|
||||
--- stopgap for pre-nvim 0.10 - after which we can simply use the `user_data`
|
||||
--- field on the items in `vim.lsp.util.locations_to_items`
|
||||
---@param item vim.lsp.util.locations_to_items.ret
|
||||
---@param offset_encoding string|nil utf-8|utf-16|utf-32
|
||||
---@return lsp.Location
|
||||
local function item_to_location(item, offset_encoding)
|
||||
local line = item.lnum - 1
|
||||
local character = vim.lsp.util._str_utfindex_enc(item.text, item.col, offset_encoding) - 1
|
||||
local uri
|
||||
if utils.is_uri(item.filename) then
|
||||
uri = item.filename
|
||||
else
|
||||
uri = vim.uri_from_fname(item.filename)
|
||||
end
|
||||
|
||||
return locations, items
|
||||
return {
|
||||
uri = uri,
|
||||
range = {
|
||||
start = {
|
||||
line = line,
|
||||
character = character,
|
||||
},
|
||||
["end"] = {
|
||||
line = line,
|
||||
character = character,
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
---@param action string
|
||||
---@alias telescope.lsp.list_or_jump_action
|
||||
---| "textDocument/references"
|
||||
---| "textDocument/definition"
|
||||
---| "textDocument/typeDefinition"
|
||||
---| "textDocument/implementation"
|
||||
|
||||
---@param action telescope.lsp.list_or_jump_action
|
||||
---@param items vim.lsp.util.locations_to_items.ret[]
|
||||
---@param opts table
|
||||
---@return vim.lsp.util.locations_to_items.ret[]
|
||||
local apply_action_handler = function(action, items, opts)
|
||||
if action == "textDocument/references" and not opts.include_current_line then
|
||||
local lnum = vim.api.nvim_win_get_cursor(opts.winnr)[1]
|
||||
items = vim.tbl_filter(function(v)
|
||||
return not (v.filename == opts.curr_filepath and v.lnum == lnum)
|
||||
end, items)
|
||||
end
|
||||
|
||||
return items
|
||||
end
|
||||
|
||||
---@param action telescope.lsp.list_or_jump_action
|
||||
---@param title string prompt title
|
||||
---@param funname string: name of the calling function
|
||||
---@param params lsp.TextDocumentPositionParams
|
||||
---@param opts table
|
||||
local function list_or_jump(action, title, params, opts)
|
||||
local function list_or_jump(action, title, funname, params, opts)
|
||||
opts.reuse_win = vim.F.if_nil(opts.reuse_win, false)
|
||||
opts.curr_filepath = vim.api.nvim_buf_get_name(opts.bufnr)
|
||||
|
||||
vim.lsp.buf_request(opts.bufnr, action, params, function(err, result, ctx, _)
|
||||
if err then
|
||||
vim.api.nvim_err_writeln("Error when executing " .. action .. " : " .. err.message)
|
||||
@ -160,19 +175,20 @@ local function list_or_jump(action, title, params, opts)
|
||||
|
||||
local offset_encoding = vim.lsp.get_client_by_id(ctx.client_id).offset_encoding
|
||||
local items = vim.lsp.util.locations_to_items(locations, offset_encoding)
|
||||
items = apply_action_handler(action, items, opts)
|
||||
|
||||
locations, items = apply_action_handler(action, locations, items, opts)
|
||||
|
||||
if vim.tbl_isempty(locations) then
|
||||
if vim.tbl_isempty(items) then
|
||||
utils.notify(funname, {
|
||||
msg = string.format("No %s found", title),
|
||||
level = "INFO",
|
||||
})
|
||||
return
|
||||
end
|
||||
|
||||
if #locations == 1 and opts.jump_type ~= "never" then
|
||||
local current_uri = params.textDocument.uri
|
||||
local target_uri = locations[1].uri or locations[1].targetUri
|
||||
if current_uri ~= target_uri then
|
||||
if #items == 1 and opts.jump_type ~= "never" then
|
||||
local item = items[1]
|
||||
if opts.curr_filepath ~= item.filename then
|
||||
local cmd
|
||||
local file_path = vim.uri_to_fname(target_uri)
|
||||
if opts.jump_type == "tab" then
|
||||
cmd = "tabedit"
|
||||
elseif opts.jump_type == "split" then
|
||||
@ -184,11 +200,12 @@ local function list_or_jump(action, title, params, opts)
|
||||
end
|
||||
|
||||
if cmd then
|
||||
vim.cmd(string.format("%s %s", cmd, file_path))
|
||||
vim.cmd(string.format("%s %s", cmd, item.filename))
|
||||
end
|
||||
end
|
||||
|
||||
vim.lsp.util.jump_to_location(locations[1], offset_encoding, opts.reuse_win)
|
||||
local location = item_to_location(item, offset_encoding)
|
||||
vim.lsp.util.jump_to_location(location, offset_encoding, opts.reuse_win)
|
||||
else
|
||||
pickers
|
||||
.new(opts, {
|
||||
@ -208,24 +225,31 @@ local function list_or_jump(action, title, params, opts)
|
||||
end
|
||||
|
||||
lsp.references = function(opts)
|
||||
opts.include_current_line = vim.F.if_nil(opts.include_current_line, false)
|
||||
local params = vim.lsp.util.make_position_params(opts.winnr)
|
||||
params.context = { includeDeclaration = vim.F.if_nil(opts.include_declaration, true) }
|
||||
return list_or_jump("textDocument/references", "LSP References", params, opts)
|
||||
return list_or_jump("textDocument/references", "LSP References", "builtin.lsp_references", params, opts)
|
||||
end
|
||||
|
||||
lsp.definitions = function(opts)
|
||||
local params = vim.lsp.util.make_position_params(opts.winnr)
|
||||
return list_or_jump("textDocument/definition", "LSP Definitions", params, opts)
|
||||
return list_or_jump("textDocument/definition", "LSP Definitions", "builtin.lsp_definitions", params, opts)
|
||||
end
|
||||
|
||||
lsp.type_definitions = function(opts)
|
||||
local params = vim.lsp.util.make_position_params(opts.winnr)
|
||||
return list_or_jump("textDocument/typeDefinition", "LSP Type Definitions", params, opts)
|
||||
return list_or_jump(
|
||||
"textDocument/typeDefinition",
|
||||
"LSP Type Definitions",
|
||||
"builtin.lsp_type_definitions",
|
||||
params,
|
||||
opts
|
||||
)
|
||||
end
|
||||
|
||||
lsp.implementations = function(opts)
|
||||
local params = vim.lsp.util.make_position_params(opts.winnr)
|
||||
return list_or_jump("textDocument/implementation", "LSP Implementations", params, opts)
|
||||
return list_or_jump("textDocument/implementation", "LSP Implementations", "builtin.lsp_implementations", params, opts)
|
||||
end
|
||||
|
||||
local symbols_sorter = function(symbols)
|
||||
|
||||
@ -339,6 +339,8 @@ builtin.man_pages = require_on_exported_call("telescope.builtin.__internal").man
|
||||
builtin.reloader = require_on_exported_call("telescope.builtin.__internal").reloader
|
||||
|
||||
--- Lists open buffers in current neovim instance, opens selected buffer on `<cr>`
|
||||
--- - Default keymaps:
|
||||
--- - `<M-d>`: delete the currently selected buffer
|
||||
---@param opts table: options to pass to the picker
|
||||
---@field cwd string: specify a working directory to filter buffers list by
|
||||
---@field show_all_buffers boolean: if true, show all buffers, including unloaded buffers (default: true)
|
||||
@ -357,6 +359,7 @@ builtin.buffers = require_on_exported_call("telescope.builtin.__internal").buffe
|
||||
---@param opts table: options to pass to the picker
|
||||
---@field colors table: a list of additional colorschemes to explicitly make available to telescope (default: {})
|
||||
---@field enable_preview boolean: if true, will preview the selected color
|
||||
---@field ignore_builtins boolean: if true, builtin colorschemes are not listed
|
||||
builtin.colorscheme = require_on_exported_call("telescope.builtin.__internal").colorscheme
|
||||
|
||||
--- Lists vim marks and their value, jumps to the mark on `<cr>`
|
||||
@ -421,6 +424,7 @@ builtin.jumplist = require_on_exported_call("telescope.builtin.__internal").jump
|
||||
---@field jump_type string: how to goto reference if there is only one and the definition file is different from the current file, values: "tab", "tab drop", "split", "vsplit", "never"
|
||||
---@field show_line boolean: show results text (default: true)
|
||||
---@field trim_text boolean: trim results text (default: false)
|
||||
---@field reuse_win boolean: jump to existing window if buffer is already opened (default: false)
|
||||
---@field file_encoding string: file encoding for the previewer
|
||||
builtin.lsp_references = require_on_exported_call("telescope.builtin.__lsp").references
|
||||
|
||||
|
||||
@ -535,6 +535,7 @@ function Picker:find()
|
||||
self.__original_mousemoveevent = vim.o.mousemoveevent
|
||||
vim.o.mousemoveevent = true
|
||||
|
||||
self.original_bufnr = a.nvim_get_current_buf()
|
||||
self.original_win_id = a.nvim_get_current_win()
|
||||
_, self.original_cword = pcall(vim.fn.expand, "<cword>")
|
||||
_, self.original_cWORD = pcall(vim.fn.expand, "<cWORD>")
|
||||
|
||||
@ -771,10 +771,10 @@ layout_strategies.flex = make_documented_layout(
|
||||
horizontal = "Options to pass when switching to horizontal layout",
|
||||
}),
|
||||
function(self, max_columns, max_lines, layout_config)
|
||||
local flip_columns = vim.F.if_nil(layout_config.flip_columns, 100)
|
||||
local flip_lines = vim.F.if_nil(layout_config.flip_lines, 20)
|
||||
local flip_columns = vim.F.if_nil(layout_config.flip_columns, layout_config.horizontal.preview_cutoff)
|
||||
local flip_lines = vim.F.if_nil(layout_config.flip_lines, layout_config.vertical.preview_cutoff)
|
||||
|
||||
if max_columns < flip_columns and max_lines > flip_lines then
|
||||
if max_columns < flip_columns and max_lines >= flip_lines then
|
||||
self.__flex_strategy = "vertical"
|
||||
self.layout_config.flip_columns = nil
|
||||
self.layout_config.flip_lines = nil
|
||||
|
||||
@ -170,6 +170,65 @@ utils.filter_symbols = function(results, opts, post_filter)
|
||||
end
|
||||
end
|
||||
|
||||
local path_filename_first = function(path, reverse_directories)
|
||||
local dirs = vim.split(path, utils.get_separator())
|
||||
local filename
|
||||
|
||||
if reverse_directories then
|
||||
dirs = utils.reverse_table(dirs)
|
||||
filename = table.remove(dirs, 1)
|
||||
else
|
||||
filename = table.remove(dirs, #dirs)
|
||||
end
|
||||
|
||||
local tail = table.concat(dirs, utils.get_separator())
|
||||
-- Trim prevents a top-level filename to have a trailing white space
|
||||
local transformed_path = vim.trim(filename .. " " .. tail)
|
||||
local path_style = { { { #filename, #transformed_path }, "TelescopeResultsComment" } }
|
||||
|
||||
return transformed_path, path_style
|
||||
end
|
||||
|
||||
local calc_result_length = function(truncate_len)
|
||||
local status = get_status(vim.api.nvim_get_current_buf())
|
||||
local len = vim.api.nvim_win_get_width(status.layout.results.winid) - status.picker.selection_caret:len() - 2
|
||||
return type(truncate_len) == "number" and len - truncate_len or len
|
||||
end
|
||||
|
||||
local path_truncate = function(path, truncate_len, opts)
|
||||
if opts.__length == nil then
|
||||
opts.__length = calc_result_length(truncate_len)
|
||||
end
|
||||
if opts.__prefix == nil then
|
||||
opts.__prefix = 0
|
||||
end
|
||||
return truncate(path, opts.__length - opts.__prefix, nil, -1)
|
||||
end
|
||||
|
||||
local path_shorten = function(path, length, exclude)
|
||||
if exclude ~= nil then
|
||||
return Path:new(path):shorten(length, exclude)
|
||||
else
|
||||
return Path:new(path):shorten(length)
|
||||
end
|
||||
end
|
||||
|
||||
local path_abs = function(path, opts)
|
||||
local cwd
|
||||
if opts.cwd then
|
||||
cwd = opts.cwd
|
||||
if not vim.in_fast_event() then
|
||||
cwd = utils.path_expand(opts.cwd)
|
||||
end
|
||||
else
|
||||
cwd = vim.loop.cwd()
|
||||
end
|
||||
return Path:new(path):make_relative(cwd)
|
||||
end
|
||||
|
||||
-- IMPORTANT: This function should have been a local function as it's only used
|
||||
-- in this file, but the code was already exported a long time ago. By making it
|
||||
-- local we would potential break consumers of this method.
|
||||
utils.path_smart = (function()
|
||||
local paths = {}
|
||||
local os_sep = utils.get_separator()
|
||||
@ -274,12 +333,6 @@ utils.is_uri = function(filename)
|
||||
return false
|
||||
end
|
||||
|
||||
local calc_result_length = function(truncate_len)
|
||||
local status = get_status(vim.api.nvim_get_current_buf())
|
||||
local len = vim.api.nvim_win_get_width(status.layout.results.winid) - status.picker.selection_caret:len() - 2
|
||||
return type(truncate_len) == "number" and len - truncate_len or len
|
||||
end
|
||||
|
||||
--- Transform path is a util function that formats a path based on path_display
|
||||
--- found in `opts` or the default value from config.
|
||||
--- It is meant to be used in make_entry to have a uniform interface for
|
||||
@ -312,75 +365,50 @@ utils.transform_path = function(opts, path)
|
||||
return "", path_style
|
||||
elseif type(path_display) == "table" then
|
||||
if vim.tbl_contains(path_display, "tail") or path_display.tail then
|
||||
transformed_path = utils.path_tail(transformed_path)
|
||||
elseif vim.tbl_contains(path_display, "smart") or path_display.smart then
|
||||
return utils.path_tail(transformed_path), path_style
|
||||
end
|
||||
|
||||
if not vim.tbl_contains(path_display, "absolute") and not path_display.absolute then
|
||||
transformed_path = path_abs(transformed_path, opts)
|
||||
end
|
||||
|
||||
if vim.tbl_contains(path_display, "smart") or path_display.smart then
|
||||
transformed_path = utils.path_smart(transformed_path)
|
||||
else
|
||||
if not vim.tbl_contains(path_display, "absolute") and not path_display.absolute then
|
||||
local cwd
|
||||
if opts.cwd then
|
||||
cwd = opts.cwd
|
||||
if not vim.in_fast_event() then
|
||||
cwd = utils.path_expand(opts.cwd)
|
||||
end
|
||||
end
|
||||
|
||||
if vim.tbl_contains(path_display, "shorten") or path_display["shorten"] ~= nil then
|
||||
local length
|
||||
local exclude = nil
|
||||
|
||||
if type(path_display["shorten"]) == "table" then
|
||||
local shorten = path_display["shorten"]
|
||||
length = shorten.len
|
||||
exclude = shorten.exclude
|
||||
else
|
||||
length = type(path_display["shorten"]) == "number" and path_display["shorten"]
|
||||
end
|
||||
|
||||
transformed_path = path_shorten(transformed_path, length, exclude)
|
||||
end
|
||||
|
||||
if vim.tbl_contains(path_display, "truncate") or path_display.truncate then
|
||||
transformed_path = path_truncate(transformed_path, path_display.truncate, opts)
|
||||
end
|
||||
|
||||
if vim.tbl_contains(path_display, "filename_first") or path_display["filename_first"] ~= nil then
|
||||
local reverse_directories = false
|
||||
|
||||
if type(path_display["filename_first"]) == "table" then
|
||||
local filename_first_opts = path_display["filename_first"]
|
||||
|
||||
if filename_first_opts.reverse_directories == nil or filename_first_opts.reverse_directories == false then
|
||||
reverse_directories = false
|
||||
else
|
||||
cwd = vim.loop.cwd()
|
||||
end
|
||||
transformed_path = Path:new(transformed_path):make_relative(cwd)
|
||||
end
|
||||
|
||||
if vim.tbl_contains(path_display, "shorten") or path_display["shorten"] ~= nil then
|
||||
if type(path_display["shorten"]) == "table" then
|
||||
local shorten = path_display["shorten"]
|
||||
transformed_path = Path:new(transformed_path):shorten(shorten.len, shorten.exclude)
|
||||
else
|
||||
local length = type(path_display["shorten"]) == "number" and path_display["shorten"]
|
||||
transformed_path = Path:new(transformed_path):shorten(length)
|
||||
reverse_directories = filename_first_opts.reverse_directories
|
||||
end
|
||||
end
|
||||
|
||||
if vim.tbl_contains(path_display, "truncate") or path_display.truncate then
|
||||
if opts.__length == nil then
|
||||
opts.__length = calc_result_length(path_display.truncate)
|
||||
end
|
||||
if opts.__prefix == nil then
|
||||
opts.__prefix = 0
|
||||
end
|
||||
transformed_path = truncate(transformed_path, opts.__length - opts.__prefix, nil, -1)
|
||||
end
|
||||
|
||||
-- IMPORTANT: filename_first needs to be the last option. Otherwise the
|
||||
-- other options will not be displayed correctly.
|
||||
if vim.tbl_contains(path_display, "filename_first") or path_display["filename_first"] ~= nil then
|
||||
local reverse_directories = false
|
||||
|
||||
if type(path_display["filename_first"]) == "table" then
|
||||
local filename_first_opts = path_display["filename_first"]
|
||||
|
||||
if filename_first_opts.reverse_directories == nil or filename_first_opts.reverse_directories == false then
|
||||
reverse_directories = false
|
||||
else
|
||||
reverse_directories = filename_first_opts.reverse_directories
|
||||
end
|
||||
end
|
||||
|
||||
local dirs = vim.split(transformed_path, utils.get_separator())
|
||||
local filename
|
||||
|
||||
if reverse_directories then
|
||||
dirs = utils.reverse_table(dirs)
|
||||
filename = table.remove(dirs, 1)
|
||||
else
|
||||
filename = table.remove(dirs, #dirs)
|
||||
end
|
||||
|
||||
local tail = table.concat(dirs, utils.get_separator())
|
||||
|
||||
-- Prevents a toplevel filename to have a trailing whitespace
|
||||
transformed_path = vim.trim(filename .. " " .. tail)
|
||||
|
||||
path_style = { { { #filename, #transformed_path }, "TelescopeResultsComment" } }
|
||||
end
|
||||
transformed_path, path_style = path_filename_first(transformed_path, reverse_directories)
|
||||
end
|
||||
|
||||
return transformed_path, path_style
|
||||
@ -494,6 +522,9 @@ function utils.max_split(s, pattern, maxsplit)
|
||||
return t
|
||||
end
|
||||
|
||||
-- IMPORTANT: This function should have been a local function as it's only used
|
||||
-- in this file, but the code was already exported a long time ago. By making it
|
||||
-- local we would potential break consumers of this method.
|
||||
function utils.data_directory()
|
||||
local sourced_file = require("plenary.debug_utils").sourced_filepath()
|
||||
local base_directory = vim.fn.fnamemodify(sourced_file, ":h:h:h")
|
||||
@ -548,6 +579,9 @@ local load_once = function(f)
|
||||
end
|
||||
end
|
||||
|
||||
-- IMPORTANT: This function should have been a local function as it's only used
|
||||
-- in this file, but the code was already exported a long time ago. By making it
|
||||
-- local we would potential break consumers of this method.
|
||||
utils.file_extension = function(filename)
|
||||
local parts = vim.split(filename, "%.")
|
||||
-- this check enables us to get multi-part extensions, like *.test.js for example
|
||||
@ -718,19 +752,22 @@ utils.__separate_file_path_location = function(path)
|
||||
return path, nil, nil
|
||||
end
|
||||
|
||||
utils.merge_styles = function(style1, style2, offset)
|
||||
local function addOffset(i, obj)
|
||||
return { obj[1] + i, obj[2] + i }
|
||||
end
|
||||
local function add_offset(offset, obj)
|
||||
return { obj[1] + offset, obj[2] + offset }
|
||||
end
|
||||
|
||||
utils.merge_styles = function(style1, style2, offset)
|
||||
for _, item in ipairs(style2) do
|
||||
item[1] = addOffset(offset, item[1])
|
||||
item[1] = add_offset(offset, item[1])
|
||||
table.insert(style1, item)
|
||||
end
|
||||
|
||||
return style1
|
||||
end
|
||||
|
||||
-- IMPORTANT: This function should have been a local function as it's only used
|
||||
-- in this file, but the code was already exported a long time ago. By making it
|
||||
-- local we would potential break consumers of this method.
|
||||
utils.reverse_table = function(input_table)
|
||||
local temp_table = {}
|
||||
for index = 0, #input_table do
|
||||
|
||||
Reference in New Issue
Block a user