tree-sitter / tree-sitter-rust

Rust grammar for tree-sitter
MIT License
341 stars 97 forks source link

Indented comments don't get continued lines indented #108

Closed lf- closed 3 years ago

lf- commented 3 years ago

Describe the bug

Indented comments don't wrap onto indented new lines in rust. Seems to be ok in the lua plugin.

To Reproduce

Steps to reproduce the behavior:

  1. nvim a.rs
  2. 
    struct A;

impl A { /// Do some stuff!! (put cursor here and press enter) fn a(); }

3. Get
```rust
struct A;

impl A {
    /// Do some stuff!!
/// |<- cursor here
    fn a();
}

Expected behavior

struct A;

impl A {
    /// Do some stuff!!
    /// |<- cursor here
    fn a();
}

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check ======================================================================== ## Installation - OK: `tree-sitter` found 0.19.4 (parser generator, only needed for :TSInstallFromGrammar) - OK: `node` found v16.1.0 (only needed for :TSInstallFromGrammar) - OK: `git` executable found. - OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl" } - OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI. ## Parser/Features H L F I - c_sharp ✓ . . . - svelte ✓ . ✓ ✓ - beancount ✓ . ✓ . - zig ✓ ✓ ✓ ✓ - c ✓ ✓ ✓ ✓ - teal ✓ ✓ ✓ ✓ - java ✓ ✓ . ✓ - python ✓ ✓ ✓ ✓ - bibtex ✓ . ✓ ✓ - sparql ✓ ✓ ✓ ✓ - comment ✓ . . . - gomod ✓ . . . - dart ✓ ✓ . ✓ - lua ✓ ✓ ✓ ✓ - latex ✓ . ✓ . - ocaml ✓ ✓ ✓ . - bash ✓ ✓ ✓ . - r ✓ ✓ . . - yaml ✓ ✓ ✓ ✓ - json ✓ ✓ ✓ ✓ - jsdoc ✓ . . . - ledger ✓ . ✓ ✓ - php ✓ ✓ ✓ ✓ - julia ✓ ✓ . . - supercollider ✓ ✓ ✓ ✓ - devicetree ✓ ✓ ✓ ✓ - gdscript ✓ ✓ . . - turtle ✓ ✓ ✓ ✓ - vue ✓ . ✓ . - html ✓ ✓ ✓ ✓ - typescript ✓ ✓ ✓ ✓ - regex ✓ . . . - verilog ✓ ✓ ✓ . - jsonc ✓ ✓ ✓ ✓ - ql ✓ ✓ . ✓ - fennel ✓ ✓ . . - rst ✓ ✓ . . - nix ✓ ✓ ✓ . - query ✓ ✓ ✓ ✓ - graphql ✓ . . ✓ - cpp ✓ ✓ ✓ ✓ - toml ✓ ✓ ✓ ✓ - kotlin ✓ . . . - ruby ✓ ✓ ✓ ✓ - fish ✓ ✓ ✓ ✓ - ocamllex ✓ . . . - dockerfile ✓ . . . - rust ✓ ✓ ✓ ✓ - ocaml_interface✓ ✓ ✓ . - javascript ✓ ✓ ✓ ✓ - css ✓ . ✓ ✓ - glimmer ✓ . . . - erlang . . . . - clojure ✓ ✓ . . - go ✓ ✓ ✓ ✓ - tsx ✓ ✓ ✓ ✓ Legend: H[ighlight], L[ocals], F[olds], I[ndents] +) multiple parsers found, only one will be used x) errors found in the query, try to run :TSUpdate {lang}

Output of nvim --version

NVIM v0.5.0-dev+1318-g61aefaf29 Build type: RelWithDebInfo LuaJIT 2.0.5 Compilation: /usr/bin/cc -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -g -fvar-tracking-assignments -fdebug-prefix-map=/home/jade/.cache/aurutils/sync/neovim-git/src=/usr/src/debug -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/jade/.cache/aurutils/sync/neovim-git/src/build/config -I/home/jade/.cache/aurutils/sync/neovim-git/src/neovim-git/src -I/usr/include -I/home/jade/.cache/aurutils/sync/neovim-git/src/build/src/nvim/auto -I/home/jade/.cache/aurutils/sync/neovim-git/src/build/include Compiled by jade@tail-bot Features: +acl +iconv +tui See ":help feature-compile" system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/share/nvim" Run :checkhealth for more info

Additional context

Treesitter config is:

lua <<EOF
require'nvim-treesitter.configs'.setup {
  ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
  -- ignore_install = { "javascript" }, -- List of parsers to ignore installing
  highlight = {
    enable = true,              -- false will disable the whole extension
    --disable = { },  -- list of language that will be disabled
  },
  indent = {
    enable = true
  },
}
EOF

:set indentexpr?: indentexpr=nvim_treesitter#indent()

maxbrunsfeld commented 3 years ago

I think you're describing a Neovim issue here? This repository is just the parser, which is then used by Neovim to provide things like auto-indent. Can you reopen this on the Neovim or nvim-treesitter repo?

lf- commented 3 years ago

I think you're describing a Neovim issue here? This repository is just the parser, which is then used by Neovim to provide things like auto-indent. Can you reopen this on the Neovim or nvim-treesitter repo?

I'm unsure if it's one of those: the treesitter-lua and c++ modules appear to have working indentation in this situation, by comparison, which led me to believe it's a rust grammar specific issue. I was initially going to file this on nvim-treesitter but reconsidered on the basis of it being seemingly language specific.

Is there any debug info I could get that might be helpful?

maxbrunsfeld commented 3 years ago

It may be a language-specific issue inside of nvim-treesitter? Not all language-specific logic is contained in this repository: just the parser itself.