summaryrefslogtreecommitdiff
path: root/vis/visrc.lua
blob: 004b665a70e88aa63c07e40616006bd620443020 (plain)
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
--load standard vis module, providing parts of the Lua API
require('vis')
require('plugins/vis-commentary')
require('plugins/vis-complete-line')
local smart_backspace = require('plugins/vis-smart-backspace')
smart_backspace.tab_width = 2
require('plugins/vis-cursors')

vis.events.subscribe(vis.events.INIT, function()
	--global configuration options
	vis:command('set theme zenburn_foot_variant')
	vis:command('set tabwidth 2')
	vis:command('set expandtab on')
	vis:command('langmap йцукенгшщзхъ qwertyuiop[]')
	vis:command('langmap фывапролдж asdfghjkl;')
	vis:command('langmap ячсмитьбю zxcvbnm,.')
	vis:command('langmap ЙЦУКЕНГШЩЗХЪ QWERTYUIOP{}')
	vis:command('langmap ФЫВАПРОЛДЖ ASDFGHJKL:')
	vis:command('langmap ЯЧСМИТЬБЮ ZXCVBNM<>')
end)

vis.events.subscribe(vis.events.WIN_OPEN, function()
	--per window configuration options
	vis:command('set colorcolumn 80')
	vis:command('set cursorline on')
	vis:command('set layout v')
	vis:command('set ignorecase yes')
	vis:command('set autoindent yes')
end)

vis:operator_new("gq", function(file, range)
	local status, out, err = vis:pipe(file, range, "fmt -w 80 -g 80")
	if not status then
		vis:info(err)
	else
		file:delete(range)
		file:insert(range.start, out)
	end
	return range.start -- new cursor location
end, "Formating operator, filter range through fmt(1)")

vis:operator_new("U", function(file, range)
	local out = string.upper(vis.win.file:content(range))
	file:delete(range)
	file:insert(range.start, out)
	return range.start -- new cursor location
end, "Convert selection to upper case")

vis:operator_new("L", function(file, range)
	local out = string.lower(vis.win.file:content(range))
	file:delete(range)
	file:insert(range.start, out)
	return range.start -- new cursor location
end, "Convert selection to lower case")