tangled
alpha
login
or
join now
seth.computer
/
dotfiles
0
fork
atom
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
git-open, a bunch more keybindings, plugins, etc
seth.computer
2 years ago
fd4a6b59
4bcf5b49
verified
This commit was signed with the committer's
known signature
.
seth.computer
SSH Key Fingerprint:
SHA256:l+TmfElcKWTGSvrmVQkRAqucAII4w28uPbCCkXB+x7o=
+140
-7
6 changed files
expand all
collapse all
unified
split
git
gitconfig-adhoc
playbooks
roles
misc
tasks
main.yml
scripts
git-open.sh
vim
lvim
config.lua
lazy-lock.json
zsh
zshrc
-3
git/gitconfig-adhoc
···
1
1
-
[user]
2
2
-
name = Seth Etter
3
3
-
email = seth@adhoc.team
+9
-1
playbooks/roles/misc/tasks/main.yml
···
1
1
+
# TODO: rectangle?!
2
2
+
1
3
- name: link-lazygit-config
2
4
ansible.builtin.file:
3
5
src: "{{ dotfiles_dir }}/misc/lazygit.yml"
···
44
46
dest: "{{ home_dir }}/.config/direnv/direnv.toml"
45
47
state: link
46
48
force: true
47
47
-
# TODO: rectangle?!
49
49
+
50
50
+
- name: install-git-open-script
51
51
+
ansible.builtin.file:
52
52
+
src: "{{ dotfiles_dir }}/scripts/git-open.sh"
53
53
+
dest: "{{ home_dir }}/.local/bin/git-open"
54
54
+
state: link
55
55
+
force: true
+47
scripts/git-open.sh
···
1
1
+
#!/bin/bash
2
2
+
3
3
+
filename=$1
4
4
+
linerange=$2 # This is now optional
5
5
+
6
6
+
git_config="$(git rev-parse --show-toplevel)/.git/config"
7
7
+
8
8
+
# Git the repo URL
9
9
+
repo_url=$(grep "url =" $git_config | sed 's/ url = //g')
10
10
+
11
11
+
# Convert SSH URL to HTTPS if needed
12
12
+
if [[ $repo_url == git@* ]]; then
13
13
+
repo_domain=$(echo $repo_url | awk -F':' '{print $1}' | sed 's/git@//')
14
14
+
repo_path=$(echo $repo_url | awk -F':' '{print $2}')
15
15
+
repo_url="https://$repo_domain/$repo_path"
16
16
+
fi
17
17
+
18
18
+
# Get the current commit
19
19
+
current_commit=$(git rev-parse HEAD)
20
20
+
21
21
+
# Handle github vs gitlab
22
22
+
if [[ $repo_url == *"github.com"* ]]; then
23
23
+
platform="github"
24
24
+
elif [[ $repo_url == *"gitlab.com"* ]]; then
25
25
+
platform="gitlab"
26
26
+
else
27
27
+
echo "Unknown platform"
28
28
+
exit 1
29
29
+
fi
30
30
+
31
31
+
# Generate the final URL
32
32
+
if [[ $platform == "github" ]]; then
33
33
+
final_url="${repo_url%.git}/blob/$current_commit/${filename}"
34
34
+
# Format line range for GitHub
35
35
+
if [ ! -z "$linerange" ]; then
36
36
+
linerange="L${linerange%-*}-L${linerange#*-}"
37
37
+
fi
38
38
+
elif [[ $platform == "gitlab" ]]; then
39
39
+
final_url="${repo_url%.git}/-/blob/$current_commit/${filename}"
40
40
+
fi
41
41
+
42
42
+
# Add line range if it exists
43
43
+
if [ ! -z "$linerange" ]; then
44
44
+
final_url="${final_url}#L${linerange}"
45
45
+
fi
46
46
+
47
47
+
echo $final_url
+80
-2
vim/lvim/config.lua
···
6
6
-- Plugins
7
7
lvim.plugins = {
8
8
{ "ishan9299/nvim-solarized-lua" },
9
9
+
{
10
10
+
"harrisoncramer/gitlab.nvim",
11
11
+
dependencies = {
12
12
+
"MunifTanjim/nui.nvim",
13
13
+
"nvim-lua/plenary.nvim",
14
14
+
"stevearc/dressing.nvim", -- Recommended but not required. Better UI for pickers.
15
15
+
enabled = true,
16
16
+
},
17
17
+
build = function() require("gitlab.server").build(true) end,
18
18
+
config = function() require("gitlab").setup() end,
19
19
+
},
9
20
}
10
21
11
22
-- Display
···
20
31
lvim.builtin.nvimtree.setup.view.width = 40
21
32
22
33
-- Keybindings
23
23
-
lvim.keys.normal_mode["<S-h>"] = ":bprev<CR>"
24
24
-
lvim.keys.normal_mode["<S-l>"] = ":bnext<CR>"
34
34
+
lvim.keys.normal_mode["<S-h>"] = ":bprev<cr>"
35
35
+
lvim.keys.normal_mode["<S-l>"] = ":bnext<cr>"
36
36
+
25
37
lvim.builtin.which_key.mappings["w?"] = { ":sp<cr>", "Split horizontal" }
26
38
lvim.builtin.which_key.mappings["w/"] = { ":vsp<cr>", "Split vertical" }
39
39
+
40
40
+
lvim.builtin.which_key.mappings["gO"] = { ":GitOpen<cr>", "Open file in github/gitlab", mode = { "n", "v" } }
41
41
+
lvim.builtin.which_key.mappings["gL"] = { ":GitCopy<cr>", "Open file in github/gitlab", mode = { "n", "v" } }
42
42
+
43
43
+
lvim.builtin.which_key.mappings["G"] = {
44
44
+
name = "Gitlab",
45
45
+
s = { "<cmd>lua require('gitlab').summary()<cr>", "View MR summary" },
46
46
+
A = { "<cmd>lua require('gitlab').approve()<cr>", "Approve MR" },
47
47
+
R = { "<cmd>lua require('gitlab').revoke()<cr>", "Revoke MR" },
48
48
+
c = { "<cmd>lua require('gitlab').create_comment()<cr>", "Create comment" },
49
49
+
n = { "<cmd>lua require('gitlab').create_note()<cr>", "Create note" },
50
50
+
d = { "<cmd>lua require('gitlab').toggle_discussions()<cr>", "Toggle discussions" },
51
51
+
aa = { "<cmd>lua require('gitlab').add_assignee()<cr>", "Add assignee" },
52
52
+
ad = { "<cmd>lua require('gitlab').delete_assignee()<cr>", "Remove assignee" },
53
53
+
rr = { "<cmd>lua require('gitlab').review()<cr>", "Review MR" },
54
54
+
ra = { "<cmd>lua require('gitlab').add_reviewer()<cr>", "Add reviewer" },
55
55
+
rd = { "<cmd>lua require('gitlab').delete_reviewer()<cr>", "Remove reviewer" },
56
56
+
p = { "<cmd>lua require('gitlab').pipeline()<cr>", "View MR pipeline" },
57
57
+
}
58
58
+
59
59
+
-- Lang specific config
60
60
+
local formatters = require "lvim.lsp.null-ls.formatters"
61
61
+
formatters.setup {
62
62
+
{
63
63
+
name = "prettier",
64
64
+
filetypes = {
65
65
+
"typescript",
66
66
+
"typescriptreact",
67
67
+
"javascript",
68
68
+
"javascriptreact",
69
69
+
"markdown",
70
70
+
"json",
71
71
+
},
72
72
+
}
73
73
+
}
74
74
+
75
75
+
-- Calls the git-open command to get the URL for a specific file/line
76
76
+
-- in the github or gitlab remote repo.
77
77
+
function Git_url(line1, line2)
78
78
+
local lines = ""
79
79
+
80
80
+
-- Check if multiple lines are selected
81
81
+
if line1 ~= line2 then
82
82
+
lines = line1 .. "-" .. line2
83
83
+
end
84
84
+
85
85
+
local git_root = vim.fn.systemlist("git rev-parse --show-toplevel")[1]
86
86
+
local full_path = vim.fn.expand("%:p")
87
87
+
local filename = string.sub(full_path, string.len(git_root) + 2)
88
88
+
89
89
+
-- Create the shell command
90
90
+
return string.format("git-open %s %s", filename, lines)
91
91
+
end
92
92
+
93
93
+
function Git_open(line1, line2)
94
94
+
local git_open_cmd = Git_url(line1, line2)
95
95
+
vim.cmd(string.format("!%s | xargs open", git_open_cmd))
96
96
+
end
97
97
+
98
98
+
function Git_copy(line1, line2)
99
99
+
local git_open_cmd = Git_url(line1, line2)
100
100
+
vim.cmd(string.format("!%s | pbcopy", git_open_cmd))
101
101
+
end
102
102
+
103
103
+
vim.cmd [[command! -range GitOpen :lua Git_open(<line1>, <line2>)]]
104
104
+
vim.cmd [[command! -range GitCopy :lua Git_copy(<line1>, <line2>)]]
+3
vim/lvim/lazy-lock.json
···
8
8
"cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" },
9
9
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
10
10
"cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" },
11
11
+
"dressing.nvim": { "branch": "master", "commit": "c1e1d5fa44fe08811b6ef4aadac2b50e602f9504" },
11
12
"friendly-snippets": { "branch": "main", "commit": "631f79e346b0b3203d2ce3eae619ca8d612e5463" },
13
13
+
"gitlab.nvim": { "branch": "main", "commit": "ad3203c214866e14a5b9f08ff2461d593c1f2003" },
12
14
"gitsigns.nvim": { "branch": "main", "commit": "e5edefd9976039f5352e0c900f35206770b33a2d" },
13
15
"indent-blankline.nvim": { "branch": "master", "commit": "018bd04d80c9a73d399c1061fa0c3b14a7614399" },
14
16
"lazy.nvim": { "branch": "main", "commit": "d6a782c7002682f4a01b79fc3918c4584ad6e8fb" },
···
19
21
"mason.nvim": { "branch": "main", "commit": "057ac5ca159c83e302a55bd839a96ff1ea2396db" },
20
22
"neodev.nvim": { "branch": "main", "commit": "0043cf91c18aeac8db5765eb86c6078e17ac9325" },
21
23
"nlsp-settings.nvim": { "branch": "main", "commit": "32aa12da328258f2dccb15d327c26a8d21d9f4bd" },
24
24
+
"nui.nvim": { "branch": "main", "commit": "c8de23342caf8d50b15d6b28368d36a56a69d76f" },
22
25
"null-ls.nvim": { "branch": "main", "commit": "33b853a3933eed3137cd055aac4e539e69832ad0" },
23
26
"nvim-autopairs": { "branch": "master", "commit": "7566a86f44bb72ba2b1a609f528a27d93241502d" },
24
27
"nvim-cmp": { "branch": "main", "commit": "11102d3db12c7f8b35265ad0e17a21511e5b1e68" },
+1
-1
zsh/zshrc
···
16
16
*":$PNPM_HOME:"*) ;;
17
17
*) export PATH="$PNPM_HOME:$PATH" ;;
18
18
esac
19
19
-
# pnpm end
19
19
+
# pnpm end