ecosse3 / nvim

A non-minimal Neovim config built to work most efficiently with Frontend Development
GNU General Public License v3.0
1.19k stars 109 forks source link

Bad performance after opening any typescript or css file #128

Closed killerart closed 1 year ago

killerart commented 1 year ago

After opening and typescript (react tsx) or css file, any actions become delayed by approximately 1 second like switching between buffers, switching to file tree, starting typing a command or opening/switching to a terminal. So any action just freezes nvim for an entire second.

I don't have any modifications to the code besides a few keymappings.

Neovim 8.3 M1 iMac

killerart commented 1 year ago

Started getting the issue after the "lazy" update

ecosse3 commented 1 year ago

I think that's a bit of expected behaviour that UI will be frozen for 200-500ms because that's the time to load TypeScript Language Server tsserver. Could you please show the output of :Lazy profile, :Lazy debug after opening a tsx or css file?

Did you install LSP servers via Mason or manually via npm/yarn?

You can always try to opt-out from using them and use faster alternative like bun. I tried it but didn't have better results.

killerart commented 1 year ago

:Lazy profile after opening a tsx file:

  Startuptime: 112.57ms

  Based on the actual CPU time of the Neovim process till UIEnter.
  This is more accurate than `nvim --startuptime`.
    LazyStart 15.61ms
    LazyDone  61.02ms (+45.42ms)
    UIEnter   112.57ms (+51.55ms)

  Profile

  You can press <C-s> to change sorting between chronological order & time taken.
  Press <C-f> to filter profiling entries that took more time than a given threshold

    ●   lazy.nvim 5.09ms
      ➜   module 1.46ms
      ➜   config 0.2ms
      ➜   spec 1.84ms
        ★   config.plugins 1.35ms
      ➜   state 0.23ms
      ➜   install 0.02ms
      ➜   handlers 1.33ms
    ●  startup 59.45ms
      ➜   runtime/filetype.lua 0.19ms
      ➜  init 0.01ms
        ★   init   nvim-notify 0ms
      ➜  start 56.85ms
        ★  start   tokyonight.nvim 6.98ms
        ★  start   nvim-surround 2.03ms
        ★  start   nvim-toggleterm.lua 1.61ms
        ★  start   Comment.nvim 1.76ms
          ‒   Comment.nvim/plugin/Comment.lua 1.06ms
        ★  start   neovim-session-manager 3.92ms
          ‒   neovim-session-manager/plugin/session_manager.lua 3.41ms
            ●   plenary.nvim 0.27ms
              ➜   plenary.nvim/plugin/plenary.vim 0.2ms
        ★  start   printer.nvim 0.75ms
        ★  start   switch.vim 0.49ms
          ‒   switch.vim/plugin/switch.vim 0.42ms
        ★  start   numb.nvim 0.63ms
        ★  start   stay-in-place.nvim 0.41ms
        ★  start   telescope.nvim 24.37ms
          ‒   popup.nvim 0.15ms
          ‒   telescope-fzf-native.nvim 0.18ms
          ‒   telescope-repo.nvim 0.18ms
          ‒   telescope.nvim/plugin/telescope.lua 0.25ms
          ‒   nvim-treesitter 9.36ms
            ●   nvim-ts-rainbow 3.43ms
              ➜   nvim-ts-rainbow/plugin/rainbow.vim 3.18ms
            ●   nvim-ts-context-commentstring 0.52ms
              ➜   nvim-ts-context-commentstring/plugin/ts_context_commentstring.vim 0.48ms
            ●   nvim-treesitter-textobjects 1.63ms
              ➜   nvim-treesitter-textobjects/plugin/nvim-treesitter-textobjects.vim 1.55ms
            ●   nvim-treesitter-textsubjects 0.52ms
              ➜   nvim-treesitter-textsubjects/plugin/nvim-treesitter-textsubjects.vim 0.48ms
            ●   hlargs.nvim 1.11ms
            ●   nvim-treesitter/plugin/nvim-treesitter.lua 0.48ms
          ‒   git-worktree.nvim 0.95ms
        ★  start   alpha-nvim 9.55ms
        ★  start   mini.align 1.08ms
        ★  start   vim-repeat 0.05ms
        ★  start   todo-comments.nvim 1.94ms
          ‒   todo-comments.nvim/plugin/todo.vim 0.2ms
        ★  start   vim-speeddating 0.59ms
          ‒   vim-speeddating/plugin/speeddating.vim 0.5ms
        ★  start   splitjoin.vim 0.57ms
          ‒   splitjoin.vim/plugin/splitjoin.vim 0.25ms
      ➜  rtp plugins 2.24ms
        ★   runtime/plugin/health.vim 0.06ms
        ★   runtime/plugin/man.lua 0.25ms
        ★   runtime/plugin/matchit.vim 1.25ms
        ★   runtime/plugin/matchparen.vim 0.15ms
        ★   runtime/plugin/rplugin.vim 0.23ms
        ★   runtime/plugin/shada.vim 0.09ms
        ★   runtime/plugin/spellfile.vim 0.06ms
      ➜  after 0.14ms
    ●   which-key.nvim 2.8ms
      ➜   which-key.nvim/plugin/which-key.vim 0.21ms
    ●   typescript.nvim 0.03ms
    ●   nvim-lspconfig 3.81ms
      ➜   mason.nvim 0.35ms
      ➜   mason-lspconfig.nvim 0.26ms
      ➜   cmp-nvim-lsp 0.92ms
        ★   after/plugin/cmp_nvim_lsp.lua 0.65ms
      ➜   nvim-lspconfig/plugin/lspconfig.lua 2.22ms
    ●   nvim-ufo 0.95ms
      ➜   promise-async 0.39ms
    ●   LuaSnip 2.8ms
      ➜   friendly-snippets 0.38ms
      ➜   LuaSnip/plugin/luasnip.vim 2.13ms
      ➜   LuaSnip/ftdetect/snippets.vim 0.17ms
    ●   nvim-gps 1.57ms
      ➜   nvim-gps/plugin/nvim-gps.vim 0.65ms
    ●  VeryLazy 5.72ms
      ➜   galaxyline.nvim 3.64ms
        ★   galaxyline.nvim/plugin/galaxyline.vim 0.96ms
        ★   package-info.nvim 1.89ms
      ➜   dressing.nvim 2.06ms
        ★   nui.nvim 0.38ms
        ★   dressing.nvim/plugin/dressing.lua 0.84ms
    ●   nvim-notify 3.28ms
    ●   markdown 5.05ms
      ➜   markdown-preview.nvim 0.4ms
        ★   markdown-preview.nvim/plugin/mkdp.vim 0.3ms
      ➜   vim-table-mode 1.28ms
        ★   vim-table-mode/plugin/table-mode.vim 0.52ms
    ●   nvim-tree.lua 16.41ms
      ➜   barbar.nvim 6.36ms
        ★   nvim-web-devicons 3.01ms
          ‒   nvim-web-devicons/plugin/nvim-web-devicons.vim 0.25ms
        ★   barbar.nvim/plugin/bufferline.lua 2.83ms
    ●  BufReadPre 22.11ms
      ➜   gitsigns.nvim 13.89ms
        ★   trouble.nvim 4.43ms
          ‒   trouble.nvim/plugin/trouble.vim 0.32ms
      ➜   indent-blankline.nvim 3.63ms
        ★   indent-blankline.nvim/plugin/indent_blankline.vim 3.07ms
      ➜   null-ls.nvim 4.51ms
    ●  BufRead 9.11ms
      ➜   diffview.nvim 9.03ms
        ★   diffview.nvim/plugin/diffview.lua 1.59ms
    ●   typescriptreact 6.42ms
      ➜   template-string.nvim 2.46ms
    ●   lsp-inlayhints.nvim 3.97ms
killerart commented 1 year ago

:Lazy debug:

  Active Handlers
    This shows only the lazy handlers that are still active. When a plugin loads, its handlers are removed
    ●   ChatGPT   ChatGPT.nvim
    ●   ChatGPTEditWithInstructions   ChatGPT.nvim
    ●   LazyGit   lazygit.nvim
    ●   LazyGitCurrentFile   lazygit.nvim
    ●   LazyGitFilter   lazygit.nvim
    ●   LazyGitFilterCurrentFile   lazygit.nvim
    ●   ZenMode   zen-mode.nvim
    ●  InsertEnter   copilot.lua   nvim-autopairs   nvim-cmp
    ●   <C-Down>   vim-visual-multi
    ●   <C-n>   vim-visual-multi
    ●   <C-Up>   vim-visual-multi
    ●   <Leader>da   nvim-dap
    ●   <Leader>db   nvim-dap
    ●   <Leader>dc   nvim-dap
    ●   <Leader>dd   nvim-dap
    ●   <Leader>dh   nvim-dap
    ●   <Leader>di   nvim-dap
    ●   <Leader>dO   nvim-dap
    ●   <Leader>do   nvim-dap
    ●   <Leader>dt   nvim-dap
    ●   <S-Down>   vim-visual-multi
    ●   <S-Left>   vim-visual-multi
    ●   <S-Right>   vim-visual-multi
    ●   <S-Up>   vim-visual-multi

  Cache.find()
    total     766
    time      57.055ms
    avg time  0.074ms
    index     93
    fs_stat   1077
    not found 45
killerart commented 1 year ago

I understand that tsserver is loading for quite a while and it is expected to freeze a little on the first open, but it happens even after it's loaded on every window change, or just moving the cursor to nvim-tree and back to tsx file. The tsserver should already be loaded by that point

killerart commented 1 year ago

I've installed LSP servers via Mason

killerart commented 1 year ago

I also have LuaJIT version 5.4.4_1, if that would help

killerart commented 1 year ago

I downgraded EcoVim to release 2.4.2 and the performance is great

killerart commented 1 year ago

I don't know what the issue was, but I cleared ~/.local/nvim and ~/.cache/nvim and it got fixed.

ecosse3 commented 1 year ago

I am happy that's resolved! I couldn't reproduce it as well and didn't think that could be a cache problem.