Skip to content

Commit

Permalink
neovim: update ShowInGitHub command
Browse files Browse the repository at this point in the history
  • Loading branch information
geodimm committed Oct 19, 2024
1 parent c6c8042 commit 2db5955
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nvim/lua/user/command.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ local function get_github_repo()
end

local function get_main_branch()
local result = trim_space(vim.fn.system('git symbolic-ref refs/remotes/origin/HEAD'))
local result = trim_space(vim.fn.system('git symbolic-ref HEAD'))
local parts = {}
for part in string.gmatch(result, '([^/]+)') do
table.insert(parts, part)
Expand All @@ -32,7 +32,7 @@ local function get_main_branch()
end

local function generate_github_link()
local repo_root = vim.fs.dirname(vim.fs.find('.git', { upward = true })[1])
local repo_root = vim.fs.root(0, '.git')
local repo = get_github_repo()
local branch = get_main_branch()
local path = string.sub(vim.fn.expand('%:p'), string.len(repo_root .. '/') + 1)
Expand Down

0 comments on commit 2db5955

Please sign in to comment.