Skip to content

Commit 066e589

Browse files
docs: document the code
1 parent 6583234 commit 066e589

20 files changed

+407
-896
lines changed

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ test:
1212
luarocks test --local
1313

1414
docgen:
15-
lemmy-help lua/rest-nvim/client/curl.lua > doc/rest-nvim-curl.txt
1615
lemmy-help lua/rest-nvim/commands.lua > doc/rest-nvim-commands.txt
1716
lemmy-help lua/rest-nvim/config/init.lua > doc/rest-nvim-config.txt
18-
lemmy-help lua/rest-nvim/parser/dynamic_vars.lua lua/rest-nvim/parser/env_vars.lua lua/rest-nvim/parser/script_vars.lua lua/rest-nvim/parser/init.lua > doc/rest-nvim-parser.txt
19-
lemmy-help lua/rest-nvim/api.lua lua/rest-nvim/utils.lua lua/rest-nvim/functions.lua lua/rest-nvim/logger.lua lua/rest-nvim/result/init.lua lua/rest-nvim/result/winbar.lua lua/rest-nvim/result/help.lua > doc/rest-nvim-api.txt
17+
lemmy-help lua/rest-nvim/cookie_jar.lua > doc/rest-nvim-cookies.txt
18+
lemmy-help lua/rest-nvim/script.lua > doc/rest-nvim-script.txt
19+
lemmy-help lua/rest-nvim/api.lua lua/rest-nvim/utils.lua > doc/rest-nvim-api.txt
20+
lemmy-help lua/rest-nvim/client/curl/cli.lua lua/rest-nvim/client/curl/utils.lua > doc/rest-nvim-client-curl.txt

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ CLI. For more information on this, please see this [blog post](https://amartin.c
3232
## Features
3333

3434
- Easy to use
35-
- Friendly and organized request results window
35+
- Friendly, organized and featureful request results window
3636
- Fast runtime with statistics about your request
3737
- Set custom pre-request and post-request hooks to dynamically interact with the data
3838
- Easily set environment variables based on the response to re-use the data later
3939
- Tree-sitter based parsing and syntax highlighting for speed and perfect accuracy
4040
- Possibility of using dynamic/environment variables and Lua scripting in HTTP files
41+
- Save received cookies and load them automatically
4142

4243
## Install
4344

@@ -208,12 +209,12 @@ request and run the <kbd>:Rest run</kbd> command.
208209
> request in the current cursor line, no matters the position as long as
209210
> the cursor is on a request tree-sitter node.
210211
211-
## Keybindings
212+
### Keybindings
212213

213214
By default `rest.nvim` does not have any key mappings except the result buffers so you will not have
214215
conflicts with any of your existing ones.
215216

216-
## Commands
217+
### Commands
217218

218219
| User Command | Behavior |
219220
|------------------------|------------------------------------------------------|
@@ -227,6 +228,8 @@ conflicts with any of your existing ones.
227228
| `:Rest env select` | Select & register `.env` file with `vim.ui.select()` |
228229
| `:Rest env set {path}` | Register `.env` file to current `.http` file |
229230

231+
See `:h rest-nvim.commands` for more info
232+
230233
## Extensions
231234

232235
### Telescope Extension

doc/rest-nvim-api.txt

Lines changed: 38 additions & 227 deletions
Original file line numberDiff line numberDiff line change
@@ -45,35 +45,30 @@ api.register_rest_subcommand({name}, {cmd})
4545
{cmd} (RestCmd)
4646

4747

48-
*api.register_rest_keybind*
49-
api.register_rest_keybind({mode}, {lhs}, {cmd}, {opts})
50-
51-
52-
Parameters: ~
53-
{mode} (string) Keybind mode
54-
{lhs} (string) Keybind trigger
55-
{cmd} (string) Command to be run
56-
{opts} (table) Keybind options
57-
58-
5948
==============================================================================
6049
rest.nvim utilities *rest-nvim.utils*
6150

6251

6352
rest.nvim utility functions
6453

6554

66-
utils.escape({str}) *utils.escape*
55+
utils.escape({str}, {only_necessary?}) *utils.escape*
6756
Encodes a string into its escaped hexadecimal representation
68-
taken from Lua Socket and added underscore to ignore
6957

7058
Parameters: ~
71-
{str} (string) Binary string to be encoded
59+
{str} (string) Binary string to be encoded
60+
{only_necessary?} (boolean) Encode only necessary characters
7261

7362
Returns: ~
7463
(string)
7564

7665

66+
utils.url_decode({str}) *utils.url_decode*
67+
68+
Parameters: ~
69+
{str} (string)
70+
71+
7772
utils.file_exists({path}) *utils.file_exists*
7873
Check if a file exists in the given `path`
7974

@@ -94,250 +89,66 @@ utils.read_file({path}) *utils.read_file*
9489
(string)
9590

9691

97-
*utils.highlight*
98-
utils.highlight({bufnr}, {start}, {end_}, {ns})
99-
Highlight a request
100-
101-
Parameters: ~
102-
{bufnr} (number) Buffer handler ID
103-
{start} (number) Request tree-sitter node start
104-
{end_} (number) Request tree-sitter node end
105-
{ns} (number) rest.nvim Neovim namespace
106-
107-
108-
==============================================================================
109-
rest.nvim functions *rest-nvim.functions*
110-
92+
utils.parse_http_time() *utils.parse_http_time*
11193

112-
rest.nvim functions
11394

114-
115-
functions.exec({scope}) *functions.exec*
116-
Execute one or several HTTP requests depending on given `scope`
117-
and return request(s) results in a table that will be used to render results
118-
in a buffer.
119-
120-
Parameters: ~
121-
{scope} (string) Defines the request execution scope. Can be: `last`, `cursor` (default) or `document`
122-
123-
124-
functions.find_env_files() *functions.find_env_files*
125-
Find a list of environment files starting from the current directory
126-
127-
Returns: ~
128-
(string[]) variable files path
129-
130-
131-
functions.env({action}, {path}) *functions.env*
132-
Manage the environment file that is currently in use while running requests
133-
134-
If you choose to `set` the environment, you must provide a `path` to the environment file.
95+
*utils.ts_highlight_node*
96+
utils.ts_highlight_node({bufnr}, {node}, {ns})
13597

13698
Parameters: ~
137-
{action} (string|nil) Determines the action to be taken. Can be: `set` or `show` (default)
138-
{path} (string|nil) Path to the environment variables file
99+
{bufnr} (number)
100+
{node} (TSNode)
101+
{ns} (number)
139102

140103

141-
functions.cycle_result_pane({cycle}) *functions.cycle_result_pane*
142-
Cycle through the results buffer winbar panes
104+
utils.ts_parse_source({source}) *utils.ts_parse_source*
143105

144106
Parameters: ~
145-
{cycle} (string) Cycle direction, can be: `"next"` or `"prev"`
146-
147-
148-
==============================================================================
149-
rest.nvim logger *rest-nvim.logger*
150-
151-
152-
Logging library for rest.nvim, slightly inspired by rmagatti/logger.nvim
153-
Intended for use by internal and third-party modules.
154-
155-
Default logger instance is made during the `setup` and can be accessed
156-
by anyone through the `_G._rest_nvim.logger` configuration field
157-
that is set automatically.
158-
159-
------------------------------------------------------------------------------
160-
161-
Usage:
162-
163-
```lua
164-
local logger = require("rest-nvim.logger"):new({ level = "debug" })
165-
166-
logger:set_log_level("info")
167-
168-
logger:info("This is an info log")
169-
-- [rest.nvim] INFO: This is an info log
170-
```
171-
172-
173-
Logger *Logger*
174-
175-
176-
LoggerLevels *LoggerLevels*
177-
178-
179-
LoggerConfig *LoggerConfig*
180-
181-
Fields: ~
182-
{level_name} (string) Logging level name. Default is `"info"`
183-
{save_logs} (boolean) Whether to save log messages into a `.log` file. Default is `true`
184-
185-
186-
logger:new({opts}) *logger:new*
187-
Create a new logger instance
188-
189-
Parameters: ~
190-
{opts} (LoggerConfig) Logger configuration
107+
{source} (string|integer)
191108

192109
Returns: ~
193-
(Logger)
194-
195-
196-
logger:set_log_level({level}) *logger:set_log_level*
197-
Set the log level for the logger
198-
199-
Parameters: ~
200-
{level} (string) New logging level
201-
202-
See: ~
203-
|vim.log.levels|
204-
205-
206-
logger:trace({msg}) *logger:trace*
207-
Log a trace message
208-
209-
Parameters: ~
210-
{msg} (string) Log message
110+
(vim.treesitter.LanguageTree)
111+
(TSTree)
211112

212113

213-
logger:debug({msg}) *logger:debug*
214-
Log a debug message
114+
utils.ts_find({node}, {type}) *utils.ts_find*
215115

216116
Parameters: ~
217-
{msg} (string) Log message
117+
{node} (TSNode)
118+
{type} (string) @return TSNode?
218119

219120

220-
logger:info({msg}) *logger:info*
221-
Log an info message
121+
*utils.ts_node_spec*
122+
utils.ts_node_spec({node}, {expected_type})
222123

223124
Parameters: ~
224-
{msg} (string) Log message
225-
226-
227-
logger:warn({msg}) *logger:warn*
228-
Log a warning message
229-
230-
Parameters: ~
231-
{msg} (string) Log message
232-
233-
234-
logger:error({msg}) *logger:error*
235-
Log an error message
236-
237-
Parameters: ~
238-
{msg} (string) Log message
239-
240-
241-
==============================================================================
242-
rest.nvim result buffer *rest-nvim.result*
243-
244-
245-
rest.nvim result buffer handling
246-
247-
248-
result.bufnr *result.bufnr*
249-
Results buffer handler number
250-
251-
Type: ~
252-
(number|nil)
253-
254-
255-
result.get_or_create_buf() *result.get_or_create_buf*
125+
{node} (TSNode)
126+
{expected_type} (string)
256127

257128
Returns: ~
258-
(number) handler number
259-
260-
261-
result.write_block() *result.write_block*
262-
263-
See: ~
264-
|vim.api.nvim_buf_set_lines|
265-
266-
267-
result.display_buf({bufnr}, {stats}) *result.display_buf*
268-
Display results buffer window
269-
270-
Parameters: ~
271-
{bufnr} (number) The target buffer
272-
{stats} (table) Request statistics
273-
129+
(table)
274130

275-
result.write_res({bufnr}, {res}) *result.write_res*
276-
Write request results in the given buffer and display it
277-
278-
Parameters: ~
279-
{bufnr} (number) The target buffer
280-
{res} (table) Request results
281-
282-
283-
==============================================================================
284-
rest.nvim result buffer winbar add-on *rest-nvim.result.winbar*
285-
286-
287-
rest.nvim result buffer winbar
288131

289-
290-
winbar.current_pane_index *winbar.current_pane_index*
291-
Current pane index in the results window winbar
292-
293-
Type: ~
294-
(number)
295-
296-
297-
winbar.get_content({stats}) *winbar.get_content*
298-
Create the winbar contents and return them
132+
utils.ts_node_error_log({node}) *utils.ts_node_error_log*
133+
Create error log for TSNode that has a syntax error
299134

300135
Parameters: ~
301-
{stats} (table) Request statistics
136+
{node} (TSNode) Tree-sitter node
302137

303138
Returns: ~
304139
(string)
305140

306141

307-
ResultPane *ResultPane*
308-
309-
Fields: ~
310-
{name} (string) Pane name
311-
{contents} (string[]) Pane contents
312-
313-
314-
winbar.set_hl() *winbar.set_hl*
315-
Set the results window winbar highlighting groups
316-
317-
318-
winbar.set_pane({selected}) *winbar.set_pane*
319-
Select the winbar panel based on the pane index and set the pane contents
320-
321-
If the pane index is higher than 4 or lower than 1, it will cycle through
322-
the panes, e.g. >= 5 gets converted to 1 and <= 0 gets converted to 4
142+
*utils.nvim_lazy_set_wo*
143+
utils.nvim_lazy_set_wo({bufnr}, {name}, {value})
144+
Set window-option to specific buffer
145+
Some options leaves in `vim.wo` while they are actually tied to buffers
146+
see: <https://github.com/neovim/neovim/issues/11525> and `:h local-options`
323147

324148
Parameters: ~
325-
{selected} (number) winbar pane index
326-
327-
328-
==============================================================================
329-
rest.nvim result buffer help *rest-nvim.result.help*
330-
331-
332-
rest.nvim result buffer help window handling
333-
334-
335-
help.open() *help.open*
336-
Open the request results help window
337-
338-
339-
help.close() *help.close*
340-
Close the request results help window
149+
{bufnr} (number)
150+
{name} (string)
151+
{value} (any)
341152

342153

343154
vim:tw=78:ts=8:noet:ft=help:norl:

0 commit comments

Comments
 (0)