Get mark list in lua table
rodrigoEsquel opened this issue · 0 comments
rodrigoEsquel commented
Similar to a previous issue I would like to be able to get the added marks as a table in lua to interact with my configuration (for example)
This will require adding a new option in the choose_list
function M.choose_list(list_type)
local list_fn
if list_type == "loclist" then
list_fn = function(items, flags) vim.fn.setloclist(0, items, flags) end
elseif list_type == "quickfixlist" then
list_fn = vim.fn.setqflist
---------
elseif list_type == "table" then
list_fn = function(items) return items end
---------
end
return list_fn
end
And for this to work properly it is needed to add a return in the Mark functions
function Mark:buffer_to_list(list_type, bufnr)
list_type = list_type or "loclist"
local list_fn = utils.choose_list(list_type)
........................
>return< list_fn(items, "r")
end
function Mark:all_to_list(list_type)
list_type = list_type or "loclist"
local list_fn = utils.choose_list(list_type)
............
>return< list_fn(items, "r")
end
function Mark:global_to_list(list_type)
list_type = list_type or "loclist"
local list_fn = utils.choose_list(list_type)
............
>return< list_fn(items, "r")
end
I will happily make the PR if you think this approach is correct