diff --git a/README.md b/README.md index 1bb5ce1..6845d52 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ require("osmium").setup({ gitsigns = false, telescope = false, indent_blankline = false, + oil = false, }, transparent_bg = false, -- whether to use a transparent background show_end_of_buffer = false, -- whether to show the end of buffer @@ -64,6 +65,7 @@ require("osmium").setup({ - [gitsigns](https://github.com/lewis6991/gitsigns.nvim) - [telescope](https://github.com/nvim-telescope/telescope.nvim) - [indent_blankline](https://github.com/lukas-reineke/indent-blankline.nvim) +- [oil.nvim](https://github.com/stevearc/oil.nvim) ## Contributing diff --git a/lua/osmium/groups/integrations/init.lua b/lua/osmium/groups/integrations/init.lua index a88758e..bed26e6 100644 --- a/lua/osmium/groups/integrations/init.lua +++ b/lua/osmium/groups/integrations/init.lua @@ -15,6 +15,9 @@ local function highlight_integrations(highlights, configs) if configs.integrations.indent_blankline then combined = require("osmium.groups.integrations.indent_blankline")(combined, configs.colors) end + if configs.integrations.oil then + combined = require("osmium.groups.integrations.oil")(combined, configs.colors) + end return combined end diff --git a/lua/osmium/groups/integrations/oil.lua b/lua/osmium/groups/integrations/oil.lua new file mode 100644 index 0000000..f3efb2f --- /dev/null +++ b/lua/osmium/groups/integrations/oil.lua @@ -0,0 +1,33 @@ +local combine = require("osmium.groups.utils").combine + +---@param highlights HighlightGroups +---@param colors Palette +return function(highlights, colors) + return combine(highlights, { + OilDir = { fg = colors.blueFg, bold = true }, + OilDirIcon = { fg = colors.blueFg }, + OilLink = { fg = colors.purpleFg }, + OilLinkTarget = { fg = colors.purpleFgDim }, + OilOrphanLink = { fg = colors.redFg }, + OilOrphanLinkTarget = { fg = colors.redFgDim }, + OilFile = { fg = colors.foreground1 }, + OilHidden = { fg = colors.foreground2 }, + OilDirHidden = { fg = colors.blueFgDim }, + OilFileHidden = { fg = colors.foreground2 }, + OilLinkHidden = { fg = colors.purpleFgDim }, + OilLinkTargetHidden = { fg = colors.foreground2 }, + OilOrphanLinkHidden = { fg = colors.redFgDim }, + OilOrphanLinkTargetHidden = { fg = colors.foreground2 }, + OilSocket = { fg = colors.pinkFg }, + OilSocketHidden = { fg = colors.pinkFgDim }, + OilCreate = { fg = colors.greenFg, bg = colors.greenBg }, + OilDelete = { fg = colors.redFg, bg = colors.redBg }, + OilMove = { fg = colors.yellowFg, bg = colors.yellowBg }, + OilCopy = { fg = colors.blueFg, bg = colors.blueBg }, + OilChange = { fg = colors.orangeFg, bg = colors.orangeBg }, + OilRestore = { fg = colors.greenFg }, + OilPurge = { fg = colors.redFg }, + OilTrash = { fg = colors.foreground2 }, + OilTrashSourcePath = { fg = colors.foreground2 }, + }) +end diff --git a/lua/osmium/init.lua b/lua/osmium/init.lua index 05b8856..e9b857a 100644 --- a/lua/osmium/init.lua +++ b/lua/osmium/init.lua @@ -2,6 +2,7 @@ ---@field gitsigns? boolean ---@field telescope? boolean ---@field indent_blankline? boolean +---@field oil? boolean ---@class OsmiumConfig ---@field italic_comment? boolean @@ -12,35 +13,35 @@ ---@field integrations? Integrations ---@field overrides? HighlightGroups | fun(colors: Palette): HighlightGroups local DEFAULT_CONFIG = { - italic_comment = false, - transparent_bg = false, - show_end_of_buffer = false, - colors = require("osmium.palette"), - overrides = {}, - integrations = {}, - theme = 'osmium' + italic_comment = false, + transparent_bg = false, + show_end_of_buffer = false, + colors = require("osmium.palette"), + overrides = {}, + integrations = {}, + theme = 'osmium' } ---@param colors Palette local function apply_term_colors(colors) - vim.g.terminal_color_0 = colors.foreground2 - vim.g.terminal_color_1 = colors.redFgDim - vim.g.terminal_color_2 = colors.greenFgDim - vim.g.terminal_color_3 = colors.yellowFgDim - vim.g.terminal_color_4 = colors.purpleFgDim - vim.g.terminal_color_5 = colors.pinkFgDim - vim.g.terminal_color_6 = colors.blueFgDim - vim.g.terminal_color_7 = colors.foreground1 - vim.g.terminal_color_8 = colors.foreground2 - vim.g.terminal_color_9 = colors.redFg - vim.g.terminal_color_10 = colors.greenFg - vim.g.terminal_color_11 = colors.yellowFg - vim.g.terminal_color_12 = colors.blueFg - vim.g.terminal_color_13 = colors.pinkFg - vim.g.terminal_color_14 = colors.blueFg - vim.g.terminal_color_15 = colors.foreground0 - vim.g.terminal_color_background = colors.root - vim.g.terminal_color_foreground = colors.foreground1 + vim.g.terminal_color_0 = colors.foreground2 + vim.g.terminal_color_1 = colors.redFgDim + vim.g.terminal_color_2 = colors.greenFgDim + vim.g.terminal_color_3 = colors.yellowFgDim + vim.g.terminal_color_4 = colors.purpleFgDim + vim.g.terminal_color_5 = colors.pinkFgDim + vim.g.terminal_color_6 = colors.blueFgDim + vim.g.terminal_color_7 = colors.foreground1 + vim.g.terminal_color_8 = colors.foreground2 + vim.g.terminal_color_9 = colors.redFg + vim.g.terminal_color_10 = colors.greenFg + vim.g.terminal_color_11 = colors.yellowFg + vim.g.terminal_color_12 = colors.blueFg + vim.g.terminal_color_13 = colors.pinkFg + vim.g.terminal_color_14 = colors.blueFg + vim.g.terminal_color_15 = colors.foreground0 + vim.g.terminal_color_background = colors.root + vim.g.terminal_color_foreground = colors.foreground1 end --- override colors with colors @@ -48,32 +49,32 @@ end ---@param overrides HighlightGroups ---@return HighlightGroups local function override_groups(groups, overrides) - for group, setting in pairs(overrides) do - groups[group] = setting - end - return groups + for group, setting in pairs(overrides) do + groups[group] = setting + end + return groups end ---@param configs OsmiumConfig local function apply(configs) - local colors = configs.colors - apply_term_colors( - colors --[[@as Palette]] - ) - local groups = require("osmium.groups").setup(configs) - - if type(configs.overrides) == "table" then - groups = override_groups(groups, configs.overrides --[[@as HighlightGroups]]) - elseif type(configs.overrides) == "function" then - groups = override_groups(groups, configs.overrides( - colors --[[@as Palette]] - )) - end - - -- set defined highlights - for group, setting in pairs(groups) do - vim.api.nvim_set_hl(0, group, setting) - end + local colors = configs.colors + apply_term_colors( + colors --[[@as Palette]] + ) + local groups = require("osmium.groups").setup(configs) + + if type(configs.overrides) == "table" then + groups = override_groups(groups, configs.overrides --[[@as HighlightGroups]]) + elseif type(configs.overrides) == "function" then + groups = override_groups(groups, configs.overrides( + colors --[[@as Palette]] + )) + end + + -- set defined highlights + for group, setting in pairs(groups) do + vim.api.nvim_set_hl(0, group, setting) + end end ---@type OsmiumConfig @@ -82,46 +83,46 @@ local user_configs = {} --- get osmium configs ---@return OsmiumConfig local function get_configs() - local configs = DEFAULT_CONFIG + local configs = DEFAULT_CONFIG - configs = vim.tbl_deep_extend("force", configs, user_configs) + configs = vim.tbl_deep_extend("force", configs, user_configs) - return configs + return configs end ---setup osmium colorscheme ---@param configs OsmiumConfig? local function setup(configs) - if type(configs) == "table" then - user_configs = configs --[[@as OsmiumConfig]] - end + if type(configs) == "table" then + user_configs = configs --[[@as OsmiumConfig]] + end end local function load() - if vim.fn.has("nvim-0.7") ~= 1 then - vim.notify("osmium.nvim: neovim >= 0.7 required") - return - end + if vim.fn.has("nvim-0.7") ~= 1 then + vim.notify("osmium.nvim: neovim >= 0.7 required") + return + end - -- reset colors - if vim.g.colors_name then - vim.cmd("hi clear") - end + -- reset colors + if vim.g.colors_name then + vim.cmd("hi clear") + end - if vim.fn.exists("syntax_on") then - vim.cmd("syntax reset") - end + if vim.fn.exists("syntax_on") then + vim.cmd("syntax reset") + end - vim.o.background = "dark" - vim.o.termguicolors = true - vim.g.colors_name = 'osmium' + vim.o.background = "dark" + vim.o.termguicolors = true + vim.g.colors_name = 'osmium' - apply(get_configs()) + apply(get_configs()) end return { - load = load, - setup = setup, - configs = get_configs, - colors = function() return get_configs().colors end, + load = load, + setup = setup, + configs = get_configs, + colors = function() return get_configs().colors end, }