Sunglasses.nvim
Put on your shades so you only see what you care about
Install / Use
/learn @miversen33/Sunglasses.nvimREADME
sunglasses.nvim
Put on your shades so you only see what you care about
Installation
Lazy
require("lazy").setup({"miversen33/sunglasses.nvim", config = true})
Super Lazy
If you want, you can lazy load sunglasses, tied to the UIEnter event. By default though, sunglasses already does most of its "work" after this event fires so you aren't really gaining much by lazy loading sunglasses.
But I am not here to stop you from getting every last millisecond shaved off your startup time so here ya go
require("lazy").setup({"miversen33/sunglasses.nvim", config = true, event = "UIEnter"})
Pictures
<sup></sup>Feel to submit a pr to add more images to this. At least until I get tired of updating it<sub></sub>
Pictures are worth a thousand words (or however many are in your buffers ;) )
Shaded
-- Config: https://github.com/miversen33
{
filter_type = "SHADE",
filter_percent = .65
}
Tinted
-- Config: https://github.com/miversen33
{
filter_type = "TINT",
filter_percent = .65
}
NOSYNTAX
-- Config: https://github.com/miversen33
{
filter_type = "NOSYNTAX",
filter_percent = .65
}
Catppuccin
Theme
Shaded
-- Config: https://github.com/miversen33
{
filter_type = "NOSYNTAX",
filter_percent = .65
}
Tinted
-- Config: https://github.com/miversen33
{
filter_type = "TINT",
filter_percent = .65
}
NOSYNTAX
-- Config: https://github.com/miversen33
{
filter_type = "NOSYNTAX",
filter_percent = .65
}
TokyoNight
Shaded
-- Config: https://github.com/miversen33
{
filter_type = "SHADE",
filter_percent = .65
}
Tinted
-- Config: https://github.com/miversen33
{
filter_type = "TINT",
filter_percent = .65
}
NOSYNTAX
-- Config: https://github.com/miversen33
{
filter_type = "NOSYNTAX",
filter_percent = .65
}
Features
- Able to be used with any neovim or vim theme
- Works with Sessions
- Works with Transparent buffers
- Easy to Setup
- Easy to Customize
- No external dependencies
- Only a minimal amount of shenanigans happening!
Requirements
- Currently only supports neovim 0.9 newer
Configuration
Sunglasses has sane defaults (as shown below) and therefore doesn't require configuration to get started. However, if you would like below is the list of defaults and changes that can be applied to them
-- lua
local sunglasses_defaults = {
filter_percent = 0.65,
filter_type = "SHADE",
log_level = "ERROR",
refresh_timer = 5,
excluded_filetypes = {
"dashboard",
"lspsagafinder",
"packer",
"checkhealth",
"mason",
"NvimTree",
"neo-tree",
"plugin",
"lazy",
"TelescopePrompt",
"alpha",
"toggleterm",
"sagafinder",
"better_term",
"fugitiveblame",
"starter",
"NeogitPopup",
"NeogitStatus",
"DiffviewFiles",
"DiffviewFileHistory",
"DressingInput",
"spectre_panel",
"zsh",
"registers",
"startuptime",
"OverseerList",
"Outline",
"Navbuddy",
"noice",
"notify",
"saga_codeaction",
"sagarename"
},
excluded_highlights = {
"WinSeparator",
{"lualine_.*", glob = true},
},
can_shade_callback = function(opts)
local conditions = {
function()
return vim.api.nvim_get_option_value("diff", { win = opts.window })
end,
}
for _, condition in ipairs(conditions) do
if condition() then
return false
end
end
return true
end,
}
-- The above table will is the default configuration.
-- If you do not wish to set any configuration options, you can simply
-- pass nil into your setup
require("sunglasses").setup()
-- Or you can provide your own values. Please configure your
-- options by looking at each option available and setting it
require("sunglasses").setup({
filter_percent = 0.65,
filter_type = "SHADE",
log_level = "ERROR",
refresh_timer = 5,
excluded_filetypes = {
"dashboard",
"lspsagafinder",
"packer",
"checkhealth",
"mason",
"NvimTree",
"neo-tree",
"plugin",
"lazy",
"TelescopePrompt",
"alpha",
"toggleterm",
"sagafinder",
"better_term",
"fugitiveblame",
"starter",
"NeogitPopup",
"NeogitStatus",
"DiffviewFiles",
"DiffviewFileHistory",
"DressingInput",
"spectre_panel",
"zsh",
"registers",
"startuptime",
"OverseerList",
"Outline",
"Navbuddy",
"noice",
"notify",
"saga_codeaction",
"sagarename"
},
excluded_highlights = {
"WinSeparator",
{"lualine_.*", glob = true},
},
can_shade_callback = function(opts)
local conditions = {
function()
return vim.api.nvim_get_option_value("diff", { win = opts.window })
end,
}
for _, condition in ipairs(conditions) do
if condition() then
return false
end
end
return true
end,
})
Config.filter_percent
Version Added: 0.1
Default: .65
This is the percentage to modify inactive buffer's highlights. This value must be between 0 and 1 and is clamped as such. An example of how to use this is as follows
-- lua
local sunglasses_options = {
filter_percent = 0.65
}
require("sunglasses").setup(sunglasses_options)
Config.filter_type
Version Added: 0.1
Version Updated: 0.2.01
Default: "SHADE"
This is the kind of filter to apply to inactive buffers. Valid filter_types are
- "SHADE"
- "TINT"
- "NOSYNTAX"
SHADE
Darkens the inactive buffer's highlights
TINT
Brightens the inactive buffers highlights
NOSYNTAX
Disables syntax highlighting on the inactive buffer.
An example of how to use this is as follows
-- lua
local sunglasses_options = {
filter_type = "SHADE"
}
require("sunglasses").setup(sunglasses_options)
Config.log_level
Version Added: 0.1
Default: "ERROR"
This is the level to filter all logs against. This means that logs with a level under "ERROR" will not be written to the file. If you are looking to submit a bug report, please set this to a lower level.
Your sunglasses log can be located with the following command
-- lua
print(vim.fn.stdpath('log') .. '/sunglasses.log')
Below are a list of valid log levels (in filter order). Anything lower than the level in this list will be filtered at that level. As an example, with a level of "ERROR" (the default), logs of level "WARNING" will be filtered
- "CRITICAL"
- "ERROR"
- "WARNING"
- "INFO"
- "DEBUG"
- "TRACE"
- "TRACE2"
- "TRACE3"
**** Be aware, any of the trace levels will very quickly produce lots of logs
An example of how to set this is as follows
-- lua
local sunglasses_options = {
filter_level = "ERROR"
}
require("sunglasses").setup(sunglasses_options)
Config.refresh_timer
Version Added: 0.1
Default: 5
This tells sunglasses how often (in seconds) to refresh its internal highlights cache. This is how sunglasses is able to deal with highlight groups that are dynamically created over time.
An example of how to set this is as follows
-- lua
local sunglasses_options = {
refresh_timer = 5
}
require("sunglasses").setup(refresh_timer)
Config.excluded_filetypes
Version Added: 0.1
Default:
-- lua
{
"dashboard",
"lspsagafinder",
"packer",
"checkhealth",
"mason",
"NvimTree",
"neo-tree",
"plugin",
"lazy",
"TelescopePrompt",
"alpha",
"toggleterm",
"sagafinder",
"better_term",
"fugitiveblame",
"starter",
"NeogitPopup",
"NeogitStatus",
"DiffviewFiles",
"DiffviewFileHistory",
"DressingInput",
"spectre_panel",
"zsh",
"registers",
"startuptime",
"OverseerList",
"Outline",
"Navbuddy",
"noice",
"notify",
"saga_codeaction",
"sagarename"
}
This is a list of filetypes to be excluded when shading inactive windows.
If you are making changes to this table, consider submitting a PR to update it for everyone instead!
An example of how to set this is as follows
-- lua
local sunglasses_options = {
exclud
