dim inactive windows

 avatar
unknown
lua
3 years ago
651 B
48
Indexable
function M.toggleDimWindows()
  local windowsIds = api.nvim_list_wins()
  local currentWindowId = api.nvim_get_current_win()

  print(windowIsRelative(currentWindowId))

  if windowIsRelative(currentWindowId) then
    return
  end

  for _, id in ipairs(windowsIds) do
    if id == currentWindowId then
      pcall(function()
        vim.fn.matchdelete(vim.w.dimMatchId)
      end)
    else
      if not windowIsRelative(id) then
        pcall(function()
          api.nvim_win_set_var(
            id,
            'dimMatchId',
            fn.matchadd('BufDimText', '.', 200, id, { window = id })
          )
        end)
      end
    end
  end
end
Editor is loading...