Skip to content

Commit

Permalink
feat: giving up.. :(
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePrimeagen committed Jan 23, 2024
1 parent 4954e78 commit be9b4e2
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 30 deletions.
58 changes: 46 additions & 12 deletions lua/run.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,46 @@
if VimAPMRequired then
require("vim-apm"):clear()
end

R("vim-apm")

local apm = require("vim-apm")
apm:setup({
reporter = {
type = "network",
}
})
-- if VimAPMRequired then
-- require("vim-apm"):clear()
-- end
--
-- R("vim-apm")
--
-- local apm = require("vim-apm")
-- apm:setup({
-- reporter = {
-- type = "network",
-- }
-- })

vim.on_key(function(key)
print("key: " .. key)
end)

vim.api.nvim_feedkeys("23jci{hello worldkdi(itrue", "t", false)

--[[
hello world
he ntoheuoeuaoeunato euoeuaoeuoaeu
aoeuaoeutaoeuaoeuaoeunth
aoeuoaeuoaeuth
aoeuoaeuoaeuaoeuoaeuaoeu
oaentuh
aonetuh
naoteu
ntoaeh
ntaoehntaoeu
aoenuthaonetuhaonteuhnt
ntoehu
ntoaheu
ntaoheuntoah
untaoh
euoaeuoaeu
ntaoheuntoheu } onateuhnotehu
if (true) {
ntoheuntoheutn
}
--]]
9 changes: 3 additions & 6 deletions lua/vim-apm/reporter/file-reporter.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
local APMBussin = require("vim-apm.bus")
local Stats = require("vim-apm.stats")
local Events = require("vim-apm.event_names")
local Interval = require("vim-apm.interval")

---@class APMFileReporter : APMReporter
---@field path string
---@field enabled boolean
---@field calc APMCalculator
---@field stats APMStats
---@field collector APMStatsCollector
---@field opts APMReporterIntervalOptions
local FileReporter = {}
FileReporter.__index = FileReporter
Expand All @@ -27,7 +24,7 @@ function FileReporter.new(path, opts)
return setmetatable({
path = path,
enabled = false,
calc = Stats.StatsCollector.new(opts),
collector = Stats.StatsCollector.new(opts),
opts = opts,
apms = {},
apm_sum = 0,
Expand All @@ -53,7 +50,7 @@ function FileReporter:enable()
json = Stats.empty_stats_json()
end

local merged = self.stats:merge(json)
local merged = self.collector.stats:merge(json)

local file = vim.loop.fs_open(self.path, "w", 493)
local out_json = vim.fn.json_encode(merged)
Expand Down
11 changes: 9 additions & 2 deletions lua/vim-apm/tests/full-ass-init_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,24 @@ describe("APM", function()
stats = s
end)

APMBussin:listen(Events.ON_KEY, function(key)
print("key", key)
end)

vim.wait(1000)

local buffer = vim.fn.bufnr("lua/vim-apm/tests/test-file", true)
vim.api.nvim_set_current_buf(buffer)
vim.api.nvim_win_set_cursor(0, {1, 0})
utils.play_keys("23jci{hello worldkdi(itrue", 100)
--vim.api.nvim_feedkeys("23jci{hello worldkdi(itrue", "t", false)
vim.api.nvim_feedkeys("23j", "t", false)

vim.wait(50000, function()
return apm_stats ~= nil
end)

eq(apm_stats, {})
eq(stats, {})
eq(apm_stats, {})
end)
end)

Expand Down
10 changes: 0 additions & 10 deletions lua/vim-apm/tests/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,4 @@ function M.create_file(name, contents, row, col)
return bufnr
end

---@param keys string
---@param delay_per_stroke number
function M.play_keys(keys, delay_per_stroke)
for idx = 1, #keys do
local key = keys:sub(idx, idx)
APMBussin:emit(Events.ON_KEY, key)
vim.wait(delay_per_stroke)
end
end

return M

0 comments on commit be9b4e2

Please sign in to comment.