0

nvim-cmp + Tailwind LSP lags the crap out of the editor when typing HTML class names.

I understand this must be because Tailwind's suggestions come in large quantities.

But is there a way to improve this?

My config is pretty minimal and it's already slower than VSCode. I must be doing something wrong.

My config: link

Some guidance would be greatly appreciated.

1

2 Answers 2

1

I was able to fix my issue by using someone's fork of cmp that targetered this specific issue.

https://github.com/yioneko/nvim-cmp

The suggestions seem to have some delay before showing up, but they don't lag the typing.

0
  -- create a treshhold for big files
  local preferred_sources = {
    { name = "luasnip" },
    { name = "nvim_lsp" },
    { name = "nvim_lua" },
    { name = "path" },
  }

  local function tooBig(bufnr)
    local max_filesize = 10 * 1024 -- 100 KB
    local check_stats = (vim.uv or vim.loop).fs_stat
    local ok, stats = pcall(check_stats, vim.api.nvim_buf_get_name(bufnr))
    if ok and stats and stats.size > max_filesize then
      return true
    else
      return false
    end
  end
  vim.api.nvim_create_autocmd("BufRead", {
    group = vim.api.nvim_create_augroup("CmpBufferDisableGrp", { clear = true }),
    callback = function(ev)
      local sources = preferred_sources
      if not tooBig(ev.buf) then
        sources[#sources + 1] = { name = "buffer", keyword_length = 4 }
      end
      cmp.setup.buffer({
        sources = cmp.config.sources(sources),
      })
    end,
  }) -- create a treshhold for big files (end)

Also try this:

    performance = {
      max_view_entries = 7,
    },

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.