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
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ PRs are welcomed for other git host websites!
- [Lua Function](#lua-function)
- [Create Your Own Router](#create-your-own-router)
- [Highlight Group](#highlight-group)
- [Alternative Clipboard](#alternative-clipboard)
- [Development](#development)
- [Contribute](#contribute)

Expand Down Expand Up @@ -634,6 +635,25 @@ GitLink! file_only
| -------------------------------- | ------------- | ------------------------------------ |
| NvimGitLinkerHighlightTextObject | Search | highlight line ranges when copy/open |

### Alternative Clipboard

You can define your own clipboard function during setup.

For example, to copy the url over a remote SSH session with an OSC52-compatible terminal,
you can use [nvim-osc52](https://github.com/ojroques/nvim-osc52) or Neovim's native
OSC52 since 10.0

```lua
require('gitlinker').setup({
-- with nvim-osc52
clipboard_override = require('osc52').copy,
-- or Neovim 10.0+ native
clipboard_override = function(url)
require('vim.ui.clipboard.osc52').copy('+')({url})
end
})
```

## Development

To develop the project and make PR, please setup with:
Expand Down
16 changes: 14 additions & 2 deletions lua/gitlinker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,21 @@ local function setup(opts)
local lstart = math.min(r.lstart, r.lend, command_opts.line1, command_opts.line2)
local lend = math.max(r.lstart, r.lend, command_opts.line1, command_opts.line2)
local parsed = _parse_args(args)

local action = nil
if command_opts.bang then
action = require("gitlinker.actions").system
else
-- Prefer using user provided clipboard action, if exists.
if vim.is_callable(confs.clipboard_override) then
action = confs.clipboard_override
else
action = require("gitlinker.actions").clipboard
end
end

_void_link({
action = command_opts.bang and require("gitlinker.actions").system
or require("gitlinker.actions").clipboard,
action = action,
router = function(lk)
return _router(parsed.router_type, lk)
end,
Expand Down
3 changes: 3 additions & 0 deletions lua/gitlinker/configs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ local Defaults = {

-- write logs to file
file_log = false,

-- clipboard command
clipboard_override = false,
}

--- @type gitlinker.Options
Expand Down