Browse code

Add implementation

Robert Cranston authored on 16/08/2022 23:53:24
Showing 1 changed files
... ...
@@ -2,10 +2,63 @@
2 2
 
3 3
 A 14-line [Vim][] "plugin manager" using [Git][] and [`:packadd`][].
4 4
 
5
+Annoyed by having to [bootstrap plugin manager plugins][vim-plug-installation]?
6
+By having to run a [separate install step][vim-plug-pluginstall] even though
7
+you explicitly said you wanted a plugin in your `vimrc`? Tired of your plugin
8
+manager doing [weird, hard to debug][vim-plug-issues] things behind your back?
9
+Concerned that GitHub is becoming the [implicit custodian][vim-plug-url-format]
10
+of all of the worlds software? <small>*(I bully [`vim-plug`][] here, probably
11
+undeservedly, because it is the most popular. I used it for a long time and
12
+it's great!)*</small>
13
+
14
+Give this a try in your [`vimrc`][]!
15
+
16
+```vim
17
+" https://git.rcrnstn.net/rcrnstn/vim-gitadd
18
+" Make sure to not enable |:syntax| or |:filetype| until all plugins that
19
+" interact with them have been added! See |:packadd|.
20
+command! -bar -bang -nargs=+ GitAdd call s:GitAdd(<q-bang>, <f-args>)
21
+function! s:GitAdd(bang, url, ...) abort
22
+  let name = split(a:url, '/')[-1]
23
+  let dir = split(&packpath, ',')[0] . '/pack/gitadd/opt/' . name
24
+  if !isdirectory(dir)
25
+    silent execute '!git clone --recurse-submodules' join(a:000) a:url dir
26
+    if isdirectory(dir . '/doc')
27
+      execute 'helptags' dir . '/doc'
28
+    endif
29
+  endif
30
+  if empty(a:bang)
31
+    execute 'packadd!' name
32
+  endif
33
+endfunction
34
+```
35
+
36
+Any arguments that [`git clone`][] accepts, e.g. [`--branch`][] or
37
+[`--depth`][], can be given after the URL.
38
+
39
+Requiring the full URL might be slightly annoying, but it is self-documenting,
40
+works with [`netrw-gx`][], and does not discriminate against non-GitHub
41
+repositories by making them stick out like a sore thumb.
42
+
43
+No "update plugins" command? Nope. You know what tool is great at handling
44
+different versions of software? Git! A Git alias/shell function helps,
45
+something to the effect of `for dir in *; do echo "=== $dir ==="; git -C "$dir"
46
+"$@"; done`.
47
+
5 48
 [`vim-gitadd`]: https://git.rcrnstn.net/rcrnstn/vim-gitadd
6 49
 [Vim]: https://en.wikipedia.org/wiki/Vim_(text_editor)
7 50
 [Git]: https://en.wikipedia.org/wiki/Git
8 51
 [`:packadd`]: https://vimhelp.org/repeat.txt.html#%3Apackadd
52
+[vim-plug-installation]: https://github.com/junegunn/vim-plug/blob/0.11.0/README.md#installation
53
+[vim-plug-pluginstall]: https://github.com/junegunn/vim-plug/blob/0.11.0/README.md#pluginstall-and-plugupdate
54
+[vim-plug-issues]: https://github.com/junegunn/vim-plug/issues?q=
55
+[vim-plug-url-format]: https://github.com/junegunn/vim-plug/blob/0.11.0/doc/plug.txt#L231
56
+[`vim-plug`]: https://github.com/junegunn/vim-plug
57
+[`vimrc`]: https://vimhelp.org/starting.txt.html#vimrc
58
+[`git clone`]: https://git-scm.com/docs/git-clone
59
+[`--branch`]: https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---branchltnamegt
60
+[`--depth`]: https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---depthltdepthgt
61
+[`netrw-gx`]: https://vimhelp.org/pi_netrw.txt.html#netrw-gx
9 62
 
10 63
 ## License
11 64
 
Browse code

Add license

Robert Cranston authored on 16/08/2022 23:50:22
Showing 1 changed files
... ...
@@ -6,3 +6,11 @@ A 14-line [Vim][] "plugin manager" using [Git][] and [`:packadd`][].
6 6
 [Vim]: https://en.wikipedia.org/wiki/Vim_(text_editor)
7 7
 [Git]: https://en.wikipedia.org/wiki/Git
8 8
 [`:packadd`]: https://vimhelp.org/repeat.txt.html#%3Apackadd
9
+
10
+## License
11
+
12
+Licensed under the [ISC License][] unless otherwise noted, see the
13
+[`LICENSE`][] file.
14
+
15
+[ISC License]: https://choosealicense.com/licenses/isc
16
+[`LICENSE`]: LICENSE
Browse code

Add readme

Robert Cranston authored on 16/08/2022 23:50:16
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,8 @@
1
+# [`vim-gitadd`][]
2
+
3
+A 14-line [Vim][] "plugin manager" using [Git][] and [`:packadd`][].
4
+
5
+[`vim-gitadd`]: https://git.rcrnstn.net/rcrnstn/vim-gitadd
6
+[Vim]: https://en.wikipedia.org/wiki/Vim_(text_editor)
7
+[Git]: https://en.wikipedia.org/wiki/Git
8
+[`:packadd`]: https://vimhelp.org/repeat.txt.html#%3Apackadd