1

Refresh generated neovim config

This commit is contained in:
2024-08-15 13:01:03 +02:00
parent 64b51cf53a
commit f5af8e2b28
1836 changed files with 38979 additions and 31094 deletions

View File

@ -2,7 +2,7 @@ local actions = require("telescope.actions")
local actions_state = require("telescope.actions.state")
local function _get_default_register()
local clipboardFlags = vim.split(vim.api.nvim_get_option("clipboard"), ",")
local clipboardFlags = vim.split(vim.api.nvim_get_option_value("clipboard", {}), ",")
if vim.tbl_contains(clipboardFlags, "unnamedplus") then
return "+"
end

View File

@ -2,9 +2,9 @@ local finders = require("telescope.finders")
local pickers = require("telescope.pickers")
local conf = require("telescope.config").values
require("telescope-undo.previewer")
require("telescope-undo.actions")
require("telescope-undo.lua-timeago")
local get_previewer = require("telescope-undo.previewer").get_previewer
local timeago = require("telescope-undo.lua-timeago").timeago
local function _traverse_undotree(opts, entries, level)
local undolist = {}
@ -28,10 +28,7 @@ local function _traverse_undotree(opts, entries, level)
local header = filename .. "\n--- " .. filename .. "\n+++ " .. filename .. "\n"
-- do the diff using our internal diff function
local diff = vim.diff(buffer_before, buffer_after, {
algorithm = "patience",
ctxlen = opts.diff_context_lines or 0,
})
local diff = vim.diff(buffer_before, buffer_after, opts.vim_diff_opts)
-- extract data for yanking and searching
local ordinal = ""
@ -96,7 +93,7 @@ end
local M = {}
M.undo = function(opts)
if not vim.api.nvim_buf_get_option(0, "modifiable") then
if not vim.api.nvim_get_option_value("modifiable", { buf = 0 }) then
print("telescope-undo.nvim: Current buffer is not modifiable.")
return
end

View File

@ -17,7 +17,7 @@ local function round(num)
return math.floor(num + 0.5)
end
function timeago(time)
local function timeago(time)
local now = os.time()
local diff_seconds = os.difftime(now, time)
if diff_seconds < 45 then
@ -70,3 +70,5 @@ function timeago(time)
end
return round(diff_years) .. " " .. language.year.plural
end
return { timeago = timeago }

View File

@ -3,10 +3,10 @@ local is_wsl = (function()
local output = vim.fn.systemlist("uname -r")
return not not string.find(output[1] or "", "WSL")
end)()
function get_previewer(opts)
local function get_previewer(opts)
if opts.use_custom_command ~= nil then
return previewers.new_termopen_previewer({
get_command = function(entry, status)
get_command = function(entry, _)
local difftext = entry.value.diff:gsub("'", [['"'"']])
local shlexed = {}
for i, part in ipairs(opts.use_custom_command) do
@ -20,7 +20,7 @@ function get_previewer(opts)
local has_bash = vim.fn.executable("bash") == 1
if opts.use_delta and not is_wsl and (has_powershell or has_bash) and vim.fn.executable("delta") == 1 then
return previewers.new_termopen_previewer({
get_command = function(entry, status)
get_command = function(entry, _)
local append = ""
if opts.side_by_side == true then
append = append .. " -s"
@ -44,7 +44,7 @@ function get_previewer(opts)
else
return previewers.new_buffer_previewer({
-- this is not the prettiest preview...
define_preview = function(self, entry, status)
define_preview = function(self, entry, _)
vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, true, vim.split(entry.value.diff, "\n"))
require("telescope.previewers.utils").highlighter(
self.state.bufnr,
@ -55,3 +55,4 @@ function get_previewer(opts)
})
end
end
return { get_previewer = get_previewer }

View File

@ -8,10 +8,12 @@ local defaults = {
use_delta = true,
use_custom_command = nil, -- should be in this format: { "bash", "-c", "echo '$DIFF' | delta" }
side_by_side = false,
diff_context_lines = vim.o.scrolloff,
entry_format = "state #$ID, $STAT, $TIME",
time_format = "",
saved_only = false,
vim_diff_opts = {
ctxlen = vim.o.scrolloff,
},
mappings = {
i = {
["<cr>"] = require("telescope-undo.actions").yank_additions,
@ -33,25 +35,53 @@ local M = {
exports = {},
}
M.exports.undo = function(config)
config = vim.tbl_deep_extend("force", M.config, config or {})
local function extend_config(base, extend)
local config = vim.tbl_deep_extend("force", base, extend)
-- deprecation notices
if config.diff_context_lines ~= nil then
vim.deprecate(
"diff_context_lines",
"vim_diff_opts = { ctxlen = " .. config.diff_context_lines .. " }",
"1.0",
"telescope-undo.nvim",
false
)
config.vim_diff_opts.ctxlen = config.diff_context_lines
config.diff_context_lines = nil
end
-- warn about impossible configurations
if config["side_by_side"] and not config["use_delta"] then
error("telescope_undo.nvim: setting side_by_side but not use_delta will have no effect")
end
-- remove default keymaps that have been disabled by the user
for _, mode in ipairs({ "i", "n" }) do
config.mappings[mode] = vim.tbl_map(function(val)
return val ~= false and val or nil
end, config.mappings[mode])
end
-- expand theme configs
if config.theme then
config = require("telescope.themes")["get_" .. config.theme](config)
end
require("telescope-undo").undo(config)
return config
end
M.setup = function(extension_config, telescope_config)
M.config = vim.tbl_deep_extend("force", defaults, extension_config)
-- Remove default keymaps that have been disabled by the user.
for _, mode in ipairs({ "i", "n" }) do
M.config.mappings[mode] = vim.tbl_map(function(val)
return val ~= false and val or nil
end, M.config.mappings[mode])
end
if M.config["side_by_side"] and not M.config["use_delta"] then
error("telescope_undo.nvim: setting side_by_side but not use_delta will have no effect")
M.exports.undo = function(config)
local final_config
-- skip reevaluation of extend_config if we're updating with an empty table
if config == nil or next(config) == nil then
final_config = M.config
else
final_config = extend_config(M.config, config)
end
require("telescope-undo").undo(final_config)
end
M.setup = function(extension_config, _)
M.config = extend_config(defaults, extension_config)
end
return telescope.register_extension(M)