rest.nvim icon indicating copy to clipboard operation
rest.nvim copied to clipboard

New update from nvim-treesitter breaks http syntax highlight

Open dakennguyen opened this issue 1 year ago • 12 comments

Hi,

since this commit I encounter this error whenever I go to HTTP file image

This is the minimal config to reproduce the issue:

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

local plugins = {
  {
    'nvim-treesitter/nvim-treesitter',
    commit = "eedc5198a1b4bb1b08ae6d4f64f3d76e376957aa", -- remove this line to cause error
    build = ":TSUpdate",
    opts = {
      ensure_installed = { 'http' },
      highlight = {
        enable = true,
      }
    },
    config = function(_, opts)
      require('nvim-treesitter.configs').setup(opts)
    end,
  },
  'NTBBloodbath/rest.nvim',
}

require("lazy").setup(plugins, {})

Here is the maintainer's suggestion:

rest.nvim specific captures have been removed; they should be added in that plugin (as an ; extends) query. Please open an issue on that repo.

dakennguyen avatar Apr 21 '23 10:04 dakennguyen

Created issue for same in here https://github.com/rest-nvim/tree-sitter-http/issues/11

guruor avatar Apr 24 '23 04:04 guruor

Hey, I've finally managed to address this issue. See tree-sitter-http#11 comment.

Queries have been updated here too, so they will probably break if you've pinned your http tree-sitter parser using an older commit, please check it out and let me know if the issue persists.

Cheers

NTBBloodbath avatar May 04 '23 22:05 NTBBloodbath

Hi @NTBBloodbath, thank you for the update! image For me the env variable doesn't work anymore

dakennguyen avatar May 05 '23 09:05 dakennguyen

Hi @NTBBloodbath, thank you for the update! image For me the env variable doesn't work anymore

Hmm could you open a separate issue for this one? That way we have more organization to track latest changes bugs

NTBBloodbath avatar May 05 '23 16:05 NTBBloodbath

I also encountered into this issue

zhangddjs avatar May 23 '23 01:05 zhangddjs

Just updated my plugins yesterday and now I also run into this. Syntax highlighting won't work, and it even corrupts my session as soon as I enter a http file and I have to :SessionDelete. But this is a treesitter issue I believe, right?

KyrillGobber avatar Jun 23 '23 21:06 KyrillGobber

I get error


E5108: Error executing lua ...0.9.4/share/nvim/runtime/lua/vim/treesitter/language.lua:93: no parser for 'conf' language, see :help treesitter-parsers
stack traceback:
        [C]: in function 'error'
        ...0.9.4/share/nvim/runtime/lua/vim/treesitter/language.lua:93: in function 'add'
        ...4/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:98: in function 'new'
        ...r/neovim/0.9.4/share/nvim/runtime/lua/vim/treesitter.lua:61: in function '_create_parser'
        ...r/neovim/0.9.4/share/nvim/runtime/lua/vim/treesitter.lua:131: in function 'get_parser'
        ...l/share/nvim/lazy/rest.nvim/lua/rest-nvim/utils/init.lua:218: in function 'read_document_variables'
        ...l/share/nvim/lazy/rest.nvim/lua/rest-nvim/utils/init.lua:250: in function 'read_variables'
        ...l/share/nvim/lazy/rest.nvim/lua/rest-nvim/utils/init.lua:260: in function 'replace_vars'
        ...share/nvim/lazy/rest.nvim/lua/rest-nvim/request/init.lua:253: in function 'parse_url'
        ...share/nvim/lazy/rest.nvim/lua/rest-nvim/request/init.lua:286: in function 'get_current_request'
        .../.local/share/nvim/lazy/rest.nvim/lua/rest-nvim/init.lua:25: in function 'run'
        [string ":lua"]:1: in main chunk

Structure

.rest
   |  .env
   |  dev-1.rest

volga629-1 avatar Dec 19 '23 04:12 volga629-1

I get error


E5108: Error executing lua ...0.9.4/share/nvim/runtime/lua/vim/treesitter/language.lua:93: no parser for 'conf' language, see :help treesitter-parsers
stack traceback:
        [C]: in function 'error'
        ...0.9.4/share/nvim/runtime/lua/vim/treesitter/language.lua:93: in function 'add'
        ...4/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:98: in function 'new'
        ...r/neovim/0.9.4/share/nvim/runtime/lua/vim/treesitter.lua:61: in function '_create_parser'
        ...r/neovim/0.9.4/share/nvim/runtime/lua/vim/treesitter.lua:131: in function 'get_parser'
        ...l/share/nvim/lazy/rest.nvim/lua/rest-nvim/utils/init.lua:218: in function 'read_document_variables'
        ...l/share/nvim/lazy/rest.nvim/lua/rest-nvim/utils/init.lua:250: in function 'read_variables'
        ...l/share/nvim/lazy/rest.nvim/lua/rest-nvim/utils/init.lua:260: in function 'replace_vars'
        ...share/nvim/lazy/rest.nvim/lua/rest-nvim/request/init.lua:253: in function 'parse_url'
        ...share/nvim/lazy/rest.nvim/lua/rest-nvim/request/init.lua:286: in function 'get_current_request'
        .../.local/share/nvim/lazy/rest.nvim/lua/rest-nvim/init.lua:25: in function 'run'
        [string ":lua"]:1: in main chunk

Structure

.rest
   |  .env
   |  dev-1.rest

Hey, this is odd.

  1. Are you using a .http file?
  2. Are you lazy-loading rest.nvim somehow?

NTBBloodbath avatar Dec 19 '23 11:12 NTBBloodbath

No lazy loading and I tried http and rest extensions, http give error http and rest give error conf

volga629-1 avatar Dec 19 '23 13:12 volga629-1

I'm pretty sure it broke on neovim 0.9.4 with this diff https://github.com/neovim/neovim/commit/c5b9643bf1b0f6d5166b4abf6a7c3f29532aefeb

Adding the http parser for treesitter fixes the issue. http parser is not enabled by default in LazyVim.

I'd suggest you check for that and if it fails just disable the .env functionality instead of erroring out?

Edit: wrapping this call in pcall will probably be enough to let it fail silently and not break the functionality: https://github.com/rest-nvim/rest.nvim/blob/84e81a19ab24ccf05c9233d34d4dfce61c233abe/lua/rest-nvim/utils/init.lua#L218

MZAWeb avatar Dec 20 '23 21:12 MZAWeb

No lazy loading and I tried http and rest extensions, http give error http and rest give error conf

@volga629-1 try ensuring the http treesitter parser is installed

MZAWeb avatar Dec 20 '23 21:12 MZAWeb

Thank you for reply, indeed I reinstalled plugin and make sure set

ensure_installed = {
        "http",

volga629-1 avatar Dec 21 '23 20:12 volga629-1