-
Notifications
You must be signed in to change notification settings - Fork 399
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
fix(async): properly trigger callbacks when canceling and fix delays in throttle.sync
#1611
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
vim.wait(timeout_ or 1000, function() | ||
return not self.running | ||
end) | ||
end, 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the real fix for the delay some users experienced.
Reason is that previsouly the code was not async, so filter would not be running in most cases.
With async, we are hitting the wait in cmp.sync
.
Default interval is 200ms
for vim.wait
which was causing the delays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you, i will check it now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@folke delay is greatly reduced, but not completely gone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hrsh7th instead of 10
, it could be set to an even lower value, but I personally don't see the delays anymore in the repro.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still pretty bad, I tried this:
cmp.visible = cmp.sync(function()
return cmp.core.view:visible() or vim.fn.pumvisible() == 1
end)
to
cmp.visible = function()
return cmp.core.view:visible() or vim.fn.pumvisible() == 1
end
and the delay is gone. I have no idea about the architecture of nvim-cmp
and why a visibility check would require so much code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll look into it more closely in the evening. I'm sure I saw this PR title when I did Lazy sync
.
throttle.sync
Thank you so much! |
I'm still get laggy after this patch.
/tmp/mini.luavim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.cmd([[set packpath=/tmp/cmp-min/site]])
local package_root = "/tmp/cmp-min/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
require("packer").startup({
{
"wbthomason/packer.nvim",
{
"williamboman/mason.nvim",
config = function()
require("mason").setup({
install_root_dir = "/tmp/cmp-min/data",
})
end,
},
{
"WhoIsSethDaniel/mason-tool-installer.nvim",
config = function()
require("mason-tool-installer").setup({
ensure_installed = {
"typescript-language-server",
},
})
end,
},
{
"neovim/nvim-lspconfig",
config = function()
local capabilities = require("cmp_nvim_lsp").default_capabilities()
require("lspconfig")["tsserver"].setup({
capabilities = capabilities,
})
end,
},
{
"ray-x/lsp_signature.nvim",
config = function()
require("lsp_signature").setup({
bind = true,
toggle_key = "<C-s>",
toggle_key_flip_floatwin_setting = true,
})
end,
},
{
"hrsh7th/nvim-cmp",
requires = { "hrsh7th/cmp-nvim-lsp" },
config = function()
local cmp = require("cmp")
cmp.setup({
mapping = {
["<CR>"] = cmp.mapping.confirm({ select = true }),
},
sources = cmp.config.sources({
{ name = "nvim_lsp" },
}),
})
end,
},
},
config = {
package_root = package_root,
compile_path = install_path .. "/plugin/packer_compiled.lua",
display = { non_interactive = true },
},
})
end
if vim.fn.isdirectory(install_path) == 0 then
vim.fn.system({ "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path })
end
load_plugins()
require("packer").sync() Run with 2023-06-10_01-21-12.online-video-cutter.com.mp4As you can see. This doesn't BTW. I've checked that after removing |
Same here, it's better but still get laggy: #273 |
…indow * upstream/main: Expand docs for select_next_item select_prev_item (hrsh7th#1626) fix type of the config.autocomplete to accept false (hrsh7th#1624) Update ghost_text type to allow true (hrsh7th#1616) Format with stylua fix: huge single line performance (hrsh7th#1433) (hrsh7th#1615) Format with stylua restore max_item_count fix(async): properly trigger callbacks when canceling and fix delays in `throttle.sync` (hrsh7th#1611) Improve types related to mapping definitions (hrsh7th#1604) fix: handle godot LSP better (hrsh7th#1592) Updating documentation as cmp_git source as been moved to git (hrsh7th#1603) fix(entry): fix matches highlight information fixes hrsh7th#1426 fix(entry): remove offset + 1 for tailwindcss Add extmark inline feature detection Restore schedule_wrap
Fixes #1610 #1608 #1610