diff --git a/doc/styler.nvim.txt b/doc/styler.nvim.txt index 5dbf2d7..7a4f033 100644 --- a/doc/styler.nvim.txt +++ b/doc/styler.nvim.txt @@ -34,6 +34,13 @@ Install the plugin with your preferred package manager: themes = { markdown = { colorscheme = "gruvbox" }, help = { colorscheme = "catppuccin-mocha", background = "dark" }, + python = function(buf_path) { + if buf_path:match("cool_project") then + return { colorscheme = "tokyonight-storm" } + else + return { colorscheme = "gruvbox", bakcground = "dark" } + end + } }, }) end, diff --git a/lua/styler/init.lua b/lua/styler/init.lua index 132e5ce..7c8f43e 100644 --- a/lua/styler/init.lua +++ b/lua/styler/init.lua @@ -5,7 +5,7 @@ M.themes = {} ---@type table M.bufs = {} ----@alias Theme {colorscheme: string, background?: "light"|"dark"} +---@alias Theme function|{colorscheme: string, background?: "light"|"dark"} ---@alias ThemeHighlights table ---@param win window window id or 0 for the current window @@ -42,7 +42,8 @@ function M.update(opts) local buf = vim.api.nvim_win_get_buf(win) if not (opts.buf and opts.buf ~= buf) then local ft = vim.bo[buf].filetype - local theme = M.bufs[buf] or M.themes[ft] + local theme = M.bufs[buf] + or (type(M.themes[ft]) == "function" and M.themes[ft](vim.api.nvim_buf_get_name(buf)) or M.themes[ft]) if theme then M.set_theme(win, theme) else