Coder Social home page Coder Social logo

Comments (3)

JoosepAlviste avatar JoosepAlviste commented on August 18, 2024

Thanks for the report! Performance is something I haven't really thought about too much as I haven't had issues with it before.

I tried to reproduce this with some large markdown files, but didn't manage to. I tried the example you gave as well as this large-ish file: https://github.com/romkatv/powerlevel10k/blob/master/README.md.

Could you try commenting out some parts of the code in this plugin to see where exactly the issue is? Cloning the plugin somewhere, setting dev = true, and configuring the dev path for Lazy.nvim:

{
  path = '~/folder/where/the/plugin/is/cloned',
}

should make it rather easy to debug. This is the main entrypoint for the calculation:

function M.calculate_commentstring(args)

from nvim-ts-context-commentstring.

ribru17 avatar ribru17 commented on August 18, 2024

Thank you for the response! I have made a minimal config file that was able to reproduce the bug that I saw:

local root = vim.fn.fnamemodify('./.repro', ':p')

-- set stdpaths to use .repro
for _, name in ipairs { 'config', 'data', 'state', 'cache' } do
  vim.env[('XDG_%s_HOME'):format(name:upper())] = root .. '/' .. name
end

-- bootstrap lazy
local lazypath = root .. '/plugins/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system {
    'git',
    'clone',
    '--filter=blob:none',
    '--single-branch',
    'https://github.com/folke/lazy.nvim.git',
    lazypath,
  }
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  {
    'nvim-treesitter/nvim-treesitter',
    build = ':TSUpdate',
    event = { 'BufReadPost', 'BufNewFile' },
    config = function()
      require('nvim-treesitter.configs').setup {
        ensure_installed = {
          'markdown',
          'markdown_inline',
          'html',
          'comment',
        },
        highlight = {
          enable = true,
        },
      }
    end,
  },
  'folke/tokyonight.nvim',
  -- add this to your lua/plugins.lua, lua/plugins/init.lua,  or the file you keep your other plugins:
  {
    'numToStr/Comment.nvim',
    config = function()
      require('Comment').setup {
        pre_hook = require(
          'ts_context_commentstring.integrations.comment_nvim'
        ).create_pre_hook(),
      }
    end,
    keys = { 'gc' },
  },
  {
    'JoosepAlviste/nvim-ts-context-commentstring',
    main = 'ts_context_commentstring',
    opts = {
      enable_autocmd = false,
    },
    lazy = true,
  },
}
require('lazy').setup(plugins, {
  root = root .. '/plugins',
})

vim.cmd.colorscheme('tokyonight')

Without Treesitter, the commenting is quite fast but with it it is very slow, at least with the file I linked above. I ran it with nvim -u repro.lua

from nvim-ts-context-commentstring.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.