Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trouble getting this to work with jsx #67

Closed
michael-odonovan opened this issue May 13, 2023 · 3 comments
Closed

trouble getting this to work with jsx #67

michael-odonovan opened this issue May 13, 2023 · 3 comments

Comments

@michael-odonovan
Copy link

This is my config:

  {
    'nvim-treesitter/nvim-treesitter',
    dependencies = {
      'JoosepAlviste/nvim-ts-context-commentstring',
    },

    build = function()
      pcall(require('nvim-treesitter.install').update { with_sync = true })
    end,

    config = function()
      require('nvim-treesitter.configs').setup {
        ensure_installed = {
          'json', 'query', 'tsx', 'yaml', 'c', 'html', 'javascript', 'lua', 'cpp', 'go', 'lua', 'python', 'rust', 'typescript', 'vimdoc', 'vim', 'regex', 'bash', 'css', 'scss',
        },

        -- Install parsers synchronously (only applied to `ensure_installed`)
        sync_install = false,

        -- Automatically install missing parsers when entering buffer
        -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
        auto_install = false,

        highlight = {
          enable = true,

          ------------------------------------------------------------------------------
          -- !!! THIS IS WHAT MAKES MARKDOWN HEADINGS H1 ABLE TO BE DIFFERENT COLORS: !!
          ------------------------------------------------------------------------------
          disable = { "markdown" },

          additional_vim_regex_highlighting = false,

        },

        context_commentstring = {
          enable = true,
        },

      }
    end
  },

Is there something I am missing?

@JoosepAlviste
Copy link
Owner

Hey @michael-odonovan! The configuration seems correct. Here are a few questions and things to try:

  1. Which commenting plugin are you using? How are you checking whether or not this plugin works?
  2. Which file type are you testing this on?
  3. It looks like you're using the default CursorHold autocommand. Have you configured your updatetime to be smaller? E.g., vim.opt.updatetime = 100
  4. To check if this plugin is set up correctly, you can try running :=require('ts_context_commentstring.internal').calculate_commentstring(). This should return the correct commentstring based on your cursor location.

@michael-odonovan
Copy link
Author

Hey Joosep,
Thanks for getting back to me, your suggestions were really helpful.
After reading your README I realised I was missing the config that points Comment.nvim to you ts-context plugin.
My dumb.
Very cool plugin, thanks

@JoosepAlviste
Copy link
Owner

Glad to hear it! Although it should still work without the integration. Oh well 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants