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
2 changes: 2 additions & 0 deletions lua/gitlinker/git.lua
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ local function get_branch_remote()
return nil
end

--- @type string[]
local remotes = remote_result.stdout
for _, remote in ipairs(remotes) do
if remote_from_upstream_branch == remote then
Expand All @@ -262,6 +263,7 @@ local function get_branch_remote()
return nil
end

--- @type table<string, function>
local M = {
result_has_out = result_has_out,
result_has_err = result_has_err,
Expand Down
34 changes: 12 additions & 22 deletions lua/gitlinker/util.lua
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
local path = require("plenary.path")
local logger = require("gitlinker.logger")
local os = vim.loop.os_uname().sysname

--- @return boolean
local function is_macos()
return os == "Darwin"
return vim.loop.os_uname().sysname == "Darwin"
end

--- @return boolean
local function is_windows()
if os:match("Windows") then
return true
else
return false
end
return vim.fn.has("win32") or vim.fn.has("win64")
end

--- @param cwd string|nil
--- @return string
local function relative_path(cwd)
-- In Windows, path separator is '\\'
-- But git root command will give us path with '/' separator
Expand Down Expand Up @@ -44,29 +43,20 @@ local function relative_path(cwd)
return relpath
end

--- @class LineRange
--- @field lstart integer
--- @field lend integer

--- @return LineRange
local function line_range()
-- local lstart
-- local lend
-- local mode = vim.api.nvim_get_mode().mode
-- if mode:lower() == "v" or mode:lower() == "x" then
local pos1 = vim.fn.getpos("v")[2]
local pos2 = vim.fn.getcurpos()[2]
local lstart = math.min(pos1, pos2)
local lend = math.max(pos1, pos2)
-- log.debug(
-- "[util.selected_line_range] mode:%s, pos1:%d, pos2:%d",
-- mode,
-- pos1,
-- pos2
-- )
-- else
-- lstart = vim.api.nvim_win_get_cursor(0)[1]
-- log.debug("[util.selected_line_range] mode:%s, lstart:%d", mode, lstart)
-- end
--
return { lstart = lstart, lend = lend }
end

--- @type table<string, function>
local M = {
is_macos = is_macos,
is_windows = is_windows,
Expand Down