Skip to content

Commit

Permalink
chore(test): adds colorscheme to minimal.lua / setup options in expec…
Browse files Browse the repository at this point in the history
…t.txt (#105)

* doc: updates readme, adds notes

* chore(test): adds colorscheme to minimal.lua
- adds all setup options to expect.txt
  • Loading branch information
catgoose authored Nov 22, 2024
1 parent 4487342 commit a040f4d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 32 deletions.
39 changes: 21 additions & 18 deletions test/expect.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
-- vim:ft=lua

-- Configuration options
-- Colorizer setup opts
return {
RGB = true,
RRGGBB = true,
names = true,
RRGGBBAA = true,
AARRGGBB = true,
rgb_fn = true,
hsl_fn = true,
css = true,
css_fn = true,
mode = "background",
tailwind = "both",
sass = {
enable = false,
parsers = { "css" },
filetypes = { "*" },
buftypes = { "!prompt", "!popup" },
user_commands = true,
user_default_options = {
RGB = true,
RRGGBB = true,
names = true,
RRGGBBAA = true,
AARRGGBB = true,
rgb_fn = true,
hsl_fn = true,
css = true,
css_fn = true,
mode = "background",
tailwind = false,
sass = { enable = false, parsers = { css = true } },
virtualtext = "",
virtualtext_inline = false,
virtualtext_mode = "foreground",
always_update = false,
},
virtualtext = "",
virtualtext_inline = false,
virtualtext_mode = "foreground",
}

--[[ TEST CASES
Expand Down
41 changes: 27 additions & 14 deletions test/minimal.lua
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
-- Run this file as `nvim --clean -u minimal.lua`
local base_dir = "colorizer_issue"
local use_remote = false
local local_plugin_dir = os.getenv("HOME") .. "/git/nvim-colorizer.lua"

local use_remote = true
local function clone_repo_if_missing(name, url, dir)
local install_path = vim.fn.fnamemodify(dir .. "/" .. name, ":p")
if vim.fn.isdirectory(install_path) == 0 then
vim.fn.system({ "git", "clone", "--depth=1", url, install_path })
end
vim.opt.runtimepath:append(install_path)
end

if use_remote then
for name, url in pairs({
local remote_plugins = {
colorizer = "https://github.com/NvChad/nvim-colorizer.lua",
}) do
local install_path = vim.fn.fnamemodify("colorizer_issue/" .. name, ":p")
if vim.fn.isdirectory(install_path) == 0 then
vim.fn.system({ "git", "clone", "--depth=1", url, install_path })
end
vim.opt.runtimepath:append(install_path)
kanagawa = "https://github.com/rebelot/kanagawa.nvim",
}
for name, url in pairs(remote_plugins) do
clone_repo_if_missing(name, url, base_dir)
end
else
local local_plugin_dir = os.getenv("HOME") .. "/git/nvim-colorizer.lua"
local remote_plugins = {
kanagawa = "https://github.com/rebelot/kanagawa.nvim",
}
for name, url in pairs(remote_plugins) do
clone_repo_if_missing(name, url, base_dir)
end
if vim.fn.isdirectory(local_plugin_dir) == 1 then
vim.opt.runtimepath:append(local_plugin_dir)
else
Expand All @@ -38,25 +50,26 @@ local function get_opts(file_path)
end

-- Configure setup opts
local setup_opts = {
user_default_options = get_opts("expect.txt"),
buftypes = { "!prompt", "!popup" },
user_commands = true,
}
local setup_opts = get_opts("expect.txt")
require("colorizer").setup(setup_opts)

vim.api.nvim_create_autocmd("BufWritePost", {
pattern = "expect.txt",
callback = function(evt)
vim.schedule(function()
local opts = get_opts(evt.match)
if not opts then
return
end
opts = opts.user_default_options
require("colorizer").detach_from_buffer(evt.buf)
require("colorizer").attach_to_buffer(evt.buf, opts)
vim.notify("Colorizer reloaded with updated options from " .. evt.match, vim.log.levels.INFO)
end)
end,
})

vim.cmd.colorscheme("kanagawa")
vim.cmd.edit("expect.txt")

-- ADD INIT.LUA SETTINGS _NECESSARY_ FOR REPRODUCING THE ISSUE

0 comments on commit a040f4d

Please sign in to comment.