-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnvimInstall
More file actions
executable file
·181 lines (165 loc) · 4.96 KB
/
nvimInstall
File metadata and controls
executable file
·181 lines (165 loc) · 4.96 KB
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
#!/bin/sh
#
# nvimInstall: Installs Neovim configuration files.
#
# usage: nvimInstall [ --install | --check | --remove | --clean | --nuke ]
#
# where --install: installs nvim config into ~/.config/nvim
# --check: checks what was installed
# --remove: removes all files which were installed
# --clean: same as above, but also lazy.nvim installation
# --nuke: removes everything nvim related
#
# shellcheck shell=dash
#
export scriptName=nvimInstall
home="${DOTFILES_GIT_REPO:=~/devel/dotfiles}"/home
cd "$home" 2>/dev/null || {
printf '\n%s: Error - failed to cd into "%s"\n\n' "$scriptName" "$home"
return 1
}
. ../bin/parse_cmdline_and_source_functions.sh
dot_config_files='
after/ftplugin/c.lua
after/ftplugin/cpp.lua
after/ftplugin/csv.lua
after/ftplugin/fish.lua
after/ftplugin/go.lua
after/ftplugin/haskell.lua
after/ftplugin/help.lua
after/ftplugin/html.lua
after/ftplugin/lua.lua
after/ftplugin/markdown.lua
after/ftplugin/ocaml.lua
after/ftplugin/python.lua
after/ftplugin/rust.lua
after/ftplugin/sbt.lua
after/ftplugin/scala.lua
after/ftplugin/sh.lua
after/ftplugin/toml.lua
after/ftplugin/text.lua
after/ftplugin/tsv.lua
after/ftplugin/zig.lua
lsp/bashls.lua
lsp/cssls.lua
lsp/css_modules_ls.lua
lsp/css_variables.lua
lsp/html.lua
lsp/lua_ls.lua
lsp/marksman.lua
lsp/pylsp.lua
lsp/ruff.lua
lsp/tombi.lua
lsp/zls.lua
lua/grs/config/autocmds_lsp.lua
lua/grs/config/autocmds_text.lua
lua/grs/config/configs.lua
lua/grs/config/globals.lua
lua/grs/config/keymaps.lua
lua/grs/config/keymaps_whichkey.lua
lua/grs/config/options.lua
lua/grs/core/lazy.lua
lua/grs/core/lsp.lua
lua/grs/lib/functional.lua
lua/grs/lib/scroll.lua
lua/grs/lib/text.lua
lua/grs/plugins/coding/init.lua
lua/grs/plugins/coding/format.lua
lua/grs/plugins/coding/gitsigns.lua
lua/grs/plugins/coding/lint.lua
lua/grs/plugins/coding/textedit.lua
lua/grs/plugins/ide/init.lua
lua/grs/plugins/ide/ide.lua
lua/grs/plugins/infrastructure/init.lua
lua/grs/plugins/infrastructure/appearance.lua
lua/grs/plugins/infrastructure/luarocks.lua
lua/grs/plugins/infrastructure/mason.lua
lua/grs/plugins/infrastructure/telescope.lua
lua/grs/plugins/infrastructure/treesitter.lua
lua/grs/plugins/infrastructure/whichkey.lua
spell/en.utf-8.add
init.lua
'
toml_files='
stylua.toml
'
remove_items="
$XDG_CONFIG_HOME/nvim/lua/grs/plugins/ide/completions.lua
$XDG_CONFIG_HOME/nvim/lua/grs/plugins/infrastructure/lazy_rock.lua
$XDG_CONFIG_HOME/nvim/lua/grs/plugins/ide/fidget.lua
$XDG_CONFIG_HOME/nvim/lua/grs/plugins/ide/cmp.lua
$XDG_CONFIG_HOME/nvim/lua/grs/config/grs.lua
"
dirs_to_create=""
# Pre ACTION Checks and Tasks
# Determine if spellfile needs to be processed
SpellFile="$XDG_CONFIG_HOME/nvim/spell/en.utf-8.add"
if which nvim > /dev/null 2>&1
then
if test ! -e "$SpellFile"
then
compileSpellFile=yes
elif ! diff -q "$SpellFile" config/nvim/spell/en.utf-8.add 2>&1
then
compileSpellFile=yes
else
compileSpellFile=no
fi
fi
# Configure config/globals.lua with XDG directory locations
sedScript="s!<xdg_config_home>!$XDG_CONFIG_HOME!
s!<xdg_cache_home>!$XDG_CACHE_HOME!
s!<xdg_data_home>!$XDG_DATA_HOME!
s!<xdg_state_home>!$XDG_STATE_HOME!"
config_dir=config/nvim/lua/grs/config
sed -E -e "$sedScript" $config_dir/globals.template.lua > $config_dir/globals.lua
# Perform ACTION
case "$DF_ACTION" in
install|check|remove)
# Install/Check Neovim files & nvim related TOML files
process_files "$XDG_CONFIG_HOME/nvim" "
$dot_config_files
$toml_files
" config/nvim 0644 "$home"
chmod 0755 "$XDG_CONFIG_HOME/nvim"
# Remove/report no longer needed files and directories
remove_items "$remove_items"
# Create/report missing directories
ensure_dirs "$dirs_to_create"
;;
clean)
remove_item "$XDG_CONFIG_HOME/nvim"
remove_item "$XDG_DATA_HOME/nvim/lazy"
remove_item "$XDG_STATE_HOME/nvim/lazy"
remove_item "$XDG_CACHE_HOME/nvim/luac"
;;
nuke)
remove_item "$XDG_CONFIG_HOME/nvim"
remove_item "$XDG_DATA_HOME/nvim"
remove_item "$XDG_STATE_HOME/nvim"
remove_item "$XDG_CACHE_HOME/nvim"
;;
esac
# Post ACTION Tasks
case "$DF_ACTION" in
install)
# Recompiled spell file if necessary
if test "$compileSpellFile" = yes
then
sf="${SpellFile##*/}"
sf_dir="${SpellFile%/*}"
( if cd "$sf_dir"
then
nvim -u NONE --cmd "mkspell!$sf" --cmd 'qa!'
fi )
fi
;;
check)
# Indicate whether the spellfile will be recompiled on next install
if test "$compileSpellFile" = yes
then
printf 'nvimInstall: Spellfile "%s" will be\n' "$SpellFile"
printf ' recompiled on the next install.\n\n'
fi
;;
esac