Skip to content

Commit

Permalink
Merge pull request #304 from tecosaur/master
Browse files Browse the repository at this point in the history
Add OneLight/TommorowDay themes, update bracket colours
  • Loading branch information
KristofferC authored Mar 15, 2023
2 parents d1671dc + fabd07d commit f77d8f3
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/OhMyREPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ include("prompt.jl")
import .BracketInserter.enable_autocomplete_brackets

function colorscheme!(name::String)
Passes.SyntaxHighlighter.activate!(Passes.SyntaxHighlighter.SYNTAX_HIGHLIGHTER_SETTINGS,
name)
Passes.SyntaxHighlighter.activate!(
Passes.SyntaxHighlighter.SYNTAX_HIGHLIGHTER_SETTINGS, name)
Passes.RainbowBrackets.updatebracketcolors!(
Passes.SyntaxHighlighter.SYNTAX_HIGHLIGHTER_SETTINGS.active)
end

function colorschemes()
Expand Down
24 changes: 17 additions & 7 deletions src/passes/RainbowBrackets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import Tokenize.Tokens: Token, kind, startpos, endpos, untokenize

import OhMyREPL: add_pass!, PASS_HANDLER, SUPPORTS_256_COLORS

using ..SyntaxHighlighter

mutable struct RainBowTokens
parenthesis_tokens::Vector{Crayon}
brackets_tokens::Vector{Crayon}
Expand Down Expand Up @@ -36,22 +38,30 @@ end
activate_16colors() = RAINBOWBRACKETS_SETTINGS.active = RAINBOWBRACKETS_SETTINGS.tokens_16
activate_256colors() = RAINBOWBRACKETS_SETTINGS.active = RAINBOWBRACKETS_SETTINGS.tokens_256


const RAINBOW_TOKENS_16 =
RainBowTokens([Crayon(foreground = :yellow), Crayon(foreground = :green)],
[Crayon(foreground = :cyan), Crayon(foreground = :magenta)],
[Crayon(foreground = :light_gray), Crayon(foreground = :default)],
Crayon(foreground = :light_red))
[Crayon(foreground = :cyan), Crayon(foreground = :magenta)],
[Crayon(foreground = :light_gray), Crayon(foreground = :default)],
Crayon(foreground = :light_red))

const RAINBOW_TOKENS_256 =
RainBowTokens([Crayon(foreground = 178), Crayon(foreground = 161), Crayon(foreground = 034), Crayon(foreground = 200)],
[Crayon(foreground = 045), Crayon(foreground = 099), Crayon(foreground = 033)],
[Crayon(foreground = 223), Crayon(foreground = 130), Crayon(foreground = 202)],
Crayon(foreground = 196, bold = true))
[Crayon(foreground = 045), Crayon(foreground = 099), Crayon(foreground = 033)],
[Crayon(foreground = 223), Crayon(foreground = 130), Crayon(foreground = 202)],
Crayon(foreground = 196, bold = true))

const RAINBOWBRACKETS_SETTINGS = RainbowBracketsSettings(RAINBOW_TOKENS_256, RAINBOW_TOKENS_16,
SUPPORTS_256_COLORS ? RAINBOW_TOKENS_256 : RAINBOW_TOKENS_16)

function updatebracketcolors!(cs::SyntaxHighlighter.ColorScheme)
RAINBOWBRACKETS_SETTINGS.active.parenthesis_tokens =
[cs.argdef, cs.keyword, cs.string]
RAINBOWBRACKETS_SETTINGS.active.brackets_tokens =
[cs.call, cs.op]
RAINBOWBRACKETS_SETTINGS.active.curly_tokens =
[cs.argdef, cs.number]
RAINBOWBRACKETS_SETTINGS.active.error_token = cs.error
end

function (rainbow::RainbowBracketsSettings)(ansitokens::Vector{Crayon}, tokens::Vector{Token}, cursorpos::Int)
p, s, b = 0, 0, 0
Expand Down
2 changes: 2 additions & 0 deletions src/passes/SyntaxHighlighter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ add!(SYNTAX_HIGHLIGHTER_SETTINGS, "TomorrowNightBright", _create_tomorrow_night_
add!(SYNTAX_HIGHLIGHTER_SETTINGS, "TomorrowNightBright24bit", _create_tomorrow_night_bright_24())
add!(SYNTAX_HIGHLIGHTER_SETTINGS, "Tomorrow24bit", _create_tomorrow_24())
add!(SYNTAX_HIGHLIGHTER_SETTINGS, "Tomorrow", _create_tomorrow_256())
add!(SYNTAX_HIGHLIGHTER_SETTINGS, "TomorrowDay", _create_tomorrow_day())
add!(SYNTAX_HIGHLIGHTER_SETTINGS, "Distinguished", _create_distinguished())
add!(SYNTAX_HIGHLIGHTER_SETTINGS, "OneDark", _create_onedark())
add!(SYNTAX_HIGHLIGHTER_SETTINGS, "OneLight", _create_onelight())
add!(SYNTAX_HIGHLIGHTER_SETTINGS, "Base16MaterialDarker", _create_base16_material_darker())
add!(SYNTAX_HIGHLIGHTER_SETTINGS, "GruvboxDark", _create_gruvbox_dark())
add!(SYNTAX_HIGHLIGHTER_SETTINGS, "GitHubLight", _create_github_light())
Expand Down
34 changes: 34 additions & 0 deletions src/passes/colorschemes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,23 @@ function _create_tomorrow_256()
return cs
end

function _create_tomorrow_day()
cs = ColorScheme()
symbol!(cs, Crayon(foreground = 0x8959a8))
comment!(cs, Crayon(foreground = 0x8e908c))
string!(cs, Crayon(foreground = 0x718c00))
call!(cs, Crayon(foreground = 0x4271ae))
op!(cs, Crayon(foreground = 0x4271ae))
keyword!(cs, Crayon(foreground = 0x8959a8))
text!(cs, Crayon(foreground = 0x4d4d4c))
macro!(cs, Crayon(foreground = 0xf5871f))
function_def!(cs, Crayon(foreground = 0xf5871f))
error!(cs, Crayon(foreground = 0xc82829))
argdef!(cs, Crayon(foreground = 0xbb9200))
number!(cs, Crayon(foreground = 0xf5871f))
return cs
end

function _create_distinguished()
cs = ColorScheme()
symbol!(cs, Crayon(foreground = 66, bold=true))
Expand Down Expand Up @@ -187,6 +204,23 @@ function _create_onedark()
return cs
end

function _create_onelight()
cs = ColorScheme()
symbol!(cs, Crayon(foreground = 0xe45649))
comment!(cs, Crayon(foreground = 0x9ca0a4))
string!(cs, Crayon(foreground = 0x50a14f))
call!(cs, Crayon(foreground = 0x4078f2))
op!(cs, Crayon(foreground = 0x0184bc))
keyword!(cs, Crayon(foreground = 0xe45649))
text!(cs, Crayon(foreground = 0x383a42))
macro!(cs, Crayon(foreground = 0xa626a4))
function_def!(cs, Crayon(foreground = 0xa626a4))
error!(cs, Crayon(foreground = 0xe45649))
argdef!(cs, Crayon(foreground = 0x986801))
number!(cs, Crayon(foreground = 0xda8548))
return cs
end

function _create_base16_material_darker()
cs = ColorScheme()
symbol!(cs, Crayon(foreground = 0xf07178))
Expand Down

0 comments on commit f77d8f3

Please sign in to comment.