Files
text-transform.nvim/lua/text-transform/config.lua
2024-05-07 01:00:38 +03:00

85 lines
2.4 KiB
Lua

local commands = require("text-transform.commands")
local D = require("text-transform.utils.debug")
local utils = require("text-transform.utils")
local config = {}
local function ensure_config()
-- when the config is not set to the global object, we set it
if _G.TextTransform.config == nil then
_G.TextTransform.config = config.config
end
end
local function init()
ensure_config()
local o = config.config
D.log("config", "Initializing TextTransform with %s", vim.inspect(o))
commands.init_commands()
commands.init_keymaps()
end
--- Your plugin configuration with its default values.
---
--- Default values:
---@eval return MiniDoc.afterlines_to_code(MiniDoc.current.eval_section)
config.config = {
--- Prints information about internals of the plugin. Very verbose, only useful for debugging.
debug = false,
--- Keymap configurations
keymap = {
--- Keymap to open the telescope popup. Set to `false` or `nil` to disable keymapping
--- You can always customize your own keymapping manually.
telescope_popup = {
--- Opens the popup in normal mode
["n"] = "<Leader>~",
--- Opens the popup in visual/visual block modes
["v"] = "<Leader>~",
},
},
---
--- Configurations for the text-transform replacers
--- Keys indicate the replacer name, and the value is a table with the following options:
---
--- - `enabled` (boolean): Enable or disable the replacer - disabled replacers do not show up in the popup.
replacers = {
camel_case = { enabled = true },
const_case = { enabled = true },
dot_case = { enabled = true },
kebab_case = { enabled = true },
pascal_case = { enabled = true },
snake_case = { enabled = true },
title_case = { enabled = true },
},
--- Sort the replacers in the popup.
--- Possible values: 'frequency', 'name'
sort_by = "frequency",
--- The popup type to show.
--- Possible values: 'telescope', 'select'
popup_type = "telescope",
}
--- Define your text-transform setup.
---
---@param options table Module config table. See |TextTransform.options|.
---
---@usage `require("text-transform").setup()` (add `{}` with your |TextTransform.options| table)
function config.setup(options)
options = options or {}
config.config = utils.merge(config.config, options)
if vim.api.nvim_get_vvar("vim_did_enter") == 0 then
vim.defer_fn(function()
init()
end, 0)
else
init()
end
return config.config
end
return config