require('vis') local pickers = require('pickers') local build = require('build') require('plugins/vis-ctags') -- --------------------------------------------------------------------------- -- Syntax highlighting: ~/.config/vis/lexers/odin.lua -- --------------------------------------------------------------------------- if vis.ftdetect then -- vis 0.9 and earlier if vis.ftdetect.filetypes then 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 1') vis:command('set autoindent off') vis:command('set theme custom_zen') -- pickers vis:map(vis.modes.NORMAL, '', pickers.files, 'Fuzzy find / create a file') vis:map(vis.modes.NORMAL, '', pickers.grep, 'Live grep the project with ripgrep') vis:map(vis.modes.NORMAL, '', pickers.fm, 'terminal file manager') -- picker commands vis:command_register('files', function() pickers.files() return true end, 'Fuzzy find / create a file') vis:command_register('grep', function() pickers.grep() return true end, 'Live grep the project with ripgrep') vis:command_register('fm', function() pickers.fm() return true end, 'Pick a file with a terminal file manager') vis:command_register('git', function() pickers.git() return true end, 'Open gitu') -- build.sh setup vis:map(vis.modes.NORMAL, '', 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') -- system clipboard local function clip_copy() vis:feedkeys(':>wl-copy 2>/dev/null') vis:feedkeys('') -- drop the selection / leave visual mode end local function clip_paste() vis:feedkeys(':') vis:feedkeys('') -- clear any selection left on the pasted text end vis:map(vis.modes.VISUAL, '', clip_copy, 'Copy selection to system clipboard') vis:map(vis.modes.VISUAL, '', clip_paste, 'Paste system clipboard at cursor') vis:map(vis.modes.NORMAL, '', clip_paste, 'Paste system clipboard at cursor') -- ctags: 'gd' to jump to tag definition under cursor -- vis-ctags binds (jump) and (back) itself; vis:map(vis.modes.NORMAL, 'gd', '') end) -- --------------------------------------------------------------------------- -- Per-window options -- --------------------------------------------------------------------------- vis.events.subscribe(vis.events.WIN_OPEN, function(win) vis:command('set tabwidth 4') vis:command('set expandtab on') vis:command('set number on') end)