-
Notifications
You must be signed in to change notification settings - Fork 32
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
Commenting is slow in large Markdown files #88
Comments
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 {
path = '~/folder/where/the/plugin/is/cloned',
} should make it rather easy to debug. This is the main entrypoint for the calculation:
|
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 |
Minimal reproducible full config
Description
When operating on large
.md
files (~1500 lines), it takes over a second to toggle a comment line usingComment.nvim
. Removing this plugin while still usingComment.nvim
removes the delay.Steps to reproduce
Expected behavior
It takes a long amount of time just to comment one line
Actual behavior
Commenting a line should be quite quick
Additional context
For reference, the original file I had issues with is https://github.com/ribru17/118cs-notes/blob/master/README.md
The text was updated successfully, but these errors were encountered: