Skip to content

Commit 647cb16

Browse files
committed
chore: update doc dir
1 parent 5575f9f commit 647cb16

File tree

2 files changed

+136
-17
lines changed

2 files changed

+136
-17
lines changed

doc/auto-fix-return.nvim.txt

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
*auto-fix-return.nvim.txt*
2+
3+
==============================================================================
4+
CONTENTS *auto-fix-return.nvim-contents*
5+
6+
1. Introduction ................ |auto-fix-return.nvim-introduction|
7+
2. Installation ................ |auto-fix-return.nvim-installation|
8+
3. Compatibility ............... |auto-fix-return.nvim-compatibility|
9+
4. Configuration ............... |auto-fix-return.nvim-configuration|
10+
5. Commands .................... |auto-fix-return.nvim-commands|
11+
6. Usage Notes ................. |auto-fix-return.nvim-usage-notes|
12+
13+
==============================================================================
14+
1. INTRODUCTION *auto-fix-return.nvim-introduction*
15+
16+
Plugin inspired by GoLand that adds or removes parenthesis from Golang return
17+
definitions as you type.
18+
19+
Supports:
20+
- Functions
21+
- Methods
22+
- Interfaces
23+
- Single returns
24+
- Multi returns
25+
- Named returns
26+
- Channel returns
27+
28+
Coming soon:
29+
- Closures
30+
31+
==============================================================================
32+
2. INSTALLATION *auto-fix-return.nvim-installation*
33+
34+
Requirements:
35+
- Go treesitter parser must be installed
36+
- Run `TSInstall go` if using nvim-treesitter
37+
38+
Lazy.nvim:
39+
>
40+
return {
41+
"Jay-Madden/auto-fix-return.nvim",
42+
event = "VeryLazy",
43+
44+
-- nvim-treesitter is optional, the plugin will work fine without it as long as
45+
-- you have a valid Go parser in $rtp/parsers.
46+
-- However due to the Go grammar not being on Treesitter ABI 15 without 'nvim-treesitter'
47+
-- we are unable to detect and warn if an invalid parser version is being used.
48+
dependencies = {
49+
"nvim-treesitter/nvim-treesitter",
50+
},
51+
52+
config = function()
53+
require("auto-fix-return").setup({})
54+
end
55+
}
56+
<
57+
58+
==============================================================================
59+
3. COMPATIBILITY *auto-fix-return.nvim-compatibility*
60+
61+
Due to attempting to use in progress or invalid parse trees this plugin is
62+
very sensitive to changes in the compiled version of the underlying Go
63+
treesitter parser.
64+
65+
The current tested version of the Go parser that this plugin was written
66+
against is: `5e73f476efafe5c768eda19bbe877f188ded6144`
67+
68+
If you are using `nvim-treesitter` you can view your installed Go parser
69+
version with the following command:
70+
>
71+
lua vim.print(io.open(require("nvim-treesitter.configs").get_parser_info_dir() .. "/go.revision"):read("*a"))
72+
<
73+
74+
Using an untested parser version may or may not work in all scenarios. The
75+
plugin will not write the fix back to the buffer in the case the fix will
76+
generate an invalid parse tree. So an untested parser version will refuse to
77+
make fixes in some circumstances.
78+
79+
==============================================================================
80+
4. CONFIGURATION *auto-fix-return.nvim-configuration*
81+
82+
Setup function with defaults:
83+
>
84+
require("auto-fix-return").setup({
85+
-- Enable or disable the autofix on type behavior
86+
enabled = true,
87+
88+
-- Default logging level for the plugin, if the plugin does not behave as it should
89+
-- set this to vim.log.levels.DEBUG
90+
log_level = vim.log.levels.INFO
91+
})
92+
<
93+
94+
==============================================================================
95+
5. COMMANDS *auto-fix-return.nvim-commands*
96+
97+
*:AutoFixReturn*
98+
`:AutoFixReturn` Format the function definition under the cursor,
99+
adding or removing parenthesis as needed
100+
101+
`:AutoFixReturn enable` Enable the autofix on type behavior
102+
103+
`:AutoFixReturn disable` Disable the autofix on type behavior
104+
105+
==============================================================================
106+
6. USAGE NOTES *auto-fix-return.nvim-usage-notes*
107+
108+
IMPORTANT: The plugin attempts to add parenthesis as you type. Which means
109+
that its mostly working off of invalid parse trees. This is very nice to use
110+
but makes it very difficult to cover all edgecases from a parsing standpoint,
111+
as different error states of the tree can be matched incorrectly.
112+
113+
You can run the command `AutoFixReturn disable` to turn off the autocommand
114+
and make whatever changes you need to that line. Then reenable the plugin
115+
with `AutoFixReturn enable` and the line will not be edited unless you touch
116+
the declarations return definition again.
117+
118+
TIP: You can always invoke the fix manually with `AutoFixReturn` as long as
119+
your cursor is in the return definition.
120+
121+
NOTE: To ensure that we are not overly aggressive in the fixes that we apply
122+
and break unrelated code, whenever a fix is found, the contents of the current
123+
buffer and the fix are first copied to a scratch buffer and a full TreeSitter
124+
parse is run there before the fix is applied to the live buffer. If the buffer
125+
with the proposed fix from the builder contains ANY parse errors in it the fix
126+
will be ignored.
127+
128+
This is because in rare cases treesitter error tokens can apply across an
129+
arbitrary number of rows and we would end up deleting large swathes of code
130+
which is not what we want.
131+
132+
In practice this means that an invalid syntax error elsewhere in the buffer
133+
will essentially disable this plugin for that buffer.
134+
135+
==============================================================================
136+
vim:tw=78:ts=8:noet:ft=help:norl:

doc/auto-fix-return.txt

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)