repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

neovim/lua/bugabinga/cursorword.lua

Raw
local puk = require 'std.puk'
local table = require 'std.table'
local auto = require 'std.auto'

puk.defer 'mini.cursorword' (function (cursorword) 
  cursorword.setup {
    delay = 4242,
  }
  vim.api.nvim_set_hl( 0, 'MiniCursorwordCurrent', { reverse = true } )
  local cursorword_blocklist = function ()
    local curword = vim.fn.expand '<cword>'
    local filetype = vim.bo.filetype

    -- Add any disabling global or filetype-specific logic here
    local blocklist = {
      'if',
      'else',
      'switch',
      'case',
      'return',
      'true', 'false',
    }
    if filetype == 'lua' then
      table.join( blocklist, {
        'local',
        'require',
        'prequire',
        'then',
        'end',
        'not',
        'elseif',
      } )
    elseif filetype == 'java' then
      table.join( blocklist, {
        'import',
        'class',
        'final',
        'interface',
        'record',
        'abstract',
        'static',
        'public',
        'private',
      } )
    end

    if #curword >= 2 then
      table.insert(blocklist, curword)
    end

    vim.b.minicursorword_disable = vim.tbl_contains( blocklist, curword )
  end

  -- Make sure to add this autocommand *before* calling module's `setup()`.
  auto 'mini_cursorword_blocklist_update' {
    description = 'Disable Cursorword for certain words.',
    events = 'CursorMoved',
    pattern = '*',
    command = cursorword_blocklist,
  }
end)