Nvim: add new plugins, optimize old
This commit is contained in:
101
.config/nvim/lua/plugins/repolink.lua
Normal file
101
.config/nvim/lua/plugins/repolink.lua
Normal file
@@ -0,0 +1,101 @@
|
||||
return {
|
||||
"9seconds/repolink.nvim",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim"
|
||||
},
|
||||
cmd = {
|
||||
"RepoLink"
|
||||
},
|
||||
|
||||
config = function()
|
||||
-- ssh://git@git.viessmann.com:7999/sysfunc/hemsapplication.git
|
||||
-- https://git.viessmann.com/projects/SYSFUNC/repos/hemsdocumentation/browse/README.md?useDefaultHandler=true#13
|
||||
viessmann = function(args)
|
||||
local anchor = "#" .. tostring(args.start_line)
|
||||
|
||||
return string.format(
|
||||
"https://%s/projects/%s/repos/%s/browse/%s#%s",
|
||||
args.host,
|
||||
args.host_data.user,
|
||||
args.host_data.project,
|
||||
args.path,
|
||||
anchor
|
||||
)
|
||||
end
|
||||
|
||||
-- ssh://git@git.viessmann.com:7999/sysfunc/hemsapplication.git
|
||||
-- https://git.viessmann.com/projects/SYSFUNC/repos/hemsdocumentation/browse/README.md?useDefaultHandler=true#13
|
||||
url_parser = function(remote_url)
|
||||
vim.pretty_print(remote_url)
|
||||
local host, group, project = string.match(remote_url,
|
||||
"ssh://git@([^:]+):7999/([^/]+)/([^%.]+)")
|
||||
return host, { user = group, project = project }
|
||||
end
|
||||
|
||||
require("repolink").setup({
|
||||
-- By default, repolink tries to create links with short commits
|
||||
-- like, 42dd21c instead of 42dd21cf54779c9175c4ff7450d91a9ad0387491
|
||||
-- If you like to have full commits, please enable this flag
|
||||
use_full_commit_hash = false,
|
||||
|
||||
-- repolink takes remote URLs from git itself and can parse
|
||||
-- most common ones: from Github, Bitbucket, Sourcehut, Gitlab, Gitea, etc.
|
||||
-- but sometimes you can have a quite weird configuration, made with,
|
||||
-- for example, cgit, so the default one won't work for you.
|
||||
--
|
||||
-- If you provide this custom parser, it should be a function that
|
||||
-- parses a remote URL and returns a hostname and some data blob
|
||||
-- that could be used later, on URL building.
|
||||
--
|
||||
-- host parameter would be used to find out a function that is used
|
||||
-- to convert remote URL and repository data to an HTTP permalink
|
||||
--
|
||||
-- data parameter can be anything but you want to use the default URL
|
||||
-- builders, it should be a table of
|
||||
-- { user = "YOUR USER", project = "PROJECT NAME" }
|
||||
--
|
||||
-- Example of parser for git@github.com:9seconds/repolink.nvim.git URL:
|
||||
--
|
||||
-- function(remote_url)
|
||||
-- local host, user, project = string.match(
|
||||
-- remote_url,
|
||||
-- "^git@([^:]+):([^/]+)/(.+)%.git$")
|
||||
-- if host then
|
||||
-- return host, {
|
||||
-- user = user,
|
||||
-- project = project
|
||||
-- }
|
||||
-- end
|
||||
-- end
|
||||
custom_url_parser = url_parser,
|
||||
|
||||
-- By default RepoLink just notifies about generated URL but if
|
||||
-- this setting is not nil, then URL could also be copied into
|
||||
-- a given register.
|
||||
--
|
||||
-- If you want to copy it into a register, run RepoLink! (with bang).
|
||||
bang_register = "+",
|
||||
|
||||
-- repolink runs Git. Usually, it finishes quite fast but if you have a
|
||||
-- slow storage, like NFS, can take some time. This is a timeout
|
||||
-- after which repolink fails.
|
||||
timeout = 5000,
|
||||
url_builders = {
|
||||
--["git.viessmann.com"] = require("repolink").url_builder_for_bitbucket("git.viessmann.com"),
|
||||
["git.viessmann.com"] = viessmann,
|
||||
}
|
||||
|
||||
-- {
|
||||
-- start_line = 1
|
||||
-- end_line = 2,
|
||||
-- host = "github.com",
|
||||
-- host_data = {
|
||||
-- user = "9seconds",
|
||||
-- project = "repolink.nvim"
|
||||
-- },
|
||||
-- commit_hash = "42dd21c",
|
||||
-- path = "doc/repolink.txt",
|
||||
-- }
|
||||
})
|
||||
end
|
||||
}
|
||||
Reference in New Issue
Block a user