break: deprecate utils.get_default utils.if_nil (#1545)

This commit is contained in:
Simon Hauser
2022-05-22 12:53:37 +02:00
committed by Simon Hauser
parent a1aec79cb1
commit 83b6cadb2c
12 changed files with 81 additions and 81 deletions

View File

@@ -1059,22 +1059,22 @@ end
---@param prompt_bufnr number: The prompt bufnr
actions.which_key = function(prompt_bufnr, opts)
opts = opts or {}
opts.max_height = utils.get_default(opts.max_height, 0.4)
opts.only_show_current_mode = utils.get_default(opts.only_show_current_mode, true)
opts.mode_width = utils.get_default(opts.mode_width, 1)
opts.keybind_width = utils.get_default(opts.keybind_width, 7)
opts.name_width = utils.get_default(opts.name_width, 30)
opts.line_padding = utils.get_default(opts.line_padding, 1)
opts.separator = utils.get_default(opts.separator, " -> ")
opts.close_with_action = utils.get_default(opts.close_with_action, true)
opts.normal_hl = utils.get_default(opts.normal_hl, "TelescopePrompt")
opts.border_hl = utils.get_default(opts.border_hl, "TelescopePromptBorder")
opts.winblend = utils.get_default(opts.winblend, config.values.winblend)
opts.column_padding = utils.get_default(opts.column_padding, " ")
opts.max_height = vim.F.if_nil(opts.max_height, 0.4)
opts.only_show_current_mode = vim.F.if_nil(opts.only_show_current_mode, true)
opts.mode_width = vim.F.if_nil(opts.mode_width, 1)
opts.keybind_width = vim.F.if_nil(opts.keybind_width, 7)
opts.name_width = vim.F.if_nil(opts.name_width, 30)
opts.line_padding = vim.F.if_nil(opts.line_padding, 1)
opts.separator = vim.F.if_nil(opts.separator, " -> ")
opts.close_with_action = vim.F.if_nil(opts.close_with_action, true)
opts.normal_hl = vim.F.if_nil(opts.normal_hl, "TelescopePrompt")
opts.border_hl = vim.F.if_nil(opts.border_hl, "TelescopePromptBorder")
opts.winblend = vim.F.if_nil(opts.winblend, config.values.winblend)
opts.column_padding = vim.F.if_nil(opts.column_padding, " ")
-- Assigning into 'opts.column_indent' would override a number with a string and
-- cause issues with subsequent calls, keep a local copy of the string instead
local column_indent = table.concat(utils.repeated_table(utils.get_default(opts.column_indent, 4), " "))
local column_indent = table.concat(utils.repeated_table(vim.F.if_nil(opts.column_indent, 4), " "))
-- close on repeated keypress
local km_bufs = (function()
@@ -1111,9 +1111,9 @@ actions.which_key = function(prompt_bufnr, opts)
local make_display = function(mapping)
return displayer {
{ mapping.mode, utils.get_default(opts.mode_hl, "TelescopeResultsConstant") },
{ mapping.keybind, utils.get_default(opts.keybind_hl, "TelescopeResultsVariable") },
{ mapping.name, utils.get_default(opts.name_hl, "TelescopeResultsFunction") },
{ mapping.mode, vim.F.if_nil(opts.mode_hl, "TelescopeResultsConstant") },
{ mapping.keybind, vim.F.if_nil(opts.keybind_hl, "TelescopeResultsVariable") },
{ mapping.name, vim.F.if_nil(opts.name_hl, "TelescopeResultsFunction") },
}
end