|
20 | 20 | ---dot-repeat, counts, line ('//') and block ('/* */') comments, and can be used |
21 | 21 | ---with motion and text-objects. It has native integration with tressitter to |
22 | 22 | ---support embedded filetypes like html, vue, markdown with codeblocks etc. |
23 | | ---- |
24 | | ----Comment.nvim uses |g@| and |Operator-pending-mode| to be able to easily comment |
25 | | ----and to support dot-repeat. Following is the brief architecture of the plugin |
26 | | ---- |
27 | | ----> |
28 | | ---- - START (keybinding or API) |
29 | | ---- |
30 | | ---- - Determine the region using marks, changed text |'[| |']| or visual |'>| |'<| |
31 | | ---- |
32 | | ---- - Pick commentstring either linewise/blockwise from one of the following places |
33 | | ---- 1. pre_hook (if string is returned) |
34 | | ---- 2. stored inside the plugin (with the help of treesitter) |
35 | | ---- 3. vim.bo.commentstring |
36 | | ---- |
37 | | ---- - Parse commentstring, returns LHS and RHS of commentstring |
38 | | ---- |
39 | | ---- >> Every is_comment check is made using the commentstring from the above step |
40 | | ---- |
41 | | ---- >> If `gc` is used on the current line i.e., `gc3w` then use blockwise |
42 | | ---- |
43 | | ---- - If linewise |
44 | | ---- 1. if every line is commented |
45 | | ---- 1.1 uncomment |
46 | | ---- |
47 | | ---- 2. else |
48 | | ---- 2.1 find the column no. to start the comment from (indentation) |
49 | | ---- 2.2 comment |
50 | | ---- |
51 | | ---- - If blockwise |
52 | | ---- 1. if the first line or start of the block is commented with LHS |
53 | | ---- and the last line or end of the block is commented with RHS |
54 | | ---- 1.1 uncomment |
55 | | ---- |
56 | | ---- 2. else |
57 | | ---- 2.1 Prepend the LHS into the first line |
58 | | ---- 2.2 Append the RHS into the last line |
59 | | ---- |
60 | | ---- >> In visual block, we can't preprend or append, so in this case we need |
61 | | ---- >> to slice and concat the line, putting RHS and LHS of commentstring into |
62 | | ---- >> right place when doing comment and removing LHS and RHS when uncomment |
63 | | ---- |
64 | | ---- - END |
65 | | ----< |
66 | 23 | ---@brief ]] |
67 | | - |
| 24 | +---@tag comment.dotrepeat |
| 25 | +---@brief [[ |
| 26 | +---Comment.nvim uses |operatorfunc| combined with |g@| to support dot-repeat, and |
| 27 | +---various marks i.e., |'[| |']| |'<| |'>| to deduce the region with the {motion} |
| 28 | +---argument provided by 'operatorfunc'. See |comment.api.call| |
| 29 | +---@brief ]] |
68 | 30 | ---@tag comment.commentstring |
69 | 31 | ---@brief [[ |
70 | 32 | ---Comment.nvim picks commentstring, either linewise/blockwise, from one of the |
|
0 commit comments