Skip to content
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: Handle Dictionary Responses in jsonfly.lua for Neovim 0.10.1 #20

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 22 additions & 27 deletions lua/jsonfly/cache.lua
Original file line number Diff line number Diff line change
@@ -1,47 +1,42 @@
local M = {};
local M = {}

local _cache = {};
local _cache = {}

---@param buffer integer
function M:cache_buffer(buffer, value)
_cache[buffer] = value;
_cache[buffer] = value
end

---@param buffer integer
function M:invalidate_buffer(buffer)
_cache[buffer] = nil;
_cache[buffer] = nil
end

---@param buffer integer
---@return string[]|nil
function M:get_cache(buffer)
return _cache[buffer];
return _cache[buffer]
end

local _listening_buffers = {};
local _listening_buffers = {}

---@param buffer integer
function M:register_listeners(buffer)
if _listening_buffers[buffer] then
return;
end

_listening_buffers[buffer] = true;

vim.api.nvim_buf_attach(
buffer,
false,
{
on_lines = function()
self:invalidate_buffer(buffer)
end,
on_detach = function()
self:invalidate_buffer(buffer)
_listening_buffers[buffer] = nil;
end,
}
);
if _listening_buffers[buffer] then
return
end

_listening_buffers[buffer] = true

vim.api.nvim_buf_attach(buffer, false, {
on_lines = function()
self:invalidate_buffer(buffer)
end,
on_detach = function()
self:invalidate_buffer(buffer)
_listening_buffers[buffer] = nil
end,
})
end

return M;

return M
Loading
Loading