neovim plugin i use to add wakatime total time to my lazyvim lualine! p.s. some of this was probably stolen :3
line.lua edited
61 lines 1.4 kB view raw
1local uv = require("luv") 2 3local current_time = "" 4local function set_interval(interval, callback) 5 local timer = uv.new_timer() 6 local function ontimeout() 7 callback(timer) 8 end 9 uv.timer_start(timer, interval, interval, ontimeout) 10 return timer 11end 12 13local function update_wakatime() 14 local stdin = uv.new_pipe() 15 local stdout = uv.new_pipe() 16 local stderr = uv.new_pipe() 17 18 local handle, pid = uv.spawn("wakatime-cli", { 19 args = { "--today" }, 20 stdio = { stdin, stdout, stderr }, 21 }, function(code, signal) -- on exit 22 stdin:close() 23 stdout:close() 24 stderr:close() 25 end) 26 27 uv.read_start(stdout, function(err, data) 28 assert(not err, err) 29 if data then 30 current_time = "🕜 " .. data:sub(1, #data - 2) .. " " 31 end 32 end) 33end 34 35set_interval(5000, update_wakatime) 36 37local function get_wakatime() 38 return current_time 39end 40 41return { 42 "nvim-lualine/lualine.nvim", 43 dependencies = { "nvim-tree/nvim-web-devicons" }, 44 config = function() 45 local my_filename = require("lualine.components.filename"):extend() 46 my_filename.apply_icon = require("lualine.components.filetype").apply_icon 47 my_filename.icon_hl_cache = {} 48 49 require("lualine").setup({ 50 theme = "gruvbox", 51 disabled_filetypes = { "neo-tree" }, 52 sections = { 53 lualine_y = { 54 get_wakatime, 55 }, 56 57 lualine_c = { { my_filename, colored = true } }, 58 }, 59 }) 60 end, 61}