repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

resurecting puk :(

375c32163039f23b83dca66e20a4f9e9a33af3ba

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (3)

neovim/README.md

Modified
39 39 # todo
41 +* inline simple plugins into config (in-and-out, refjump)
41 42 * merge mini-nvim with main config
42 43 * learn mini.operators
43 44 * use in-and-out

neovim/puk.nu

Added
new file mode 100755
1 +#!/usr/bin/env nu
3 +# an out-of-band plugin manager for neovim.
4 +# cannot do a lot, compared to "normal" neovim plugin managers, but:
5 +# - it does not depend on git, only on tar and curl (and nushell right now, but that could change)
6 +# - tar and curl should be available on any system that neovim is installed, even win32
7 +# - does not incur runtime costs on neovim
8 +# - uses built-in vim packages
9 +def main [] {
10 + let data_path = nvim --headless --clean +'lua print(vim.fn.stdpath "data")' +q | complete | get stderr
11 + let cache_path = nvim --headless --clean +'lua print(vim.fn.stdpath "cache")' +q | complete | get stderr
12 + let plugins_path = [ $data_path site pack puk opt ] | path join
13 + let plugin_specs = open puk.plugins.nuon
14 + $plugin_specs | par-each { install-spec $in $plugins_path $cache_path }
15 + nvim --headless -u NONE +'helptags ALL' +q
18 +# given a plugin spec, and a plugins base install directory, this method generates
19 +# a new path, that points to the location the plugin should be installed into.
20 +def make-plugin-path [
21 + spec: record # a plugin to install
22 + plugins_path: path # folder to install plugins into
23 +] { [$plugins_path $spec.name] | path join }
25 +# given a path to an installed plugin, this method generates a path to a file holding
26 +# the commit of the plugin. even though git is not really involved in installing
27 +# plugins here, we use the commit as a kind of version number and lock file in one.
28 +def make-commit-file-path [
29 + plugin_path: path # path to an installed plugin
30 +] { [$plugin_path .commit.puk] | path join }
32 +def plugin-is-installed [
33 + spec: record # a plugin to install
34 + plugins_path: path # folder to install plugins into
35 +] {
36 + let predicted_plugin_path = make-plugin-path $spec $plugins_path
37 + if not ( $predicted_plugin_path | path exists ) {
38 + return false
39 + }
40 + let commit_file_path = make-commit-file-path $predicted_plugin_path
41 + if not ($commit_file_path | path exists) {
42 + return false
43 + }
44 + let commit = open --raw $commit_file_path | str trim
45 + $commit == $spec.commit
48 +def generate-download-url [
49 + spec: record # a plugin to install
50 +] {
51 + let url_format = match $spec.source {
52 + github => { 'https://github.com/{repo}/archive/{commit}.tar.gz ' },
53 + codeberg => { 'https://codeberg.org/{repo}/archive/{commit}.tar.gz' },
54 + srht => { 'https://git.sr.ht/{repo}/archive/{commit}.tar.gz' },
55 + _ => { error make {
56 + msg: 'unknown plugin source given'
57 + label: {
58 + text: 'dunno this one'
59 + span: (metadata $spec.source).span
60 + }
61 + }
62 + }
63 + }
64 + $spec | format pattern $url_format
67 +def download-plugin [
68 + spec: record # a plugin to install
69 + cache_path: path # folder to cache downloaded archives into
70 +] {
71 + let archive_path = [ $cache_path ($spec.name + '.tar.gz') ] | path join
72 + if ($archive_path | path exists) {
73 + return $archive_path
74 + }
75 + let url = generate-download-url $spec
76 + http get --raw $url | save $archive_path
77 + $archive_path
80 +def unpack-plugin-archive [
81 + spec: record # a plugin to install
82 + archive_path: path # path to a plugin archive
83 +] {
84 + let tmp_path = mktemp --directory
85 + # hopefully strip-componets works on win32 as well
86 + run-external tar '--extract' '--file' $archive_path '--directory' $tmp_path '--strip-components=1'
88 + if $spec.build != null {
89 + print $"Build step for plugin ($spec.name) detected! Executing now..."
90 + cd $tmp_path
91 + run-external $spec.build.0 ...($spec.build | range 1.. )
92 + }
93 + $tmp_path
96 +def install-plugin [
97 + spec: record # a plugin to install
98 + folder_path: path # unpacked path to plugin folder
99 + plugins_path: path # folder to install plugins into
100 +] {
101 + let plugin_path = make-plugin-path $spec $plugins_path
102 + try { rm --trash --recursive $plugin_path }
103 + mkdir $plugin_path
104 + cd $folder_path
105 + glob **/*.{lua,vim,scm,txt,so,dll,dylib} --exclude [**/tests/**, **/scripts/**, **/fixtures/**, **/target/release/deps/**] |
106 + path relative-to (pwd) |
107 + par-each { | file |
108 + let rebased_parent = [$plugin_path ($file | path dirname | to text)] | path join
109 + mkdir $rebased_parent
110 + cp $file $rebased_parent
112 + let commit_file_path = make-commit-file-path $plugin_path
113 + $spec.commit | save $commit_file_path
114 + $plugin_path
117 +def install-spec [
118 + spec: record # a plugin to install
119 + plugins_path: path # folder to install plugins into
120 + cache_path: path # folder to cache downloaded archives into
121 +] {
122 + if (plugin-is-installed $spec $plugins_path) {
123 + print $"Plugin ($spec.name) is already installed and up-to-date!"
124 + return
126 + let archive_path = download-plugin $spec $cache_path
127 + let unpacked_path = unpack-plugin-archive $spec $archive_path
128 + let installed_plugin_path = install-plugin $spec $unpacked_path $plugins_path
130 + print $"Plugin ($spec.name) installed into ($installed_plugin_path)!"

neovim/puk.plugins.nuon

Added
new file mode 100644
1 +[
2 + [name, source, repo, commit, build];
4 + [blink, github, 'Saghen/blink.cmp', '180be7ba574033baa30fa8af0db4f59db7353584', [cargo build '--release'] ],
5 + [nvim-surround, github, 'kylechui/nvim-surround', 'dca2e998ff26681ee422b92c6ed39b3d2908d8a9', null ],
6 + [ivy, github, 'AdeAttwood/ivy.nvim', 'cfa7e29ae4d955508d4f7f2ef08cc0c51ee745ed', null ],
7 + [in-and-out, github, 'ysmb-wtsg/in-and-out.nvim', 'ab24cafadc3418dffb0c7e9b0621cff60b9ac551', null ],
8 + [neoterm, github, 'itmecho/neoterm.nvim', '23a780136892b1128485f20d772a771e528b651b', null ],
9 +]