JoosepAlviste / nvim-ts-context-commentstring

Neovim treesitter plugin for setting the commentstring based on the cursor location in a file.
MIT License
1.18k stars 35 forks source link

Incorrect commentstring for erb tags on eruby files #111

Open smarquez1 opened 6 months ago

smarquez1 commented 6 months ago

Minimal reproducible full config

-- Install lazy.nvim automatically
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)

-- Or some other small value (Vim default is 4000)
vim.opt.updatetime = 100

require('lazy').setup {
  'JoosepAlviste/nvim-ts-context-commentstring',
  {
    'nvim-treesitter/nvim-treesitter',
    build = ':TSUpdate',
    config = function()
      require('nvim-treesitter.configs').setup {
        ensure_installed = { 'vim', 'lua', 'ruby', 'embedded_template', 'html' },
        highlight = {
          enable = true,
        },
      }
    end,
  },
  {
    'numToStr/Comment.nvim',
    config = function()
      require('Comment').setup {
        pre_hook = function()
          return vim.bo.commentstring
        end,
      }
    end,
  },
}

Description

Fails to recognize and comment out erb tags, instead it uses HTML comments.

Steps to reproduce

Try to comment out the third line of the following erb file:

<div>
  <p>test</p>
  <%= test %>
</div>

Expected behavior

<div>
  <!-- <p>test</p> -->
  <%# test %>
</div>

Actual behavior

<div>
  <!-- <p>test</p> -->
  <!-- <%= test %> -->
</div>

Additional context

nvim-treesitter uses embedded_template to highlight eruby (erb) files. I'm not sure if this is a nvim-ts-context-commentstring or a tree-sitter-embedded-template issue but would appreciate your insights.