fix: prevent error when user pass a nil value to setup

added more tests and makefile
This commit is contained in:
Max Miliano 2024-09-19 10:39:43 -03:00
parent 01d8c0afe1
commit 3ae785b553
4 changed files with 28 additions and 6 deletions

View file

@ -1,8 +1,3 @@
services:
solarized:
build: .
volumes:
- solarized:/solarized
volumes:
solarized:

View file

@ -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 = {

4
makefile Normal file
View file

@ -0,0 +1,4 @@
fmt:
stylua -f ./stylua.toml .
test:
vusted ./tests

View file

@ -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)