Something went wrong. Try again.
neovim plugin i use to add wakatime total time to my lazyvim lualine! p.s. some of this was probably stolen :3
Something went wrong. Try again.
1.4 kB · 61 lines · Created 5mo ago
Lua
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162local uv = require("luv")
local current_time = ""local function set_interval(interval, callback) local timer = uv.new_timer() local function ontimeout() callback(timer) end uv.timer_start(timer, interval, interval, ontimeout) return timerend
local function update_wakatime() local stdin = uv.new_pipe() local stdout = uv.new_pipe() local stderr = uv.new_pipe()
local handle, pid = uv.spawn("wakatime-cli", { args = { "--today" }, stdio = { stdin, stdout, stderr }, }, function(code, signal) -- on exit stdin:close() stdout:close() stderr:close() end)
uv.read_start(stdout, function(err, data) assert(not err, err) if data then current_time = "🕜 " .. data:sub(1, #data - 2) .. " " end end)end
set_interval(5000, update_wakatime)
local function get_wakatime() return current_timeend
return { "nvim-lualine/lualine.nvim", dependencies = { "nvim-tree/nvim-web-devicons" }, config = function() local my_filename = require("lualine.components.filename"):extend() my_filename.apply_icon = require("lualine.components.filetype").apply_icon my_filename.icon_hl_cache = {}
require("lualine").setup({ theme = "gruvbox", disabled_filetypes = { "neo-tree" }, sections = { lualine_y = { get_wakatime, },
lualine_c = { { my_filename, colored = true } }, }, }) end,}