Tree-sitter support for SuperCollider

Mine is practically the same as yours, except with some lazy-related changes that might be equivalent to what you have already, and I’m not even sure whether they’re easier to read or in any way better:

local M = {
  "davidgranstrom/scnvim",
  ft = { "supercollider" }, 
  config = function(_,opts)
    local scnvim = require("scnvim")
    scnvim.setup(opts)
  end,
  opts = function()
    local map = require("scnvim").map
    local map_expr = require("scnvim").map_expr
    return {
       -- table of options to sclang, basically the same as the table you're passing to scnvim.setup
    }
    end
}
return M

I also don’t think that the scnvim configuration has much to do with the nvim-treesitter at all. I think they’re independent of each other?
The rest of my config is just default lazyvim for all I can tell.
Did you checkhealth nvim-treesitter?

thanks for sharing, I don’t have yet a clear understanding of how nvim configuration works, just copy pasted the file from scnvim github page. To be sure, I tried with your file but it didn’t solve the issue. :checkhealth nvim-treesitter looks fine and the sc language is listed as installed.

I even tried booting linux from a usb drive to do some tests in a clean environment, but had same problem! :sweat:

That’s strange. But your nvim-treesitter works for other languages, right? (You can test it for lua if you open for instance the scnvim config file and enter :inspectTree)

1 Like

Yes! it’s so strange that tree-sitter works with other languages. I tried cpp and python and for those languages it works. but not for sc!

Hey, I think I might’ve figured out a fix. Because earlier when I said my nvim-treesitter was working again, I mostly looked at whether there were any errors in the tree, and not at the highlights etc., which still didn’t work (I didn’t get round to actually doing any work in sc those last few weeks so I overlooked that… or chalked it up to some vim-side settings). No idea, in hindsight, why the tree worked and the highlights didn’t…

Anyway now I redid a very clean lazyvim installation from scratch again, downloaded the supercollider grammar (no scnvim yet: They really don’t have anything to do with each other), and I was back to the original problem that you still have.

What helped, finally, was replacing the dynamic library that nvim-treesitter had installed (~/.local/share/nvim/site/parser/supercollider.so) with a locally built one.
Building that isn’t all that difficult, essentially you download the repo for the grammar, and run tree-sitter build. I think there were some setup steps beforehand (I forgot what they were, but TS will complain at you about them so you’ll know). This will generate a supercollider.so file that you can move to the above directory to overwrite the one that is in there. For now, it looks like it’s finally working like it somehow does, out of the box, on mac.

2 Likes