Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

No longer works for SuperCollider? #55

Open
madskjeldgaard opened this issue Aug 16, 2021 · 25 comments
Open

No longer works for SuperCollider? #55

madskjeldgaard opened this issue Aug 16, 2021 · 25 comments

Comments

@madskjeldgaard
Copy link

Hello

All of a sudden, playground stopped working for supercollider files. Did you disable supercollider somehow? In other languages like python it works fine. But running :TSPlaygroundToggle in a supercollider buffer (.scd) no longer does anything

@vigoux
Copy link
Member

vigoux commented Aug 16, 2021

That's the least useful issue we've had in a while, could you at least try to fill in the forms and add valuable information into the issues ?

We can't do anything without context.

@madskjeldgaard
Copy link
Author

That's the least useful issue we've had in a while, could you at least try to fill in the forms and add valuable information into the issues ?

We can't do anything without context.

There are no forms for this repo and so nothing to fill out.

That said, I understand that a lack of context isn't helpful.

What would you like to know ?

I'm using tree-sitter version 0.20.0
On Manjaro Linux
Nvim v.0.5.0
tree-sitter-nvim is at commit '460a26ef3218057a544b3fd6697e979e6bad648d'
playground is at commit 'deb887b3f49d66654d9faa9778e8949fe0d80bc3'

To replicate:
Open a supercollider file, eg someting.scd and run :PlaygroundToggle. Nothing happens.
Then run :tabnew otherfile.py to open a python file and then :PlaygroundToggle and then it opens for that buffer correctly.

@vigoux
Copy link
Member

vigoux commented Aug 16, 2021

Are you sure the supercollider filetype is on for the file you are trying to open ?

@madskjeldgaard
Copy link
Author

Are you sure the supercollider filetype is on for the file you are trying to open ?

yes. The strange thing is it used to work fine but all of a sudden it stopped, which is why I was curious if anything changed that would disable it by default or something for supercollider?

@madskjeldgaard
Copy link
Author

I tried going back to an earlier version (commit 1bf0f79) but that didn't help, so maybe it isn't something in this plugin that changed after all. Any ideas what it could be?

@vigoux
Copy link
Member

vigoux commented Aug 16, 2021

I have absolutely no idea, what does checkhealth report ?

@madskjeldgaard
Copy link
Author

Seems alright:


health#nvim_treesitter#check
========================================================================
## Installation
  - OK: `tree-sitter` found  0.20.0 (parser generator, only needed for :TSInstallFromGrammar)
  - OK: `node` found v16.6.1 (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 J
  - ocaml_interface✓ ✓ ✓ . ✓ 
  - beancount      ✓ . ✓ . . 
  - python         ✓ ✓ ✓ ✓ ✓ 
  - r              ✓ ✓ . . . 
  - comment        ✓ . . . . 
  - lua            ✓ ✓ ✓ ✓ ✓ 
  - ocaml          ✓ ✓ ✓ . ✓ 
  - go             ✓ ✓ ✓ ✓ ✓ 
  - scss           ✓ . . ✓ . 
  - json           ✓ ✓ ✓ ✓ . 
  - jsdoc          ✓ . . . . 
  - ledger         ✓ . ✓ ✓ ✓ 
  - php            ✓ ✓ ✓ ✓ ✓ 
  - clojure        ✓ ✓ ✓ . ✓ 
  - supercollider  ✓ ✓ ✓ ✓ ✓ 
  - typescript     ✓ ✓ ✓ ✓ ✓ 
  - fennel         ✓ ✓ . . ✓ 
  - query          ✓ ✓ ✓ ✓ ✓ 
  - cpp            ✓ ✓ ✓ ✓ ✓ 
  - vue            ✓ . ✓ . ✓ 
  - latex          ✓ . ✓ . ✓ 
  - rst            ✓ ✓ . . ✓ 
  - css            ✓ . ✓ ✓ ✓ 
  - glimmer        ✓ . . . . 
  - erlang         . . . . . 
  - regex          ✓ . . . . 
  - svelte         ✓ . ✓ ✓ ✓ 
  - c              ✓ ✓ ✓ ✓ ✓ 
  - fortran        ✓ . ✓ ✓ . 
  - teal           ✓ ✓ ✓ ✓ ✓ 
  - java           ✓ ✓ . ✓ ✓ 
  - gomod          ✓ . . . . 
  - dart           ✓ ✓ . ✓ ✓ 
  - verilog        ✓ ✓ ✓ . ✓ 
  - bash           ✓ ✓ ✓ . ✓ 
  - yaml           ✓ ✓ ✓ ✓ ✓ 
  - julia          ✓ ✓ ✓ ✓ ✓ 
  - turtle         ✓ ✓ ✓ ✓ ✓ 
  - cmake          ✓ . ✓ . . 
  - html           ✓ ✓ ✓ ✓ ✓ 
  - zig            ✓ . ✓ ✓ ✓ 
  - bibtex         ✓ . ✓ ✓ . 
  - tsx            ✓ ✓ ✓ ✓ ✓ 
  - yang           ✓ . ✓ . . 
  - nix            ✓ ✓ ✓ . ✓ 
  - surface        ✓ . ✓ ✓ ✓ 
  - godotResource  ✓ ✓ ✓ . . 
  - c_sharp        ✓ ✓ ✓ . ✓ 
  - commonlisp     ✓ ✓ ✓ . . 
  - elixir         ✓ ✓ ✓ ✓ ✓ 
  - cuda           ✓ ✓ ✓ ✓ ✓ 
  - haskell        ✓ . . . ✓ 
  - ocamllex       ✓ . . . ✓ 
  - kotlin         ✓ . . . ✓ 
  - ruby           ✓ ✓ ✓ ✓ ✓ 
  - fish           ✓ ✓ ✓ ✓ ✓ 
  - devicetree     ✓ ✓ ✓ ✓ ✓ 
  - dockerfile     ✓ . . . ✓ 
  - rust           ✓ ✓ ✓ ✓ ✓ 
  - gdscript       ✓ ✓ . . ✓ 
  - toml           ✓ ✓ ✓ ✓ ✓ 
  - javascript     ✓ ✓ ✓ ✓ ✓ 
  - jsonc          ✓ ✓ ✓ ✓ ✓ 
  - graphql        ✓ . . ✓ ✓ 
  - ql             ✓ ✓ . ✓ ✓ 
  - sparql         ✓ ✓ ✓ ✓ ✓ 
  - hcl            ✓ . ✓ ✓ ✓ 

 Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang}


@vigoux
Copy link
Member

vigoux commented Aug 16, 2021

I really don't know then

@stsewd
Copy link
Member

stsewd commented Aug 16, 2021

@madskjeldgaard can you share the file you are using for testing?

@catniptwinz
Copy link

Can reproduce.

Arch Linux
neovim 0.5.0
nvim-treesitter @ f2076b267ef2d53c35a964a8752eef38d7040fd5
playground @ deb887b

:checkhealth:

health#nvim_treesitter#check
========================================================================
## Installation
  - OK: `tree-sitter` found  0.20.0 (parser generator, only needed for :TSInstallFromGrammar)
  - OK: `node` found v16.6.2 (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 J
  - ocaml_interface✓ ✓ ✓ . ✓ 
  - beancount      ✓ . ✓ . . 
  - python         ✓ ✓ ✓ ✓ ✓ 
  - r              ✓ ✓ . . . 
  - comment        ✓ . . . . 
  - lua            ✓ ✓ ✓ ✓ ✓ 
  - ocaml          ✓ ✓ ✓ . ✓ 
  - go             ✓ ✓ ✓ ✓ ✓ 
  - scss           ✓ . . ✓ . 
  - json           ✓ ✓ ✓ ✓ . 
  - jsdoc          ✓ . . . . 
  - ledger         ✓ . ✓ ✓ ✓ 
  - php            ✓ ✓ ✓ ✓ ✓ 
  - clojure        ✓ ✓ ✓ . ✓ 
  - supercollider  ✓ ✓ ✓ ✓ ✓ 
  - typescript     ✓ ✓ ✓ ✓ ✓ 
  - fennel         ✓ ✓ . . ✓ 
  - query          ✓ ✓ ✓ ✓ ✓ 
  - cpp            ✓ ✓ ✓ ✓ ✓ 
  - vue            ✓ . ✓ . ✓ 
  - latex          ✓ . ✓ . ✓ 
  - rst            ✓ ✓ . . ✓ 
  - css            ✓ . ✓ ✓ ✓ 
  - glimmer        ✓ . . . . 
  - erlang         . . . . . 
  - regex          ✓ . . . . 
  - svelte         ✓ . ✓ ✓ ✓ 
  - c              ✓ ✓ ✓ ✓ ✓ 
  - teal           ✓ ✓ ✓ ✓ ✓ 
  - java           ✓ ✓ . ✓ ✓ 
  - gomod          ✓ . . . . 
  - dart           ✓ ✓ . ✓ ✓ 
  - verilog        ✓ ✓ ✓ . ✓ 
  - bash           ✓ ✓ ✓ . ✓ 
  - yaml           ✓ ✓ ✓ ✓ ✓ 
  - julia          ✓ ✓ ✓ ✓ ✓ 
  - vim            ✓ . . . ✓ 
  - turtle         ✓ ✓ ✓ ✓ ✓ 
  - cmake          ✓ . ✓ . . 
  - html           ✓ ✓ ✓ ✓ ✓ 
  - zig            ✓ . ✓ ✓ ✓ 
  - bibtex         ✓ . ✓ ✓ . 
  - tsx            ✓ ✓ ✓ ✓ ✓ 
  - yang           ✓ . ✓ . . 
  - nix            ✓ ✓ ✓ . ✓ 
  - surface        ✓ . ✓ ✓ ✓ 
  - godotResource  ✓ ✓ ✓ . . 
  - c_sharp        ✓ ✓ ✓ . ✓ 
  - commonlisp     ✓ ✓ ✓ . . 
  - elixir         ✓ ✓ ✓ ✓ ✓ 
  - cuda           ✓ ✓ ✓ ✓ ✓ 
  - ocamllex       ✓ . . . ✓ 
  - kotlin         ✓ . . . ✓ 
  - ruby           ✓ ✓ ✓ ✓ ✓ 
  - fish           ✓ ✓ ✓ ✓ ✓ 
  - devicetree     ✓ ✓ ✓ ✓ ✓ 
  - dockerfile     ✓ . . . ✓ 
  - rust           ✓ ✓ ✓ ✓ ✓ 
  - gdscript       ✓ ✓ . . ✓ 
  - toml           ✓ ✓ ✓ ✓ ✓ 
  - javascript     ✓ ✓ ✓ ✓ ✓ 
  - jsonc          ✓ ✓ ✓ ✓ ✓ 
  - graphql        ✓ . . ✓ ✓ 
  - ql             ✓ ✓ . ✓ ✓ 
  - sparql         ✓ ✓ ✓ ✓ ✓ 
  - hcl            ✓ . ✓ ✓ ✓ 

 Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang}

@madskjeldgaard
Copy link
Author

Here is a simple example:
yo.scd:

(
a = 10;
)

Parses as

(source_file [0, 0] - [3, 0]
  (code_block [0, 0] - [2, 1]
    (variable_definition [1, 0] - [1, 6]
      name: (variable [1, 0] - [1, 1]
        (environment_var [1, 0] - [1, 1]
          name: (identifier [1, 0] - [1, 1])))
      value: (literal [1, 4] - [1, 6]
        (number [1, 4] - [1, 6]
          (integer [1, 4] - [1, 6]))))))

Using the cli tool tree-sitter parse yo.scd.

The supercollider parser and nvim treesitter work fine otherwise. Code highlighting is correct, the parsing looks correct too behind the scenes, but there's just nothing happening when running playgrund

@madskjeldgaard
Copy link
Author

Debugging this a bit now. Seems like it is the split function that is failing and that it might be connected to the window? WTF?

if you uncomment this line:

api.nvim_set_current_win(current_window)

The split opens with the parsed node tree. But then, when you jump back to the main window (where the buffer of the file to be parsed is) it closes the Playground split automatically?

Here I am with the set window line uncommented, navigating the node tree and then jumping to the main buffer using C-w and then it disappears.

ts

@madskjeldgaard
Copy link
Author

Ah and then if you also comment out this line:
https://github.com/nvim-treesitter/playground/blob/master/lua/nvim-treesitter-playground/internal.lua#L765
It is fixed.

Can some of the devs with more knowledge of what's going on here clarify what the issue might be?

@madskjeldgaard
Copy link
Author

When I run the toggle playground command, this is the value of

bufnr: 1
current_window: 1000
M._entries[bufnr].display_bufnr: 2

in the .open() method

@madskjeldgaard
Copy link
Author

Something odd: the .detach() method is called before opening the split when using .scd files, but not for for example .cpp files.

@madskjeldgaard
Copy link
Author

When opening TSPlaygroundToggle in a SuperCollider buffer M.attach is called, followed by M.detach followed by M.attach. This does not happen in .cpp.

@salkin-mada
Copy link

I can also reproduce.

Arch Linux
neovim 0.6.1 and 0.7.0
nvim-treesitter @ 783a54e305e06d1f5e239efb0baa4a3d91e9fbe7
playground @ 7dbcd4d

nvim-treesitter: require("nvim-treesitter.health").check()
========================================================================
## Installation
  - OK: `tree-sitter` found 0.20.6 (parser generator, only needed for :TSInstallFromGrammar)
  - OK: `node` found v17.8.0 (only needed for :TSInstallFromGrammar)
  - OK: `git` executable found.
  - OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
    Version: cc (GCC) 11.2.0
  - OK: Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

## Parser/Features H L F I J
..
...
... ...
  - supercollider  ✓ ✓ ✓ ✓ ✓ 
... ...
...

and when commenting out nvim-treesitter-playground/internal.lua#L765 as suggested by @madskjeldgaard and to sum it up doing this: madskjeldgaard@854afcf
then :TSPlaygroundToggle works as expected with the supercollider filetype

@salkin-mada
Copy link

salkin-mada commented Mar 30, 2022

So I bisected a bit and rolled back several times in the commit history of playground to see when I could get it to work. No luck. But I found something else which seems to be the real issue.
As long as a buffer is called *.scd or *.sc (no matter if the file exist or not) then :TSPlaygroundToggle does absolutely nothing. BUT opening an empty buffer and setting the filetype to supercollider (very important that buffer is not named *.scd / *.sc) then playground works just fine.

@madskjeldgaard
Copy link
Author

madskjeldgaard commented Mar 30, 2022 via email

@salkin-mada
Copy link

Aha! So a quick test with both nvim-tressiter and playground in "buddy/friends rollback"-mode. Now I'm at the latest commit on both repos as of 22 March 2021. It was def not enough to just rollback on Playground. Because now :TSPlaygroundToggle works with .scd / .sc files again. And I also just tested with the latest playground commit and a nvim-treesitter commit from 22 March. And there :TSPlaygroundToggle also works. So it seems that this is not really a Playground issue it is a Nvim-TreeSitter issue.

@salkin-mada
Copy link

salkin-mada commented Mar 30, 2022

Ah maybe this is about scnvim's filetype setting ?Get Outlook for Android

Maybe a combination, i remember we did some scnvim filetype detect stuff recently.
I will never get Outlook :)~

@salkin-mada
Copy link

salkin-mada commented Mar 30, 2022

Okay the jsonc filetype detect fix: 9be9ebd (on nvim-treesitter) is breaking supercollider usage with :TSPlaygroundToggle. So it definitely seems to be a filetype detect issue here.

nvim-treesitter/nvim-treesitter@9be9ebd

@salkin-mada
Copy link

salkin-mada commented Mar 30, 2022

And it seems the issue is how the scnvim plugin is making filetype detection on .scd files.
I just tried disabling (removing) scnvim from my setup. And now I can use :TSPlaygroundToggle with .scd and .sc files, though the first is now detected as a scdoc file and the latter as a scala file. But setting the filetype to supercollider yields success.
So this is not a nvim-treesitter or playground issue but a scnvim issue. It seems [fingers crossed]. Next up is to try and figure out what we need to do in scnvim to detect the filetypes properly (using the newer nvim filetype.lua) and still not reintroduce the issue of jumpy scala-supercollider behavior due to the standard "last one wins"-way of filetype detection, which just switches filetypes in order.

-- notes on using playground while having scnvim installed
-- 9be9ebd seems to break playground usage with sc filetype or at least trigger something which is broken in scnvims detect sys
    commit = "74d1d58572a0e017aacb3fb66b43add9d208b86e", -- Jul 18, 2021 working
    commit = "9be9ebda0ad5d5ffb880829ad3315ab7c55a2acc", -- Jul 18, 2021 not working

@salkin-mada
Copy link

salkin-mada commented Mar 30, 2022

Yes without scnvim installed I can now use :TSPlaygroundToggle again with .scd and .sc files on an up to date nvim-treesitter and playground. Here I mean use as in Playground toggles a split.

But I do get errors without the scnvim plugin installed when scala short form is detected and rules all. At least there is some buggy behavior in regard to the supercollider filetype and scala detection even without the scnvim plugin. Soo maybe this is something nvim-treesitter have to deal with, the the same way scnvim had to deal with it? atleast vanilla nvim now detects a .sc file as scala, but lets say the treesitter user wants to use the supercollider parser and changes filetype on the buffer, then we would want treesitter/playground to switch parser, yes. Note that this is something else than the .scd issue, which seems to be linked to the scnvim plugin filedetect extension (I'm looking into this).
The .sc scala "issue" is due to the addition of the scala short form detection which was added here: neovim/neovim@7a239a8

Okay this is easier to show by making a list consisting of setup and result.

An up to date treesitter, nvim and playground, including all maintained parsers installed

  • Parsers up to date in relation to the lockfile at least.
  • Also making sure that there no manual config which set the filetype on BufEnter etc. of *.scd and *.sc files.

with scnvim installed

  1. nvim test.scd reported filetype is supercollider, insert Ndef(\).mold(2) into the buffer and do a :TSPlaygroundToggle results in:
    Nothing happens. No split is created. Nothing in :mess

  2. nvim test.sc reported filetype is supercollider, insert Ndef(\).mold(2) into the buffer and do a :TSPlaygroundToggle results in:
    Nothing happens. No split is created. Nothing in :mess

  3. nvim and do a :setfiletype supercollider, insert Ndef(\).mold(2) into the buffer and do a :TSPlaygroundToggle results in:

    function_call [0, 0] - [0, 15]
      receiver [0, 0] - [0, 7]
        function_call [0, 0] - [0, 7]
          class [0, 0] - [0, 4]
          parameter_call_list [0, 5] - [0, 6]
            argument_calls [0, 5] - [0, 6]
              unnamed_argument [0, 5] - [0, 6]
                literal [0, 5] - [0, 6]
                  symbol [0, 5] - [0, 6]
      method_call [0, 7] - [0, 15]
        name: method_name [0, 8] - [0, 12]
        parameter_call_list [0, 13] - [0, 14]
          argument_calls [0, 13] - [0, 14]
            unnamed_argument [0, 13] - [0, 14]
              literal [0, 13] - [0, 14]
                number [0, 13] - [0, 14]
                  integer [0, 13] - [0, 14]
    

without scnvim

  1. nvim test.scd reported filetype is scdoc, do a :setfiletype supercollider and insert Ndef(\).mold(2) into the buffer and do a :TSPlaygroundToggle results in:
    Split is created and reports

    function_call [0, 0] - [0, 15]
      receiver [0, 0] - [0, 7]
        function_call [0, 0] - [0, 7]
          class [0, 0] - [0, 4]
          parameter_call_list [0, 5] - [0, 6]
            argument_calls [0, 5] - [0, 6]
              unnamed_argument [0, 5] - [0, 6]
                literal [0, 5] - [0, 6]
                  symbol [0, 5] - [0, 6]
      method_call [0, 7] - [0, 15]
        name: method_name [0, 8] - [0, 12]
        parameter_call_list [0, 13] - [0, 14]
          argument_calls [0, 13] - [0, 14]
            unnamed_argument [0, 13] - [0, 14]
              literal [0, 13] - [0, 14]
                number [0, 13] - [0, 14]
                  integer [0, 13] - [0, 14]
    
  2. nvim test.sc reported filetype is scala, do a :setfiletype supercollider and insert Ndef(\).mold(2) into the buffer and do a :TSPlaygroundToggle results in:
    Split is created and reports

    ERROR [0, 0] - [1, 0]
      identifier [0, 0] - [0, 4]
      ERROR [0, 5] - [0, 6]
      identifier [0, 8] - [0, 12]
      integer_literal [0, 13] - [0, 14]
    

    But clear the buffer for content and insert object max (scala code) results in

    object_definition [0, 0] - [0, 10]
      name: identifier [0, 7] - [0, 10]
    

    So the filetype detected by treesitter is still scala? or at least it is still the scala parser which is loaded it seems.

  3. nvim and do a :setfiletype supercollider, insert Ndef(\).mold(2) into the buffer and do a :TSPlaygroundToggle results in:

    function_call [0, 0] - [0, 15]
     receiver [0, 0] - [0, 7]
       function_call [0, 0] - [0, 7]
         class [0, 0] - [0, 4]
         parameter_call_list [0, 5] - [0, 6]
           argument_calls [0, 5] - [0, 6]
             unnamed_argument [0, 5] - [0, 6]
               literal [0, 5] - [0, 6]
                 symbol [0, 5] - [0, 6]
     method_call [0, 7] - [0, 15]
       name: method_name [0, 8] - [0, 12]
       parameter_call_list [0, 13] - [0, 14]
         argument_calls [0, 13] - [0, 14]
           unnamed_argument [0, 13] - [0, 14]
             literal [0, 13] - [0, 14]
               number [0, 13] - [0, 14]
                 integer [0, 13] - [0, 14]
    

@salkin-mada
Copy link

Looking into the new API with filetype.lua (in version 0.7.0). Then all of this may not even be a problem. Potential RIP hours :)
Will report back at some point.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants