-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
lazyman.sh
executable file
·5845 lines (5725 loc) · 189 KB
/
lazyman.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
#
# lazyman - install, initialize, manage, and explore multiple Neovim configurations
#
# Written by Ronald Record <[email protected]>, Spring 2023
#
# shellcheck disable=SC1090,SC2001,SC2002,SC2016,SC2006,SC2086,SC2181,SC2129,SC2059,SC2076,SC2126
LAZYMAN="nvim-Lazyman"
ANVMMAN="nvim-AstroNvimV4"
WEBDMAN="nvim-Webdev"
LIDEMAN="nvim-LazyIde"
DOTCONF="${HOME}/.config"
LMANDIR="${DOTCONF}/${LAZYMAN}"
ANVMDIR="${DOTCONF}/${ANVMMAN}"
WEBDDIR="${DOTCONF}/${WEBDMAN}"
LIDEDIR="${DOTCONF}/${LIDEMAN}"
NVIMDIRS="${LMANDIR}/.nvimdirs"
LZYMANRC="${LMANDIR}/.lazymanrc"
NVIMCONF="${LMANDIR}/lua/configuration.lua"
CONFBACK="${LMANDIR}/lua/configuration-orig.lua"
SCRIPTSD="${LMANDIR}/scripts"
CONFIGRC="${SCRIPTSD}/configrc"
HEALTHSC="${SCRIPTSD}/healthcheck.sh"
INFOSCPT="${SCRIPTSD}/information.sh"
INSTNVIM="${SCRIPTSD}/install_neovim.sh"
KILLNVIM="${SCRIPTSD}/kill_all_neovim.sh"
SUBMENUS="${SCRIPTSD}/lazyman_config.sh"
ANVMV4="${SCRIPTSD}/anvmv4_config.sh"
WEBDEV="${SCRIPTSD}/webdev_config.sh"
LZYIDE="${SCRIPTSD}/lzyide_config.sh"
FONTDIR="${SCRIPTSD}/figlet-fonts"
LOLCAT="lolcat"
BOLD=$(tput bold 2> /dev/null)
NORM=$(tput sgr0 2> /dev/null)
LINE=$(tput smul 2> /dev/null)
# We use GNU sed on macOS
SED="sed"
have_gsed=$(type -p gsed)
[ "${have_gsed}" ] && SED="gsed"
# Use a Github API token if one is set
[ "${GITHUB_TOKEN}" ] || {
[ "${GH_API_TOKEN}" ] && export GITHUB_TOKEN="${GH_API_TOKEN}"
[ "${GITHUB_TOKEN}" ] || {
[ "${GH_TOKEN}" ] && export GITHUB_TOKEN="${GH_TOKEN}"
}
}
# Use TMPDIR or TEMPDIR if they are set, otherwise /tmp
TMP=
if [ "${TMPDIR}" ]; then
[ -d "${TMPDIR}" ] && TMP="${TMPDIR}"
else
[ "${TEMPDIR}" ] && [ -d "${TEMPDIR}" ] && TMP="${TEMPDIR}"
fi
[ "${TMP}" ] || TMP="/tmp"
export TMPDIR="${TMP}"
prompt_continue() {
printf "\nPress <Enter> to continue ... "
read -r yn
}
USEGUI=
if [ -f "${CONFIGRC}" ]; then
source "${CONFIGRC}"
else
[ -f "${LMANDIR}/.initialized" ] && {
printf "\n\nERROR: Missing ${CONFIGRC}"
printf "\n\tReinstall Lazyman\n"
prompt_continue
}
fi
SPDIR="${HOME}/.SpaceVim.d"
# Timeout length for nvim headless execution
timeout=120
# Array with font names
fonts=("Epic" "Fire Font-k" "Graceful" "Script" "Shadow" "Slant" "Small" "Speed" "Standard")
cfginst=1
cfgpart=
cfginstalled=0
showinstalled=1
brief_usage() {
printf "\nUsage: lazyman [-4] [-9] [-A] [-a] [-B] [-b branch] [-c] [-d] [-E config]"
printf "\n [-e] [-f path] [-F menu] [-g] [-i group] [-j] [-k] [-l] [-m] [-M] [-s]"
printf "\n [-S] [-v] [-n] [-o] [-O name] [-p] [-P] [-q] [-Q] [-h] [-H] [-I] [-J]"
printf "\n [-L lang] [-rR] [-C url] [-D subdir] [-N nvimdir] [-G] [-tT] [-U]"
printf "\n [-V url] [-w conf] [-W] [-x conf] [-X] [-y] [-Y] [-z] [-Z] [-K conf] [-u]"
printf "\n [health] [info] [init] [install [bob]] [open] [remove] [search] [status] [usage]"
[ "$1" == "noexit" ] || {
printf "\n"
exit 1
}
}
usage() {
brief_usage noexit
printf "\nWhere:"
printf "\n -4 indicates install indicated repo as an AstroNvim v4 custom configuration"
printf "\n -9 indicates do not apply any patches to this configuration"
printf "\n -A indicates install all supported Neovim configurations"
printf "\n -a indicates install and initialize AstroNvimPlus Neovim configuration"
printf "\n -B indicates install and initialize all 'Base' Neovim configurations"
printf "\n -b 'branch' specifies an ${LAZYMAN} git branch to checkout"
printf "\n -c indicates install and initialize NvChad Neovim configuration"
printf "\n -d indicates debug mode"
printf "\n -D 'subdir' specifies the subdirectory of the repository to retrieve"
printf "\n -e indicates install and initialize Ecovim Neovim configuration"
printf "\n -E 'config' execute 'nvim' with 'config' Neovim configuration"
printf "\n 'config' can be one of:"
printf "\n 'lazyman', 'astronvim', 'kickstart', 'magicvim',"
printf "\n 'ecovim', 'nvchad', 'lazyvim', 'lunarvim', 'spacevim'"
printf "\n or any Neovim configuration directory in '~/.config'"
printf "\n (e.g. 'lazyman -E lazyvim foo.lua')"
printf "\n -f 'path' fix treesitter 'help' parser in config file 'path'"
printf "\n -F 'menu' indicates present the specified Lazyman menu"
printf "\n 'menu' can be one of:"
printf "\n main, conf, lsp, format, plugin, anvmv4 lazyide, webdev"
printf "\n -G indicates no plugin manager, initialize with :TSUpdate"
printf "\n -g indicates install and initialize Abstract Neovim configuration"
printf "\n -j indicates install and initialize BasicIde Neovim configuration"
printf "\n -k indicates install and initialize Kickstart Neovim configuration"
printf "\n -l indicates install and initialize LazyVim Neovim configuration"
printf "\n -m indicates install and initialize MagicVim Neovim configuration"
printf "\n -M indicates install and initialize Mini Neovim configuration"
printf "\n -o indicates input required during initialization"
printf "\n -O 'name' indicates set Lazyman configuration to namespace 'name'"
printf "\n 'name' can be one of: free onno ecovim"
printf "\n -s indicates install and initialize SpaceVim Neovim configuration"
printf "\n -v indicates install and initialize LunarVim Neovim configuration"
printf "\n -S indicates show Neovim configuration fuzzy selector menu"
printf "\n -n indicates dry run, don't actually do anything, just printf's"
printf "\n -p indicates use vim-plug rather than Lazy to initialize"
printf "\n -P indicates use Packer rather than Lazy to initialize"
printf "\n -q indicates quiet install"
printf "\n -Q indicates exit after performing specified action(s)"
printf "\n -h indicates use Homebrew to install rather than native pkg mgr"
printf "\n (Pacman is always used on Arch Linux, Homebrew on macOS)"
printf "\n -H indicates compile and install the nightly Neovim build"
printf "\n -i 'group' specifies a group to install/remove/update"
printf "\n 'group' can be one of:"
printf "\n astronvim kickstart lazyvim lunarvim nvchad packer plug"
printf "\n -I indicates install all language servers and tools for coding diagnostics"
printf "\n -J indicates install indicated repo as an AstroNvim v3 custom configuration"
printf "\n -L 'lang' indicates install the 'lang' Language configuration"
printf "\n 'lang' can be one of:"
printf "\n All ${LANGUCFGS}"
printf "\n -r indicates remove the previously installed configuration"
printf "\n -R indicates remove previously installed configuration and backups"
printf "\n -C 'url' specifies a URL to a Neovim configuration git repository"
printf "\n -N 'nvimdir' specifies the folder name to use for the config given by -C"
printf "\n -t indicates list all installed Lazyman Neovim configurations"
printf "\n -T indicates list all uninstalled Lazyman Neovim configurations"
printf "\n -U indicates update an existing configuration"
printf "\n -V 'url' specifies an NvChad user configuration git repository"
printf "\n -w 'conf' indicates install and initialize Personal 'conf' config"
printf "\n 'conf' can be one of:"
printf "\n All ${PRSNLCFGS}"
printf "\n -W indicates install and initialize all 'Personal' Neovim configurations"
printf "\n -x 'conf' indicates install and initialize nvim-starter 'conf' config"
printf "\n 'conf' can be one of:"
printf "\n All ${STARTCFGS}"
printf "\n -X indicates install and initialize all 'Starter' configs"
printf "\n -y indicates do not prompt, answer 'yes' to any prompt"
printf "\n -Y indicates use the following arguments as 'name'/'value' to set Lazyman config"
printf "\n For example: lazyman -Y theme kanagawa"
printf "\n If the 'name' argument is 'get' then the current value is returned"
printf "\n -z indicates do not run nvim after initialization"
printf "\n -Z indicates do not install Homebrew, Neovim, or any other tools"
printf "\n -K 'conf' indicates install 'conf' in development unsupported config"
printf "\n -u displays this usage message and exits"
printf "\n 'health' generate and display a health check for a configuration"
printf "\n 'info' open an information page for a configuration in the default browser"
printf "\n 'init' initialize specified Neovim configuration and exit"
printf "\n 'install' fuzzy search and select configuration to install"
printf "\n 'install bob' install the Bob Neovim version manager"
printf "\n 'open' fuzzy search and select configuration to open"
printf "\n 'remove' fuzzy search and select configuration to remove"
printf "\n 'search' fuzzy search and select configurations for a plugin"
printf "\n 'status' displays a brief status report and exits"
printf "\n 'usage' displays this usage message and exits"
printf "\nCommands act on NVIM_APPNAME, override with '-N nvimdir' or '-A'"
printf "\nWithout arguments lazyman installs and initializes ${LAZYMAN}"
printf "\nor, if initialized, an interactive menu system is displayed.\n"
exit 1
}
# Use a timeout function in case the headless nvim hangs waiting for input
xtimeout() {
timeout=$1
shift
command=("$@")
(
"${command[@]}" &
runnerpid=$!
trap -- '' SIGTERM
( # killer job
sleep $timeout
if ps -p $runnerpid > /dev/null; then
kill -SIGKILL $runnerpid 2> /dev/null
fi
ps -ef | grep nvim | grep headless | grep -v grep | while read l; do
pid=$(echo "$l" | awk ' { print $2 } ')
kill ${pid}
done
) &
killerpid=$!
wait $runnerpid
kill -SIGKILL $killerpid
)
}
set_haves() {
have_brew=$(type -p brew)
have_fzf=$(type -p fzf)
have_neovide=$(type -p neovide)
have_figlet=$(type -p figlet)
have_lolcat=$(type -p lolcat)
have_rich=$(type -p rich)
}
# Patch references to ~/.config/lvim/
fix_lvim_dir() {
fixlvimdir="$1"
[ "${fixlvimdir}" == "${LAZYMAN}" ] || {
find "${DOTCONF}/${fixlvimdir}" \
-type f -a \( -name \*\.lua -o -name \*\.vim -o -name \*\.fnl \) \
| while read -r f; do
echo "$f" | grep /.git/ > /dev/null && continue
grep /lvim/ "$f" > /dev/null && {
cat "$f" | ${SED} -e "s%/lvim/%/${fixlvimdir}/%g" > ${TMPDIR}/lvim$$
cp ${TMPDIR}/lvim$$ "$f"
rm -f ${TMPDIR}/lvim$$
}
done
}
}
# Patch references to ~/.config/nvim/
fix_nvim_dir() {
fixnvimdir="$1"
[ "${fixnvimdir}" == "${LAZYMAN}" ] || {
find "${DOTCONF}/${fixnvimdir}" \
-type f -a \( -name \*\.lua -o -name \*\.vim -o -name \*\.fnl \) \
| while read -r f; do
echo "$f" | grep /.git/ > /dev/null && continue
grep /nvim/ "$f" > /dev/null && {
cat "$f" | ${SED} -e "s%/nvim/%/${fixnvimdir}/%g" > ${TMPDIR}/nvim$$
cp ${TMPDIR}/nvim$$ "$f"
rm -f ${TMPDIR}/nvim$$
}
done
}
}
fix_help_file() {
helpfile="$1"
[ -f "${helpfile}" ] && {
grep help "${helpfile}" > /dev/null && {
cat "${helpfile}" | ${SED} -e "s/\"help\",/\"vimdoc\",/" > ${TMPDIR}/nvimhelp$$
cp ${TMPDIR}/nvimhelp$$ "${helpfile}"
rm -f ${TMPDIR}/nvimhelp$$
}
}
}
calc_elapsed() {
FINISH_SECONDS=$(date +%s)
ELAPSECS=$((FINISH_SECONDS - START_SECONDS))
ELAPSED=$(eval "echo $(date -ud "@$ELAPSECS" +'$((%s/3600/24)) days %H hr %M min %S sec')")
}
init_lvim() {
lvimdir="$1"
export NVIM_APPNAME="${lvimdir}"
#export LUNARVIM_CONFIG_DIR="$HOME/.config/lvim"
#export LUNARVIM_CACHE_DIR="$HOME/.cache/lvim"
#export LUNARVIM_BASE_DIR="${HOME}/.local/share/${NVIM_APPNAME}/lvim"
#export LUNARVIM_BASE_DIR="$HOME/.local/share/lunarvim/lvim"
#export LUNARVIM_RUNTIME_DIR="$HOME/.local/share/lunarvim"
export LUNARVIM_RUNTIME_DIR="${HOME}/.local/share/${NVIM_APPNAME}"
export LUNARVIM_CONFIG_DIR="${DOTCONF}/${NVIM_APPNAME}"
export LUNARVIM_CACHE_DIR="${HOME}/.cache/${NVIM_APPNAME}"
export LUNARVIM_BASE_DIR="${DOTCONF}/${NVIM_APPNAME}"
LVIM_URL="https://raw.githubusercontent.com/LunarVim/LunarVim"
LVIM_INSTALL="${LVIM_URL}/master/utils/installer/install.sh"
[ "$quiet" ] || printf "\nCloning and initializing LunarVim"
[ "$tellme" ] || {
curl -s ${LVIM_INSTALL} > ${TMPDIR}/lvim-install$$.sh
chmod 755 ${TMPDIR}/lvim-install$$.sh
[ -x $HOME/.local/bin/lvim ] || {
[ -f ${LMANDIR}/scripts/lvim ] && {
if [ "${lvimdir}" == "nvim-LunarVim" ]; then
cp ${LMANDIR}/scripts/lvim $HOME/.local/bin/lvim
else
cat ${LMANDIR}/scripts/lvim \
| ${SED} -e "s/nvim-LunarVim/${lvimdir}/" > $HOME/.local/bin/lvim
fi
chmod 755 $HOME/.local/bin/lvim
}
}
if [ "$debug" ]; then
${TMPDIR}/lvim-install$$.sh --no-install-dependencies --yes
else
${TMPDIR}/lvim-install$$.sh --no-install-dependencies --yes > /dev/null 2>&1
fi
rm -f ${TMPDIR}/lvim-install$$.sh
add_nvimdirs_entry "${lvimdir}"
}
}
init_neovim() {
neodir="$1"
[ "${input_req}" ] && debug=1
[ -d "${DOTCONF}/${neodir}" ] || return
[ "${neodir}" == "${LAZYMAN}" ] || [ "${neodir}" == "${minivimdir}" ] && {
oldpack=${packer}
oldplug=${plug}
plug=
packer=
}
[ "${neodir}" == "${abstractdir}" ] && {
oldpack=${packer}
packer=1
}
export NVIM_APPNAME="${neodir}"
[ "${neodir}" == "nvim-Nyoom" ] && {
[ -x ${DOTCONF}/nvim-Nyoom/bin/nyoom ] && {
if [ "${debug}" ]; then
${DOTCONF}/nvim-Nyoom/bin/nyoom install
${DOTCONF}/nvim-Nyoom/bin/nyoom sync
else
${DOTCONF}/nvim-Nyoom/bin/nyoom install > /dev/null 2>&1
${DOTCONF}/nvim-Nyoom/bin/nyoom sync > /dev/null 2>&1
fi
}
}
[ "${packer}" ] && {
PACKER="${HOME}/.local/share/${neodir}/site/pack/packer/start/packer.nvim"
[ -d "${PACKER}" ] || {
[ "$quiet" ] || {
printf "\nCloning packer.nvim into"
printf "\n\t${PACKER}"
}
[ "$tellme" ] || {
git clone --depth 1 \
https://github.com/wbthomason/packer.nvim "${PACKER}" > /dev/null 2>&1
}
}
}
[ "${neodir}" == "${abstractdir}" ] && {
BUILDER="${HOME}/.local/share/${neodir}/custom_tools/lazy-builder"
if [ -d "${BUILDER}" ]; then
[ "$tellme" ] || git -C ${BUILDER} pull > /dev/null 2>&1
else
[ "$quiet" ] || {
printf "\nCloning lazy builder into"
printf "\n\t${BUILDER}"
}
[ "$tellme" ] || {
git clone https://github.com/Abstract-IDE/lazy-builder \
"${BUILDER}" > /dev/null 2>&1
}
fi
}
[ "${neodir}" == "${lunarvimdir}" ] \
|| [ "${neodir}" == "nvim-LunarIde" ] \
|| [ "${neodir}" == "nvim-LvimAdib" ] \
|| [ "${neodir}" == "nvim-Shuvro" ] && fix_lvim_dir "${neodir}"
[ "${plug}" ] && {
PLUG="${HOME}/.local/share/${neodir}/site/autoload/plug.vim"
[ -d "${PLUG}" ] || {
[ "$quiet" ] || {
printf "\nCopying plug.vim to"
printf "\n\t${PLUG}"
}
[ "$tellme" ] || {
sh -c "curl -fLo ${PLUG} --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" \
> /dev/null 2>&1
}
}
}
skipthis=
if [ "${neodir}" == "nvim-AstroNvimV4" ]; then
[ -x ${ANVMV4} ] && ${ANVMV4} -i
custom_url=
else
if [ "${neodir}" == "nvim-Webdev" ]; then
[ -x ${WEBDEV} ] && ${WEBDEV} -i
custom_url=
else
[ "${neodir}" == "nvim-LazyIde" ] && {
[ -x ${LZYIDE} ] && ${LZYIDE} -i
custom_url=
}
fi
fi
[ "${custom_url}" ] && {
[ "${neodir}" == "nvim-JustinOhMy" ] || {
# Check for wakatime plugin and use debug mode if found
havewaka=
find "${DOTCONF}/${neodir}" -type f \
-a \( -name \*\.lua -o -name \*\.vim -o -name \*\.fnl \) -print0 \
| xargs -0 grep wakatime/vim-wakatime > /dev/null && {
[ -f "${HOME}"/.wakatime.cfg ] && havewaka=1
if [ "${havewaka}" ]; then
skipthis=
else
printf "\n\nThe ${neodir} Neovim configuration appears to use the WakaTime metrics plugin."
printf "\nand cannot be automatically initialized as it requires user interaction."
skipthis=1
fi
[ "${skipthis}" ] && {
wakafile=$(find "${DOTCONF}/${neodir}" -type f -print0 | xargs -0 grep wakatime/vim-wakatime | head -1 | awk -F ':' ' { print $1 } ')
printf "\nTo initialize this configuration, either comment out the WakaTime plugin in:"
printf "\n\t${wakafile}"
printf "\nor get a WakaTime API key and manually initialize this configuration with:"
printf "\n\tNVIM_APPNAME=${neodir} nvim"
printf "\n\nSkipping auto-initialization, press <Enter> to continue ... "
read -r yn
}
}
}
}
[ "${skipthis}" ] || {
if [ "$debug" ]; then
LOG="${LMANDIR}/logs/${neodir}"
[ "$quiet" ] || {
printf "\nInitializing configuration in debug mode."
printf "\nLogging output in ${LMANDIR}/logs/${neodir}"
}
[ -d ${LMANDIR}/logs ] || mkdir -p ${LMANDIR}/logs
START_SECONDS=$(date +%s)
if [ "${packer}" ]; then
xtimeout ${timeout} nvim --headless \
-c 'autocmd User PackerComplete quitall' \
-c 'PackerSync' 2>&1 | tee -a ${LOG}
else
if [ "${plug}" ]; then
xtimeout ${timeout} nvim --headless -c \
'PlugInstall!' -c 'qa' 2>&1 | tee -a ${LOG}
xtimeout ${timeout} nvim --headless -c \
'UpdateRemotePlugins' -c 'qa' 2>&1 | tee -a ${LOG}
xtimeout ${timeout} nvim --headless -c \
'GoInstallBinaries' -c 'qa' 2>&1 | tee -a ${LOG}
else
if [ "${neodir}" == "${spacevimdir}" ]; then
xtimeout ${timeout} nvim --headless "+SPInstall" +qa 2>&1 \
| tee -a ${LOG}
xtimeout ${timeout} nvim --headless "+UpdateRemotePlugins" +qa 2>&1 \
| tee -a ${LOG}
else
[ "${neodir}" == "${lunarvimdir}" ] \
|| [ "${neodir}" == "nvim-LvimAdib" ] \
|| [ "${neodir}" == "nvim-Shuvro" ] \
|| [ "${neodir}" == "nvim-LunarIde" ] && {
export NVIM_APPNAME="${neodir}"
export LUNARVIM_RUNTIME_DIR="${HOME}/.local/share/${NVIM_APPNAME}"
export LUNARVIM_CONFIG_DIR="${DOTCONF}/${NVIM_APPNAME}"
export LUNARVIM_CACHE_DIR="${HOME}/.cache/${NVIM_APPNAME}"
export LUNARVIM_BASE_DIR="${DOTCONF}/${NVIM_APPNAME}"
}
if [ "${treesitter}" ]; then
xtimeout ${timeout} nvim --headless '+TSUpdate' +qa 2>&1 \
| tee -a ${LOG}
else
[ "${neodir}" == "${minivimdir}" ] || {
[ "${neodir}" == "nvim-Nyoom" ] || {
[ "${neodir}" == "nvim-Vimacs" ] || {
xtimeout ${timeout} nvim --headless "+Lazy! sync" +qa 2>&1 \
| tee -a ${LOG}
}
[ "${neodir}" == "${nvchaddir}" ] \
|| [ "${neodir}" == "nvim-Cpp" ] \
|| [ "${neodir}" == "nvim-Go" ] \
|| [ "${neodir}" == "nvim-LazyIde" ] \
|| [ "${neodir}" == "nvim-Rust" ] \
|| [ "${neodir}" == "nvim-Python" ] && {
xtimeout ${timeout} nvim --headless "+MasonInstallAll" +qa 2>&1 \
| tee -a ${LOG}
}
[ "${neodir}" == "nvim-2k" ] && {
xtimeout ${timeout} nvim --headless "+UpdateRemotePlugins" +qa 2>&1 \
| tee -a ${LOG}
}
# Perform a 2nd sync on some configs
[ "${neodir}" == "nvim-Allaman" ] && {
xtimeout ${timeout} nvim --headless "+Lazy! sync" +qa 2>&1 \
| tee -a ${LOG}
}
}
}
fi
fi
fi
fi
[ -d "${DOTCONF}/${neodir}/doc" ] && {
xtimeout ${timeout} nvim --headless \
"+helptags ${DOTCONF}/${neodir}/doc" +qa 2>&1 | tee -a ${LOG}
}
[ "$quiet" ] || printf "\n"
calc_elapsed
printf "\nInitialization elapsed time = ${ELAPSED}\n"
else
[ "$quiet" ] || printf "\nInitializing configuration"
if [ "${packer}" ]; then
xtimeout ${timeout} nvim --headless \
-c 'autocmd User PackerComplete quitall' \
-c 'PackerSync' > /dev/null 2>&1
else
if [ "${plug}" ]; then
xtimeout ${timeout} nvim --headless \
-c 'PlugInstall!' -c 'qa' > /dev/null 2>&1
xtimeout ${timeout} nvim --headless \
-c 'UpdateRemotePlugins' -c 'qa' > /dev/null 2>&1
xtimeout ${timeout} nvim --headless \
-c 'GoInstallBinaries' -c 'qa' > /dev/null 2>&1
else
if [ "${neodir}" == "${spacevimdir}" ]; then
xtimeout ${timeout} nvim --headless \
"+SPInstall" +qa > /dev/null 2>&1
xtimeout ${timeout} nvim --headless \
"+UpdateRemotePlugins" +qa > /dev/null 2>&1
else
[ "${neodir}" == "${lunarvimdir}" ] \
|| [ "${neodir}" == "nvim-LvimAdib" ] \
|| [ "${neodir}" == "nvim-Shuvro" ] \
|| [ "${neodir}" == "nvim-LunarIde" ] && {
export NVIM_APPNAME="${neodir}"
export LUNARVIM_RUNTIME_DIR="${HOME}/.local/share/${NVIM_APPNAME}"
export LUNARVIM_CONFIG_DIR="${DOTCONF}/${NVIM_APPNAME}"
export LUNARVIM_CACHE_DIR="${HOME}/.cache/${NVIM_APPNAME}"
export LUNARVIM_BASE_DIR="${DOTCONF}/${NVIM_APPNAME}"
}
if [ "${treesitter}" ]; then
xtimeout ${timeout} nvim --headless '+TSUpdate' +qa > /dev/null 2>&1
else
[ "${neodir}" == "${minivimdir}" ] || {
[ "${neodir}" == "nvim-Nyoom" ] || {
[ "${neodir}" == "nvim-Vimacs" ] || {
xtimeout ${timeout} nvim --headless \
"+Lazy! sync" +qa > /dev/null 2>&1
}
[ "${neodir}" == "${nvchaddir}" ] \
|| [ "${neodir}" == "nvim-Cpp" ] \
|| [ "${neodir}" == "nvim-Go" ] \
|| [ "${neodir}" == "nvim-LazyIde" ] \
|| [ "${neodir}" == "nvim-Rust" ] \
|| [ "${neodir}" == "nvim-Python" ] && {
xtimeout ${timeout} nvim --headless \
"+MasonInstallAll" +qa > /dev/null 2>&1
}
[ "${neodir}" == "nvim-2k" ] && {
xtimeout ${timeout} nvim \
--headless "+UpdateRemotePlugins" +qa > /dev/null 2>&1
}
# Perform a 2nd sync on some configs
[ "${neodir}" == "nvim-Allaman" ] && {
xtimeout ${timeout} nvim --headless \
"+Lazy! sync" +qa > /dev/null 2>&1
}
}
}
fi
fi
fi
fi
[ -d "${DOTCONF}/${neodir}/doc" ] && {
xtimeout ${timeout} nvim --headless \
"+helptags ${DOTCONF}/${neodir}/doc" +qa > /dev/null 2>&1
}
[ "$quiet" ] || printf "\n"
fi
}
[ "${neodir}" == "${LAZYMAN}" ] && {
[ -f "${LMANDIR}/.initialized" ] || {
touch "${LMANDIR}/.initialized"
}
}
[ "${neodir}" == "${LAZYMAN}" ] || [ "${neodir}" == "${minivimdir}" ] && {
packer=${oldpack}
plug=${oldplug}
}
# Backup original configuration.lua for managed configurations
[ "${neodir}" == "nvim-AstroNvimV4" ] \
|| [ "${neodir}" == "nvim-LazyIde" ] \
|| [ "${neodir}" == "nvim-Webdev" ] && {
[ -f "${DOTCONF}/${neodir}/lua/configuration.lua" ] && {
cp "${DOTCONF}/${neodir}/lua/configuration.lua" \
"${DOTCONF}/${neodir}/lua/configuration-orig.lua"
}
}
}
add_nvimdirs_entry() {
ndir="$1"
if [ -f "${NVIMDIRS}" ]; then
grep ^"$ndir"$ "${NVIMDIRS}" > /dev/null || {
echo "$ndir" >> "${NVIMDIRS}"
}
else
[ -d "${LMANDIR}" ] && {
echo "$ndir" > "${NVIMDIRS}"
}
fi
}
remove_nvimdirs_entry() {
ndir="$1"
[ -f "${NVIMDIRS}" ] && {
grep ^"$ndir"$ "${NVIMDIRS}" > /dev/null && {
grep -v ^"$ndir"$ "${NVIMDIRS}" > ${TMPDIR}/nvimdirs$$
cp ${TMPDIR}/nvimdirs$$ "${NVIMDIRS}"
rm -f ${TMPDIR}/nvimdirs$$
}
}
}
remove_config() {
ndir="$1"
if [ "${ndir}" == "nvim" ]; then
printf "\nYou have requested removal of the Neovim configuration at:"
printf "\n\t${DOTCONF}/nvim\n"
printf "\nLazyman will not modify the standard nvim folders in any way."
printf "\nRemoval cancelled, press <Enter> to continue ... "
read -r yn
return
fi
[ -d "${DOTCONF}/${ndir}" ] || {
[ -d "${DOTCONF}/nvim-${ndir}" ] && ndir="nvim-${ndir}"
}
remove_lazyman=
if [ "${ndir}" == "${LAZYMAN}" ]; then
if [ -f ${NVIMDIRS} ]; then
numinst=$(grep -v nvim-Lazyman ${NVIMDIRS} | grep -v ^$ | wc -l)
else
numinst=0
fi
printf "\nYou have requested removal of the Lazyman Neovim configuration at:"
printf "\n\t${DOTCONF}/nvim-Lazyman\n"
if [ ${numinst} -gt 0 ]; then
printf "\nThis will remove Lazyman and ${numinst} Neovim configurations installed with lazyman."
printf "\nConfirm removal of Lazyman and ${numinst} Neovim configuratioins\n"
else
printf "\nThis will remove Lazyman and $HOME/.local/bin/lazyman"
printf "\nConfirm removal of Lazyman\n"
fi
while true; do
read -r -p "Remove Lazyman ? (y/n) " yn
case $yn in
[Yy]*)
proceed=1
removeall=1
remove_lazyman=1
break
;;
[Nn]*)
printf "\nAborting removal of Lazyman and exiting\n"
exit 0
;;
*)
printf "\nPlease answer yes or no.\n"
;;
esac
done
fi
[ "$proceed" ] || {
printf "\nYou have requested removal of the Neovim configuration at:"
printf "\n\t${DOTCONF}/${ndir}\n"
printf "\nConfirm removal of the Neovim ${ndir} configuration\n"
while true; do
read -r -p "Remove ${ndir} ? (y/n) " yn
case $yn in
[Yy]*)
break
;;
[Nn]*)
printf "\nAborting removal and exiting\n"
exit 0
;;
*)
printf "\nPlease answer yes or no.\n"
;;
esac
done
}
[ "$remove_lazyman" ] && {
printf "\nRemoving all Lazyman installed Neovim configurations ..."
[ "$tellme" ] || lazyman -R -A -y -q > /dev/null 2>&1
printf " done"
}
# Some configurations have custom files and folders
if [ "${ndir}" == "nvim-Allaman" ]; then
rm -f ${HOME}/.nvim_config.lua
elif [ "${ndir}" == "${spacevimdir}" ]; then
[ -f ${SPDIR}/.git/config ] && {
grep github.com/doctorfree/spacevim ${SPDIR}/.git/config > /dev/null && {
[ "$quiet" ] || {
printf "\nRemoving custom SpaceVim config at ${SPDIR}"
}
[ "$tellme" ] || {
rm -rf "${SPDIR}"
}
}
}
elif [ "${ndir}" == "${lunarvimdir}" ]; then
USCP="${HOME}/.local/share/${lunarvimdir}/lvim/utils/installer/uninstall.sh"
[ -x ${USCP} ] || {
LVIM_URL="https://raw.githubusercontent.com/lunarvim/lunarvim"
LVIM_UNINSTALL="${LVIM_URL}/master/utils/installer/uninstall.sh"
curl -s ${LVIM_UNINSTALL} > ${TMPDIR}/lvim-uninstall$$.sh
chmod 755 ${TMPDIR}/lvim-uninstall$$.sh
USCP="${TMPDIR}/lvim-uninstall$$.sh"
}
[ "$quiet" ] || {
printf "\nRunning LunarVim uninstall script"
}
[ "$tellme" ] || {
export NVIM_APPNAME="${lunarvimdir}"
export LUNARVIM_RUNTIME_DIR="${HOME}/.local/share/${NVIM_APPNAME}"
export LUNARVIM_CONFIG_DIR="${DOTCONF}/${NVIM_APPNAME}"
export LUNARVIM_CACHE_DIR="${HOME}/.cache/${NVIM_APPNAME}"
export LUNARVIM_BASE_DIR="${DOTCONF}/${NVIM_APPNAME}"
remove_backups=
[ "$removeall" ] && remove_backups="--remove-backups"
${USCP} ${remove_backups} --remove-config > /dev/null 2>&1
rm -f "${TMPDIR}/lvim-uninstall$$.sh"
}
fi
[ -d "${DOTCONF}/$ndir" ] && {
[ "$quiet" ] || {
printf "\nRemoving existing ${ndir} config at ${DOTCONF}/${ndir}"
}
[ "$tellme" ] || {
rm -rf "${DOTCONF}/$ndir"
}
}
[ "$removeall" ] && {
[ "$quiet" ] || {
printf "\nRemoving any ${ndir} config backups"
}
[ "$tellme" ] || {
rm -rf "${DOTCONF}/$ndir"-bak*
rm -rf "${DOTCONF}/$ndir".old
}
}
[ -d "${HOME}/.local/share/$ndir" ] && {
[ "$quiet" ] || {
printf "\nRemoving existing ${ndir} plugins at ${HOME}/.local/share/${ndir}"
}
[ "$tellme" ] || {
rm -rf "${HOME}/.local/share/$ndir"
}
}
[ "$removeall" ] && {
[ "$quiet" ] || {
printf "\nRemoving any ${ndir} plugins backups"
}
[ "$tellme" ] || {
rm -rf "${HOME}/.local/share/$ndir"-bak*
rm -rf "${HOME}/.local/share/$ndir".old
}
}
[ -d "${HOME}/.local/state/$ndir" ] && {
[ "$quiet" ] || {
printf "\nRemoving existing ${ndir} state at ${HOME}/.local/state/${ndir}"
}
[ "$tellme" ] || {
rm -rf "${HOME}/.local/state/$ndir"
}
}
[ "$removeall" ] && {
[ "$quiet" ] || {
printf "\nRemoving any ${ndir} state backups"
}
[ "$tellme" ] || {
rm -rf "${HOME}/.local/state/$ndir"-bak*
rm -rf "${HOME}/.local/state/$ndir".old
}
}
[ -d "${HOME}/.cache/$ndir" ] && {
[ "$quiet" ] || {
printf "\nRemoving existing ${ndir} cache at ${HOME}/.cache/${ndir}"
}
[ "$tellme" ] || {
rm -rf "${HOME}/.cache/$ndir"
}
}
[ "$removeall" ] && {
[ "$quiet" ] || {
printf "\nRemoving any ${ndir} cache backups"
}
[ "$tellme" ] || {
rm -rf "${HOME}/.cache/$ndir"-bak*
rm -rf "${HOME}/.cache/$ndir".old
}
}
[ "$tellme" ] || {
remove_nvimdirs_entry "$ndir"
}
[ "$remove_lazyman" ] && {
[ "$tellme" ] || {
rm -f "${HOME}/.local/bin/lazyman"
rm -f "${HOME}/.local/bin/lman"
}
}
}
apply_patch() {
patchdir="$1"
[ "${nopatch}" ] || {
[ -f "${LMANDIR}"/scripts/patches/${patchdir}.patch ] && {
[ -x "${LMANDIR}"/scripts/patch_config.sh ] && {
"${LMANDIR}"/scripts/patch_config.sh "${patchdir}"
}
}
}
}
update_config() {
ndir="$1"
GITDIR=".config/${ndir}"
[ -d "${HOME}/${GITDIR}" ] || {
[ -d "${DOTCONF}/nvim-${ndir}" ] && {
ndir="nvim-${ndir}"
GITDIR=".config/${ndir}"
}
}
[ -d "${HOME}/${GITDIR}" ] && {
printf "\nUpdating existing ${ndir} config at ${HOME}/${GITDIR}"
[ "$tellme" ] || {
[ "${ndir}" == "${LAZYMAN}" ] \
|| [ "${ndir}" == "${ANVMMAN}" ] \
|| [ "${ndir}" == "${WEBDMAN}" ] \
|| [ "${ndir}" == "${LIDEMAN}" ] && {
[ -f "${HOME}/${GITDIR}/lua/configuration.lua" ] && {
cp "${HOME}/${GITDIR}/lua/configuration.lua" ${TMPDIR}/lazyconf$$
}
}
git -C "${HOME}/${GITDIR}" stash > /dev/null 2>&1
git -C "${HOME}/${GITDIR}" reset --hard > /dev/null 2>&1
git -C "${HOME}/${GITDIR}" pull > /dev/null 2>&1
}
[ "$tellme" ] || add_nvimdirs_entry "${ndir}"
}
[ "$tellme" ] || {
if [ "${ndir}" == "${LAZYMAN}" ]; then
NVIMCONF="${LMANDIR}/lua/configuration.lua"
CONFBACK="${LMANDIR}/lua/configuration-orig.lua"
else
if [ "${ndir}" == "${ANVMMAN}" ]; then
NVIMCONF="${ANVMDIR}/lua/configuration.lua"
CONFBACK="${ANVMDIR}/lua/configuration-orig.lua"
else
if [ "${ndir}" == "${WEBDMAN}" ]; then
NVIMCONF="${WEBDDIR}/lua/configuration.lua"
CONFBACK="${WEBDDIR}/lua/configuration-orig.lua"
else
if [ "${ndir}" == "${LIDEMAN}" ]; then
NVIMCONF="${LIDEDIR}/lua/configuration.lua"
CONFBACK="${LIDEDIR}/lua/configuration-orig.lua"
else
NVIMCONF=
CONFBACK=
fi
fi
fi
fi
[ -f "${NVIMCONF}" ] && {
cp ${NVIMCONF} ${CONFBACK}
[ -f ${TMPDIR}/lazyconf$$ ] && {
restore_config=
numconfold=$(grep ^conf ${TMPDIR}/lazyconf$$ | wc -l)
if [ -f "${HOME}/${GITDIR}/lua/configuration.lua" ]; then
numconfnew=$(grep ^conf "${HOME}/${GITDIR}/lua/configuration.lua" | wc -l)
[ ${numconfold} -eq ${numconfnew} ] && restore_config=1
else
restore_config=1
fi
if [ "${restore_config}" ]; then
[ -f "${HOME}/${GITDIR}/lua/configuration.lua" ] && {
printf "\nSaving new configuration file as:"
printf "\n\t${HOME}/${GITDIR}/lua/configuration-new.lua"
cp "${HOME}/${GITDIR}/lua/configuration.lua" \
"${HOME}/${GITDIR}/lua/configuration-new.lua"
}
printf "\nRestoring your previous configuration file as:"
printf "\n\t${HOME}/${GITDIR}/lua/configuration.lua"
cp ${TMPDIR}/lazyconf$$ "${HOME}/${GITDIR}/lua/configuration.lua"
else
cp ${TMPDIR}/lazyconf$$ "${HOME}/${GITDIR}/lua/configuration-prev.lua"
printf "\n\nThe format of the Lazyman configuration file has changed."
printf "\nSaving your previous configuration file as:"
printf "\n\t${HOME}/${GITDIR}/lua/configuration-prev.lua"
printf "\nRe-apply any customizations to the new config at:"
printf "\n\t${HOME}/${GITDIR}/lua/configuration.lua"
prompt_continue
fi
rm -f ${TMPDIR}/lazyconf$$
${SUBMENUS} -i
}
[ -d "${HOME}"/.local/bin ] || mkdir -p "${HOME}"/.local/bin
[ -f "${LMANDIR}"/lazyman.sh ] && {
cp "${LMANDIR}"/lazyman.sh "${HOME}"/.local/bin/lazyman
chmod 755 "${HOME}"/.local/bin/lazyman
}
[ -f "${SCRIPTSD}"/lman.sh ] && {
cp "${SCRIPTSD}"/lman.sh "${HOME}"/.local/bin/lman
chmod 755 "${HOME}"/.local/bin/lman
}
}
[ "${ndir}" == "${astronvimdir}" ] \
|| [ "${ndir}" == "${nvchaddir}" ] \
|| [ "${ndir}" == "nvim-Cpp" ] \
|| [ "${ndir}" == "nvim-Go" ] \
|| [ "${ndir}" == "nvim-Rust" ] \
|| [ "${ndir}" == "nvim-Vimacs" ] \
|| [ "${ndir}" == "nvim-Python" ] \
|| [ "${customastro}" ] && {
if [ "${ndir}" == "${astronvimdir}" ] || [ "${customastro}" ]; then
cdir="lua/user"
else
cdir="lua/custom"
fi
[ -d "${HOME}/${GITDIR}/${cdir}" ] && {
printf "\nUpdating existing add-on config at ${DOTCONF}/${ndir}/${cdir}"
[ "$tellme" ] || {
git -C "${HOME}/${GITDIR}/${cdir}" stash > /dev/null 2>&1
git -C "${HOME}/${GITDIR}"/${cdir} reset --hard > /dev/null 2>&1
git -C "${HOME}/${GITDIR}"/${cdir} pull > /dev/null 2>&1
}
}
}
[ "${ndir}" == "${spacevimdir}" ] && {
[ -d "${SPDIR}"/.git ] && {
printf "\nUpdating existing SpaceVim add-on config at ${SPDIR}"
[ "$tellme" ] || {
git -C "${SPDIR}" stash > /dev/null 2>&1
git -C "${SPDIR}" reset --hard > /dev/null 2>&1
git -C "${SPDIR}" pull > /dev/null 2>&1
}
}
}
[ "${ndir}" == "${minivimdir}" ] && {
git -C "${HOME}/${GITDIR}" submodule update \
--remote --init --recursive > /dev/null 2>&1
}
[ "${ndir}" == "${LAZYMAN}" ] || fix_nvim_dir "${ndir}"
[ "${ndir}" == "${lunarvimdir}" ] \
|| [ "${ndir}" == "nvim-LunarIde" ] \
|| [ "${ndir}" == "nvim-LvimAdib" ] \
|| [ "${ndir}" == "nvim-Shuvro" ] && fix_lvim_dir "${ndir}"
apply_patch "${ndir}"
[ "${ndir}" == "${latexvimdir}" ] && {
fix_help_file "${DOTCONF}/${ndir}/${fix_latex}"
}
}
}
set_brew() {
if [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then
HOMEBREW_HOME="/home/linuxbrew/.linuxbrew"
else
if [ -x /usr/local/bin/brew ]; then
HOMEBREW_HOME="/usr/local"
else
if [ -x /opt/homebrew/bin/brew ]; then
HOMEBREW_HOME="/opt/homebrew"
else
HOMEBREW_HOME=
fi
fi
fi
if [ "$HOMEBREW_HOME" ]; then
BREW_EXE="${HOMEBREW_HOME}/bin/brew"
else
BREW_EXE=
fi
}
clone_repo() {
reponame="$1"
repourl="$2"
repodest="$3"