-
-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling get_buf_range_url
through a user command not including ranges
#62
Comments
I am terrible at neovim and lua, but for me changing local pos1 = vim.api.nvim_buf_get_mark(0, "<")[1]
local pos2 = vim.api.nvim_buf_get_mark(0, ">")[1] seemed to solve the issue |
Hey @GlebBeloded what problem where you getting exactly? Right now I use lazy.nvim to setup my plugins including keymaps. This is how I setup gitlinker: function _G.gitOpenInBrowser(mode)
local linker = require "gitlinker"
local actions = require "gitlinker.actions"
local callback = { action_callback = actions.open_in_browser }
linker.get_buf_range_url(mode, callback)
end
return {
"ruifm/gitlinker.nvim",
config = function() require("gitlinker").setup() end,
keys = {
...
{ "<leader>gB", function() _G.gitOpenInBrowser("n") end, },
{ "<leader>gB", function() _G.gitOpenInBrowser("v") end, mode = "v",
},
},
} The problem I'm getting now is that while gitlinker opens up a browser with a code region highlighted, the range code is displaced by one line both at the beginning and the end. Is that the issue that your comment fixes? |
@smarquez1 local pos1 = vim.fn.getpos("v")[2]
local pos2 = vim.fn.getcurpos()[2] returned the same number, because I called gitlinked code not from a binding, but from user-defined command. So the edit I've shown you above gets last visual selection, even if you are in normal mode now. My command looks like this: vim.api.nvim_create_user_command("Gitlink", function(t)
local mode = t.range > 0 and "v" or "n"
require("gitlinker").get_buf_range_url(mode, { action_callback = require("gitlinker.actions").copy_to_clipboard })
end, { range = true }) The code range is not displaced also on my end, so maybe it will fix stuff for you too. |
Hi, I created a user command based on a user's comment to open the current selected lines on github.
The problem is that, in Visual mode, it will not add the current code range to the URL.
Am I missing to pass something to the new user command or maybe this is a bug?
The text was updated successfully, but these errors were encountered: