JoosepAlviste / nvim-ts-context-commentstring

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

does not work correctly for vim inside lua #31

Closed jdhao closed 2 years ago

jdhao commented 2 years ago

I am using nvim 0.6.0 release. I have installed nvim-treesitter (lua, viml parsers are installed), commentary.vim, and this plugin.

This is my config for treesitter:

require("nvim-treesitter.configs").setup({
  ensure_installed = {"python", "cpp", "lua", "vim"},
  ignore_install = {}, -- List of parsers to ignore installing
  highlight = {
    enable = true, -- false will disable the whole extension
    disable = {}, -- list of language that will be disabled
  },
  context_commentstring = {
    enable = true,
    -- enable_autocmd = false,
   config = {
      vim = '" %s',
    }
  }
})

When commenting viml inside lua, my test code is:

    vim.cmd([[
      hi link LspReferenceRead Visual
      hi link LspReferenceText Visual
      hi link LspReferenceWrite Visual
      augroup lsp_document_highlight
        autocmd! * <buffer>
        autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
        autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
      augroup END
    ]])

the comment string is still --, not ", is this supported or am I doing it wrong?

JoosepAlviste commented 2 years ago

Hey @jdhao! I think that this is related to this neovim issue: https://github.com/neovim/neovim/pull/16348 Vimscript highlighting does not seem to be injected correctly for me too.

Is the vim.cmd contents highlighted correctly as vimscript for you?

jdhao commented 2 years ago

@JoosepAlviste Nope, the viml inside vim.cmd is highlighted as string.

image

numToStr commented 2 years ago

So https://github.com/neovim/neovim/pull/16348 is merged. Now this will work as expected :)

https://user-images.githubusercontent.com/24727447/145793469-cc1d3efe-9f89-4c2b-81af-9a16a8642301.mp4

JoosepAlviste commented 2 years ago

Yep, this seems to work for me as well now. I'll close this for now but feel free to comment if it's not fixed for you for some reason @jdhao

jdhao commented 2 years ago

okay, thanks for the notice. I will try it ASAP.👍