Skip to content

Commit

Permalink
chore(docs, cli): lsp docs and error in cli
Browse files Browse the repository at this point in the history
  • Loading branch information
tamasfe committed Jun 18, 2022
1 parent e62d706 commit 56fe769
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/taplo-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = "A CLI for Taplo TOML toolkit"
license = "MIT"
edition = "2021"
name = "taplo-cli"
version = "0.6.7"
version = "0.6.8"
homepage = "https://taplo.tamasfe.dev"
repository = "https://github.com/tamasfe/taplo"
categories = ["development-tools", "command-line-utilities"]
Expand Down
2 changes: 0 additions & 2 deletions crates/taplo-cli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ pub enum TaploCommand {
#[clap(visible_aliases = &["fmt"])]
Format(FormatCommand),
/// Language server operations.
#[cfg(feature = "lsp")]
Lsp {
#[clap(subcommand)]
cmd: LspCommand,
Expand Down Expand Up @@ -105,7 +104,6 @@ pub struct FormatCommand {
pub stdin_filepath: Option<String>,
}

#[cfg(feature = "lsp")]
#[derive(Clone, Subcommand)]
pub enum LspCommand {
/// Run the language server and listen on a TCP address.
Expand Down
15 changes: 13 additions & 2 deletions crates/taplo-cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use anyhow::anyhow;
use taplo_common::environment::Environment;

use crate::{
Expand Down Expand Up @@ -25,8 +26,18 @@ impl<E: Environment> Taplo<E> {

match taplo.cmd {
TaploCommand::Format(fmt) => self.execute_format(fmt).await,
#[cfg(feature = "lsp")]
TaploCommand::Lsp { cmd } => self.execute_lsp(cmd).await,
TaploCommand::Lsp { cmd } => {
#[cfg(feature = "lsp")]
{
self.execute_lsp(cmd).await
}
#[cfg(not(feature = "lsp"))]
{
let _ = cmd;
return Err(anyhow!("the LSP is not part of this build, please consult the documentation about enabling the functionality"));
}
}

#[cfg(feature = "toml-test")]
TaploCommand::TomlTest {} => self.execute_toml_test().await,
TaploCommand::Lint(cmd) => self.execute_lint(cmd).await,
Expand Down
2 changes: 1 addition & 1 deletion js/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@taplo/cli",
"version": "0.4.0",
"version": "0.4.1",
"description": "A TOML utility tool.",
"bin": {
"taplo": "dist/cli.js"
Expand Down
4 changes: 4 additions & 0 deletions site/site/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ export default defineConfigWithTheme<DefaultTheme.Config>({
text: "Conversion and Extraction",
link: "/cli/usage/conversion-and-extraction",
},
{
text: "Language Server",
link: "/cli/usage/language-server",
},
],
},
],
Expand Down
5 changes: 3 additions & 2 deletions site/site/cli/usage/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

## Log Level

Taplo uses the Rust `tracing` library for configurable logging features and respects the `RUST_LOG` environment variable.
Taplo uses the Rust `tracing` library for configurable logging features and respects the `RUST_LOG` environment variable. All logs regardless of log level are printed to the standard error output.

In most cases you might wish to disable logging after a certain log level, for example if you wish to only see error messages, you can do the following:
In most cases you might wish to disable logging below a certain log level.
As an example if you wish to only see error messages, you can do the following:

```sh
RUST_LOG=error taplo lint foo.toml
Expand Down
29 changes: 29 additions & 0 deletions site/site/cli/usage/language-server.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Language Server

The TOML language server can be used via the CLI and it supports communication via standard i/o or TCP.

::: tip

The language server is not part of the default builds, and is not available if Taplo was installed via NPM.

Consult the build or installation documentation on how to enable the functionality.

:::

## Via Standard i/o

```
taplo lsp stdio
```

In this mode Taplo expects messages from the standard input, and will print messages intended for the client to the standard output.

## Via TCP

```
taplo lsp tcp --address 0.0.0.0:9181
```

The server will listen on the given TCP address.

Multiple clients are not supported.

0 comments on commit 56fe769

Please sign in to comment.