52 lines
2.1 KiB
Lua
52 lines
2.1 KiB
Lua
-- load the standard vis module (provides the Lua API)
|
|
require('vis')
|
|
|
|
-- ~/.config/vis/fzf.lua and ~/.config/vis/build.lua
|
|
local fzf = require('fzf')
|
|
local build = require('build')
|
|
|
|
-- ---------------------------------------------------------------------------
|
|
-- Odin syntax highlighting (lexer lives in ~/.config/vis/lexers/odin.lua)
|
|
-- ---------------------------------------------------------------------------
|
|
if vis.ftdetect then
|
|
if vis.ftdetect.extensions then -- newer vis (git master)
|
|
vis.ftdetect.extensions.odin = 'odin'
|
|
end
|
|
if vis.ftdetect.filetypes then -- vis 0.9 and earlier
|
|
vis.ftdetect.filetypes.odin = { ext = { '%.odin$' } }
|
|
end
|
|
end
|
|
|
|
-- ---------------------------------------------------------------------------
|
|
-- Global options, key mappings and commands
|
|
-- ---------------------------------------------------------------------------
|
|
vis.events.subscribe(vis.events.INIT, function()
|
|
vis:command('set escdelay 15')
|
|
vis:command('set autoindent on')
|
|
vis:command('set theme custom')
|
|
|
|
-- pickers
|
|
vis:map(vis.modes.NORMAL, '<C-p>', fzf.files, 'Fuzzy find / create a file')
|
|
vis:map(vis.modes.NORMAL, '<C-f>', fzf.grep, 'Live grep the project with ripgrep')
|
|
vis:command_register('files', function() fzf.files() return true end, 'Fuzzy find / create a file')
|
|
vis:command_register('grep', function() fzf.grep() return true end, 'Live grep the project with ripgrep')
|
|
vis:command_register('fm', function() fzf.fm() return true end, 'Pick a file with a terminal file manager')
|
|
|
|
vis:map(vis.modes.NORMAL, '<C-b>', function() build.run({}) end, 'Run ./build.sh')
|
|
vis:command_register('build', function(argv)
|
|
local args = {}
|
|
for i = 1, #argv do table.insert(args, argv[i]) end
|
|
build.run(args)
|
|
return true
|
|
end, 'Run ./build.sh with optional flags, e.g. :build run')
|
|
end)
|
|
|
|
-- ---------------------------------------------------------------------------
|
|
-- Per-window options
|
|
-- ---------------------------------------------------------------------------
|
|
vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused args
|
|
vis:command('set tabwidth 4')
|
|
vis:command('set expandtab on')
|
|
vis:command('set number on')
|
|
end)
|