Skip to content

Commit

Permalink
docs: add debugging section to plugins overview
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Jan 22, 2024
1 parent 7009a09 commit ed021d1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
16 changes: 16 additions & 0 deletions docs/plugins/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,19 @@ When the user specifies [`multi = true`](../configuration/yazi.md#preloaders) fo

Typically, a preloader only needs to implement one of them - either single or multiple. This depends on the specific task and the magnitude of the workload.
If it truly requires loading multiple files at once, the user needs to be prompted to enable the `multi` option for it.

## Debugging

Please ensure that your `~/.config/yazi/init.lua` includes valid Lua code with the correct syntax, otherwise will result in Yazi being unable to parse and execute your `init.lua` to initialize.

We recommend installing a Lua plugin in your editor for syntax checking to avoid any syntax errors.
For example, install the [Lua plugin](https://marketplace.visualstudio.com/items?itemName=sumneko.lua) for VSCode, and for Neovim, use [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) to configure your Lua LSP.

If you have no experience with Lua, you can quickly get started through https://learnxinyminutes.com/docs/lua/

### Logging

Once you get started, if you want to debug some runtime data, use [`ya.dbg()`](./utils.md#dbgmsg) and [`ya.err()`](./utils.md#errmsg) to print what you want to debug to either:

- `~/.local/state/yazi/yazi.log` on Unix-like systems.
- `C:\Users\USERNAME\AppData\Roaming\yazi\state\yazi.log` on Windows.
6 changes: 3 additions & 3 deletions docs/plugins/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ Pre-cache the image to a specified url based on user-configured [`max_width` and

### `dbg(msg)`

Append messages to Yazi's log file at the debug level:
Append messages to [the log file](./overview.md#logging) at the debug level:

- `msg` - Required, the message to be logged, which is a string

Note that if you build in release mode, the log level for Yazi is "error" instead of "debug", so you'll need to use [`ya.err`](#errmsg).
Note that if you use a release build of Yazi, the log level is "error" instead of "debug", so you'll need to use [`ya.err`](#errmsg).

### `err(msg)`

Append messages to Yazi's log file at the error level:
Append messages to [the log file](./overview.md#logging) at the error level:

- `msg` - Required, the message to be logged, which is a string

Expand Down
2 changes: 1 addition & 1 deletion docs/tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ You can change the `<Esc>` of input component from the default `escape` to `clos
{ on = [ "<Esc>" ], exec = "close", desc = "Cancel input" }
```

To exiting input directly, without entering Vi mode, making it behave like a regular input box.
to exiting input directly, without entering Vi mode, making it behave like a regular input box.

## Smart enter: `enter` for directory, `open` for file

Expand Down

0 comments on commit ed021d1

Please sign in to comment.