mirror of
https://github.com/chenasraf/text-transform.nvim.git
synced 2026-05-17 17:48:04 +00:00
feat: enable/disable specific replacers
This commit is contained in:
17
README.md
17
README.md
@@ -137,8 +137,7 @@ require("text-transform").setup({
|
||||
debug = false,
|
||||
-- Keymap configurations
|
||||
keymap = {
|
||||
-- Keymaps to open the telescope popup. Set to `false` or `nil` to disable keymapping for
|
||||
-- the Telescope popup.
|
||||
-- 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
|
||||
@@ -147,6 +146,20 @@ require("text-transform").setup({
|
||||
["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 },
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
@@ -28,6 +28,20 @@ Default values:
|
||||
["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 },
|
||||
},
|
||||
}
|
||||
|
||||
local function init()
|
||||
|
||||
@@ -22,6 +22,20 @@ TextTransform.options = {
|
||||
["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 },
|
||||
},
|
||||
}
|
||||
|
||||
local function init()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
-- local config = require("text-transform.config")
|
||||
local utils = require("text-transform.util")
|
||||
local tt = require("text-transform.transformers")
|
||||
local replacers = require("text-transform.replacers")
|
||||
@@ -10,6 +11,7 @@ local function merge(table)
|
||||
TextTransform = utils.merge(TextTransform, table)
|
||||
end
|
||||
|
||||
-- merge(config)
|
||||
merge(tt)
|
||||
merge(replacers)
|
||||
merge(state)
|
||||
|
||||
@@ -57,6 +57,17 @@ local items = {
|
||||
function TextTransform.popup()
|
||||
state.save_positions()
|
||||
|
||||
local filtered = {}
|
||||
local config = _G.TextTransform.options
|
||||
|
||||
for _, item in ipairs(items) do
|
||||
if not config.replacers[item.value] or not config.replacers[item.value].enabled then
|
||||
goto continue
|
||||
end
|
||||
table.insert(filtered, item)
|
||||
::continue::
|
||||
end
|
||||
|
||||
local picker = pickers.new(dropdown, {
|
||||
prompt_title = "Change Case",
|
||||
finder = finders.new_table({
|
||||
|
||||
Reference in New Issue
Block a user