vis: clone plugins with shell script, update visrc.lua

This commit is contained in:
2025-10-03 21:05:56 +02:00
parent 9130eb1a37
commit e54be984ac
2 changed files with 70 additions and 25 deletions

60
vis/.config/vis/plugins.sh Executable file
View File

@@ -0,0 +1,60 @@
#!/bin/sh
if [ $# -eq 0 ]; then
echo 'error: argument required (action), one of: clone, fetch, merge' >&2
exit 1
fi
ACTION="$1"
PLUGINS_DIR=$(dirname $(realpath "$0"))/plugins
cd "$PLUGINS_DIR"
action() {
case "$1" in
*:*)
P="$1"
;;
*)
P="https://github.com/$1"
;;
esac
B=$(basename "$1")
B="${B%.git}"
case "$ACTION" in
clone)
if [ ! -e "$B" ]; then
echo "$ACTION $B"
git clone "$P"
fi
;;
fetch)
if [ -e "$B" ]; then
echo "$ACTION $B"
git -C "$B" fetch
fi
;;
merge)
if [ -e "$B" ]; then
echo "$ACTION $B"
git -C "$B" merge
fi
;;
*)
echo "error: unsupported action: $ACTION" >&2
exit 1
;;
esac
}
for plugin in \
'https://gitlab.com/muhq/vis-lspc' \
'lutobler/vis-commentary' \
'https://repo.or.cz/vis-surround.git' \
'peaceant/vis-fzf-mru' \
'https://gitlab.com/muhq/vis-build' \
'erf/vis-cursors'; \
do
action "$plugin"
done

View File

@@ -1,44 +1,29 @@
require('vis') require('vis')
require('fast-jump') require('fast-jump')
local plug = (function() local lspc = require('plugins/vis-lspc')
if not pcall(require, 'plugins/vis-plug') then require('plugins/vis-commentary')
os.execute('git clone --quiet https://github.com/erf/vis-plug ' .. require('plugins/vis-surround')
(os.getenv('XDG_CONFIG_HOME') or os.getenv('HOME') .. '/.config') local fzfmru = require('plugins/vis-fzf-mru/fzf-mru')
.. '/vis/plugins/vis-plug') require('plugins/vis-build')
end require('plugins/vis-cursors')
return require('plugins/vis-plug')
end)()
plug = require('plugins/vis-plug')
local plugins = {
{ 'https://gitlab.com/muhq/vis-lspc', alias = 'lspc' },
{ 'lutobler/vis-commentary' },
{ 'https://repo.or.cz/vis-surround.git' },
{ 'peaceant/vis-fzf-mru', file = 'fzf-mru', alias = 'fzfmru' },
{ 'https://gitlab.com/muhq/vis-build' },
{ 'erf/vis-cursors' },
}
plug.init(plugins, true)
vis.ftdetect.filetypes.go_ext = vis.ftdetect.filetypes.go vis.ftdetect.filetypes.go_ext = vis.ftdetect.filetypes.go
vis.ftdetect.filetypes.go = nil vis.ftdetect.filetypes.go = nil
plug.plugins.lspc.ls_map.go_ext = plug.plugins.lspc.ls_map.go lspc.ls_map.go_ext = lspc.ls_map.go
vis.ftdetect.filetypes.templ = { vis.ftdetect.filetypes.templ = {
ext = { "%.templ$" }, ext = { "%.templ$" },
} }
plug.plugins.lspc.message_level = 2 lspc.message_level = 2
plug.plugins.lspc.ls_map.templ = { lspc.ls_map.templ = {
name = 'templ-lsp', name = 'templ-lsp',
cmd = 'templ lsp', cmd = 'templ lsp',
} }
plug.plugins.fzfmru.fzfmru_history = 60 fzfmru.fzfmru_history = 60
local function open_file(file, cmd) local function open_file(file, cmd)
vis:command((cmd or 'o') .. ' ' .. file) vis:command((cmd or 'o') .. ' ' .. file)