Skip to content

Commit

Permalink
fix: prevent error when user pass a nil value to setup
Browse files Browse the repository at this point in the history
added more tests and makefile
  • Loading branch information
maxmx03 committed Sep 19, 2024
1 parent 01d8c0a commit 3ae785b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
5 changes: 0 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
services:
solarized:
build: .
volumes:
- solarized:/solarized

volumes:
solarized:
2 changes: 1 addition & 1 deletion lua/solarized/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ local M = {}
M.config = require 'solarized.config'

M.setup = function(config)
M.config = vim.tbl_deep_extend('force', M.config, config)
M.config = vim.tbl_deep_extend('force', M.config, config or {})

if M.config.styles.enabled == false then
M.config.styles = {
Expand Down
4 changes: 4 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fmt:
stylua -f ./stylua.toml .
test:
vusted ./tests
23 changes: 23 additions & 0 deletions tests/setup_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,27 @@ describe('solarized.setup', function()
assert.True(strings.italic)
assert.True(comments.bold)
end)

test('styles.enabled', function()
local solarized = require 'solarized'
solarized.setup {
styles = {
enabled = false,
strings = { italic = true },
comments = { bold = true },
},
}
vim.cmd 'colorscheme solarized'

local strings = nvim_get_hl 'String'
local comments = nvim_get_hl 'Comment'
assert.Nil(strings.italic)
assert.Nil(comments.bold)
end)

test('nil config', function()
local solarized = require 'solarized'
solarized.setup()
vim.cmd 'colorscheme solarized'
end)
end)

0 comments on commit 3ae785b

Please sign in to comment.