feat: rename everything

This commit is contained in:
Barrett Ruth 2026-02-02 22:09:13 -05:00
parent 8f7442eaa2
commit 67116f38bc
16 changed files with 172 additions and 165 deletions

View file

@ -1,19 +1,19 @@
local M = {}
function M.check()
vim.health.start('fugitive-ts.nvim')
vim.health.start('diffs.nvim')
if vim.fn.has('nvim-0.9.0') == 1 then
vim.health.ok('Neovim 0.9.0+ detected')
else
vim.health.error('fugitive-ts.nvim requires Neovim 0.9.0+')
vim.health.error('diffs.nvim requires Neovim 0.9.0+')
end
local fugitive_loaded = vim.fn.exists(':Git') == 2
if fugitive_loaded then
vim.health.ok('vim-fugitive detected')
else
vim.health.warn('vim-fugitive not detected (required for this plugin to be useful)')
vim.health.warn('vim-fugitive not detected (required for unified diff highlighting)')
end
end

View file

@ -1,10 +1,10 @@
local M = {}
local dbg = require('fugitive-ts.log').dbg
local dbg = require('diffs.log').dbg
---@param bufnr integer
---@param ns integer
---@param hunk fugitive-ts.Hunk
---@param hunk diffs.Hunk
---@param col_offset integer
---@param text string
---@param lang string
@ -49,15 +49,15 @@ local function highlight_text(bufnr, ns, hunk, col_offset, text, lang)
return extmark_count
end
---@class fugitive-ts.HunkOpts
---@class diffs.HunkOpts
---@field hide_prefix boolean
---@field treesitter fugitive-ts.TreesitterConfig
---@field vim fugitive-ts.VimConfig
---@field highlights fugitive-ts.Highlights
---@field treesitter diffs.TreesitterConfig
---@field vim diffs.VimConfig
---@field highlights diffs.Highlights
---@param bufnr integer
---@param ns integer
---@param hunk fugitive-ts.Hunk
---@param hunk diffs.Hunk
---@param code_lines string[]
---@return integer
local function highlight_treesitter(bufnr, ns, hunk, code_lines)
@ -125,9 +125,9 @@ local function highlight_treesitter(bufnr, ns, hunk, code_lines)
return extmark_count
end
---@alias fugitive-ts.SyntaxQueryFn fun(line: integer, col: integer): integer, string
---@alias diffs.SyntaxQueryFn fun(line: integer, col: integer): integer, string
---@param query_fn fugitive-ts.SyntaxQueryFn
---@param query_fn diffs.SyntaxQueryFn
---@param code_lines string[]
---@return {line: integer, col_start: integer, col_end: integer, hl_name: string}[]
function M.coalesce_syntax_spans(query_fn, code_lines)
@ -168,7 +168,7 @@ end
---@param bufnr integer
---@param ns integer
---@param hunk fugitive-ts.Hunk
---@param hunk diffs.Hunk
---@param code_lines string[]
---@return integer
local function highlight_vim_syntax(bufnr, ns, hunk, code_lines)
@ -223,8 +223,8 @@ end
---@param bufnr integer
---@param ns integer
---@param hunk fugitive-ts.Hunk
---@param opts fugitive-ts.HunkOpts
---@param hunk diffs.Hunk
---@param opts diffs.HunkOpts
function M.highlight_hunk(bufnr, ns, hunk, opts)
local use_ts = hunk.lang and opts.treesitter.enabled
local use_vim = not use_ts and hunk.ft and opts.vim.enabled
@ -267,10 +267,8 @@ function M.highlight_hunk(bufnr, ns, hunk, opts)
local prefix = line:sub(1, 1)
local is_diff_line = prefix == '+' or prefix == '-'
local line_hl = is_diff_line and (prefix == '+' and 'FugitiveTsAdd' or 'FugitiveTsDelete')
or nil
local number_hl = is_diff_line and (prefix == '+' and 'FugitiveTsAddNr' or 'FugitiveTsDeleteNr')
or nil
local line_hl = is_diff_line and (prefix == '+' and 'DiffsAdd' or 'DiffsDelete') or nil
local number_hl = is_diff_line and (prefix == '+' and 'DiffsAddNr' or 'DiffsDeleteNr') or nil
if opts.hide_prefix then
local virt_hl = (opts.highlights.background and line_hl) or nil

View file

@ -1,35 +1,35 @@
---@class fugitive-ts.Highlights
---@class diffs.Highlights
---@field background boolean
---@field gutter boolean
---@class fugitive-ts.TreesitterConfig
---@class diffs.TreesitterConfig
---@field enabled boolean
---@field max_lines integer
---@class fugitive-ts.VimConfig
---@class diffs.VimConfig
---@field enabled boolean
---@field max_lines integer
---@class fugitive-ts.Config
---@class diffs.Config
---@field enabled boolean
---@field debug boolean
---@field debounce_ms integer
---@field hide_prefix boolean
---@field treesitter fugitive-ts.TreesitterConfig
---@field vim fugitive-ts.VimConfig
---@field highlights fugitive-ts.Highlights
---@field treesitter diffs.TreesitterConfig
---@field vim diffs.VimConfig
---@field highlights diffs.Highlights
---@class fugitive-ts
---@class diffs
---@field attach fun(bufnr?: integer)
---@field refresh fun(bufnr?: integer)
---@field setup fun(opts?: fugitive-ts.Config)
---@field setup fun(opts?: diffs.Config)
local M = {}
local highlight = require('fugitive-ts.highlight')
local log = require('fugitive-ts.log')
local parser = require('fugitive-ts.parser')
local highlight = require('diffs.highlight')
local log = require('diffs.log')
local parser = require('diffs.parser')
local ns = vim.api.nvim_create_namespace('fugitive_ts')
local ns = vim.api.nvim_create_namespace('diffs')
---@param hex integer
---@param bg_hex integer
@ -63,7 +63,7 @@ local function resolve_hl(name)
return hl
end
---@type fugitive-ts.Config
---@type diffs.Config
local default_config = {
enabled = true,
debug = false,
@ -83,7 +83,7 @@ local default_config = {
},
}
---@type fugitive-ts.Config
---@type diffs.Config
local config = vim.deepcopy(default_config)
---@type table<integer, boolean>
@ -220,25 +220,25 @@ local function compute_highlight_groups()
local blended_add = blend_color(add_bg, bg, 0.4)
local blended_del = blend_color(del_bg, bg, 0.4)
vim.api.nvim_set_hl(0, 'FugitiveTsAdd', { bg = blended_add })
vim.api.nvim_set_hl(0, 'FugitiveTsDelete', { bg = blended_del })
vim.api.nvim_set_hl(0, 'FugitiveTsAddNr', { fg = add_fg, bg = blended_add })
vim.api.nvim_set_hl(0, 'FugitiveTsDeleteNr', { fg = del_fg, bg = blended_del })
vim.api.nvim_set_hl(0, 'DiffsAdd', { bg = blended_add })
vim.api.nvim_set_hl(0, 'DiffsDelete', { bg = blended_del })
vim.api.nvim_set_hl(0, 'DiffsAddNr', { fg = add_fg, bg = blended_add })
vim.api.nvim_set_hl(0, 'DiffsDeleteNr', { fg = del_fg, bg = blended_del })
local diff_change = resolve_hl('DiffChange')
local diff_text = resolve_hl('DiffText')
vim.api.nvim_set_hl(0, 'FugitiveTsDiffAdd', { bg = diff_add.bg })
vim.api.nvim_set_hl(0, 'FugitiveTsDiffDelete', { bg = diff_delete.bg })
vim.api.nvim_set_hl(0, 'FugitiveTsDiffChange', { bg = diff_change.bg })
vim.api.nvim_set_hl(0, 'FugitiveTsDiffText', { bg = diff_text.bg })
vim.api.nvim_set_hl(0, 'DiffsDiffAdd', { bg = diff_add.bg })
vim.api.nvim_set_hl(0, 'DiffsDiffDelete', { bg = diff_delete.bg })
vim.api.nvim_set_hl(0, 'DiffsDiffChange', { bg = diff_change.bg })
vim.api.nvim_set_hl(0, 'DiffsDiffText', { bg = diff_text.bg })
end
local DIFF_WINHIGHLIGHT = table.concat({
'DiffAdd:FugitiveTsDiffAdd',
'DiffDelete:FugitiveTsDiffDelete',
'DiffChange:FugitiveTsDiffChange',
'DiffText:FugitiveTsDiffText',
'DiffAdd:DiffsDiffAdd',
'DiffDelete:DiffsDiffDelete',
'DiffChange:DiffsDiffChange',
'DiffText:DiffsDiffText',
}, ',')
function M.attach_diff()
@ -249,20 +249,15 @@ function M.attach_diff()
local tabpage = vim.api.nvim_get_current_tabpage()
local wins = vim.api.nvim_tabpage_list_wins(tabpage)
local has_fugitive = false
local diff_wins = {}
for _, win in ipairs(wins) do
if vim.api.nvim_win_is_valid(win) and vim.wo[win].diff then
table.insert(diff_wins, win)
local bufnr = vim.api.nvim_win_get_buf(win)
if M.is_fugitive_buffer(bufnr) then
has_fugitive = true
end
end
end
if not has_fugitive then
if #diff_wins == 0 then
return
end
@ -282,7 +277,7 @@ function M.detach_diff()
end
end
---@param opts? fugitive-ts.Config
---@param opts? diffs.Config
function M.setup(opts)
opts = opts or {}
@ -318,13 +313,13 @@ function M.setup(opts)
end
if opts.debounce_ms and opts.debounce_ms < 0 then
error('fugitive-ts: debounce_ms must be >= 0')
error('diffs: debounce_ms must be >= 0')
end
if opts.treesitter and opts.treesitter.max_lines and opts.treesitter.max_lines < 1 then
error('fugitive-ts: treesitter.max_lines must be >= 1')
error('diffs: treesitter.max_lines must be >= 1')
end
if opts.vim and opts.vim.max_lines and opts.vim.max_lines < 1 then
error('fugitive-ts: vim.max_lines must be >= 1')
error('diffs: vim.max_lines must be >= 1')
end
config = vim.tbl_deep_extend('force', default_config, opts)

View file

@ -13,7 +13,7 @@ function M.dbg(msg, ...)
if not enabled then
return
end
vim.notify('[fugitive-ts] ' .. string.format(msg, ...), vim.log.levels.DEBUG)
vim.notify('[diffs] ' .. string.format(msg, ...), vim.log.levels.DEBUG)
end
return M

View file

@ -1,4 +1,4 @@
---@class fugitive-ts.Hunk
---@class diffs.Hunk
---@field filename string
---@field ft string?
---@field lang string?
@ -9,7 +9,7 @@
local M = {}
local dbg = require('fugitive-ts.log').dbg
local dbg = require('diffs.log').dbg
---@param filename string
---@return string?
@ -38,10 +38,10 @@ local function get_lang_from_ft(ft)
end
---@param bufnr integer
---@return fugitive-ts.Hunk[]
---@return diffs.Hunk[]
function M.parse_buffer(bufnr)
local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
---@type fugitive-ts.Hunk[]
---@type diffs.Hunk[]
local hunks = {}
---@type string?