nvim-treesitter / nvim-treesitter

Nvim Treesitter configurations and abstraction layer
Apache License 2.0
10.84k stars 900 forks source link

a few remarks on the debugging outputs #4053

Open teto opened 1 year ago

teto commented 1 year ago

Is your feature request related to a problem? Please describe.

I would like the equivalent of :LspInfo that dumps only what is relevant to debug my current buffer, maybe something like :TSInfo ? TSModuleInfo dumps too much information, here it dumps 137 lines for all the languages I have nothing installed.

Other remarks on checkhealth:

- WARNING `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- WARNING `node` executable not found (only needed for :TSInstallFromGrammar, not required for :TSInstall)
- ERROR `cc` executable not found.
  - ADVICE:
    - Check that any of { vim.NIL, "cc", "gcc", "clang", "cl", "zig" } is in your $PATH or set the environment variable CC or `require"nvim-treesitter.install".compilers` explicitly!
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
  machine = "x86_64",
  release = "6.1.1",
  sysname = "Linux",
  version = "#1-NixOS SMP PREEMPT_DYNAMIC Wed Dec 21 16:48:12 UTC 2022"
} ~

I install all my grammars via nix, I find it weird to see the absence of a compiler. It should be a warning or popup when running TSInstall.

- WARNING `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- WARNING `node` executable not found (only needed for :TSInstallFromGrammar, not required for :TSInstall)

I've tried :h :TSInstall to no avail, so I wonder what's the difference between TSInstallFromGrammar and TSInstall ? Might be worth adding to documentation. As for the "OS info" part, if every plugin starts to add a similar output to its healthcheck, we are doomed. It is relevant though so maybe it should be upstreamed to bneovim instead.

theHamsta commented 1 year ago

I would like the equivalent of :LspInfo that dumps only what is relevant to debug my current buffer, maybe something like :TSInfo ?

So you would like to have something like :TSModuleInfo? But filtered for the languages for the current buffer?

I've tried :h :TSInstall to no avail, so I wonder what's the difference between TSInstallFromGrammar and TSInstall ? Might be worth adding to documentation.

:TSInstall installs the parsers with minimal steps needed. Typically, just compiling the C sources. :TSInstallFromGrammar generates the parser from grammar.js so you need node and for some parsers even npm when they have dependencies on other grammars.

As for the "OS info" part, if every plugin starts to add a similar output to its healthcheck, we are doomed. It is relevant though so maybe it should be upstreamed to bneovim instead.

Yes, we really need the OS info since we often debug compiler errors. In particular, we would like to know whether they are on MacOS, Windows or Linux, and the arch on Windows and MacOS.Many users compile for the wrong architecture (e.g. 32bit parsers on 64bit Neovim or arm64 parsers for a Rosetta emulated x64 Neovim or vice-versa. Many users don't seem to be able to provide this information reliably as they didn't notice that their OS runs a different architecture for them. This would be something that could be somehow deducible from nvim --version

It is relevant though so maybe it should be upstreamed to bneovim instead.

What do you mean? Where upstream Neovim should put it? It's just the output of vim.loop.os_uname()

teto commented 1 year ago

So you would like to have something like :TSModuleInfo? But filtered for the languages for the current buffer?

Yes, I would be happy with :TSModuleInfo <filetype> but since there are already TSBuf commands maybe TSBufInfo could be an alias to :TSModuleInfo <filetype>

It's just the output of vim.loop.os_uname()

I understand it's valuable information but we can't have every plugin dump that in checkhealth. Rather than displaying this in treesitter, I say let's dump it in require("nvim.health").check() so that all plugins can get the info (ask for a full dump of checkhealth in the bug report).

Thnaks for the explanation about TSInstall. Worth adding to docs imo

theHamsta commented 1 year ago

I've tried :h :TSInstall to no avail, so I wonder what's the difference between TSInstallFromGrammar and TSInstall ? Might be worth adding to documentation.

I just tried to fix that. But I discovered that we already have a :TSInstall tag. Did you miss generating the help tags for nvim-treesitter.

teto commented 1 year ago

yeah I can see the tag now, not sure why it didn't work before. I've been playing with the playground it's great, but I think I hit https://github.com/nvim-treesitter/playground/issues/88 . I've ran a nvim-treesitter checkhealth image could the message say in which query the errors were found ?

NB: found the issue, I had not the "query" grammar installed