5555### Supported Languages<a name =" supported-languages " ></a >
5656
5757Given that this is a work in progress, the languages supported for the
58- operations listed below is ** constantly changing** . As of now, these languages are
59- supported (with individual support for each function may vary):
58+ operations listed below is ** constantly changing** . As of now, these languages
59+ are supported (with individual support for each function may vary):
6060
6161- TypeScript
6262- JavaScript
@@ -72,22 +72,41 @@ supported (with individual support for each function may vary):
7272- Support for various common refactoring operations
7373 - ** 106: Extract Function**
7474 - In visual mode, extracts the selected code to a separate function
75- - Optionally prompts for function param types and return types (see [ configuration for type prompt operations] ( #config-prompt ) )
75+ - Optionally prompts for function param types and return types (see
76+ [ configuration for type prompt operations] ( #config-prompt ) )
7677 - Also possible to Extract Block.
77- - Both Extract Function and Extract Block have the capability to extract to a separate file.
78+ - Both Extract Function and Extract Block have the capability to extract to
79+ a separate file.
7880 - ** 119: Extract Variable**
79- - In visual mode, extracts occurences of a selected expression to its own variable, replacing occurences of that expression with the variable
81+ - In visual mode, extracts occurences of a selected expression to its own
82+ variable, replacing occurences of that expression with the variable
8083 - ** 123: Inline Variable**
8184 - Inverse of extract variable
8285 - Replaces all occurences of a variable with its value
83- - Cursor must be on an identifier for this function to work
86+ - Can be used in normal mode or visual mode
87+ - Using this function in normal mode will automatically find the variable
88+ under the cursor and inline it
89+ - Using this function in visual mode will find the variable(s) in the
90+ visual selection.
91+ - If there is more than one variable in the selection, the plugin will
92+ prompt for which variable to inline,
93+ - If there is only one variable in the visual selection, it will
94+ automatically inline that variable
8495
8596### Debug Features<a name =" debug-features " ></a >
8697
8798- Also comes with various useful features for debugging
88- - ** Printf:** Automated insertion of print statement to mark the calling of a function
89- - ** Print var:** Automated insertion of print statement to print a variable at a given point in the code
90- - ** Cleanup:** Automated cleanup of all print statements generated by the plugin
99+ - ** Printf:** Automated insertion of print statement to mark the calling of a
100+ function
101+ - ** Print var:** Automated insertion of print statement to print a variable
102+ at a given point in the code. This map can be made with either visual or
103+ normal mode:
104+ - Using this function in visual mode will print out whatever is in the
105+ visual selection.
106+ - Passing ` { normal = true } ` to the function will automatically find the variable
107+ under the cursor and print it from normal mode without needing visual mode at all
108+ - ** Cleanup:** Automated cleanup of all print statements generated by the
109+ plugin
91110
92111## Configuration<a name =" configuration " ></a >
93112
@@ -102,6 +121,37 @@ setup function.
102121require (' refactoring' ).setup ({})
103122```
104123
124+ Here are all the available options for the setup function and their defaults:
125+
126+ ``` lua
127+ require (' refactoring' ).setup ({
128+ prompt_func_return_type = {
129+ go = false ,
130+ java = false ,
131+
132+ cpp = false ,
133+ c = false ,
134+ h = false ,
135+ hpp = false ,
136+ cxx = false ,
137+ },
138+ prompt_func_param_type = {
139+ go = false ,
140+ java = false ,
141+
142+ cpp = false ,
143+ c = false ,
144+ h = false ,
145+ hpp = false ,
146+ cxx = false ,
147+ },
148+ printf_statements = {},
149+ print_var_statements = {},
150+ })
151+ ```
152+
153+ See each of the sections below for details on each configuration option.
154+
105155### Configuration for Refactoring Operations<a name =" config-refactoring " ></a >
106156
107157#### Using Direct Remaps<a name =" config-refactoring-direct " ></a >
@@ -144,13 +194,14 @@ vim.api.nvim_set_keymap(
144194)
145195```
146196
147- This remap should also be made in ** visual mode** , or functionality for some refactors will not work properly.
197+ This remap should also be made in ** visual mode** , or functionality for some
198+ refactors will not work properly.
148199
149200#### Using Telescope<a name =" config-refactoring-telescope " ></a >
150201
151- If you would prefer to use Telescope to choose a refactor when you're in visual mode,
152- you can do so use using the ** Telescope extension.** Here is an example config
153- for this setup:
202+ If you would prefer to use Telescope to choose a refactor when you're in visual
203+ mode, you can do so use using the ** Telescope extension.** Here is an example
204+ config for this setup:
154205
155206``` lua
156207-- load refactoring Telescope extension
@@ -167,7 +218,8 @@ vim.api.nvim_set_keymap(
167218
168219### Configuration for Debug Operations<a name =" config-debug " ></a >
169220
170- Finally, you can configure remaps for the debug operations of this plugin like this:
221+ Finally, you can configure remaps for the debug operations of this plugin like
222+ this:
171223
172224``` lua
173225-- You can also use below = true here to to change the position of the printf
@@ -179,7 +231,11 @@ vim.api.nvim_set_keymap(
179231 { noremap = true }
180232)
181233
182- -- Print var: this remap should be made in visual mode
234+ -- Print var
235+
236+ -- Remap in normal mode and passing { normal = true } will automatically find the variable under the cursor and print it
237+ vim .api .nvim_set_keymap (" n" , " <leader>rv" , " :lua require('refactoring').debug.print_var({ normal = true })<CR>" , { noremap = true })
238+ -- Remap in visual mode will print whatever is in the visual selection
183239vim .api .nvim_set_keymap (" v" , " <leader>rv" , " :lua require('refactoring').debug.print_var({})<CR>" , { noremap = true })
184240
185241-- Cleanup function: this remap should be made in normal mode
@@ -193,7 +249,8 @@ functionalities.
193249
194250##### Customizing Printf Statements<a name =" config-debug-stringification-printf " ></a >
195251
196- You can add to the printf statements for any language by adding something like the below to your configuration:
252+ You can add to the printf statements for any language by adding something like
253+ the below to your configuration:
197254
198255``` lua
199256require (' refactoring' ).setup ({
@@ -236,8 +293,10 @@ sequence like this: `%%s`. For an example custom print var statement, go to
236293[ this folder] ( lua/refactoring/tests/debug/print_var ) , select your language, and
237294view ` multiple-statements/print_var.config ` .
238295
239- ** Note:** for either of these functions, if you have multiple statements
240- (including the default), the plugin will prompt for which one should be inserted.
296+ ** Note:** for either of these functions, if you have multiple custom
297+ statements, the plugin will prompt for which one should be inserted. If you
298+ just have one custom statement in your config, it will override the default
299+ automatically.
241300
242301### Configuration for Type Prompt Operations<a name =" config-prompt " ></a >
243302
0 commit comments