From e54be984ac22e4a9f29e7b667dd9aa42032bf99e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Pankowski?= Date: Fri, 3 Oct 2025 21:05:56 +0200 Subject: [PATCH] vis: clone plugins with shell script, update visrc.lua --- vis/.config/vis/plugins.sh | 60 ++++++++++++++++++++++++++++++++++++++ vis/.config/vis/visrc.lua | 35 +++++++--------------- 2 files changed, 70 insertions(+), 25 deletions(-) create mode 100755 vis/.config/vis/plugins.sh diff --git a/vis/.config/vis/plugins.sh b/vis/.config/vis/plugins.sh new file mode 100755 index 0000000..e5f4cb1 --- /dev/null +++ b/vis/.config/vis/plugins.sh @@ -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 diff --git a/vis/.config/vis/visrc.lua b/vis/.config/vis/visrc.lua index c2a4521..057e835 100644 --- a/vis/.config/vis/visrc.lua +++ b/vis/.config/vis/visrc.lua @@ -1,44 +1,29 @@ require('vis') require('fast-jump') -local plug = (function() - if not pcall(require, 'plugins/vis-plug') then - os.execute('git clone --quiet https://github.com/erf/vis-plug ' .. - (os.getenv('XDG_CONFIG_HOME') or os.getenv('HOME') .. '/.config') - .. '/vis/plugins/vis-plug') - end - 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) +local lspc = require('plugins/vis-lspc') +require('plugins/vis-commentary') +require('plugins/vis-surround') +local fzfmru = require('plugins/vis-fzf-mru/fzf-mru') +require('plugins/vis-build') +require('plugins/vis-cursors') vis.ftdetect.filetypes.go_ext = vis.ftdetect.filetypes.go 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 = { 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', cmd = 'templ lsp', } -plug.plugins.fzfmru.fzfmru_history = 60 +fzfmru.fzfmru_history = 60 local function open_file(file, cmd) vis:command((cmd or 'o') .. ' ' .. file)