tamasfe / taplo

A TOML toolkit written in Rust
https://taplo.tamasfe.dev
MIT License
1.48k stars 114 forks source link

Numerous bugs with schema #650

Open arisudesu opened 3 months ago

arisudesu commented 3 months ago

Vscode extension doesn't work if file extension is not .toml. Says "this document has been excluded" in the first line and schema selection doesn't work. File contents is Telegraf configuration.

Additionally, when I change the file extension to .toml, it shows "no schema selected", however I have associated any file with "any schema":

    "evenBetterToml.schema.associations": {
        "^.*$": "https://json.schemastore.org/any.json"
    },

Furthermore, the schema selection is tripled.

Extension version is: v0.19.2.

изображение

изображение

panekj commented 3 months ago

Furthermore, the schema selection is tripled.

Duplicate of https://github.com/tamasfe/taplo/issues/395

Additionally, when I change the file extension to .toml, it shows "no schema selected"

This is currently broken, use external LSP in settings. https://github.com/tamasfe/taplo/issues/624#issuecomment-2270463328

arisudesu commented 3 months ago

Thanks, I subbed to these issues. It is a bit hard to discover them, since their titles are vague.

However, the external LSP doesn't work for me too. Logs from the extension are:

[Info  - 19:12:14] Connection to server got closed. Server will restart.
[Error - 19:12:14] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 19:12:14] Even Better TOML LSP client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 19:12:14] Connection to server got closed. Server will restart.
[Error - 19:12:14] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 19:12:14] Even Better TOML LSP client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 19:12:14] Connection to server got closed. Server will restart.
[Error - 19:12:14] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 19:12:14] Even Better TOML LSP client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 19:12:14] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 19:12:14] Connection to server got closed. Server will restart.
[Error - 19:12:14] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 19:12:14] Even Better TOML LSP client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 19:12:14] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 19:12:14] The Even Better TOML LSP server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
[Error - 19:12:14] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 19:12:14] Even Better TOML LSP client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 19:12:14] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 

I tried taplo-cli latest and taplo-cli@0.8.1.

panekj commented 3 months ago

Did you configure both evenBetterToml.taplo.bundled and evenBetterToml.taplo.path (it has to be full path)?

arisudesu commented 3 months ago

Sure. My settings are:

    "evenBetterToml.taplo.bundled": false,
    "evenBetterToml.taplo.path": "D:\\RUST\\cargo\\bin\\taplo.exe",
    "evenBetterToml.taplo.extraArgs": []

and my taplo is here

> where taplo.exe
D:\RUST\cargo\bin\taplo.exe

> taplo.exe
taplo 0.9.3

USAGE:
    taplo [OPTIONS] <SUBCOMMAND>

OPTIONS:
        --colors <COLORS>    [default: auto] [possible values: auto, always, never]
    -h, --help               Print help information
        --log-spans          Enable logging spans
    -V, --version            Print version information
        --verbose            Enable a verbose logging format

SUBCOMMANDS:
    config    Operations with the Taplo config file [aliases: cfg]
    format    Format TOML documents [aliases: fmt]
    get       Extract a value from the given TOML document
    help      Print this message or the help of the given subcommand(s)
    lint      Lint TOML documents [aliases: check, validate]
    lsp       Language server operations
panekj commented 3 months ago

I'm rarely on Windows so I can't check right now but can you verify that taplo lsp works from terminal and eventually try with / instead of \\ as path separator?

arisudesu commented 3 months ago

I don't know what taplo is doing in normal conditions, but taplo lsp works and prints usage:

> taplo lsp
taplo-lsp
Language server operations

USAGE:
    taplo lsp [OPTIONS] <SUBCOMMAND>

OPTIONS:
    -c, --config <CONFIG>            Path to the Taplo configuration file [env: TAPLO_CONFIG=]
        --cache-path <CACHE_PATH>    Set a cache path
        --colors <COLORS>            [default: auto] [possible values: auto, always, never]
    -h, --help                       Print help information
        --log-spans                  Enable logging spans
        --no-auto-config             Do not search for a configuration file
        --verbose                    Enable a verbose logging format

SUBCOMMANDS:
    help     Print this message or the help of the given subcommand(s)
    stdio    Run the language server over the standard input and output
    tcp      Run the language server and listen on a TCP address

However, running taplo lsp tcp or taplo lsp stdio (which I presume is operating mode for talking to VSCode), gives no output and the process terminates immediately. I tested on my working machine and in "clean" environment - Windows Sandbox - with the same executable.

Changing slashes from \\ to / doesn't help, same effect.

dbarnett commented 1 month ago

@arisudesu about this part:

However, running taplo lsp tcp or taplo lsp stdio (which I presume is operating mode for talking to VSCode), gives no output and the process terminates immediately.

You probably didn't install it with the lsp feature enabled. I had the same issue after installing with cargo and needed to add --features lsp to fix it. For some reason with that feature enabled they expose the lsp commands and their help normally but just silently exit when you run them... :face_with_diagonal_mouth:

(I have no context on the rest of your issues, sorry, just came across your issue and noticed that part sounded familiar.)

arisudesu commented 1 month ago

@dbarnett wow! So, it has a lsp command but it does nothing if feature isn't enabled during build... Surely taplo could report it better.

Okay, now that I know it, I noticed that there is a "taplo-full" builds on the release page. I grabbed taplo-full-windows-x86_64.zip from 0.9.3 and it does start as external LSP. I see its log in LSP output. However, apart from that nothing changed - it still has all the errors described in opening post. Now I wonder if there's more things that I miss to make it work correctly...

Settings tried ``` "evenBetterToml.taplo.bundled": false, "evenBetterToml.taplo.path": "D:\\RUST\\cargo\\bin\\taplo.exe", "evenBetterToml.taplo.extraArgs": [], "evenBetterToml.schema.associations": { "^.*\\.conf$": "https://json.schemastore.org/any.json" } ```
With --verbose arg ``` 2024-10-30T13:05:47.505234Z INFO lsp_async_stub: registered request handler, method: "initialize" at crates\lsp-async-stub\src\lib.rs:601 in taplo::taplo 2024-10-30T13:05:47.505283Z INFO lsp_async_stub: registered request handler, method: "textDocument/foldingRange" at crates\lsp-async-stub\src\lib.rs:601 in taplo::taplo 2024-10-30T13:05:47.505314Z INFO lsp_async_stub: registered request handler, method: "textDocument/formatting" at crates\lsp-async-stub\src\lib.rs:601 in taplo::taplo 2024-10-30T13:05:47.505336Z INFO lsp_async_stub: registered request handler, method: "textDocument/completion" at crates\lsp-async-stub\src\lib.rs:601 in taplo::taplo 2024-10-30T13:05:47.505368Z INFO lsp_async_stub: registered request handler, method: "textDocument/hover" at crates\lsp-async-stub\src\lib.rs:601 in taplo::taplo 2024-10-30T13:05:47.505402Z INFO lsp_async_stub: registered request handler, method: "textDocument/documentLink" at crates\lsp-async-stub\src\lib.rs:601 in taplo::taplo 2024-10-30T13:05:47.505298Z INFO lsp_async_stub: registered request handler, method: "textDocument/documentSymbol" at crates\lsp-async-stub\src\lib.rs:601 in taplo::taplo 2024-10-30T13:05:47.505479Z INFO lsp_async_stub: registered request handler, method: "textDocument/semanticTokens/full" at crates\lsp-async-stub\src\lib.rs:601 in taplo::taplo 2024-10-30T13:05:47.505491Z INFO lsp_async_stub: registered request handler, method: "textDocument/prepareRename" at crates\lsp-async-stub\src\lib.rs:601 in taplo::taplo 2024-10-30T13:05:47.505509Z INFO lsp_async_stub: registered notification handler, method: "textDocument/didOpen" at crates\lsp-async-stub\src\lib.rs:588 in taplo::taplo 2024-10-30T13:05:47.505497Z INFO lsp_async_stub: registered request handler, method: "textDocument/rename" at crates\lsp-async-stub\src\lib.rs:601 in taplo::taplo 2024-10-30T13:05:47.505544Z INFO lsp_async_stub: registered notification handler, method: "textDocument/didChange" at crates\lsp-async-stub\src\lib.rs:588 in taplo::taplo 2024-10-30T13:05:47.505553Z INFO lsp_async_stub: registered notification handler, method: "textDocument/didClose" at crates\lsp-async-stub\src\lib.rs:588 in taplo::taplo 2024-10-30T13:05:47.505583Z INFO lsp_async_stub: registered notification handler, method: "workspace/didChangeConfiguration" at crates\lsp-async-stub\src\lib.rs:588 in taplo::taplo 2024-10-30T13:05:47.505547Z INFO lsp_async_stub: registered notification handler, method: "textDocument/didSave" at crates\lsp-async-stub\src\lib.rs:588 in taplo::taplo 2024-10-30T13:05:47.505504Z INFO lsp_async_stub: registered notification handler, method: "initialized" at crates\lsp-async-stub\src\lib.rs:588 in taplo::taplo 2024-10-30T13:05:47.505654Z INFO lsp_async_stub: registered request handler, method: "taplo/convertToJson" at crates\lsp-async-stub\src\lib.rs:601 in taplo::taplo 2024-10-30T13:05:47.505619Z INFO lsp_async_stub: registered notification handler, method: "workspace/didChangeWorkspaceFolders" at crates\lsp-async-stub\src\lib.rs:588 in taplo::taplo 2024-10-30T13:05:47.505685Z INFO lsp_async_stub: registered request handler, method: "taplo/convertToToml" at crates\lsp-async-stub\src\lib.rs:601 in taplo::taplo 2024-10-30T13:05:47.505712Z INFO lsp_async_stub: registered request handler, method: "taplo/listSchemas" at crates\lsp-async-stub\src\lib.rs:601 in taplo::taplo 2024-10-30T13:05:47.505741Z INFO lsp_async_stub: registered request handler, method: "taplo/associatedSchema" at crates\lsp-async-stub\src\lib.rs:601 in taplo::taplo 2024-10-30T13:05:47.505772Z INFO lsp_async_stub: registered notification handler, method: "taplo/associateSchema" at crates\lsp-async-stub\src\lib.rs:588 in taplo::taplo 2024-10-30T13:05:47.506041Z INFO lsp_async_stub::listen::stdio: LSP server listening, transport: "stdio" at crates\lsp-async-stub\src\listen\stdio.rs:16 in taplo::taplo 2024-10-30T13:05:49.057910Z WARN taplo_lsp::world: failed to load workspace configuration, error: invalid root URL at crates\taplo-lsp\src\world.rs:160 in taplo_lsp::world::initialize with self.root=root:/// in taplo_lsp::handlers::configuration::update_configuration in taplo::taplo ```