epwalsh / obsidian.nvim

Obsidian 🀝 Neovim
Apache License 2.0
3.3k stars 150 forks source link

Editing slows down in large files when `ui` is enabled #611

Closed Addisonbean closed 1 month ago

Addisonbean commented 1 month ago

πŸ› Describe the bug

When editing a file that's larger than around 250KiB, making edits in insert and normal mode become slow. The effect is much more dramatic as the file grows towards 500KiB, like the file I noticed this on. This is much more annoying when in insert mode however as the text lags a lot while typing.

Adding ui = { enabled = false } to the settings fixes this, but as far as I'm aware there's no way to set this on a per-file basis.

Ideally the editing speed could be fixed for larger files, but I think even a way to disable ui for certain files, ideally based on a user-defined function, would be a huge improvement over the current behavior.

Here's an example of a large file that causes a bad slow down in edit speed (it's around 450KiB): https://pastebin.com/C4khy3k3

Config

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)

require('lazy').setup({
    {
        'epwalsh/obsidian.nvim',
        version = '*',
        dependencies = {
            'nvim-lua/plenary.nvim',
        },
        opts = {
            templates = {
                subdir = 'templates'
            },
            workspaces = {
                {
                    name = 'notes',
                    path = vim.env.XDG_DOCUMENTS_DIR .. '/obsidian',
                },
            },
            ui = {
                -- Uncommenting this line fixes the problem (at the cost of disabling ui features)
                -- enabled = false,
            },
        },
    },
})

Environment

NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1713773202
Run "nvim -V1 -v" for more info
Obsidian.nvim v3.7.12 (db41b1f20459293436fab510bec58c82a73bd1f7)
Status:
  β€’ buffer directory: nil
  β€’ working directory: /home/addison/documents/obsidian
Workspaces:
  βœ“ active workspace: Workspace(name='notes', path='/home/addison/documents/obsidian', root='/home/addison/documents/obsidian')
Dependencies:
  βœ“ plenary.nvim: a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683
Integrations:
  βœ“ picker: nil
  βœ— completion: disabled
Tools:
  βœ“ rg: ripgrep 14.1.0
Environment:
  β€’ operating system: Linux
Config:
  β€’ notes_subdir: nil
epwalsh commented 1 month ago

Hey @Addisonbean, increasing update_debounce may help, but I agree we need a better solution. I'll see what I can come up with.

epwalsh commented 1 month ago

Ok #613 adds the option to disable UI features for big files.

Addisonbean commented 1 month ago

Wow, that was a fast turn around. Thanks!!