aboutsummaryrefslogtreecommitdiff
path: root/env/.config/vis/visrc.lua
blob: 3d7f90cb3c4dd587edfd9c249d224ab2700ab2bb (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
-- load standard vis module, providing parts of the Lua API, sets _G.vis
require('plugins')
require('vis')

local leader = ' '

local function count_windows()
    local n = 0
    for _ in vis.windows(vis) do
        n = n + 1
    end
    return n
end


vis:map(vis.modes.NORMAL, ' ', '')

vis:map(vis.modes.VISUAL,leader.."y", '"+y"')

-- global configuration options
vis.events.subscribe(vis.events.INIT, function()
    vis:command("set theme caelus")
end)

-- per-window configuration options
vis.events.subscribe(vis.events.WIN_OPEN, function(win)
    vis:command("set tabwidth 4")
    vis:command("set relativenumbers true")
    vis:command("set autoindent true")
    vis:command("set expandtab true")
    vis:command("set ignorecase true")
    vis:map(vis.modes.NORMAL, leader.."fm", function()
        local windows = count_windows()
        vis:command("open .")
        if count_windows() == windows then
            return
        end
        vis:feedkeys("<C-w>k")
        vis:command("wq!")
    end, "")
    vis:map(vis.modes.NORMAL, leader.."p", '"+p')
end)

vis.ftdetect.filetypes["greyscript"] = { ext = { "%.src$" } }
vis.ftdetect.filetypes["asciidoc"] = { ext = { "%.adoc$" } }