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

266 lines
12 KiB
Plaintext

==============================================================================
------------------------------------------------------------------------------
*commands.init_commands()*
`commands.init_commands`()
Initializes user commands
@private
------------------------------------------------------------------------------
*commands.init_keymaps()*
`commands.init_keymaps`()
Initializes user keymaps
@private
==============================================================================
------------------------------------------------------------------------------
*config.config*
`config.config`
Your plugin configuration with its default values.
Default values:
>
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",
}
<
------------------------------------------------------------------------------
*config.setup()*
`config.setup`({options})
Define your text-transform setup.
Parameters ~
{options} `(table)` Module config table. See |TextTransform.options|.
Usage ~
`require("text-transform").setup()` (add `{}` with your |TextTransform.options| table)
==============================================================================
------------------------------------------------------------------------------
*find_word_boundaries()*
`find_word_boundaries`({line}, {start_col})
Finds the boundaries of the surrounding word around `start_col` within `line`.
@param line number
@param start_col number
@return number start_col, number end_col
------------------------------------------------------------------------------
*replacers.replace_range()*
`replacers.replace_range`({start_line}, {start_col}, {end_line}, {end_col}, {transform_name})
Replace the range between the given positions with the given transform.
Acts on the lines between the given positions, replacing the text between the given columns.
@param start_line number The starting line
@param start_col number The starting column
@param end_line number The ending line
@param end_col number The ending column
@param transform_name string The transformer name
------------------------------------------------------------------------------
*replacers.replace_word()*
`replacers.replace_word`({transform_name}, {position})
Replace the word under the cursor with the given transform.
If `position` is provided, replace the word under the given position.
Otherwise, attempts to find the word under the cursor.
@param transform_name string The transformer name
@param position table|nil A table containing the position of the word to replace
------------------------------------------------------------------------------
*replacers.replace_columns()*
`replacers.replace_columns`({transform_name})
Replaces each column in visual block mode selection with the given transform.
Assumes that the each selection is 1 character and operates on the whole word under each cursor.
@param transform_name string The transformer name
------------------------------------------------------------------------------
*replacers.replace_selection()*
`replacers.replace_selection`({transform_name})
Replaces a selection with the given transform. This function attempts to infer the replacement
type based on the cursor positiono and visual selections, and passes information to relevant
range replacement functions.
@param transform_name string The transformer name
------------------------------------------------------------------------------
*replacers.get_visual_selection_details()*
`replacers.get_visual_selection_details`()
Takes the saved positions and translates them into individual visual ranges, regardless of how
the original selection was performed.
This allows to treat all ranges equally and allows to work on each selection without knowing
the full information around the selection logic.
==============================================================================
------------------------------------------------------------------------------
*state.save_positions()*
`state.save_positions`()
Save the current cursor position, mode, and visual selection ranges
------------------------------------------------------------------------------
*state.restore_positions()*
`state.restore_positions`({new_state})
Restore the cursor position, mode, and visual selection ranges saved using `save_position()`,
or a given modified state, if passed as the first argument
==============================================================================
------------------------------------------------------------------------------
*transformers.to_words()*
`transformers.to_words`({string})
Splits a string into words.
@param string string
@return table
------------------------------------------------------------------------------
*transformers.transform_words()*
`transformers.transform_words`({words}, {with_word_cb}, {separator})
Transforms a table of strings into a string using a callback and separator.
The callback is called with the word, the index, and the table of words.
The separator is added between each word.
@param words string|table string or table of strings
@param with_word_cb function (word: string, index: number, words: table) -> string
@param separator string|nil (optional)
@return string
------------------------------------------------------------------------------
*transformers.to_camel_case()*
`transformers.to_camel_case`({string})
Transforms a string into camelCase.
@param string string
@return string
------------------------------------------------------------------------------
*transformers.to_snake_case()*
`transformers.to_snake_case`({string})
Transfroms a string into snake_case.
@param string any
@return string
------------------------------------------------------------------------------
*transformers.to_pascal_case()*
`transformers.to_pascal_case`({string})
Transforms a string into PascalCase.
@param string string
@return string
------------------------------------------------------------------------------
*transformers.to_title_case()*
`transformers.to_title_case`({string})
Transforms a string into Title Case.
@param string string
@return string
------------------------------------------------------------------------------
*transformers.to_kebab_case()*
`transformers.to_kebab_case`({string})
Transforms a string into kebab-case.
@param string string
@return string
------------------------------------------------------------------------------
*transformers.to_dot_case()*
`transformers.to_dot_case`({string})
Transforms a string into dot.case.
@param string string
@return string
------------------------------------------------------------------------------
*transformers.to_const_case()*
`transformers.to_const_case`({string})
Transforms a string into CONSTANT_CASE.
@param string string
@return string
==============================================================================
------------------------------------------------------------------------------
*popup.show_popup()*
`popup.show_popup`()
Pops up a selection menu, containing the available case transformers.
When a transformer is selected, the cursor position/range/columns will be used to replace the
words around the cursor or inside the selection.
The cursor positions/ranges are saved before opening the menu and restored once a selection is
made.
==============================================================================
------------------------------------------------------------------------------
*select.select_popup()*
`select.select_popup`()
Pops up a selection menu, containing the available case transformers.
When a transformer is selected, the cursor position/range/columns will be used to replace the
words around the cursor or inside the selection.
The cursor positions/ranges are saved before opening the menu and restored once a selection is
made.
==============================================================================
------------------------------------------------------------------------------
*telescope.telescope_popup()*
`telescope.telescope_popup`()
Pops up a telescope menu, containing the available case transformers.
When a transformer is selected, the cursor position/range/columns will be used to replace the
words around the cursor or inside the selection.
The cursor positions/ranges are saved before opening the menu and restored once a selection is
made.
==============================================================================
------------------------------------------------------------------------------
*utils.merge()*
`utils.merge`({t1}, {t2})
Merges two tables into one. Same as `vim.tbl_extend("keep", t1, t2)`.
Mutates the first table.
TODO accept multiple tables to merge
@param t1 table
@param t2 table
@return table
vim:tw=78:ts=8:noet:ft=help:norl: