From ff3bf583b28c455a19571a54cd4a4e2bc024b5b8 Mon Sep 17 00:00:00 2001 From: Jane Lewis Date: Tue, 18 Jun 2024 13:39:41 -0700 Subject: [PATCH] `ruff server`: Add tracing setup guide to Neovim documentation (#11884) A follow-up to [this suggestion](https://github.com/astral-sh/ruff/pull/11747#discussion_r1634297757) on the tracing PR. --------- Co-authored-by: Dhruv Manilawala --- crates/ruff_server/docs/setup/NEOVIM.md | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/crates/ruff_server/docs/setup/NEOVIM.md b/crates/ruff_server/docs/setup/NEOVIM.md index 09e311ac43dad..e0bd63ef93d6a 100644 --- a/crates/ruff_server/docs/setup/NEOVIM.md +++ b/crates/ruff_server/docs/setup/NEOVIM.md @@ -54,3 +54,39 @@ require('lspconfig').pyright.setup { }, } ``` + +By default, Ruff will not show any logs. To enable logging in Neovim, you'll need to set the `RUFF_TRACE` environment variable +to either `messages` or `verbose`: + +```lua +require('lspconfig').ruff.setup { + cmd_env = { RUFF_TRACE = "messages" } +} +``` + +You can set the log level in `settings`: + +```lua +require('lspconfig').ruff.setup { + cmd_env = { RUFF_TRACE = "messages" }, + init_options = { + settings = { + logLevel = "debug", + } + } +} +``` + +It's also possible to divert Ruff's logs to a separate file with the `logFile` setting: + +```lua +require('lspconfig').ruff.setup { + cmd_env = { RUFF_TRACE = "messages" }, + init_options = { + settings = { + logLevel = "debug", + logFile = "your/log/file/path/log.txt" + } + } +} +```