repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

neovim/lua/bugabinga/options/behaviour.lua

Raw
local auto = require 'std.auto'
local ignored = require 'std.ignored'
local dbg = require 'std.dbg'

auto 'highlight_yanked_text' {
  description = 'briefly highlight yanked text',
  events = 'TextYankPost',
  pattern = '*',
  command = function()
    vim.hl.on_yank {
      higroup = 'TextYankPost',
      timeout = 169,
    }
  end,
}

auto 'disable_columns_in_special_buffers' {
  description = 'Hide columns in buffers, that do not show source code.',
  events = { 'FileType' },
  pattern = ignored.filetypes,
  command = function(data)
    vim.opt_local.colorcolumn = {}
    vim.opt_local.signcolumn = 'no'
    vim.opt_local.foldcolumn = '0'
    vim.opt_local.number = false
  end,
}

auto 'handle_usr1_signal' {
  description = 'Reloads the current theme, when USR1 signal is received',
  events = { 'Signal' },
  pattern = 'SIGUSR1',
  command = function()
    dbg.print 'received signal USR1! Attempting to reload colorscheme.'
    vim.cmd.colorscheme 'nugu'
  end,
}

auto 'set_makeprg_for_just_projects' {
  description = 'Set makeprg to just when project contains justfile',
  events = 'BufEnter',
  command = function()
    local project_root = require('std.project').find_project_root()
    if project_root then
      local justfile = vim.fs.find('justfile', { path = project_root, upward = false })[1]
      if justfile then
        vim.opt.makeprg = 'just'
      end
    end
  end,
}