1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 00:50:05 +08:00

feat(telescope): fix message extensions

This commit is contained in:
wsdjeg 2022-05-17 21:36:08 +08:00
parent d93d79af40
commit 731db5a091
2 changed files with 52 additions and 2 deletions

View File

@ -12,6 +12,42 @@ function M.pick(d, keys)
return new_d
end
---
-- @function: 打印table的内容递归
-- @param: tbl 要打印的table
-- @param: level 递归的层数,默认不用传值进来
-- @param: filteDefault 是否过滤打印构造函数,默认为是
-- @return: return
function M.print( tbl , level, filteDefault)
local msg = ""
filteDefault = filteDefault or true
level = level or 1
local indent_str = ""
for i = 1, level do
indent_str = indent_str.." "
end
print(indent_str .. "{")
for k,v in pairs(tbl) do
if filteDefault then
if k ~= "_class_type" and k ~= "DeleteMe" then
local item_str = string.format("%s%s = %s", indent_str .. " ",tostring(k), tostring(v))
print(item_str)
if type(v) == "table" then
PrintTable(v, level + 1)
end
end
else
local item_str = string.format("%s%s = %s", indent_str .. " ",tostring(k), tostring(v))
print(item_str)
if type(v) == "table" then
PrintTable(v, level + 1)
end
end
end
print(indent_str .. "}")
end
return M

View File

@ -1,6 +1,9 @@
local pickers = require("telescope.pickers")
local finders = require("telescope.finders")
local action_state = require("telescope.actions.state")
local actions = require("telescope.actions")
local conf = require("telescope.config").values
local entry_display = require("telescope.pickers.entry_display")
local finders = require("telescope.finders")
local pickers = require("telescope.pickers")
local function prepare_output_table()
local lines = {}
@ -20,6 +23,17 @@ local function show_changes(opts)
results = prepare_output_table()
},
sorter = conf.generic_sorter(opts),
attach_mappings = function(prompt_bufnr)
actions.select_default:replace(function()
local entry = action_state.get_selected_entry()
actions.close(prompt_bufnr)
local reg = vim.fn.getreg('*')
vim.fn.setreg('*', entry.value)
vim.cmd("put *")
vim.fn.setreg('*', reg)
end)
return true
end,
}):find()
end