Skip to content

Commit

Permalink
INIT
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Burgin committed Sep 13, 2021
1 parent 377e60f commit b234b89
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# background.nvim
Simple plugin to automatically `set background` at after a certain hour.

## Install
#### Packer
```lua
use 'chris-burgin/background.nvim'
```
## Usage
```lua
require("background_nvim").setup()
```

### Advanced
```lua
require("background_nvim").setup({
ms = 60000, -- default
hour = 17 -- default
})
```
1 change: 0 additions & 1 deletion autoload/background_nvim.vim
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
lua require'background_nvim.lua'
26 changes: 21 additions & 5 deletions lua/background_nvim.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
function check_which_theme()
local hour = os.date("*t").hour
if (hour > 16) then
if (hour > vim.g.BackgroundNvimHour - 1) then
vim.opt.background = 'dark'
else
vim.opt.background = 'light'
end
end

local background_nvim = {}
local M = {}

local function background_nvim.setup(options)
vim.g.BackgroundNvimMS = options.ms
function M.setup(options)
if (not(vim.g.BackgroundNvimMS)) then
vim.g.BackgroundNvimMS = 60000
end

if (not(vim.g.BackgroundNvimHour)) then
vim.g.BackgroundNvimHour = 17
end

if (options) then
if (options.ms) then
vim.g.BackgroundNvimMS = options.ms
end

if (options.hour) then
vim.g.BackgroundNvimHour = options.hour
end
end

check_which_theme();

Expand All @@ -22,4 +38,4 @@ local function background_nvim.setup(options)
]])
end

return background_nvim
return M

0 comments on commit b234b89

Please sign in to comment.