Skip to content
Merged

CI #1

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
3 changes: 3 additions & 0 deletions .actrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-P ubuntu-latest=catthehacker/ubuntu:act-latest
-P ubuntu-22.04=catthehacker/ubuntu:act-22.04
-P ubuntu-20.04=catthehacker/ubuntu:act-20.04
62 changes: 62 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CI

on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Lint (luacheck + stylua)
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Lua, Luarocks, and luacheck
run: |
sudo apt-get update
sudo apt-get install -y lua5.1 luarocks
sudo luarocks install luacheck

- name: Run luacheck
run: |
luacheck . lua/* plugin/*

- name: Run stylua (format check)
uses: JohnnyMorganz/stylua-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
args: --check .

neovim-startup:
name: Neovim startup sanity check
runs-on: ubuntu-latest
needs: lint

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Neovim
run: |
sudo apt-get update
sudo apt-get install -y neovim

- name: Minimal startup test
run: |
cat << 'EOF' > minimal_init.lua
-- Add current repo to runtimepath so lua/raphael and plugin/ are visible
vim.cmd("set rtp^=.")
-- Basic setup call; adjust options if you want stricter checks
require("raphael").setup({})
EOF

nvim --headless -u minimal_init.lua -c 'qa'
2 changes: 1 addition & 1 deletion lua/raphael/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ M.defaults = {

icons = vim.deepcopy(constants.ICON),

on_apply = function(theme)
on_apply = function(_theme)
vim.schedule(function()
local ok, lualine = pcall(require, "lualine")
if ok then
Expand Down
24 changes: 12 additions & 12 deletions lua/raphael/core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ M.config = {}
--- In-memory state mirror of what is persisted via cache.
--- This is NOT the only source of truth; cache is canonical.
---@class RaphaelState
---@field current? string -- currently active theme
---@field saved? string -- last manually saved theme
---@field previous? string -- theme before current (for quick revert)
---@field auto_apply boolean -- whether BufEnter/FileType auto-apply is enabled
---@field bookmarks table<string, string[]> -- scope -> list of bookmarked themes
---@field history string[] -- recent themes (newest first)
---@field usage table<string, integer> -- usage count per theme
---@field collapsed table<string, boolean> -- group collapse state
---@field sort_mode string -- current sort mode ("alpha", "recent", "usage", or custom)
---@field undo_history table -- detailed undo stack (managed by extras.history/cache)
---@field current? string -- currently active theme
---@field saved? string -- last manually saved theme
---@field previous? string -- theme before current (for quick revert)
---@field auto_apply boolean -- whether BufEnter/FileType auto-apply is enabled
---@field bookmarks table<string, string[]> -- scope -> list of bookmarked themes
---@field history string[] -- recent themes (newest first)
---@field usage table<string, integer> -- usage count per theme
---@field collapsed table<string, boolean> -- group collapse state
---@field sort_mode string -- current sort mode ("alpha", "recent", "usage", or custom)
---@field undo_history table -- detailed undo stack (managed by extras.history/cache)
---@field quick_slots table<string, table<string, string>> -- scope -> slot("0"-"9")->theme_name
---@field current_profile? string -- active profile name (if any)
---@field current_profile? string -- active profile name (if any)
M.state = {
current = nil,
saved = nil,
Expand Down Expand Up @@ -248,7 +248,7 @@ function M.save_state()
end

function M.toggle_auto()
M.state.auto_apply = not (M.state.auto_apply == true)
M.state.auto_apply = not (M.state.auto_apply == true) -- luacheck: ignore

cache.set_auto_apply(M.state.auto_apply)
vim.api.nvim_set_var("raphael_auto_theme", M.state.auto_apply)
Expand Down
2 changes: 1 addition & 1 deletion lua/raphael/core/samples.lua
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class ApiClient {
// TODO: Add request timeout
const response = await fetch(`${this.baseUrl}/users/${id}`);
const data = await response.json();

const user = UserSchema.parse(data);
this.cache.set(`user_${id}`, user);

Expand Down
2 changes: 1 addition & 1 deletion lua/raphael/picker/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ function M.attach(ctx, fns)
local state = ctx.state

local base_title = ctx.base_title
local opts = ctx.opts
-- local opts = ctx.opts

--- Expand all groups that contain the given theme in themes.theme_map.
---
Expand Down
8 changes: 2 additions & 6 deletions lua/raphael/picker/preview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,7 @@ local function get_active_theme_label(ctx)
end
end

return active_preview_theme
or (ctx.core.state and ctx.core.state.current)
or "?"
return active_preview_theme or (ctx.core.state and ctx.core.state.current) or "?"
end

--- Update code preview buffer based on current_lang and preview/compare state.
Expand Down Expand Up @@ -447,9 +445,7 @@ function M.toggle_compare(ctx, candidate_theme)
return
end

local base = (ctx.core.state and ctx.core.state.current)
or vim.g.colors_name
or ctx.core.config.default_theme
local base = (ctx.core.state and ctx.core.state.current) or vim.g.colors_name or ctx.core.config.default_theme

if not base or not themes.is_available(base) then
vim.notify("raphael: no valid current theme to compare against", vim.log.levels.WARN)
Expand Down
6 changes: 2 additions & 4 deletions lua/raphael/picker/render.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ local function debounce(ms, fn)
local timer = nil
return function(ctx)
if timer then
local ok = pcall(function()
local ok = pcall(function() -- luacheck: ignore
if timer and not timer:is_closing() then
timer:stop()
vim.schedule(function()
Expand All @@ -103,8 +103,6 @@ local function debounce(ms, fn)
end)
end
end)
if not ok then
end
timer = nil
end
timer = vim.defer_fn(function()
Expand Down Expand Up @@ -149,7 +147,7 @@ local function render_internal(ctx)
end

local current_group
local current_line = 1
local current_line = 1 -- luacheck: ignore
local current_theme

if picker_win and vim.api.nvim_win_is_valid(picker_win) then
Expand Down