Skip to content
Open
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
7 changes: 7 additions & 0 deletions lua/getgithublink/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ function M.get_github_url(use_permalink)
local start_line = vim.fn.line("'<")
local end_line = vim.fn.line("'>")

-- Fallback to current cursor line if no visual selection
if start_line == 0 or end_line == 0 then
local cursor_line = vim.api.nvim_win_get_cursor(0)[1]
start_line = cursor_line
end_line = cursor_line
end

local repo_url = get_git_remote_url()
local relative_path = get_relative_path()
local ref = use_permalink and get_current_commit() or get_current_branch()
Expand Down