Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Lint

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
stylua:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: JohnnyMorganz/stylua-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
args: --check .

luacheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install luacheck
run: sudo apt-get install -y lua-check
- name: Run luacheck
run: luacheck lua/ plugin/
3 changes: 3 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
std = "luajit"
globals = { "vim" }
max_line_length = 120
1 change: 1 addition & 0 deletions .stylua.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferSingle"
call_parentheses = "None"
syntax = "All"
9 changes: 7 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ blast.nvim is a Neovim plugin that tracks coding activity (time, filetypes, APM,

## Commands

There are no build, test, or lint commands configured for this project. No Makefile, CI workflows, or linting/formatting configs exist.
**Lint/Format:**
- `stylua --check .` — check formatting (config in `.stylua.toml`)
- `stylua .` — auto-format
- `luacheck lua/ plugin/` — lint (config in `.luacheckrc`)

To manually test, install the plugin in Neovim and run:
**CI:** GitHub Actions runs stylua and luacheck on push/PR to master.

**Manual testing** — install the plugin in Neovim and run:

- `:BlastStatus` — show socket connection and session info
- `:BlastPing` — ping the blastd daemon
Expand Down
58 changes: 29 additions & 29 deletions lua/blast/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,66 +6,66 @@
local M = {}

function M.check()
vim.health.start("blast.nvim")
vim.health.start 'blast.nvim'

-- Check Neovim version
if vim.fn.has("nvim-0.9") == 1 then
vim.health.ok("Neovim >= 0.9")
if vim.fn.has 'nvim-0.9' == 1 then
vim.health.ok 'Neovim >= 0.9'
else
vim.health.error("Neovim >= 0.9 required", { "Upgrade Neovim to 0.9 or later" })
vim.health.error('Neovim >= 0.9 required', { 'Upgrade Neovim to 0.9 or later' })
end

-- Check glaze.nvim (optional)
local has_glaze = pcall(require, "glaze")
local has_glaze = pcall(require, 'glaze')
if has_glaze then
vim.health.ok("glaze.nvim found (binary management enabled)")
vim.health.ok 'glaze.nvim found (binary management enabled)'
else
vim.health.warn("glaze.nvim not found", {
"Install glaze.nvim for automatic blastd binary management",
"See: https://github.com/taigrr/glaze.nvim",
vim.health.warn('glaze.nvim not found', {
'Install glaze.nvim for automatic blastd binary management',
'See: https://github.com/taigrr/glaze.nvim',
})
end

-- Check blastd binary (uses glaze path if available)
local utils = require("blast.utils")
local utils = require 'blast.utils'
local bin = utils.find_blastd_bin()
if bin then
local version = vim.fn.system(vim.fn.shellescape(bin) .. " --version 2>/dev/null"):gsub("%s+$", "")
if version ~= "" then
vim.health.ok("blastd found: " .. version)
local version = vim.fn.system(vim.fn.shellescape(bin) .. ' --version 2>/dev/null'):gsub('%s+$', '')
if version ~= '' then
vim.health.ok('blastd found: ' .. version)
else
vim.health.ok("blastd found: " .. bin)
vim.health.ok('blastd found: ' .. bin)
end
else
vim.health.error("blastd not found", {
"Install with :GlazeInstall blastd (if glaze.nvim is installed)",
"Or manually: go install github.com/taigrr/blastd@latest",
"See: https://github.com/taigrr/blastd",
vim.health.error('blastd not found', {
'Install with :GlazeInstall blastd (if glaze.nvim is installed)',
'Or manually: go install github.com/taigrr/blastd@latest',
'See: https://github.com/taigrr/blastd',
})
end

-- Check socket connection
local ok, socket = pcall(require, "blast.socket")
local ok, socket = pcall(require, 'blast.socket')
if ok then
if socket.is_connected() then
vim.health.ok("Connected to blastd socket")
vim.health.ok 'Connected to blastd socket'
else
local config = require("blast").config
local socket_path = config and config.socket_path or "~/.local/share/blastd/blastd.sock"
vim.health.info("Not connected to blastd socket", {
"Socket path: " .. socket_path,
"blastd will be auto-started when needed",
local config = require('blast').config
local socket_path = config and config.socket_path or '~/.local/share/blastd/blastd.sock'
vim.health.info('Not connected to blastd socket', {
'Socket path: ' .. socket_path,
'blastd will be auto-started when needed',
})
end
end

-- Check config file
local config_path = vim.fn.expand("~/.config/blastd/config.toml")
local config_path = vim.fn.expand '~/.config/blastd/config.toml'
if vim.uv.fs_stat(config_path) then
vim.health.ok("blastd config found: " .. config_path)
vim.health.ok('blastd config found: ' .. config_path)
else
vim.health.warn("blastd config not found: " .. config_path, {
"Create config with your API token from https://www.nvimblast.com/settings",
vim.health.warn('blastd config not found: ' .. config_path, {
'Create config with your API token from https://www.nvimblast.com/settings',
})
end
end
Expand Down
10 changes: 4 additions & 6 deletions lua/blast/init.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
local M = {}

-- Register with glaze.nvim if available
local _glaze_ok, _glaze = pcall(require, "glaze")
local _glaze_ok, _glaze = pcall(require, 'glaze')
if _glaze_ok then
_glaze.register("blastd", "github.com/taigrr/blastd", {
plugin = "blast.nvim",
_glaze.register('blastd', 'github.com/taigrr/blastd', {
plugin = 'blast.nvim',
})
end

Expand Down Expand Up @@ -52,12 +52,11 @@ function M.status()

if session then
local filetype = nil
local file_count = 0
local current = tracker.get_current_file()
if current then
filetype = current.filetype
end
file_count = tracker.get_file_count()
local file_count = tracker.get_file_count()
lines[#lines + 1] = string.format(' Current session: %s', session.project or 'unknown')
lines[#lines + 1] = string.format(' Filetype: %s', filetype or 'unknown')
lines[#lines + 1] = string.format(' Files: %d', file_count)
Expand Down Expand Up @@ -101,7 +100,6 @@ function M.sync()
end)
end


local stopped = false

function M.stop()
Expand Down
2 changes: 1 addition & 1 deletion lua/blast/socket.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ local function ensure_blastd()
os.remove(sock_path)
end

local utils = require('blast.utils')
local utils = require 'blast.utils'
local bin = utils.find_blastd_bin()
if not bin then
if config.debug then
Expand Down
68 changes: 31 additions & 37 deletions lua/blast/tracker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,42 +115,39 @@ local function build_activities()

for key, m in pairs(file_metrics) do
local seconds = m.active_seconds
if seconds < 1 and m.action_count == 0 then
goto continue
end
if seconds < 1 then
seconds = 1
end
if seconds >= 1 or m.action_count > 0 then
if seconds < 1 then
seconds = 1
end

local minutes = seconds / 60
local apm = minutes > 0 and (m.action_count / minutes) or 0
local wpm = minutes > 0 and (m.words_added / minutes) or 0
local minutes = seconds / 60
local apm = minutes > 0 and (m.action_count / minutes) or 0
local wpm = minutes > 0 and (m.words_added / minutes) or 0

local filename = nil
if not session.private then
filename = make_relative(m.filepath)
end
local filename = nil
if not session.private then
filename = make_relative(m.filepath)
end

local started_at = now - seconds
activities[#activities + 1] = {
key = key,
payload = {
project = project_name,
git_remote = remote,
git_branch = branch,
started_at = os.date('!%Y-%m-%dT%H:%M:%SZ', started_at),
ended_at = os.date('!%Y-%m-%dT%H:%M:%SZ', now),
filename = filename,
filetype = m.filetype,
lines_added = m.lines_added,
lines_removed = m.lines_removed,
actions_per_minute = math.floor(apm * 10) / 10,
words_per_minute = math.floor(wpm * 10) / 10,
editor = 'neovim',
},
}

::continue::
local started_at = now - seconds
activities[#activities + 1] = {
key = key,
payload = {
project = project_name,
git_remote = remote,
git_branch = branch,
started_at = os.date('!%Y-%m-%dT%H:%M:%SZ', started_at),
ended_at = os.date('!%Y-%m-%dT%H:%M:%SZ', now),
filename = filename,
filetype = m.filetype,
lines_added = m.lines_added,
lines_removed = m.lines_removed,
actions_per_minute = math.floor(apm * 10) / 10,
words_per_minute = math.floor(wpm * 10) / 10,
editor = 'neovim',
},
}
end
end

return activities
Expand Down Expand Up @@ -198,10 +195,7 @@ local function flush()

if config.debug then
vim.schedule(function()
vim.notify(
string.format('[blast.nvim] flushed %d file activities', #activities),
vim.log.levels.DEBUG
)
vim.notify(string.format('[blast.nvim] flushed %d file activities', #activities), vim.log.levels.DEBUG)
end)
end
end
Expand Down
7 changes: 4 additions & 3 deletions lua/blast/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ end
function M.get_project_info(filepath)
local dir = vim.fn.fnamemodify(filepath, ':h')
if project_cache[dir] then
return project_cache[dir].project, project_cache[dir].git_remote, project_cache[dir].private, project_cache[dir].git_branch
local c = project_cache[dir]
return c.project, c.git_remote, c.private, c.git_branch
end

local project = nil
Expand Down Expand Up @@ -152,12 +153,12 @@ function M.find_blastd_bin()
-- Check glaze.nvim first, then fall back to PATH
local glaze_ok, glaze = pcall(require, 'glaze')
if glaze_ok and glaze.bin_path then
local bin = glaze.bin_path('blastd')
local bin = glaze.bin_path 'blastd'
if bin and bin ~= '' then
return bin
end
end
local bin = vim.fn.exepath('blastd')
local bin = vim.fn.exepath 'blastd'
if bin and bin ~= '' then
return bin
end
Expand Down
Loading