local M = {} function M.setup() -- {{{ LAYA local aug = vim.api.nvim_create_augroup('laya', {}) vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, { group = aug, pattern = '**/jopixel/**/*.php', callback = function() vim.cmd.iabbrev({ args = { '', 'TR', '$this->obtainer()->translator()->t();' } }) vim.cmd.iabbrev({ args = { '', 'TI', '$this->obtainer()->translator()->t()' } }) vim.cmd.iabbrev({ args = { '', 'LOG', '$this->obtainer()->logger()->log();' } }) vim.cmd.iabbrev({ args = { '', 'DBG', "$this->obtainer()->logger()->log('debug', 'debug',);" } }) vim.cmd.iabbrev({ args = { '', 'PROD', '$this->producer()' } }) vim.cmd.iabbrev({ args = { '', 'FILE', '$this->producer()->file()' } }) vim.cmd.iabbrev({ args = { '', 'LINK', "$this->producer()->link($this, '')" } }) vim.cmd.iabbrev({ args = { '', 'NW', '$this->obtainer()->notifications()->warning();' } }) vim.cmd.iabbrev({ args = { '', 'NS', '$this->obtainer()->notifications()->success();' } }) end }) -- }}} LAYA --- terminal {{{ local termgroup = vim.api.nvim_create_augroup('terminal', { clear = true }) vim.api.nvim_create_autocmd('TermOpen', { group = termgroup, callback = function() -- local buf = args.buf vim.api.nvim_win_set_option(0, 'number', false) vim.api.nvim_win_set_option(0, 'signcolumn', 'no') vim.schedule(vim.cmd.startinsert) -- without schedule it lock screen refresh end }) --}}} -- Buffer {{{ vim.api.nvim_create_autocmd({ "FocusGained", "TermClose", "TermLeave" }, { command = "checktime" }) -- go to last loc when opening a buffer vim.api.nvim_create_autocmd("BufReadPost", { callback = function() local mark = vim.api.nvim_buf_get_mark(0, '"') local lcount = vim.api.nvim_buf_line_count(0) if mark[1] > 0 and mark[1] <= lcount then pcall(vim.api.nvim_win_set_cursor, 0, mark) end end, }) -- }}} -- qf {{{ -- local pad = function (str, n) -- if #str > n then -- return str -- else -- return str .. string.rep(' ', n - #str) -- end -- end -- QuickfixFunc = function(info) -- local items -- if info.quickfix then -- items = vim.fn.getqflist({ id = info.id, items = 1 }).items -- else -- items = vim.fn.getloclist(info.id, { items = 1 }).items -- end -- local res = {}; -- for i = info.start_idx, info.end_idx, 1 do -- local item = items[i] -- table.insert(res, pad -- end -- end -- }}} end return M