local eta = require("eta") local eta_clickup = require("eta.clickup") vim.api.nvim_create_user_command("ETA", eta.select_task, { nargs = "?" }) ---@type eta.clickup.Session eta.clickup_session = { auth = os.getenv("CLICKUP_AUTH") or "", user = os.getenv("CLICKUP_USER_ID") or "", workspace = os.getenv("CLICKUP_WORKSPACE_ID") or "", base_url = "https://api.clickup.com/api/v2", default_reviewer = os.getenv("CLICKUP_DEFAULT_REVIEWER") or "", } ---@type eta.gitlab.Session eta.gitlab_session = { auth = os.getenv("GITLAB_AUTH") or "", base_url = "https://git.extoll.de/api/v4", } ---@type eta.solidtime.Session eta.solidtime_session = { auth = os.getenv("SOLIDTIME_AUTH") or "", org = os.getenv("SOLIDTIME_ORG") or "", base_url = os.getenv("SOLIDTIME_URL") or "", user = os.getenv("SOLIDTIME_USER") or "", } eta.ext = { ns = vim.api.nvim_create_namespace("eta"), } vim.api.nvim_set_hl(0, "EtaHlTagKey", { fg = "#a6adc8", bg = "bg", bold = true }) vim.api.nvim_set_hl(0, "EtaHlTagVal", { bg = "bg", fg = "#a6adc8" }) local special_val_hl_cases = { fail = "#f38ba8", failed = "#f38ba8", wontfix = "#f38ba8", error = "#f38ba8", err = "#f38ba8", problem = "#f38ba8", success = "#a6e3a1", succeeded = "#a6e3a1", ok = "#a6e3a1", running = "#f9e2af", in_progress = "#f9e2af", progress = "#f9e2af", warning = "#f9e2af", warn = "#f9e2af", in_review = "#94e2d5", review = "#94e2d5", selected = "#eba0ac", selected_for_development = "#eba0ac", backlog = "#7f849c", } local special_key_hl_cases = { project = "#fab387", mr = "#fab387", issue = "#fab387", task = "#b4befe", lib = "#89b4fa", library = "#89b4fa", cell = "#74c7ec", run = "#89dceb", } for special, special_hl in pairs(special_val_hl_cases) do vim.api.nvim_set_hl(0, "EtaHlTagVal" .. special, { bg = "bg", fg = special_hl }) vim.api.nvim_set_hl(0, "EtaHlTagKey" .. special, { bg = "bg", fg = special_hl }) end for special, special_hl in pairs(special_key_hl_cases) do vim.api.nvim_set_hl(0, "EtaHlTagVal" .. special, { bg = "bg", fg = special_hl }) vim.api.nvim_set_hl(0, "EtaHlTagKey" .. special, { bg = "bg", fg = special_hl }) end vim.api.nvim_create_autocmd({ "CursorHold" }, { callback = function(args) local eid = 1; for lix, line in ipairs(vim.api.nvim_buf_get_lines(args.buf, 0, -1, false)) do for match in line:gmatch("#[a-z0-9_-]+/%S+") do local offset, mend = line:find(match, 1, true) local start, colend = line:find("/%s*", offset) local val = line:sub(colend + 1 or 0, mend):gsub("%W", "_") local key = line:sub(offset + 1, start - 1):gsub("%W", "_") local vhl = "EtaHlTagVal" local khl = "EtaHlTagKey" for case, _ in pairs(special_key_hl_cases) do if case == key then vhl = vhl .. key khl = khl .. key end end for case, _ in pairs(special_val_hl_cases) do if case == val then vhl = vhl .. val khl = khl .. val end end vim.api.nvim_buf_set_extmark(args.buf, eta.ext.ns, lix - 1, colend or 0, { id = eid, end_row = lix - 1, end_col = mend, hl_group = { "EtaHlTagVal", vhl }, }) vim.api.nvim_buf_set_extmark(args.buf, eta.ext.ns, lix - 1, offset - 1, { id = eid + 1, end_row = lix - 1, end_col = colend - 1, hl_group = { "EtaHlTagKey", khl }, }) vim.api.nvim_buf_set_extmark(args.buf, eta.ext.ns, lix - 1, start - 1, { id = eid + 2, end_row = lix - 1, end_col = colend, conceal = " ", hl_group = { khl }, }) vim.api.nvim_buf_set_extmark(args.buf, eta.ext.ns, lix - 1, offset - 1, { id = eid + 3, end_row = lix - 1, end_col = offset, conceal = " ", hl_group = { khl }, }) vim.api.nvim_buf_set_extmark(args.buf, eta.ext.ns, lix - 1, mend or 0, { id = eid + 4, end_row = lix - 1, end_col = mend, conceal = "", hl_group = { khl }, priority = 200, }) for special_key, special_key_repl in pairs({ mr = " ", issue = " ", task = "", created = "󰙴 ", closed = "󰸞 ", project = "󰏖 ", branch = "󰘬", lib = "󱍵 ", library = "󱍵 ", cell = "󰌕 ", run = "󰫍", }) do if key == special_key then vim.api.nvim_buf_set_extmark(args.buf, eta.ext.ns, lix - 1, offset, { id = eid + 5, end_row = lix - 1, end_col = start, conceal = special_key_repl, hl_group = { khl }, priority = 200, }) end end eid = eid + 6 end end end })