|
6 | 6 | prefer a low-tech approach. While using a real debugger like
|
7 | 7 | [nvim-dap](https://github.com/mfussenegger/nvim-dap) is the gold standard for
|
8 | 8 | debugging a script or program, some prefer the use of the 'print' statement to
|
9 |
| -trace the output during execution. `debugprint` allows quick insertion of appropriate 'print' |
10 |
| -statements based on the language being edited. |
11 |
| - |
12 |
| -debugprint also inserts into the 'print' statements the file name and line |
13 |
| -numbers where debug lines are inserted, as well as a snippet of the previous or |
14 |
| -following line and a unique counter value from the current NeoVim session to |
15 |
| -help identify lines in debug output. Optionally it can also output variable |
16 |
| -values. |
| 9 | +trace the output during execution. `debugprint` allows quick insertion of |
| 10 | +appropriate 'print' statements based on the language being edited, including |
| 11 | +reference information such as file names, line numbers, a monotonic counter, and |
| 12 | +snippets of other lines to locate them quickly in output. `debugprint` can also |
| 13 | +output the values of variables. |
17 | 14 |
|
18 | 15 | `debugprint` supports the following filetypes/programming languages out-of-the-box:
|
19 | 16 |
|
@@ -114,21 +111,21 @@ standard way to use it. There are also some function invocations which are not
|
114 | 111 | mapped to any keymappings or commands by default, but could be. This is all
|
115 | 112 | shown in the following table.
|
116 | 113 |
|
117 |
| -| Mode | Default Keymap/Command | Purpose | Equivalent Lua Function | |
118 |
| -| ---------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | |
119 |
| -| Normal | `g?p` | Insert a 'plain' debug line appropriate to the filetype just below the current line | `require('debugprint').debugprint()` | |
120 |
| -| Normal | `g?P` | The same, but above the current line | `require('debugprint').debugprint({above = true})` | |
121 |
| -| Normal | `g?v` | Insert a variable debugging line below the current line. If the cursor is on a variable name, use that, otherwise prompt for one. | `require('debugprint').debugprint({variable = true})` | |
122 |
| -| Normal | `g?V` | The same, but above the current line | `require('debugprint').debugprint({above = true, variable = true})` | |
123 |
| -| Normal | None by default | Always prompt for a variable name, and insert a debugging line just below the current line which outputs it | `require('debugprint').debugprint({ignore_treesitter = true, variable = true})` | |
124 |
| -| Normal | None by default | Always prompt for a variable name, and insert a debugging line just above the current line which outputs it | `require('debugprint').debugprint({ignore_treesitter = true, above = true, variable = true})` | |
125 |
| -| Visual | `g?v` | Find the visually select variable name, and insert a debugging line just below the current line which outputs it | `require('debugprint').debugprint({variable = true})` | |
126 |
| -| Visual | `g?v` | Find the visually select variable name, and insert a debugging line just below the current line which outputs it | `require('debugprint').debugprint({variable = true})` | |
127 |
| -| Operator-pending | `g?o` | Locate a variable using a motion, and insert a debugging line just above the current line which outputs it | `require('debugprint').debugprint({motion = true})` | |
128 |
| -| Operator-pending | `g?O` | Locate a variable using a motion, and insert a debugging line just above the current line which outputs it | `require('debugprint').debugprint({motion = true, above = true})` | |
129 |
| -| Command | `:DeleteDebugPrints` | Delete all debug lines added to this buffer. | `require('debugprint').deleteprints()` | |
130 |
| - |
131 |
| -The keymappings are chosen specifically because by default in NeoVim they are |
| 114 | +| Mode | Default Keymap/Command | Purpose | Equivalent Lua Function | |
| 115 | +| ---------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | |
| 116 | +| Normal | `g?p` | Insert a 'plain' debug line below the current line | `require('debugprint').debugprint()` | |
| 117 | +| Normal | `g?P` | The same, but above the current line | `require('debugprint').debugprint({above = true})` | |
| 118 | +| Normal | `g?v` | Insert a variable debugging line below the current line. If the cursor is on a variable, use that, otherwise prompt for one. | `require('debugprint').debugprint({variable = true})` | |
| 119 | +| Normal | `g?V` | The same, but above the current line | `require('debugprint').debugprint({above = true, variable = true})` | |
| 120 | +| Normal | No default | Always prompt for a variable name, and insert a variable debugging line below the current line | `require('debugprint').debugprint({ignore_treesitter = true, variable = true})` | |
| 121 | +| Normal | No default | Always prompt for a variable name, and insert a variable debugging line above the current line | `require('debugprint').debugprint({ignore_treesitter = true, above = true, variable = true})` | |
| 122 | +| Visual | `g?v` | Find the visually select variable name, and insert a variable debugging line below the current line | `require('debugprint').debugprint({variable = true})` | |
| 123 | +| Visual | `g?v` | Find the visually select variable name, and insert a variable debugging line below the current line | `require('debugprint').debugprint({variable = true})` | |
| 124 | +| Op-pending | `g?o` | Locate a variable using a motion, and insert a variable debugging line above the current line | `require('debugprint').debugprint({motion = true})` | |
| 125 | +| Op-pending | `g?O` | Locate a variable using a motion, and insert a variable debugging line above the current line | `require('debugprint').debugprint({motion = true, above = true})` | |
| 126 | +| Command | `:DeleteDebugPrints` | Delete all debug lines added to this buffer. | `require('debugprint').deleteprints()` | |
| 127 | + |
| 128 | +The keymappings are chosen specifically because by default they are |
132 | 129 | used to convert sections to ROT-13, which most folks don't use. You can disable
|
133 | 130 | the defaults above from being created by setting `create_keymaps` and/or
|
134 | 131 | `create_commands`, and map them yourself to something else if you prefer:
|
|
0 commit comments