summaryrefslogtreecommitdiff
path: root/config/vis/visrc.lua
blob: 27c63b966cf365b421d64c9e40b1aa26a8ef4dc8 (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
57
58
59
require('vis')
require('plugins/vis-pairs')
local lsp = require('plugins/vis-lspc')
local format = require('plugins/vis-format')
format.formatters.caml = format.stdio_formatter("ocamlformat  --impl -")
lsp.highlight_diagnostics = 'range'
lsp.menu_cmd = 'vis-menu'

vis:command_register("spell", function(argv, force, cur_win, selection, range)
  vis:feedkeys(":!aspell -t -c $vis_filepath<Enter>")
end, 'Spell check file with aspell')

vis:command_register("fd", function(argv, force, cur_win, selection, range)
	local out = io.popen("fd . | vis-menu -i"):read()
	if out then
		vis:command(string.format('e'..' "%s"', out))
		vis:feedkeys("<vis-redraw>")
	end
end, 'fuzzy file search')

vis:command_register("grep", function(argv, force, cur_win, selection, range)
	local out = io.popen("ugrep "..argv[1].." | vis-menu | cut -d: -f1"):read()
	if out then
		vis:command(string.format('e'..' "%s"', out))
		vis:feedkeys("<vis-redraw>")
	end
end, 'Grep')

vis:command_register("todo", function(argv, force, cur_win, selection, range)
	vis:feedkeys("i* TODO ")
end, 'Add TODO item')

vis:command_register("journal", function(argv, force, cur_win, selection, range)
	vis:insert("*   :journal:")
	vis:feedkeys("11h")
end, 'Add journal entry')

vis.events.subscribe(vis.events.INIT, function()
  -- Your global configuration options

  vis:map(vis.modes.NORMAL, 'Y', ':> wl-copy 2>/dev/null -n<Enter>')
  vis:map(vis.modes.VISUAL, 'y', ':> wl-copy 2>/dev/null -n<Enter>')
  vis:command('set theme minimal-light')
  vis:map(vis.modes.NORMAL, '=', format.apply)
  vis:map(vis.modes.NORMAL, ',', ":")
  vis:map(vis.modes.VISUAL, ',', ":")
  vis:map(vis.modes.VISUAL, 'gq', function() 
      vis:feedkeys(":|fmt -w 80<Enter>")
    end)
end)

vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused args
  -- Your per window configuration options e.g.
  -- vis:command('set number')
  vis:command('set showeof off')
  vis:command('set expandtab')
  vis:command('set ai')
  vis:command('set tw 2')
end)