Skip to content

Commit

Permalink
chore: run through stylua
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis6991 committed Jul 10, 2023
1 parent 76a013d commit 0daf763
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 54 deletions.
13 changes: 8 additions & 5 deletions lua/gitsigns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,14 @@ local update_cwd_head = void(function()

local debounce_trailing = require('gitsigns.debounce').debounce_trailing

local update_head = debounce_trailing(100, void(function()
local new_head = git.get_repo_info(cwd).abbrev_head
scheduler()
vim.g.gitsigns_head = new_head
end))
local update_head = debounce_trailing(
100,
void(function()
local new_head = git.get_repo_info(cwd).abbrev_head
scheduler()
vim.g.gitsigns_head = new_head
end)
)

-- Watch .git/HEAD to detect branch changes
cwd_watcher:start(
Expand Down
2 changes: 1 addition & 1 deletion lua/gitsigns/attach.lua
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ local attach_throttled = throttle_by_id(function(cbuf, ctx, aucmd)
})

if config.watch_gitdir.enable then
local watcher = require'gitsigns.watcher'
local watcher = require('gitsigns.watcher')
cache[cbuf].gitdir_watcher = watcher.watch_gitdir(cbuf, repo.gitdir)
end

Expand Down
2 changes: 1 addition & 1 deletion lua/gitsigns/cache.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local config = require('gitsigns.config').config

local M = {
CacheEntry = {}
CacheEntry = {},
}

-- Timer object watching the gitdir
Expand Down
32 changes: 17 additions & 15 deletions lua/gitsigns/diff_int.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,23 @@ local run_diff_xdl_async = async.wrap(

vim.loop
.new_work(
--- @param a0 string
--- @param b0 string
--- @param algorithm0 string
--- @param indent_heuristic0 integer
--- @param linematch0 integer
function(a0, b0, algorithm0, indent_heuristic0, linematch0)
return vim.mpack.encode(vim.diff(a0, b0, {
result_type = 'indices',
algorithm = algorithm0,
indent_heuristic = indent_heuristic0,
linematch = linematch0,
}))
end, function(r)
callback(vim.mpack.decode(r --[[@as string]]) --[[@as Gitsigns.RawHunk[] ]])
end)
--- @param a0 string
--- @param b0 string
--- @param algorithm0 string
--- @param indent_heuristic0 integer
--- @param linematch0 integer
function(a0, b0, algorithm0, indent_heuristic0, linematch0)
return vim.mpack.encode(vim.diff(a0, b0, {
result_type = 'indices',
algorithm = algorithm0,
indent_heuristic = indent_heuristic0,
linematch = linematch0,
}))
end,
function(r)
callback(vim.mpack.decode(r --[[@as string]]) --[[@as Gitsigns.RawHunk[] ]])
end
)
:queue(a, b, algorithm, indent_heuristic, linematch)
end,
6
Expand Down
12 changes: 8 additions & 4 deletions lua/gitsigns/git.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function M._set_version(version)
args = { '--version' },
})

local line = vim.split(stdout or '', '\n', {plain=true})[1]
local line = vim.split(stdout or '', '\n', { plain = true })[1]
if not line then
err("Unable to detect git version as 'git --version' failed to return anything")
eprint(stderr)
Expand Down Expand Up @@ -154,7 +154,7 @@ local git_command = async.create(function(args, spec)
end
end

local stdout_lines = vim.split(stdout or '', '\n', {plain=true})
local stdout_lines = vim.split(stdout or '', '\n', { plain = true })

-- If stdout ends with a newline, then remove the final empty string after
-- the split
Expand Down Expand Up @@ -415,7 +415,9 @@ function Repo.new(dir, gitdir, toplevel)

self.username = git_command({ 'config', 'user.name' })[1]
local info = M.get_repo_info(dir, nil, gitdir, toplevel)
for k, v in pairs(info --[[@as table<string,any>]]) do
for k, v in
pairs(info --[[@as table<string,any>]])
do
---@diagnostic disable-next-line:no-unknown
(self)[k] = v
end
Expand All @@ -428,7 +430,9 @@ function Repo.new(dir, gitdir, toplevel)
then
M.get_repo_info(dir, 'yadm', gitdir, toplevel)
local yadm_info = M.get_repo_info(dir, 'yadm', gitdir, toplevel)
for k, v in pairs(yadm_info --[[@as table<string,any>]]) do
for k, v in
pairs(yadm_info --[[@as table<string,any>]])
do
---@diagnostic disable-next-line:no-unknown
(self)[k] = v
end
Expand Down
2 changes: 1 addition & 1 deletion lua/gitsigns/hunks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ end
--- @param line string
--- @return Gitsigns.Hunk.Hunk
function M.parse_diff_line(line)
local diffkey = vim.trim(vim.split(line, '@@', {plain=true})[2])
local diffkey = vim.trim(vim.split(line, '@@', { plain = true })[2])

-- diffKey: "-xx,n +yy"
-- pre: {xx, n}, now: {yy}
Expand Down
11 changes: 6 additions & 5 deletions lua/gitsigns/manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,9 @@ end
--- @return string str
--- @return {group:string, start:integer}[]? highlights
local function build_lno_str(win, lnum, width)
local has_col, statuscol = pcall(api.nvim_get_option_value, 'statuscolumn', {win = win, scope = "local"})
if has_col and statuscol and statuscol ~= "" then
local has_col, statuscol =
pcall(api.nvim_get_option_value, 'statuscolumn', { win = win, scope = 'local' })
if has_col and statuscol and statuscol ~= '' then
local ok, data = pcall(api.nvim_eval_statusline, statuscol, {
winid = win,
use_statuscol_lnum = lnum,
Expand All @@ -272,7 +273,7 @@ local function build_lno_str(win, lnum, width)
return data.str, data.highlights
end
end
return string.format('%'..width..'d', lnum)
return string.format('%' .. width .. 'd', lnum)
end

--- @param bufnr integer
Expand All @@ -284,7 +285,7 @@ function M.show_deleted_in_float(bufnr, nsd, hunk)
local virt_lines = {} --- @type {[1]: string, [2]: string}[][]
local textoff = vim.fn.getwininfo(cwin)[1].textoff --[[@as integer]]
for i = 1, hunk.removed.count do
local sc = build_lno_str(cwin, hunk.removed.start + i, textoff - 1)
local sc = build_lno_str(cwin, hunk.removed.start + i, textoff - 1)
virt_lines[i] = { { sc, 'LineNr' } }
end

Expand Down Expand Up @@ -314,7 +315,7 @@ function M.show_deleted_in_float(bufnr, nsd, hunk)
height = hunk.removed.count,
anchor = 'SW',
bufpos = { hunk.added.start - bufpos_offset, 0 },
style = 'minimal'
style = 'minimal',
})

vim.bo[pbufnr].filetype = vim.bo[bufnr].filetype
Expand Down
2 changes: 1 addition & 1 deletion lua/gitsigns/signs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ local dprint = require('gitsigns.debug.log').dprint

local B = {
Sign = {},
HlDef = {}
HlDef = {},
}

-- local function capitalise_word(x: string): string
Expand Down
38 changes: 17 additions & 21 deletions lua/gitsigns/watcher.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,28 +107,24 @@ function M.watch_gitdir(bufnr, gitdir)

dprintf('Watching git dir')
local w = assert(uv.new_fs_event())
w:start(
gitdir,
{},
function(err, filename, events)
local __FUNC__ = 'watcher_cb'
if err then
dprintf('Git dir update error: %s', err)
return
end

local info = string.format("Git dir update: '%s' %s", filename, inspect(events))

if vim.endswith(filename, '.lock') then
dprintf('%s (ignoring)', info)
return
end

dprint(info)

watch_gitdir_handler_db(bufnr)
w:start(gitdir, {}, function(err, filename, events)
local __FUNC__ = 'watcher_cb'
if err then
dprintf('Git dir update error: %s', err)
return
end
)

local info = string.format("Git dir update: '%s' %s", filename, inspect(events))

if vim.endswith(filename, '.lock') then
dprintf('%s (ignoring)', info)
return
end

dprint(info)

watch_gitdir_handler_db(bufnr)
end)
return w
end

Expand Down

0 comments on commit 0daf763

Please sign in to comment.