From 6fc7f49449cb237e1aa37eb1025461fe3ea39589 Mon Sep 17 00:00:00 2001 From: seraphim <18ycm9tx@anonaddy.me> Date: Thu, 27 Aug 2026 11:50:43 +0700 Subject: . --- .config/vis/visrc.lua | 169 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 162 insertions(+), 7 deletions(-) (limited to '.config/vis/visrc.lua') diff --git a/.config/vis/visrc.lua b/.config/vis/visrc.lua index 2c78715..e62a46b 100644 --- a/.config/vis/visrc.lua +++ b/.config/vis/visrc.lua @@ -1,12 +1,167 @@ require('vis') --- Auto-themed colors from wallust (palette derived from the wallpaper). --- Falls back to a built-in theme if wallust hasn't generated one yet. -local wallust = os.getenv('HOME') .. '/.cache/wallust/vis-theme.lua' -if not pcall(dofile, wallust) then - pcall(require, 'themes.solarized') -end + -- config -- +-- global +vis.events.subscribe(vis.events.INIT, function() + vis:command("set theme wallust") +end) +-- per-window vis.events.subscribe(vis.events.WIN_OPEN, function(win) - vis:command('set number') + -- kdl: no ftdetect entry ships with vis + if win.file and win.file.name:match('%.kdl$') then win.syntax = 'kdl' end + vis:command("set tabwidth 2") + vis:command("set numbers true") vis:command("set relativenumbers true") vis:command("set autoindent true") + vis:command("set showspaces false") + vis:command("set showtabs false") + vis:command("set expandtab on") + vis:command("set shell /usr/bin/env sh") + vis:map(vis.modes.VISUAL," y", '"+y"') + + -- system clipboard (wayland) via wl-copy / wl-paste + local function selected_text() + local win = vis.window + local sel = win and win.selection + if not sel then return nil end + return sel:save() + end + local function to_clipboard(text) + if not text or #text == 0 then return end + local p = io.popen("wl-copy", "w") + if p then p:write(text) p:close() end + end + local function from_clipboard() + local p = io.popen("wl-paste") + if not p then return end + local t = p:read("*a") + p:close() + return t + end + -- super+c (Ctrl+Insert): copy selection + vis:map(vis.modes.VISUAL, "", function() + to_clipboard(selected_text()) + end) + -- super+x (Shift+Delete): cut = copy selection then delete it + vis:map(vis.modes.VISUAL, "", function() + to_clipboard(selected_text()) + vis:feedkeys("x") + end) + -- super+v (Shift+Insert): paste from system clipboard + vis:map(vis.modes.INSERT, "", function() + local t = from_clipboard() + if t then vis:insert(t) end + end) + vis:map(vis.modes.NORMAL, "", function() + local t = from_clipboard() + if t then + vis:command("set paste on") + vis:insert(t) + vis:command("set paste off") + end + end) + + vis:map(vis.modes.NORMAL, " fm", function() + vis:command("open .") + vis:feedkeys("k") + vis:command("wq!") + end, "") end) + + -- plugins -- + +-- modal +local modal = require('plugins/vis-modal') +-- vis-autoclose +local autoclose = require('plugins/vis-autoclose') +-- colorizer +local colorizer = require('plugins/vis-colorizer') +colorizer.three = false +colorizer.six = true + -- complete-filename + local completefilename = require('plugins/complete-filename') + + -- stray terminal keys: Ctrl/Alt+arrows, Shift+Enter + local nop = function() end + for _, mode in ipairs({vis.modes.NORMAL, vis.modes.VISUAL, vis.modes.OPERATOR_PENDING}) do + vis:map(mode, "", "b") + vis:map(mode, "", "w") + vis:map(mode, "", "b") + vis:map(mode, "", "w") + vis:map(mode, "", "") + vis:map(mode, "", "") + vis:map(mode, "", "") + end + for _, mode in ipairs({vis.modes.INSERT, vis.modes.REPLACE, vis.modes.PROMPT}) do + vis:map(mode, "", nop) + vis:map(mode, "", nop) + vis:map(mode, "", nop) + vis:map(mode, "", nop) + vis:map(mode, "", nop) + vis:map(mode, "", nop) + vis:map(mode, "", "") + end + + -- russian layout: use QWERTY motions while Ru is active (normal/visual modes) + local ru_en = { + q="й", w="ц", e="у", r="к", t="е", y="н", u="г", i="ш", o="щ", p="з", + ["["]="х", ["]"]="ъ", + a="ф", s="ы", d="в", f="а", g="п", h="р", j="о", k="л", l="д", + [";"]="ж", ["'"]="э", + z="я", x="ч", c="с", v="м", b="и", n="т", m="ь", + [","]="б", ["."]="ю", + } + local upper_ru = { + ["Й"]="Q", ["Ц"]="W", ["У"]="E", ["К"]="R", ["Е"]="T", ["Н"]="Y", ["Г"]="U", ["Ш"]="I", ["Щ"]="O", ["З"]="P", + ["Х"]="[", ["Ъ"]="]", + ["Ф"]="A", ["Ы"]="S", ["В"]="D", ["А"]="F", ["П"]="G", ["Р"]="H", ["О"]="J", ["Л"]="K", ["Д"]="L", + ["Ж"]=";", ["Э"]="'", + ["Я"]="Z", ["Ч"]="X", ["С"]="C", ["М"]="V", ["И"]="B", ["Т"]="N", ["Ь"]="M", + ["Б"]=",", ["Ю"]=".", + } + for _, mode in ipairs({vis.modes.NORMAL, vis.modes.VISUAL, vis.modes.OPERATOR_PENDING}) do + for en, ru in pairs(ru_en) do + vis:map(mode, ru, en) + end + for ru, en in pairs(upper_ru) do + vis:map(mode, ru, en) + end + end +-- vis-lspc +local lsp = require('plugins/vis-lspc') +--lsp.ls_map.clangd = { +-- formatting_options = {tabSize = 2, insertSpaces = false} +--} +lsp.ls_map.lua = { + name = 'lua-language-server', + cmd = 'lua-language-server', + settings = { + Lua = {diagnostics = { globals = {'vis'}}, telemetry = {enable = false}}, + }, + formatting_options = {tabSize = 2, insertSpaces = true}, +} +-- python via pyright (npm) instead of pylsp +lsp.ls_map.python = { + name = 'pyright-langserver', + cmd = 'pyright-langserver --stdio', + roots = {'pyproject.toml', 'setup.py', 'requirements.txt'}, +} +-- markdown via marksman +lsp.ls_map.markdown = { + name = 'marksman', + cmd = 'marksman', +} +-- yaml (not preconfigured by vis-lspc) +lsp.ls_map.yaml = { + name = 'yaml-language-server', + cmd = 'yaml-language-server --stdio', +} +-- dockerfile (not preconfigured by vis-lspc) +lsp.ls_map.dockerfile = { + name = 'docker-langserver', + cmd = 'docker-langserver --stdio', +} + +-- gq: format buffer with the active language server +vis:map(vis.modes.NORMAL, ' gq', function() + vis:command('lspc-format') +end, 'LSP format') -- cgit v1.2.3