diff options
| author | ThePrimeAgain <theprimeagain@theprimeagain.com> | 2025-12-06 11:12:20 -0700 |
|---|---|---|
| committer | ThePrimeAgain <theprimeagain@theprimeagain.com> | 2025-12-06 11:12:20 -0700 |
| commit | 045ac5e104765415337d691ec923afa1cbd032c8 (patch) | |
| tree | 3697940fcb62c920daecad66b7bc3ce30b6e444c /scratch | |
| parent | 3ae40439f36baeb96979a77cb5faf0dd6890bf31 (diff) | |
| download | a4-045ac5e104765415337d691ec923afa1cbd032c8.tar.xz a4-045ac5e104765415337d691ec923afa1cbd032c8.zip | |
virtual text is running! no testings yet
Diffstat (limited to 'scratch')
| -rw-r--r-- | scratch/refresh.lua | 77 |
1 files changed, 61 insertions, 16 deletions
diff --git a/scratch/refresh.lua b/scratch/refresh.lua index 5347b0f..076793f 100644 --- a/scratch/refresh.lua +++ b/scratch/refresh.lua @@ -2,22 +2,67 @@ R("99") function foo() end -local ns_id = vim.api.nvim_create_namespace("turd-ferg") -local function add_virtual_text() - vim.api.nvim_buf_clear_namespace(0, ns_id, 0, -1) - vim.api.nvim_buf_set_extmark(0, ns_id, 2, 0, { - virt_lines = { - { - { "foo bar 1", "Comment" }, - }, - { - { "foo bar 2", "error" }, - }, - { - { "foo bar 4", "Comment" }, - }, - }, +--- @param m _99.Mark +---@param count number +function done(m, count) + local Logger = require("99.logger.logger") + Logger:debug("done", "count", count) + m:set_virtual_text({ + "deleting in " .. tostring(count) }) + if count <= 0 then + m:delete() + return + end + + vim.defer_fn(function() + done(m, count - 1) + end, 500) end -add_virtual_text() +---@param m _99.Mark +--- @param lines string[] +---@param index number? +function write(m, lines, index) + index = index or 1 + local Logger = require("99.logger.logger") + Logger:debug("write", "index", index) + + if index > #lines then + done(m, 5) + return + end + + vim.defer_fn(function() + m:set_virtual_text({lines[index]}) + write(m, lines, index + 1) + end, 500) +end + +function create_mark() + local Logger = require("99.logger.logger") + local Level = require("99.logger.level") + Logger:configure({ + level = Level.FATAL, + path = nil, + }) + local buffer = vim.api.nvim_get_current_buf() + local ts = require("99.editor.treesitter") + local Mark = require("99.ops.marks") + local Point = require("99.geo").Point + + Logger:info("getting containing function") + local fn = ts.containing_function(buffer, Point:from_cursor()) + assert(fn, "could not find containing function") + + local m = Mark.mark_func_body(buffer, fn):set_max_virt_lines(3) + + write(m, { + "hello, world", + "", + "this is the greatest text", + }) +end + + +create_mark() |
