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
|
require('vis')
-- 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)
-- 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, "<C-Insert>", function()
to_clipboard(selected_text())
end)
-- super+x (Shift+Delete): cut = copy selection then delete it
vis:map(vis.modes.VISUAL, "<S-Delete>", function()
to_clipboard(selected_text())
vis:feedkeys("x")
end)
-- super+v (Shift+Insert): paste from system clipboard
vis:map(vis.modes.INSERT, "<S-Insert>", function()
local t = from_clipboard()
if t then vis:insert(t) end
end)
vis:map(vis.modes.NORMAL, "<S-Insert>", 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("<C-w>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, "<C-Left>", "b")
vis:map(mode, "<C-Right>", "w")
vis:map(mode, "<M-Left>", "b")
vis:map(mode, "<M-Right>", "w")
vis:map(mode, "<M-Up>", "<vis-nop>")
vis:map(mode, "<M-Down>", "<vis-nop>")
vis:map(mode, "<S-Enter>", "<Enter>")
end
for _, mode in ipairs({vis.modes.INSERT, vis.modes.REPLACE, vis.modes.PROMPT}) do
vis:map(mode, "<C-Left>", nop)
vis:map(mode, "<C-Right>", nop)
vis:map(mode, "<M-Left>", nop)
vis:map(mode, "<M-Right>", nop)
vis:map(mode, "<M-Up>", nop)
vis:map(mode, "<M-Down>", nop)
vis:map(mode, "<S-Enter>", "<Enter>")
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')
|