-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: full completion support * test: add tests for virtual document change event * fix: use vim.validate(spec) * refactor: simplify buffer creation logic * refactor: enforce version for vbufs * refactor: use uris instead of fnames * refactor: tidy up print messages * fix: wrap `aftershave` request and notifications in coroutines * docs: mark completions as done :) * fix: log mismatch between virtual document versions instead of notifying --------- Co-authored-by: tris203 <[email protected]>
- Loading branch information
Showing
21 changed files
with
546 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
---@class rzls.EventEmitter | ||
---@field listeners (fun(...))[] | ||
local EventEmitter = {} | ||
|
||
EventEmitter.__index = EventEmitter | ||
|
||
function EventEmitter:new() | ||
return setmetatable({ | ||
listeners = {}, | ||
}, self) | ||
end | ||
|
||
function EventEmitter:fire(...) | ||
local args = { ... } | ||
vim.schedule(function() | ||
for _, handler in ipairs(self.listeners) do | ||
handler(unpack(args)) | ||
end | ||
end) | ||
end | ||
|
||
function EventEmitter:on(handler) | ||
table.insert(self.listeners, handler) | ||
|
||
return function() | ||
local handler_index = 0 | ||
for index, cur_handler in ipairs(self.listeners) do | ||
if rawequal(cur_handler, handler) then | ||
handler_index = index | ||
break | ||
end | ||
end | ||
|
||
if handler_index > 0 then | ||
table.remove(self.listeners, handler_index) | ||
end | ||
end | ||
end | ||
|
||
return EventEmitter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.