Skip to content

Commit 33eecff

Browse files
committed
refactor: use plugin name
1 parent 701d373 commit 33eecff

File tree

11 files changed

+170
-164
lines changed

11 files changed

+170
-164
lines changed

doc/tags

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
commands.init_commands() text-transform.txt /*commands.init_commands()*
2-
commands.init_keymaps() text-transform.txt /*commands.init_keymaps()*
3-
config.config text-transform.txt /*config.config*
4-
config.setup() text-transform.txt /*config.setup()*
1+
TextTransform.config text-transform.txt /*TextTransform.config*
2+
TextTransform.get_visual_selection_details() text-transform.txt /*TextTransform.get_visual_selection_details()*
3+
TextTransform.init_commands() text-transform.txt /*TextTransform.init_commands()*
4+
TextTransform.init_keymaps() text-transform.txt /*TextTransform.init_keymaps()*
5+
TextTransform.merge() text-transform.txt /*TextTransform.merge()*
6+
TextTransform.replace_columns() text-transform.txt /*TextTransform.replace_columns()*
7+
TextTransform.replace_range() text-transform.txt /*TextTransform.replace_range()*
8+
TextTransform.replace_selection() text-transform.txt /*TextTransform.replace_selection()*
9+
TextTransform.replace_word() text-transform.txt /*TextTransform.replace_word()*
10+
TextTransform.restore_positions() text-transform.txt /*TextTransform.restore_positions()*
11+
TextTransform.save_positions() text-transform.txt /*TextTransform.save_positions()*
12+
TextTransform.select_popup() text-transform.txt /*TextTransform.select_popup()*
13+
TextTransform.setup() text-transform.txt /*TextTransform.setup()*
14+
TextTransform.show_popup() text-transform.txt /*TextTransform.show_popup()*
15+
TextTransform.telescope_popup() text-transform.txt /*TextTransform.telescope_popup()*
16+
TextTransform.to_camel_case() text-transform.txt /*TextTransform.to_camel_case()*
17+
TextTransform.to_const_case() text-transform.txt /*TextTransform.to_const_case()*
18+
TextTransform.to_dot_case() text-transform.txt /*TextTransform.to_dot_case()*
19+
TextTransform.to_kebab_case() text-transform.txt /*TextTransform.to_kebab_case()*
20+
TextTransform.to_pascal_case() text-transform.txt /*TextTransform.to_pascal_case()*
21+
TextTransform.to_snake_case() text-transform.txt /*TextTransform.to_snake_case()*
22+
TextTransform.to_title_case() text-transform.txt /*TextTransform.to_title_case()*
23+
TextTransform.to_words() text-transform.txt /*TextTransform.to_words()*
24+
TextTransform.transform_words() text-transform.txt /*TextTransform.transform_words()*
525
find_word_boundaries() text-transform.txt /*find_word_boundaries()*
6-
popup.show_popup() text-transform.txt /*popup.show_popup()*
7-
replacers.get_visual_selection_details() text-transform.txt /*replacers.get_visual_selection_details()*
8-
replacers.replace_columns() text-transform.txt /*replacers.replace_columns()*
9-
replacers.replace_range() text-transform.txt /*replacers.replace_range()*
10-
replacers.replace_selection() text-transform.txt /*replacers.replace_selection()*
11-
replacers.replace_word() text-transform.txt /*replacers.replace_word()*
12-
select.select_popup() text-transform.txt /*select.select_popup()*
13-
state.restore_positions() text-transform.txt /*state.restore_positions()*
14-
state.save_positions() text-transform.txt /*state.save_positions()*
15-
telescope.telescope_popup() text-transform.txt /*telescope.telescope_popup()*
16-
transformers.to_camel_case() text-transform.txt /*transformers.to_camel_case()*
17-
transformers.to_const_case() text-transform.txt /*transformers.to_const_case()*
18-
transformers.to_dot_case() text-transform.txt /*transformers.to_dot_case()*
19-
transformers.to_kebab_case() text-transform.txt /*transformers.to_kebab_case()*
20-
transformers.to_pascal_case() text-transform.txt /*transformers.to_pascal_case()*
21-
transformers.to_snake_case() text-transform.txt /*transformers.to_snake_case()*
22-
transformers.to_title_case() text-transform.txt /*transformers.to_title_case()*
23-
transformers.to_words() text-transform.txt /*transformers.to_words()*
24-
transformers.transform_words() text-transform.txt /*transformers.transform_words()*
25-
utils.merge() text-transform.txt /*utils.merge()*

doc/text-transform.txt

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
==============================================================================
22
------------------------------------------------------------------------------
3-
*commands.init_commands()*
4-
`commands.init_commands`()
3+
*TextTransform.init_commands()*
4+
`TextTransform.init_commands`()
55
Initializes user commands
66
@private
77

88
------------------------------------------------------------------------------
9-
*commands.init_keymaps()*
10-
`commands.init_keymaps`()
9+
*TextTransform.init_keymaps()*
10+
`TextTransform.init_keymaps`()
1111
Initializes user keymaps
1212
@private
1313

1414

1515
==============================================================================
1616
------------------------------------------------------------------------------
17-
*config.config*
18-
`config.config`
17+
*TextTransform.config*
18+
`TextTransform.config`
1919
Your plugin configuration with its default values.
2020

2121
Default values:
2222
>
23-
config.config = {
23+
TextTransform.config = {
2424
--- Prints information about internals of the plugin. Very verbose, only useful for debugging.
2525
debug = false,
2626
--- Keymap configurations
@@ -61,8 +61,8 @@ Default values:
6161
<
6262

6363
------------------------------------------------------------------------------
64-
*config.setup()*
65-
`config.setup`({options})
64+
*TextTransform.setup()*
65+
`TextTransform.setup`({options})
6666
Define your text-transform setup.
6767

6868
Parameters ~
@@ -82,8 +82,8 @@ Finds the boundaries of the surrounding word around `start_col` within `line`.
8282
@return number start_col, number end_col
8383

8484
------------------------------------------------------------------------------
85-
*replacers.replace_range()*
86-
`replacers.replace_range`({start_line}, {start_col}, {end_line}, {end_col}, {transform_name})
85+
*TextTransform.replace_range()*
86+
`TextTransform.replace_range`({start_line}, {start_col}, {end_line}, {end_col}, {transform_name})
8787
Replace the range between the given positions with the given transform.
8888
Acts on the lines between the given positions, replacing the text between the given columns.
8989

@@ -94,8 +94,8 @@ Acts on the lines between the given positions, replacing the text between the gi
9494
@param transform_name string The transformer name
9595

9696
------------------------------------------------------------------------------
97-
*replacers.replace_word()*
98-
`replacers.replace_word`({transform_name}, {position})
97+
*TextTransform.replace_word()*
98+
`TextTransform.replace_word`({transform_name}, {position})
9999
Replace the word under the cursor with the given transform.
100100
If `position` is provided, replace the word under the given position.
101101
Otherwise, attempts to find the word under the cursor.
@@ -104,25 +104,25 @@ Otherwise, attempts to find the word under the cursor.
104104
@param position table|nil A table containing the position of the word to replace
105105

106106
------------------------------------------------------------------------------
107-
*replacers.replace_columns()*
108-
`replacers.replace_columns`({transform_name})
107+
*TextTransform.replace_columns()*
108+
`TextTransform.replace_columns`({transform_name})
109109
Replaces each column in visual block mode selection with the given transform.
110110
Assumes that the each selection is 1 character and operates on the whole word under each cursor.
111111

112112
@param transform_name string The transformer name
113113

114114
------------------------------------------------------------------------------
115-
*replacers.replace_selection()*
116-
`replacers.replace_selection`({transform_name})
115+
*TextTransform.replace_selection()*
116+
`TextTransform.replace_selection`({transform_name})
117117
Replaces a selection with the given transform. This function attempts to infer the replacement
118118
type based on the cursor positiono and visual selections, and passes information to relevant
119119
range replacement functions.
120120

121121
@param transform_name string The transformer name
122122

123123
------------------------------------------------------------------------------
124-
*replacers.get_visual_selection_details()*
125-
`replacers.get_visual_selection_details`()
124+
*TextTransform.get_visual_selection_details()*
125+
`TextTransform.get_visual_selection_details`()
126126
Takes the saved positions and translates them into individual visual ranges, regardless of how
127127
the original selection was performed.
128128

@@ -132,28 +132,28 @@ the full information around the selection logic.
132132

133133
==============================================================================
134134
------------------------------------------------------------------------------
135-
*state.save_positions()*
136-
`state.save_positions`()
135+
*TextTransform.save_positions()*
136+
`TextTransform.save_positions`()
137137
Save the current cursor position, mode, and visual selection ranges
138138

139139
------------------------------------------------------------------------------
140-
*state.restore_positions()*
141-
`state.restore_positions`({new_state})
140+
*TextTransform.restore_positions()*
141+
`TextTransform.restore_positions`({positions})
142142
Restore the cursor position, mode, and visual selection ranges saved using `save_position()`,
143143
or a given modified state, if passed as the first argument
144144

145145

146146
==============================================================================
147147
------------------------------------------------------------------------------
148-
*transformers.to_words()*
149-
`transformers.to_words`({string})
148+
*TextTransform.to_words()*
149+
`TextTransform.to_words`({string})
150150
Splits a string into words.
151151
@param string string
152152
@return table
153153

154154
------------------------------------------------------------------------------
155-
*transformers.transform_words()*
156-
`transformers.transform_words`({words}, {with_word_cb}, {separator})
155+
*TextTransform.transform_words()*
156+
`TextTransform.transform_words`({words}, {with_word_cb}, {separator})
157157
Transforms a table of strings into a string using a callback and separator.
158158
The callback is called with the word, the index, and the table of words.
159159
The separator is added between each word.
@@ -164,59 +164,59 @@ The separator is added between each word.
164164
@return string
165165

166166
------------------------------------------------------------------------------
167-
*transformers.to_camel_case()*
168-
`transformers.to_camel_case`({string})
167+
*TextTransform.to_camel_case()*
168+
`TextTransform.to_camel_case`({string})
169169
Transforms a string into camelCase.
170170
@param string string
171171
@return string
172172

173173
------------------------------------------------------------------------------
174-
*transformers.to_snake_case()*
175-
`transformers.to_snake_case`({string})
174+
*TextTransform.to_snake_case()*
175+
`TextTransform.to_snake_case`({string})
176176
Transfroms a string into snake_case.
177177
@param string any
178178
@return string
179179

180180
------------------------------------------------------------------------------
181-
*transformers.to_pascal_case()*
182-
`transformers.to_pascal_case`({string})
181+
*TextTransform.to_pascal_case()*
182+
`TextTransform.to_pascal_case`({string})
183183
Transforms a string into PascalCase.
184184
@param string string
185185
@return string
186186

187187
------------------------------------------------------------------------------
188-
*transformers.to_title_case()*
189-
`transformers.to_title_case`({string})
188+
*TextTransform.to_title_case()*
189+
`TextTransform.to_title_case`({string})
190190
Transforms a string into Title Case.
191191
@param string string
192192
@return string
193193

194194
------------------------------------------------------------------------------
195-
*transformers.to_kebab_case()*
196-
`transformers.to_kebab_case`({string})
195+
*TextTransform.to_kebab_case()*
196+
`TextTransform.to_kebab_case`({string})
197197
Transforms a string into kebab-case.
198198
@param string string
199199
@return string
200200

201201
------------------------------------------------------------------------------
202-
*transformers.to_dot_case()*
203-
`transformers.to_dot_case`({string})
202+
*TextTransform.to_dot_case()*
203+
`TextTransform.to_dot_case`({string})
204204
Transforms a string into dot.case.
205205
@param string string
206206
@return string
207207

208208
------------------------------------------------------------------------------
209-
*transformers.to_const_case()*
210-
`transformers.to_const_case`({string})
209+
*TextTransform.to_const_case()*
210+
`TextTransform.to_const_case`({string})
211211
Transforms a string into CONSTANT_CASE.
212212
@param string string
213213
@return string
214214

215215

216216
==============================================================================
217217
------------------------------------------------------------------------------
218-
*popup.show_popup()*
219-
`popup.show_popup`()
218+
*TextTransform.show_popup()*
219+
`TextTransform.show_popup`()
220220
Pops up a selection menu, containing the available case transformers.
221221
When a transformer is selected, the cursor position/range/columns will be used to replace the
222222
words around the cursor or inside the selection.
@@ -227,8 +227,8 @@ made.
227227

228228
==============================================================================
229229
------------------------------------------------------------------------------
230-
*select.select_popup()*
231-
`select.select_popup`()
230+
*TextTransform.select_popup()*
231+
`TextTransform.select_popup`()
232232
Pops up a selection menu, containing the available case transformers.
233233
When a transformer is selected, the cursor position/range/columns will be used to replace the
234234
words around the cursor or inside the selection.
@@ -239,8 +239,8 @@ made.
239239

240240
==============================================================================
241241
------------------------------------------------------------------------------
242-
*telescope.telescope_popup()*
243-
`telescope.telescope_popup`()
242+
*TextTransform.telescope_popup()*
243+
`TextTransform.telescope_popup`()
244244
Pops up a telescope menu, containing the available case transformers.
245245
When a transformer is selected, the cursor position/range/columns will be used to replace the
246246
words around the cursor or inside the selection.
@@ -251,8 +251,8 @@ made.
251251

252252
==============================================================================
253253
------------------------------------------------------------------------------
254-
*utils.merge()*
255-
`utils.merge`({t1}, {t2})
254+
*TextTransform.merge()*
255+
`TextTransform.merge`({t1}, {t2})
256256
Merges two tables into one. Same as `vim.tbl_extend("keep", t1, t2)`.
257257
Mutates the first table.
258258

lua/text-transform/commands.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ local replacers = require("text-transform.replacers")
55
local popup = require("text-transform.popup")
66
local common = require("text-transform.popup.common")
77

8-
local commands = {}
8+
local TextTransform = {}
99

1010
--- Initializes user commands
1111
--- @private
12-
function commands.init_commands()
12+
function TextTransform.init_commands()
1313
local map = {
1414
TtCamel = "camel_case",
1515
TtConst = "const_case",
@@ -36,6 +36,9 @@ function commands.init_commands()
3636
vim.api.nvim_create_user_command(cmd, function()
3737
state.save_positions()
3838
replacers.replace_selection(transformer_name)
39+
vim.schedule(function()
40+
state.restore_positions()
41+
end)
3942
end, opts("Change to " .. item))
4043
end
4144

@@ -55,7 +58,7 @@ end
5558

5659
--- Initializes user keymaps
5760
--- @private
58-
function commands.init_keymaps()
61+
function TextTransform.init_keymaps()
5962
local keymaps = _G.TextTransform.config.keymap
6063
D.log("init_keymaps", "Initializing keymaps, config %s", vim.inspect(_G.TextTransform))
6164
if keymaps.telescope_popup then
@@ -69,4 +72,4 @@ function commands.init_keymaps()
6972
end
7073
end
7174

72-
return commands
75+
return TextTransform

lua/text-transform/config.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
local commands = require("text-transform.commands")
22
local D = require("text-transform.utils.debug")
33
local utils = require("text-transform.utils")
4-
local config = {}
4+
local TextTransform = {}
55

66
local function ensure_config()
77
-- when the config is not set to the global object, we set it
88
if _G.TextTransform.config == nil then
9-
_G.TextTransform.config = config.config
9+
_G.TextTransform.config = TextTransform.config
1010
end
1111
end
1212

1313
local function init()
1414
ensure_config()
15-
local o = config.config
15+
local o = TextTransform.config
1616
D.log("config", "Initializing TextTransform with %s", vim.inspect(o))
1717
commands.init_commands()
1818
commands.init_keymaps()
@@ -22,7 +22,7 @@ end
2222
---
2323
--- Default values:
2424
---@eval return MiniDoc.afterlines_to_code(MiniDoc.current.eval_section)
25-
config.config = {
25+
TextTransform.config = {
2626
--- Prints information about internals of the plugin. Very verbose, only useful for debugging.
2727
debug = false,
2828
--- Keymap configurations
@@ -65,10 +65,10 @@ config.config = {
6565
---@param options table Module config table. See |TextTransform.options|.
6666
---
6767
---@usage `require("text-transform").setup()` (add `{}` with your |TextTransform.options| table)
68-
function config.setup(options)
68+
function TextTransform.setup(options)
6969
options = options or {}
7070

71-
config.config = utils.merge(config.config, options)
71+
TextTransform.config = utils.merge(TextTransform.config, options)
7272

7373
if vim.api.nvim_get_vvar("vim_did_enter") == 0 then
7474
vim.defer_fn(function()
@@ -78,7 +78,7 @@ function config.setup(options)
7878
init()
7979
end
8080

81-
return config.config
81+
return TextTransform.config
8282
end
8383

84-
return config
84+
return TextTransform

0 commit comments

Comments
 (0)