dotfiles
bugabingas dorkfiles
owned by bugabinga
neovim: restore of puk.nu
81a53472267724b3429251f809597d0d2b62ad0f
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
Browse filesCompare with HEAD
Changed files (1)
17 14 let cache_path = nvim --headless --clean +
'lua print(vim.fn.stdpath "cache")' +q | complete | get stderr
18 15 let plugins_path = [
$data_path site pack puk opt ] | path join
19 16 let plugin_specs = open puk.plugins.nuon
17 + print
'Installing plugins from puk.plugins.nuon.' 20 18 $plugin_specs | par-
each { install-spec
$in $plugins_path $cache_path }
19 + print
'Cleaning plugins, that are not part of puk.plugins.nuon.' 20 + clean-plugins
$plugins_path $plugin_specs 21 + print
'Generating helptags.' 21 22 nvim --headless -u NONE +
'helptags ALL' +q
27 +def 'main update' [] {
28 + let plugin_specs = open puk.plugins.nuon
30 + let updated =
$plugin_specs |
33 + let fresh_commit = find-latest-commit
$spec 34 + if (
$fresh_commit !=
$spec.commit) {
35 + print $
"Found fresh commit for ($spec.name):($fresh_commit)!" 36 + return
$fresh_commit 41 + if not (
$plugin_specs ==
$updated) {
44 + to nuon --indent
2 |
45 + save --force puk.plugins.updated.nuon
46 + print
"Written updated puk.plugins into puk.plugins.updated.nuon!" 48 + print
"Nothing to do." 55 + plugin_specs: list<any>
57 + ls
$plugins_path |
each {
59 + let existing_plugin_name =
$row.name | path basename
60 + if (
$plugin_specs |
where name ==
$existing_plugin_name | is-empty) {
61 + print $
"Found plugin, that is not part of the specs: ($existing_plugin_name)" 62 + rm --interactive --trash --recursive
$row.name 26 69 def make-plugin-path [
50 93 let commit = open --raw
$commit_file_path | str trim
51 - $commit ==
$spec.commit 94 + return (
$commit ==
$spec.commit)
97 +def find-latest-commit [
100 + let feed = generate-commit-feed-url
$spec 101 + let commit =
match $spec.source {
103 + http get
$feed | lines | parse --regex
"Commit/(?<commit>[a-z0-9]+)" | first | get commit
105 + codeberg => {
'TODO' },
106 + srht => {
'TODO' },
107 + _ => { error make {
108 + msg:
'unknown plugin source given' 110 + text:
'dunno this one' 111 + span: (metadata
$spec.source).span
119 +def generate-commit-feed-url [
122 + let url_format =
match $spec.source {
123 + github => {
'https://github.com/{repo}/commits/{branch}.atom' },
124 + codeberg => {
'TODO' },
125 + srht => {
'TODO' },
126 + _ => { error make {
127 + msg:
'unknown plugin source given' 129 + text:
'dunno this one' 130 + span: (metadata
$spec.source).span
135 + $spec | format pattern
$url_format 54 138 def generate-download-url [
77 161 let archive_path = [
$cache_path (
$spec.name +
'.tar.gz') ] | path join
78 162 if (
$archive_path | path exists) {
163 + print $
"($spec.name) already cached in ($archive_path)" 79 164 return
$archive_path 81 166 let url = generate-download-url
$spec 187 +let allowed_shared_lib_type =
match ( sys host | get name ) {
188 + $name if $name =~
'Windows' => {
'dll' },
189 + $name if $name =~
'Linux' => {
'so' },
190 + $name if $name =~
'Mac' => {
'dylib' },
191 + _ => { error make { msg:
'unknown operating system' } },
193 +let allowed_filetypes = [ lua vim scm txt
$allowed_shared_lib_type ]
102 195 def install-plugin [
104 197 folder_path: path
108 201 try { rm --trash --recursive
$plugin_path }
109 202 mkdir
$plugin_path 111 - let allowed_shared_lib_type =
match ( sys host | get name ) {
112 - 'Windows' => {
'dll' },
113 - 'Linux' => {
'so' },
114 - 'Mac' => {
'dylib' },
116 - let allowed_filetypes = [ lua vim scm txt
$allowed_shared_lib_type ]
117 204 let exclusions = [**/tests/**, **/scripts/**, **/fixtures/**, **/target/release/deps/**]
118 205 glob $
"**/*.{($allowed_filetypes | str join ',')}" --exclude
$exclusions |
119 206 path relative-to (pwd) |
136 223 print $
"Plugin ($spec.name) is already installed and up-to-date!" 226 + print $
"Downloading ($spec.name)..." 139 227 let archive_path = download-plugin
$spec $cache_path 228 + print $
"Unpacking ($spec.name)..." 140 229 let unpacked_path = unpack-plugin-archive
$spec $archive_path 230 + print $
"Installing ($spec.name)..." 141 231 let installed_plugin_path = install-plugin
$spec $unpacked_path $plugins_path 143 232 print $
"Plugin ($spec.name) installed into ($installed_plugin_path)!"