Last active
October 6, 2022 15:54
-
-
Save eduardoarandah/f1355e51c11e6c774b221c730fada4e1 to your computer and use it in GitHub Desktop.
neovim lua command to copy filename, line number and branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Copy filename, line number and branch | |
-- example: src/filename.js +123 # branch master | |
vim.api.nvim_create_user_command("CopyPathLineNumberBranch", function() | |
local branch = vim.fn.systemlist("git branch --show-current") | |
local comment = "" | |
if not string.find(branch[1], "not a git repository") then | |
comment = " # branch " .. branch[1] | |
end | |
vim.fn.setreg("*", vim.fn.expand("%") .. " +" .. vim.api.nvim_win_get_cursor(0)[1] .. comment) | |
end, args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment