From ed021d1c8c1ac98326fb4fea4a0a65eda61366e7 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Tue, 23 Jan 2024 05:46:24 +0800 Subject: [PATCH] docs: add debugging section to plugins overview --- docs/plugins/overview.md | 16 ++++++++++++++++ docs/plugins/utils.md | 6 +++--- docs/tips.md | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/docs/plugins/overview.md b/docs/plugins/overview.md index 71f5d9b0..93d795c1 100644 --- a/docs/plugins/overview.md +++ b/docs/plugins/overview.md @@ -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. diff --git a/docs/plugins/utils.md b/docs/plugins/utils.md index e22982e4..bbf605bf 100644 --- a/docs/plugins/utils.md +++ b/docs/plugins/utils.md @@ -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 diff --git a/docs/tips.md b/docs/tips.md index 522e5763..8a6d3078 100644 --- a/docs/tips.md +++ b/docs/tips.md @@ -73,7 +73,7 @@ You can change the `` of input component from the default `escape` to `clos { on = [ "" ], 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