Fymyte / tree-sitter-rasi

RASI grammar for tree-sitter
MIT License
7 stars 2 forks source link

Not working in neovim? #5

Closed TSoli closed 5 months ago

TSoli commented 10 months ago

Hi I have installed the parser using nvim-treesitter however I am getting no highlighting or anything in rasi files. The text is completely white, there is no auto indent or anything. Not sure if this is a problem with the nvim-treesitter plugin or the parser but thought I should try here first since it's more specific.

Fymyte commented 10 months ago

It should work within Neovim but it has been a long time since I opened a rasi file. I will try to check the behavior you describe. To be sure, what version of Neovim/nvim-treesitter are you using ?

TSoli commented 10 months ago

nvim 0.9.1, nvim-treesitter at this commit, tree-sitter cli 0.20.8 (d4c1bf7ce78051b7f4a381d1508d68928512ed5f)

EDIT: Just tried updating nvim-treesitter and still nothing. Guess I could try updating neovim and see...

Fymyte commented 10 months ago

I'll not be home before Friday so I will not be able to test this right now. I will check the recent breaking changes on nvim-treesitter part in case I missed something. If you open the treesitter playground in a rasi file, is there anything ?

TSoli commented 10 months ago

I get the following error when I run :InspectTree

Error executing Lua callback: ...usr/share/nvim/runtime/lua/vim/treesitter/playground.lua:241: No parser available for the given buffer
stack traceback:
    [C]: in function 'assert'
    ...usr/share/nvim/runtime/lua/vim/treesitter/playground.lua:241: in function 'inspect_tree'
    ...nvimOBWTPk/usr/share/nvim/runtime/lua/vim/treesitter.lua:496: in function 'inspect_tree'
    ....mount_nvimOBWTPk/usr/share/nvim/runtime/plugin/nvim.lua:18: in function <....mount_nvimOBWTPk/usr/share/nvim/runtime/plugin/nvim.lua:9>

which is strange since when I do :TSInstallInfo it shows that the rasi parser is installed. The file I have open has extension .rasi as well so I am not sure what else to try?

Fymyte commented 9 months ago

Have you tried uninstalling the parser and re-installing

TSInstall rasi

Did you modify the definition of the rasi parser in your config ? Otherwise I can't see anything rn

TSoli commented 9 months ago

Did you modify the definition of the rasi parser in your config ? Otherwise I can't see anything rn

Yes I have tried that. No luck. Do you mean you can't reproduce?

Fymyte commented 9 months ago

Nop just that until I am able to try I have no more idea

Fymyte commented 9 months ago

Sorry for this delay. I don't use rofi anymore so it is no more usual for me to open a rasi file and I have a tendency to only think about your issue when I don't have access to my PC. I will set a reminder for tomorrow. Hopefully I will think about it

TSoli commented 9 months ago

Sorry for this delay. I don't use rofi anymore so it is no more usual for me to open a rasi file and I have a tendency to only think about your issue when I don't have access to my PC. I will set a reminder for tomorrow. Hopefully I will think about it

That's ok! I appreciate your work regardless. They're only config files that I don't touch too often so it's not the end of the world haha.

Fymyte commented 9 months ago

Hi, I finally thought to test this. At least right now, I have highlighting. I am on nvim v0.10.0-dev-1492+g3ca967387 so not the same version as you however. Have you installed the simpler rasi.vim extension ? (don't know if this could cause issue. In your tree-sitter config, have you additional_vim_regex_highlighting set to false ? I know I had issue with this enabled.

Fymyte commented 9 months ago

I had a strange behavior, like if queries were cached and did not update after updating the plugin. I modified the highlight.scm query file and the highlight updated properly

Fymyte commented 9 months ago

Did you also tried TSInstallFromGrammar rasi ?

TSoli commented 8 months ago

Hi sorry for the delayed response. I do not have the rasi.vim extension installed. I have not set the additional_vim_syntax_highlighting option in treesitter and I believe the default is false. TSInstallFromGrammar rasi did not work either.

Fymyte commented 8 months ago

Ok thats very strange. Maybe if you use a "dev" setup ? Can you

See if it works. 🤷‍♂️

TSoli commented 8 months ago

Still not working with that either unfortunately. I am not sure if it is supposed to show as installed when I do TSInstallInfo with thi setup but it does not. I am wondering if it may have something to do with how I load nvim-treesitter then? At the moment I have it with event = BufReadPre. Hasn't caused an issue with any other parsers but I can't think of what could be the issue. What do you use?

Fymyte commented 8 months ago

Currently using lazy.nvim, this is my config for treesitter

local function disable_for_large_files(lang, buf)
  local max_filesize = 100 * 1024 -- 100 KB
  local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
  if ok and stats and stats.size > max_filesize then
    return true
  end
end

local ensure_installed = {
  'c',
  'cpp',
  'rust',
  'css',
  'vim',
  'lua',
  'query',
  'regex',
  'bash',
  'markdown',
  'markdown_inline',
}

local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.rasi = {
  install_info = {
    url = '~/dev/tree-sitter-rasi/',
    files = {'src/parser.c'},
  }
}

return {
  'nvim-treesitter/nvim-treesitter',
  version = false,
  build = function()
    pcall(require('nvim-treesitter.install').update { with_sync = true })
  end,
  event = 'BufReadPost',
  opts = {
    auto_install = true,
    ensure_installed = ensure_installed,
    indent = { enable = true },

    -- Highlights
    highlight = {
      enable = true,
      additional_vim_regex_highlighting = false,
      disable = disable_for_large_files,
    },

    -- Playground
    playground = {
      enable = true,
      disable = disable_for_large_files,
    },
    query_linter = { enable = true },
  },
  config = function(_, opts)
    require('nvim-treesitter.configs').setup(opts)
  end,

  dependencies = { 'nvim-treesitter/playground' },
}
Fymyte commented 8 months ago

@TSoli are you still facing the issue ?

GraysonnG commented 8 months ago

Fwiw I am facing this issue still.

TSoli commented 8 months ago

@TSoli are you still facing the issue ?

Yes unfortunately.

Fwiw I am facing this issue still.

Do you get the same error as I did when you run :InspectTree?

I don't know if it matters but I am on Linux Mint 21.3 (which is based on Ubuntu 22.04). I only think to mention it since I assume a lot of people running WMs with rofi are probably on Arch or something else?

Fymyte commented 7 months ago

I don't get any errors with neither InspectTree nor TSPlaygroundToggle I don't see how the distro could influence this but yes I am running arch at home, but I used to use Debian 10 at work and TS was working well.

Fymyte commented 7 months ago

Can you send the file you've tried to open ?

dty2 commented 5 months ago

Hey guys did the problem solved? I meet the same problem too... my neovim is v0.9.5 And my problem like this...

Error executing Lua callback: /usr/share/nvim/runtime/lua/vim/treesitter/playground.lua:246: No parser available for the given buffer
stack traceback:
        [C]: in function 'assert'
        /usr/share/nvim/runtime/lua/vim/treesitter/playground.lua:246: in function 'inspect_tree'
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:497: in function 'inspect_tree'
        /usr/share/nvim/runtime/plugin/nvim.lua:18: in function </usr/share/nvim/runtime/plugin/nvim.lua:9>

I'm a arch user and use rofi too...

Fymyte commented 5 months ago

Nope sorry, I have no idea where the issue is. Just in case, can you check what happens if you open a file in the examples ?

And also the output of :checkhealth nvim_treesitter

dty2 commented 5 months ago

I run InspectTree and then I got the following...

Error executing Lua callback: /usr/share/nvim/runtime/lua/vim/treesitter/playground.lua:246: No parser available for the given buffer
stack traceback:
        [C]: in function 'assert'
        /usr/share/nvim/runtime/lua/vim/treesitter/playground.lua:246: in function 'inspect_tree'
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:497: in function 'inspect_tree'
        /usr/share/nvim/runtime/plugin/nvim.lua:18: in function </usr/share/nvim/runtime/plugin/nvim.lua:9>

I notice "No parser available" so I run "TSInstall rasi" again and my config is

require'nvim-treesitter.configs'.setup({
  ensure_installed = {
    -- dev
    "c", "cpp",
    -- build
    "cmake", "make", "dockerfile",
    -- script
    "lua", "bash", "python",
    -- web
    "javascript", "html", "css",
    -- data
    "sql", "proto", "textproto", "json", "json5", "yaml", "toml", "rasi",
    -- other
    "gitignore", "vim", "vimdoc", "query"
  },

  highlight = { enable = true },
  indent = { enable = true },
})

but still got the errorNo parser available so I run checkhealth nvim-treesitter and then I got the following...

nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~
- WARNING `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK `node` found v18.18.2 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  Version: cc (GCC) 13.2.1 20240417
- 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.8.9-zen1-1-zen",
  sysname = "Linux",
  version = "#1 ZEN SMP PREEMPT_DYNAMIC Thu, 02 May 2024 17:48:53 +0000"
} ~

Parser/Features         H L F I J
  - bash                ✓ ✓ ✓ . ✓
  - c                   ✓ ✓ ✓ ✓ ✓
  - cmake               ✓ . ✓ ✓ .
  - cpp                 ✓ ✓ ✓ ✓ ✓
  - css                 ✓ . ✓ ✓ ✓
  - dockerfile          ✓ . . . ✓
  - gitignore           ✓ . . . .
  - html                ✓ ✓ ✓ ✓ ✓
  - javascript          ✓ ✓ ✓ ✓ ✓
  - json                ✓ ✓ ✓ ✓ .
  - json5               ✓ . . . ✓
  - lua                 ✓ ✓ ✓ ✓ ✓
  - make                ✓ . ✓ . ✓
  - markdown            ✓ . ✓ ✓ ✓
  - markdown_inline     ✓ . . . ✓
  - proto               ✓ . ✓ . .
  - python              ✓ ✓ ✓ ✓ ✓
  - query               ✓ ✓ ✓ ✓ ✓
  - rasi                ✓ ✓ ✓ ✓ ✓
  - sql                 ✓ . . ✓ ✓
  - textproto           ✓ . ✓ ✓ .
  - toml                ✓ ✓ ✓ ✓ ✓
  - vim                 ✓ ✓ ✓ . ✓
  - vimdoc              ✓ . . . ✓
  - yaml                ✓ ✓ ✓ ✓ ✓

  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} ~
Fymyte commented 5 months ago

@TSoli I have probably found the issue :sweat: rasi is not a recognized file extension by Neovim by default. You have to add it yourself, otherwise Neovim doesn't know it is a rasi file, so it doesn't try to parse it with the corresponding parser. Probably the easiest fix is to put this somewhere in your config

vim.filetype.add {
  extension = {
    rasi = 'rasi',
  },
}

The correct fix would be to add this filetype in Neovim itself. I might try to do this at some point but if you're willing to try

The reason it was working for me was because I also had the rasi.vim plugin installed, which added the rasi filetype.

Fymyte commented 5 months ago

@GraysonnG @dty2 This was probably your issue too

Fymyte commented 5 months ago

Once https://github.com/vim/vim/pull/14821 is merged, I will try to add it in neovim as well

TSoli commented 5 months ago

@TSoli I have probably found the issue 😓 rasi is not a recognized file extension by Neovim by default. You have to add it yourself, otherwise Neovim doesn't know it is a rasi file, so it doesn't try to parse it with the corresponding parser. Probably the easiest fix is to put this somewhere in your config

vim.filetype.add {
  extension = {
    rasi = 'rasi',
  },
}

The correct fix would be to add this filetype in Neovim itself. I might try to do this at some point but if you're willing to try

The reason it was working for me was because I also had the rasi.vim plugin installed, which added the rasi filetype.

Great! This seems to work for me. Thanks very much for your efforts in tracking this down.

Fymyte commented 5 months ago

Rasi filetype support has been added in vim (https://github.com/vim/vim/commit/280e5b13ca568ed592a894140bf1ac74356f4b33) and neovim (https://github.com/neovim/neovim/commit/07af492f635c51d44d02d8012611cc5e11a4af19)