From 4ec20eaeffa6144f01ae8d5a95b12ea1593f3080 Mon Sep 17 00:00:00 2001 From: Kirawi Date: Fri, 26 Nov 2021 21:19:40 -0500 Subject: Add language support for WGSL (#1166) --- runtime/queries/wgsl/highlights.scm | 102 ++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 runtime/queries/wgsl/highlights.scm (limited to 'runtime') diff --git a/runtime/queries/wgsl/highlights.scm b/runtime/queries/wgsl/highlights.scm new file mode 100644 index 00000000..7fbc87d8 --- /dev/null +++ b/runtime/queries/wgsl/highlights.scm @@ -0,0 +1,102 @@ +(const_literal) @constant.numeric + +(type_declaration) @type + +(function_declaration + (identifier) @function) + +(struct_declaration + (identifier) @type) + +(type_constructor_or_function_call_expression + (type_declaration) @function) + +(parameter + (variable_identifier_declaration (identifier) @variable.parameter)) + +[ + "struct" + "bitcast" + ; "block" + "discard" + "enable" + "fallthrough" + "fn" + "let" + "private" + "read" + "read_write" + "return" + "storage" + "type" + "uniform" + "var" + "workgroup" + "write" + (texel_format) +] @keyword ; TODO reserved keywords + +[ + (true) + (false) +] @constant.builtin.boolean + +[ "," "." ":" ";" ] @punctuation.delimiter + +;; brackets +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "loop" + "for" + "break" + "continue" + "continuing" +] @keyword.control.repeat + +[ + "if" + "else" + "elseif" + "switch" + "case" + "default" +] @keyword.control.conditional + +[ + "&" + "&&" + "/" + "!" + "=" + "==" + "!=" + ">" + ">=" + ">>" + "<" + "<=" + "<<" + "%" + "-" + "+" + "|" + "||" + "*" + "~" + "^" +] @operator + +(attribute + (identifier) @variable.other.member) + +(comment) @comment + +(ERROR) @error -- cgit v1.2.3-70-g09d2 From 6f1a7b1220c2ae565a2542fb089eb6d87f0a9421 Mon Sep 17 00:00:00 2001 From: Kirawi Date: Sun, 28 Nov 2021 20:38:17 -0500 Subject: Add llvm grammar (#1167) --- .gitmodules | 4 ++++ book/src/themes.md | 5 +++-- languages.toml | 8 ++++++++ runtime/queries/llvm/highlights.scm | 14 ++++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 runtime/queries/llvm/highlights.scm (limited to 'runtime') diff --git a/.gitmodules b/.gitmodules index 039a3ee3..6295b9e9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -146,3 +146,7 @@ path = helix-syntax/languages/tree-sitter-wgsl url = https://github.com/szebniok/tree-sitter-wgsl shallow = true +[submodule "helix-syntax/tree-sitter-llvm"] + path = helix-syntax/languages/tree-sitter-llvm + url = https://github.com/benwilliamgraham/tree-sitter-llvm + shallow = true diff --git a/book/src/themes.md b/book/src/themes.md index ecbbb6e9..fd3f5b1e 100644 --- a/book/src/themes.md +++ b/book/src/themes.md @@ -145,11 +145,12 @@ We use a similar set of scopes as - `conditional` - `if`, `else` - `repeat` - `for`, `while`, `loop` - `import` - `import`, `export` - - (TODO: return?) + - `return` + - `operator` - `or`, `in` - `directive` - Preprocessor directives (`#if` in C) - `function` - `fn`, `func` -- `operator` - `||`, `+=`, `>`, `or` +- `operator` - `||`, `+=`, `>` - `function` - `builtin` diff --git a/languages.toml b/languages.toml index 5dcbd872..4208e4b6 100644 --- a/languages.toml +++ b/languages.toml @@ -413,3 +413,11 @@ file-types = ["wgsl"] roots = [] comment-token = "//" indent = { tab-width = 4, unit = " " } + +[[language]] +name = "llvm" +scope = "source.llvm" +roots = [] +file-types = ["ll"] +comment-token = ";" +indent = { tab-width = 2, unit = " " } diff --git a/runtime/queries/llvm/highlights.scm b/runtime/queries/llvm/highlights.scm new file mode 100644 index 00000000..73afe85e --- /dev/null +++ b/runtime/queries/llvm/highlights.scm @@ -0,0 +1,14 @@ +(type) @type +(statement) @keyword.operator +(number) @constant.numeric.integer +(comment) @comment +(string) @string +(label) @label +(keyword) @keyword +"ret" @keyword.control.return +(boolean) @constant.builtin.boolean +(float) @constant.numeric.float +(constant) @constant +(identifier) @variable +(symbol) @punctuation.delimiter +(bracket) @punctuation.bracket -- cgit v1.2.3-70-g09d2 From 27ffc79c44710a18ca93cb2f0e91ee18ea19f98d Mon Sep 17 00:00:00 2001 From: WindSoilder Date: Thu, 2 Dec 2021 12:51:27 +0800 Subject: Add monokai pro theme (#1206) * add monokai_pro theme * add monokai_pro theme * claim the inspired theme and original author * make diagnostic underlined--- runtime/themes/monokai_pro.toml | 102 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 runtime/themes/monokai_pro.toml (limited to 'runtime') diff --git a/runtime/themes/monokai_pro.toml b/runtime/themes/monokai_pro.toml new file mode 100644 index 00000000..bf8a4a84 --- /dev/null +++ b/runtime/themes/monokai_pro.toml @@ -0,0 +1,102 @@ +# Author : WindSoilder +# The unofficial Monokai Pro theme, simply migrate from jetbrains monokai pro theme: https://github.com/subtheme-dev/monokai-pro +# Credit goes to the original creator: https://monokai.pro + +"ui.linenr.selected" = { bg = "base3" } +"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] } +"ui.menu.selected" = { fg = "base2", bg = "yellow" } + +"info" = "base8" +"hint" = "base8" + +# background color +"ui.background" = { bg = "base2" } +"ui.statusline.inactive" = { fg = "base8", bg = "base8x0c" } + +# status bars, panels, modals, autocompletion +"ui.statusline" = { bg = "base4" } +"ui.popup" = { bg = "base3" } +"ui.window" = { bg = "base3" } +"ui.help" = { bg = "base3" } + +# active line, highlighting +"ui.selection" = { bg = "base4" } +"ui.cursor.match" = { bg = "base4" } + +# comments, nord3 based lighter color +"comment" = { fg = "base5", modifiers = ["italic"] } +"ui.linenr" = { fg = "base5" } + +# cursor, variables, constants, attributes, fields +"ui.cursor.primary" = { fg = "base7", modifiers = ["reversed"] } +"attribute" = "blue" +"variable" = "base8" +"constant" = "orange" +"variable.builtin" = "red" +"constant.builtin" = "red" +"namespace" = "base8" + +# base text, punctuation +"ui.text" = { fg = "base8" } +"punctuation" = "base6" + +# classes, types, primiatives +"type" = "green" +"type.builtin" = { fg = "red"} +"label" = "base8" + +# declaration, methods, routines +"constructor" = "blue" +"function" = "green" +"function.macro" = { fg = "blue" } +"function.builtin" = { fg = "cyan" } + +# operator, tags, units, punctuations +"operator" = "red" +"variable.other.member" = "base8" + +# keywords, special +"keyword" = { fg = "red" } +"keyword.directive" = "blue" +"variable.parameter" = "#f59762" + +# error +"error" = "red" + +# annotations, decorators +"special" = "#f59762" +"module" = "#f59762" + +# warnings, escape characters, regex +"warning" = "orange" +"constant.character.escape" = { fg = "base8" } + +# strings +"string" = "yellow" + +# integer, floating point +"constant.numeric" = "purple" + +# make diagnostic underlined, to distinguish with selection text. +diagnostic = { modifiers = ["underlined"] } + +[palette] +# primary colors +"red" = "#ff6188" +"orange" = "#fc9867" +"yellow" = "#ffd866" +"green" = "#a9dc76" +"blue" = "#78dce8" +"purple" = "#ab9df2" +# base colors, sorted from darkest to lightest +"base0" = "#19181a" +"base1" = "#221f22" +"base2" = "#2d2a2e" +"base3" = "#403e41" +"base4" = "#5b595c" +"base5" = "#727072" +"base6" = "#939293" +"base7" = "#c1c0c0" +"base8" = "#fcfcfa" +# variants (for when transparency isn't supported) +"base8x0c" = "#363337" # using base2 as bg -- cgit v1.2.3-70-g09d2 From cf40e61b0abcdb3a8add01baaa0fbde830743cda Mon Sep 17 00:00:00 2001 From: WindSoilder Date: Fri, 3 Dec 2021 22:13:21 +0800 Subject: add more monokai pro filter themes (#1220) --- runtime/themes/monokai_pro_machine.toml | 102 ++++++++++++++++++++++++++++++ runtime/themes/monokai_pro_octagon.toml | 102 ++++++++++++++++++++++++++++++ runtime/themes/monokai_pro_ristretto.toml | 102 ++++++++++++++++++++++++++++++ runtime/themes/monokai_pro_spectrum.toml | 102 ++++++++++++++++++++++++++++++ 4 files changed, 408 insertions(+) create mode 100644 runtime/themes/monokai_pro_machine.toml create mode 100644 runtime/themes/monokai_pro_octagon.toml create mode 100644 runtime/themes/monokai_pro_ristretto.toml create mode 100644 runtime/themes/monokai_pro_spectrum.toml (limited to 'runtime') diff --git a/runtime/themes/monokai_pro_machine.toml b/runtime/themes/monokai_pro_machine.toml new file mode 100644 index 00000000..d8a701f1 --- /dev/null +++ b/runtime/themes/monokai_pro_machine.toml @@ -0,0 +1,102 @@ +# Author : WindSoilder +# The unofficial Monokai Pro theme, simply migrate from jetbrains monokai pro theme: https://github.com/subtheme-dev/monokai-pro +# Credit goes to the original creator: https://monokai.pro + +"ui.linenr.selected" = { bg = "base3" } +"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] } +"ui.menu.selected" = { fg = "base2", bg = "yellow" } + +"info" = "base8" +"hint" = "base8" + +# background color +"ui.background" = { bg = "base2" } +"ui.statusline.inactive" = { fg = "base8", bg = "base8x0c" } + +# status bars, panels, modals, autocompletion +"ui.statusline" = { bg = "base4" } +"ui.popup" = { bg = "base3" } +"ui.window" = { bg = "base3" } +"ui.help" = { bg = "base3" } + +# active line, highlighting +"ui.selection" = { bg = "base4" } +"ui.cursor.match" = { bg = "base4" } + +# comments, nord3 based lighter color +"comment" = { fg = "base5", modifiers = ["italic"] } +"ui.linenr" = { fg = "base5" } + +# cursor, variables, constants, attributes, fields +"ui.cursor.primary" = { fg = "base7", modifiers = ["reversed"] } +"attribute" = "blue" +"variable" = "base8" +"constant" = "orange" +"variable.builtin" = "red" +"constant.builtin" = "red" +"namespace" = "base8" + +# base text, punctuation +"ui.text" = { fg = "base8" } +"punctuation" = "base6" + +# classes, types, primiatives +"type" = "green" +"type.builtin" = { fg = "red"} +"label" = "base8" + +# declaration, methods, routines +"constructor" = "blue" +"function" = "green" +"function.macro" = { fg = "blue" } +"function.builtin" = { fg = "cyan" } + +# operator, tags, units, punctuations +"operator" = "red" +"variable.other.member" = "base8" + +# keywords, special +"keyword" = { fg = "red" } +"keyword.directive" = "blue" +"variable.parameter" = "#f59762" + +# error +"error" = "red" + +# annotations, decorators +"special" = "#f59762" +"module" = "#f59762" + +# warnings, escape characters, regex +"warning" = "orange" +"constant.character.escape" = { fg = "base8" } + +# strings +"string" = "yellow" + +# integer, floating point +"constant.numeric" = "purple" + +# make diagnostic underlined, to distinguish with selection text. +diagnostic = { modifiers = ["underlined"] } + +[palette] +# primary colors +"red" = "#ff6d7e" +"orange" = "#ffb270" +"yellow" = "#ffed72" +"green" = "#a2e57b" +"blue" = "#7cd5f1" +"purple" = "#baa0f8" +# base colors +"base0" = "#161b1e" +"base1" = "#1d2528" +"base2" = "#273136" +"base3" = "#3a4449" +"base4" = "#545f62" +"base5" = "#6b7678" +"base6" = "#798384" +"base7" = "#b8c4c3" +"base8" = "#f2fffc" +# variants +"base8x0c" = "#303a3e" diff --git a/runtime/themes/monokai_pro_octagon.toml b/runtime/themes/monokai_pro_octagon.toml new file mode 100644 index 00000000..74459472 --- /dev/null +++ b/runtime/themes/monokai_pro_octagon.toml @@ -0,0 +1,102 @@ +# Author : WindSoilder +# The unofficial Monokai Pro theme, simply migrate from jetbrains monokai pro theme: https://github.com/subtheme-dev/monokai-pro +# Credit goes to the original creator: https://monokai.pro + +"ui.linenr.selected" = { bg = "base3" } +"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] } +"ui.menu.selected" = { fg = "base2", bg = "yellow" } + +"info" = "base8" +"hint" = "base8" + +# background color +"ui.background" = { bg = "base2" } +"ui.statusline.inactive" = { fg = "base8", bg = "base8x0c" } + +# status bars, panels, modals, autocompletion +"ui.statusline" = { bg = "base4" } +"ui.popup" = { bg = "base3" } +"ui.window" = { bg = "base3" } +"ui.help" = { bg = "base3" } + +# active line, highlighting +"ui.selection" = { bg = "base4" } +"ui.cursor.match" = { bg = "base4" } + +# comments, nord3 based lighter color +"comment" = { fg = "base5", modifiers = ["italic"] } +"ui.linenr" = { fg = "base5" } + +# cursor, variables, constants, attributes, fields +"ui.cursor.primary" = { fg = "base7", modifiers = ["reversed"] } +"attribute" = "blue" +"variable" = "base8" +"constant" = "orange" +"variable.builtin" = "red" +"constant.builtin" = "red" +"namespace" = "base8" + +# base text, punctuation +"ui.text" = { fg = "base8" } +"punctuation" = "base6" + +# classes, types, primiatives +"type" = "green" +"type.builtin" = { fg = "red"} +"label" = "base8" + +# declaration, methods, routines +"constructor" = "blue" +"function" = "green" +"function.macro" = { fg = "blue" } +"function.builtin" = { fg = "cyan" } + +# operator, tags, units, punctuations +"operator" = "red" +"variable.other.member" = "base8" + +# keywords, special +"keyword" = { fg = "red" } +"keyword.directive" = "blue" +"variable.parameter" = "#f59762" + +# error +"error" = "red" + +# annotations, decorators +"special" = "#f59762" +"module" = "#f59762" + +# warnings, escape characters, regex +"warning" = "orange" +"constant.character.escape" = { fg = "base8" } + +# strings +"string" = "yellow" + +# integer, floating point +"constant.numeric" = "purple" + +# make diagnostic underlined, to distinguish with selection text. +diagnostic = { modifiers = ["underlined"] } + +[palette] +# primary colors +"red" = "#ff657a" +"orange" = "#ff9b5e" +"yellow" = "#ffd76d" +"green" = "#bad761" +"blue" = "#9cd1bb" +"purple" = "#c39ac9" +# base colors +"base0" = "#161821" +"base1" = "#1e1f2b" +"base2" = "#282a3a" +"base3" = "#3a3d4b" +"base4" = "#535763" +"base5" = "#696d77" +"base6" = "#767b81" +"base7" = "#b2b9bd" +"base8" = "#eaf2f1" +# variants +"base8x0c" = "#303342" diff --git a/runtime/themes/monokai_pro_ristretto.toml b/runtime/themes/monokai_pro_ristretto.toml new file mode 100644 index 00000000..a9cf4b34 --- /dev/null +++ b/runtime/themes/monokai_pro_ristretto.toml @@ -0,0 +1,102 @@ +# Author : WindSoilder +# The unofficial Monokai Pro theme, simply migrate from jetbrains monokai pro theme: https://github.com/subtheme-dev/monokai-pro +# Credit goes to the original creator: https://monokai.pro + +"ui.linenr.selected" = { bg = "base3" } +"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] } +"ui.menu.selected" = { fg = "base2", bg = "yellow" } + +"info" = "base8" +"hint" = "base8" + +# background color +"ui.background" = { bg = "base2" } +"ui.statusline.inactive" = { fg = "base8", bg = "base8x0c" } + +# status bars, panels, modals, autocompletion +"ui.statusline" = { bg = "base4" } +"ui.popup" = { bg = "base3" } +"ui.window" = { bg = "base3" } +"ui.help" = { bg = "base3" } + +# active line, highlighting +"ui.selection" = { bg = "base4" } +"ui.cursor.match" = { bg = "base4" } + +# comments, nord3 based lighter color +"comment" = { fg = "base5", modifiers = ["italic"] } +"ui.linenr" = { fg = "base5" } + +# cursor, variables, constants, attributes, fields +"ui.cursor.primary" = { fg = "base7", modifiers = ["reversed"] } +"attribute" = "blue" +"variable" = "base8" +"constant" = "orange" +"variable.builtin" = "red" +"constant.builtin" = "red" +"namespace" = "base8" + +# base text, punctuation +"ui.text" = { fg = "base8" } +"punctuation" = "base6" + +# classes, types, primiatives +"type" = "green" +"type.builtin" = { fg = "red"} +"label" = "base8" + +# declaration, methods, routines +"constructor" = "blue" +"function" = "green" +"function.macro" = { fg = "blue" } +"function.builtin" = { fg = "cyan" } + +# operator, tags, units, punctuations +"operator" = "red" +"variable.other.member" = "base8" + +# keywords, special +"keyword" = { fg = "red" } +"keyword.directive" = "blue" +"variable.parameter" = "#f59762" + +# error +"error" = "red" + +# annotations, decorators +"special" = "#f59762" +"module" = "#f59762" + +# warnings, escape characters, regex +"warning" = "orange" +"constant.character.escape" = { fg = "base8" } + +# strings +"string" = "yellow" + +# integer, floating point +"constant.numeric" = "purple" + +# make diagnostic underlined, to distinguish with selection text. +diagnostic = { modifiers = ["underlined"] } + +[palette] +# primary colors +"red" = "#fd6883" +"orange" = "#f38d70" +"yellow" = "#f9cc6c" +"green" = "#adda78" +"blue" = "#85dacc" +"purple" = "#a8a9eb" +# base colors +"base0" = "#191515" +"base1" = "#211c1c" +"base2" = "#2c2525" +"base3" = "#403838" +"base4" = "#5b5353" +"base5" = "#72696a" +"base6" = "#8c8384" +"base7" = "#c3b7b8" +"base8" = "#fff1f3" +# variants +"base8x0c" = "#352e2e" diff --git a/runtime/themes/monokai_pro_spectrum.toml b/runtime/themes/monokai_pro_spectrum.toml new file mode 100644 index 00000000..232adfbd --- /dev/null +++ b/runtime/themes/monokai_pro_spectrum.toml @@ -0,0 +1,102 @@ +# Author : WindSoilder +# The unofficial Monokai Pro theme, simply migrate from jetbrains monokai pro theme: https://github.com/subtheme-dev/monokai-pro +# Credit goes to the original creator: https://monokai.pro + +"ui.linenr.selected" = { bg = "base3" } +"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] } +"ui.menu.selected" = { fg = "base2", bg = "yellow" } + +"info" = "base8" +"hint" = "base8" + +# background color +"ui.background" = { bg = "base2" } +"ui.statusline.inactive" = { fg = "base8", bg = "base8x0c" } + +# status bars, panels, modals, autocompletion +"ui.statusline" = { bg = "base4" } +"ui.popup" = { bg = "base3" } +"ui.window" = { bg = "base3" } +"ui.help" = { bg = "base3" } + +# active line, highlighting +"ui.selection" = { bg = "base4" } +"ui.cursor.match" = { bg = "base4" } + +# comments, nord3 based lighter color +"comment" = { fg = "base5", modifiers = ["italic"] } +"ui.linenr" = { fg = "base5" } + +# cursor, variables, constants, attributes, fields +"ui.cursor.primary" = { fg = "base7", modifiers = ["reversed"] } +"attribute" = "blue" +"variable" = "base8" +"constant" = "orange" +"variable.builtin" = "red" +"constant.builtin" = "red" +"namespace" = "base8" + +# base text, punctuation +"ui.text" = { fg = "base8" } +"punctuation" = "base6" + +# classes, types, primiatives +"type" = "green" +"type.builtin" = { fg = "red"} +"label" = "base8" + +# declaration, methods, routines +"constructor" = "blue" +"function" = "green" +"function.macro" = { fg = "blue" } +"function.builtin" = { fg = "cyan" } + +# operator, tags, units, punctuations +"operator" = "red" +"variable.other.member" = "base8" + +# keywords, special +"keyword" = { fg = "red" } +"keyword.directive" = "blue" +"variable.parameter" = "#f59762" + +# error +"error" = "red" + +# annotations, decorators +"special" = "#f59762" +"module" = "#f59762" + +# warnings, escape characters, regex +"warning" = "orange" +"constant.character.escape" = { fg = "base8" } + +# strings +"string" = "yellow" + +# integer, floating point +"constant.numeric" = "purple" + +# make diagnostic underlined, to distinguish with selection text. +diagnostic = { modifiers = ["underlined"] } + +[palette] +# primary colors +"red" = "#fc618d" +"orange" = "#fd9353" +"yellow" = "#fce566" +"green" = "#7bd88f" +"blue" = "#5ad4e6" +"purple" = "#948ae3" +# base colors +"base0" = "#131313" +"base1" = "#191919" +"base2" = "#222222" +"base3" = "#363537" +"base4" = "#525053" +"base5" = "#69676c" +"base6" = "#8b888f" +"base7" = "#bab6c0" +"base8" = "#f7f1ff" +# variants +"base8x0c" = "#2b2b2b" -- cgit v1.2.3-70-g09d2 From 038a6ce22cb9a4eeebb63abc7d07523bb72d3175 Mon Sep 17 00:00:00 2001 From: chunghha Date: Fri, 3 Dec 2021 08:14:03 -0600 Subject: rose_pine_dawn.toml colorscheme (#1226) * adds: rose_pine_dawn.toml colorscheme * chore: define ui.statusline.inactive colors of rose_pine--- runtime/themes/rose_pine.toml | 1 + runtime/themes/rose_pine_dawn.toml | 63 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 runtime/themes/rose_pine_dawn.toml (limited to 'runtime') diff --git a/runtime/themes/rose_pine.toml b/runtime/themes/rose_pine.toml index 53777008..256b33c8 100644 --- a/runtime/themes/rose_pine.toml +++ b/runtime/themes/rose_pine.toml @@ -10,6 +10,7 @@ "ui.selection" = "highlight" "comment" = "subtle" "ui.statusline" = {fg = "foam", bg = "surface" } +"ui.statusline.inactive" = { fg = "iris", bg = "surface" } "ui.help" = { fg = "foam", bg = "surface" } "ui.cursor" = { fg = "rose", modifiers = ["reversed"] } "ui.text" = { fg = "text" } diff --git a/runtime/themes/rose_pine_dawn.toml b/runtime/themes/rose_pine_dawn.toml new file mode 100644 index 00000000..43ba24ed --- /dev/null +++ b/runtime/themes/rose_pine_dawn.toml @@ -0,0 +1,63 @@ +# Author: ChrisHa +# Author: RayGervais + +"ui.background" = { bg = "base" } +"ui.menu" = "surface" +"ui.menu.selected" = { fg = "iris", bg = "surface" } +"ui.linenr" = {fg = "subtle" } +"ui.popup" = { bg = "overlay" } +"ui.window" = { bg = "overlay" } +"ui.liner.selected" = "highlightOverlay" +"ui.selection" = "highlight" +"comment" = "subtle" +"ui.statusline" = {fg = "foam", bg = "surface" } +"ui.statusline.inactive" = { fg = "iris", bg = "surface" } +"ui.help" = { fg = "foam", bg = "surface" } +"ui.cursor" = { fg = "rose", modifiers = ["reversed"] } +"ui.text" = { fg = "text" } +"operator" = "rose" +"ui.text.focus" = { fg = "base05" } +"variable" = "text" +"number" = "iris" +"constant" = "gold" +"attributes" = "gold" +"type" = "foam" +"ui.cursor.match" = { fg = "gold", modifiers = ["underlined"] } +"string" = "gold" +"property" = "foam" +"escape" = "subtle" +"function" = "rose" +"function.builtin" = "rose" +"function.method" = "foam" +"constructor" = "gold" +"special" = "gold" +"keyword" = "pine" +"label" = "iris" +"namespace" = "pine" +"ui.popup" = { bg = "overlay" } +"ui.window" = { bg = "base" } +"ui.help" = { bg = "overlay", fg = "foam" } +"text" = "text" + +"info" = "gold" +"hint" = "gold" +"debug" = "rose" +"diagnostic" = "rose" +"error" = "love" + +[palette] +base = "#faf4ed" +surface = "#fffaf3" +overlay = "#f2e9de" +inactive = "#9893a5" +subtle = "#6e6a86" +text = "#575279" +love = "#b4637a" +gold = "#ea9d34" +rose = "#d7827e" +pine = "#286983" +foam = "#56949f" +iris = "#907aa9" +highlight = "#eee9e6" +highlightInactive = "#f2ede9" +highlightOverlay = "#e4dfde" -- cgit v1.2.3-70-g09d2 From 9bdbafa0759e482d628b7e1940809963c556ec95 Mon Sep 17 00:00:00 2001 From: Skyler Hawthorne Date: Tue, 7 Dec 2021 20:22:55 -0500 Subject: Fix solarized selection colors (#1236) * do not select a foreground color in selections, as this eliminates syntax coloring * select lighter color for selections * Make non-primary cursor cyan instead of green--- runtime/themes/solarized_dark.toml | 30 +++++++++++++----------- runtime/themes/solarized_light.toml | 46 +++++++++++++++++++------------------ 2 files changed, 40 insertions(+), 36 deletions(-) (limited to 'runtime') diff --git a/runtime/themes/solarized_dark.toml b/runtime/themes/solarized_dark.toml index 984c86ee..979fdaac 100644 --- a/runtime/themes/solarized_dark.toml +++ b/runtime/themes/solarized_dark.toml @@ -58,13 +58,13 @@ "ui.highlight" = { fg = "red", modifiers = ["bold", "italic", "underlined"] } # 主光标/selectio -"ui.cursor.primary" = {fg = "base03", bg = "base1"} -"ui.selection.primary" = { fg = "base03", bg = "base01" } -"ui.cursor.select" = {fg = "base02", bg = "green"} -"ui.selection" = { fg = "base02", bg = "yellow" } +"ui.cursor.primary" = { fg = "base03", bg = "base1" } +"ui.cursor.select" = { fg = "base02", bg = "cyan" } +"ui.selection" = { bg = "base0175" } +"ui.selection.primary" = { bg = "base015" } # normal模式的光标 -"ui.cursor" = {fg = "base03", bg = "green"} +"ui.cursor" = {fg = "base02", bg = "cyan"} "ui.cursor.insert" = {fg = "base03", bg = "base3"} # 当前光标匹配的标点符号 "ui.cursor.match" = {modifiers = ["reversed"]} @@ -73,18 +73,20 @@ "error" = { fg = "red", modifiers= ["bold", "underlined"] } "info" = { fg = "blue", modifiers= ["bold", "underlined"] } "hint" = { fg = "base01", modifiers= ["bold", "underlined"] } -"diagnostic" = { mdifiers = ["underlined"] } +"diagnostic" = { modifiers = ["underlined"] } [palette] # 深色 越来越深 -base03 = "#002b36" -base02 = "#073642" -base01 = "#586e75" -base00 = "#657b83" -base0 = "#839496" -base1 = "#93a1a1" -base2 = "#eee8d5" -base3 = "#fdf6e3" +base03 = "#002b36" +base02 = "#073642" +base0175 = "#16404b" +base015 = "#2c4f59" +base01 = "#586e75" +base00 = "#657b83" +base0 = "#839496" +base1 = "#93a1a1" +base2 = "#eee8d5" +base3 = "#fdf6e3" # 浅色 越來越浅 yellow = "#b58900" diff --git a/runtime/themes/solarized_light.toml b/runtime/themes/solarized_light.toml index 0ab1b962..ded90cc4 100644 --- a/runtime/themes/solarized_light.toml +++ b/runtime/themes/solarized_light.toml @@ -58,13 +58,13 @@ "ui.highlight" = { fg = "red", modifiers = ["bold", "italic", "underlined"] } # 主光标/selectio -"ui.cursor.primary" = {fg = "base03", bg = "base1"} -"ui.selection.primary" = { fg = "base03", bg = "base01" } -"ui.cursor.select" = {fg = "base02", bg = "green"} -"ui.selection" = { fg = "base02", bg = "yellow" } +"ui.cursor.primary" = { fg = "base03", bg = "base1" } +"ui.cursor.select" = { fg = "base02", bg = "cyan" } +"ui.selection" = { bg = "base0175" } +"ui.selection.primary" = { bg = "base015" } # normal模式的光标 -"ui.cursor" = {fg = "base03", bg = "green"} +"ui.cursor" = {fg = "base02", bg = "cyan"} "ui.cursor.insert" = {fg = "base03", bg = "base3"} # 当前光标匹配的标点符号 "ui.cursor.match" = {modifiers = ["reversed"]} @@ -73,26 +73,28 @@ "error" = { fg = "red", modifiers= ["bold", "underlined"] } "info" = { fg = "blue", modifiers= ["bold", "underlined"] } "hint" = { fg = "base01", modifiers= ["bold", "underlined"] } -"diagnostic" = { mdifiers = ["underlined"] } +"diagnostic" = { modifiers = ["underlined"] } [palette] -red = '#dc322f' -green = '#859900' -yellow = '#b58900' -blue = '#268bd2' -magenta = '#d33682' -cyan = '#2aa198' -orange = '#cb4b16' -violet = '#6c71c4' +red = '#dc322f' +green = '#859900' +yellow = '#b58900' +blue = '#268bd2' +magenta = '#d33682' +cyan = '#2aa198' +orange = '#cb4b16' +violet = '#6c71c4' # 深色 越来越深 -base0 = '#657b83' -base1 = '#586e75' -base2 = '#073642' -base3 = '#002b36' +base0 = '#657b83' +base1 = '#586e75' +base2 = '#073642' +base3 = '#002b36' ## 浅色 越來越浅 -base00 = '#839496' -base01 = '#93a1a1' -base02 = '#eee8d5' -base03 = '#fdf6e3' +base00 = '#839496' +base01 = '#93a1a1' +base015 = '#c5c8bd' +base0175 = '#dddbcc' +base02 = '#eee8d5' +base03 = '#fdf6e3' -- cgit v1.2.3-70-g09d2 From 43d17c482cda07fa0dc4985d60c14391a4926940 Mon Sep 17 00:00:00 2001 From: NNB Date: Thu, 11 Nov 2021 15:23:27 +0700 Subject: Fix Base16 Dark, add Base16 Light and Terminal Improve accuracy with line number and cursor color --- runtime/themes/base16_default_dark.toml | 25 ++++++------- runtime/themes/base16_default_light.toml | 60 ++++++++++++++++++++++++++++++++ runtime/themes/base16_terminal.toml | 41 ++++++++++++++++++++++ 3 files changed, 114 insertions(+), 12 deletions(-) create mode 100644 runtime/themes/base16_default_light.toml create mode 100644 runtime/themes/base16_terminal.toml (limited to 'runtime') diff --git a/runtime/themes/base16_default_dark.toml b/runtime/themes/base16_default_dark.toml index d65995c0..15c094a6 100644 --- a/runtime/themes/base16_default_dark.toml +++ b/runtime/themes/base16_default_dark.toml @@ -1,27 +1,28 @@ -# Author: RayGervais +# Author: RayGervais "ui.background" = { bg = "base00" } "ui.menu" = "base01" "ui.menu.selected" = { fg = "base04", bg = "base01" } -"ui.linenr" = {fg = "base01" } +"ui.linenr" = { fg = "base03", bg = "base01" } "ui.popup" = { bg = "base01" } "ui.window" = { bg = "base01" } -"ui.liner.selected" = "base02" -"ui.selection" = "base02" -"comment" = "base03" -"ui.statusline" = {fg = "base04", bg = "base01" } +"ui.linenr.selected" = { fg = "base04", bg = "base01", modifiers = ["bold"] } +"ui.selection" = { bg = "base02" } +"comment" = { fg = "base03", modifiers = ["italic"] } +"ui.statusline" = { fg = "base04", bg = "base01" } "ui.help" = { fg = "base04", bg = "base01" } -"ui.cursor" = { fg = "base05", modifiers = ["reversed"] } -"ui.text" = { fg = "base05" } +"ui.cursor" = { fg = "base04", modifiers = ["reversed"] } +"ui.cursor.primary" = { fg = "base05", modifiers = ["reversed"] } +"ui.text" = "base05" "operator" = "base05" -"ui.text.focus" = { fg = "base05" } +"ui.text.focus" = "base05" "variable" = "base08" "constant.numeric" = "base09" "constant" = "base09" -"attributes" = "base09" +"attributes" = "base09" "type" = "base0A" "ui.cursor.match" = { fg = "base0A", modifiers = ["underlined"] } -"strings" = "base0B" +"string" = "base0B" "variable.other.member" = "base0B" "constant.character.escape" = "base0C" "function" = "base0D" @@ -32,7 +33,7 @@ "namespace" = "base0E" "ui.popup" = { bg = "base01" } "ui.window" = { bg = "base00" } -"ui.help" = { bg = "base01", fg = "base06" } +"ui.help" = { fg = "base06", bg = "base01" } "info" = "base03" "hint" = "base03" diff --git a/runtime/themes/base16_default_light.toml b/runtime/themes/base16_default_light.toml new file mode 100644 index 00000000..d9f1e0ba --- /dev/null +++ b/runtime/themes/base16_default_light.toml @@ -0,0 +1,60 @@ +# Author: NNB + +"ui.background" = { bg = "base00" } +"ui.menu" = "base01" +"ui.menu.selected" = { fg = "base04", bg = "base01" } +"ui.linenr" = { fg = "base03", bg = "base01" } +"ui.popup" = { bg = "base01" } +"ui.window" = { bg = "base01" } +"ui.linenr.selected" = { fg = "base04", bg = "base01", modifiers = ["bold"] } +"ui.selection" = { bg = "base02" } +"comment" = { fg = "base03", modifiers = ["italic"] } +"ui.statusline" = { fg = "base04", bg = "base01" } +"ui.help" = { fg = "base04", bg = "base01" } +"ui.cursor" = { fg = "base04", modifiers = ["reversed"] } +"ui.cursor.primary" = { fg = "base05", modifiers = ["reversed"] } +"ui.text" = "base05" +"operator" = "base05" +"ui.text.focus" = "base05" +"variable" = "base08" +"constant.numeric" = "base09" +"constant" = "base09" +"attributes" = "base09" +"type" = "base0A" +"ui.cursor.match" = { fg = "base0A", modifiers = ["underlined"] } +"string" = "base0B" +"variable.other.member" = "base0B" +"constant.character.escape" = "base0C" +"function" = "base0D" +"constructor" = "base0D" +"special" = "base0D" +"keyword" = "base0E" +"label" = "base0E" +"namespace" = "base0E" +"ui.popup" = { bg = "base01" } +"ui.window" = { bg = "base00" } +"ui.help" = { fg = "base06", bg = "base01" } + +"info" = "base03" +"hint" = "base03" +"debug" = "base03" +"diagnostic" = "base03" +"error" = "base0E" + +[palette] +base00 = "#f8f8f8" # Default Background +base01 = "#e8e8e8" # Lighter Background (Used for status bars, line number and folding marks) +base02 = "#d8d8d8" # Selection Background +base03 = "#b8b8b8" # Comments, Invisibles, Line Highlighting +base04 = "#585858" # Dark Foreground (Used for status bars) +base05 = "#383838" # Default Foreground, Caret, Delimiters, Operators +base06 = "#282828" # Light Foreground (Not often used) +base07 = "#181818" # Light Background (Not often used) +base08 = "#ab4642" # Variables, XML Tags, Markup Link Text, Markup Lists, Diff Deleted +base09 = "#dc9656" # Integers, Boolean, Constants, XML Attributes, Markup Link Url +base0A = "#f7ca88" # Classes, Markup Bold, Search Text Background +base0B = "#a1b56c" # Strings, Inherited Class, Markup Code, Diff Inserted +base0C = "#86c1b9" # Support, Regular Expressions, Escape Characters, Markup Quotes +base0D = "#7cafc2" # Functions, Methods, Attribute IDs, Headings +base0E = "#ba8baf" # Keywords, Storage, Selector, Markup Italic, Diff Changed +base0F = "#a16946" # Deprecated, Opening/Closing Embedded Language Tags, e.g. diff --git a/runtime/themes/base16_terminal.toml b/runtime/themes/base16_terminal.toml new file mode 100644 index 00000000..bf3c73f1 --- /dev/null +++ b/runtime/themes/base16_terminal.toml @@ -0,0 +1,41 @@ +# Author: NNB + +"ui.menu" = "black" +"ui.menu.selected" = { fg = "white", bg = "black" } +"ui.linenr" = { fg = "light-gray", bg = "black" } +"ui.popup" = { bg = "black" } +"ui.window" = { bg = "black" } +"ui.linenr.selected" = { fg = "white", bg = "black", modifiers = ["bold"] } +"ui.selection" = { fg = "gray", modifiers = ["reversed"] } +"comment" = { fg = "light-gray", modifiers = ["italic"] } +"ui.statusline" = { fg = "white", bg = "black" } +"ui.help" = { fg = "white", bg = "black" } +"ui.cursor" = { fg = "light-gray", modifiers = ["reversed"] } +"ui.cursor.primary" = { fg = "white", modifiers = ["reversed"] } #FIXME +"ui.text" = "white" #FIXME +"operator" = "white" #FIXME +"ui.text.focus" = "white" #FIXME +"variable" = "light-red" +"constant.numeric" = "yellow" +"constant" = "yellow" +"attributes" = "yellow" +"type" = "light-yellow" +"ui.cursor.match" = { fg = "light-yellow", modifiers = ["underlined"] } +"string" = "light-green" +"variable.other.member" = "light-green" +"constant.character.escape" = "light-cyan" +"function" = "light-blue" +"constructor" = "light-blue" +"special" = "light-blue" +"keyword" = "light-magenta" +"label" = "light-magenta" +"namespace" = "light-magenta" +"ui.popup" = { bg = "black" } +"ui.window" = { bg = "base00" } +"ui.help" = { fg = "white", bg = "black" } + +"info" = "light-gray" +"hint" = "light-gray" +"debug" = "light-gray" +"diagnostic" = "light-gray" +"error" = "light-magenta" -- cgit v1.2.3-70-g09d2 From 98ce2a301da25152563137047377026d72fd644c Mon Sep 17 00:00:00 2001 From: Omnikar Date: Sun, 14 Nov 2021 07:26:48 -0500 Subject: Load alt default theme if true color is not supported * Move `runtime/themes/base16_default_terminal.toml` to `base16_theme.toml` alongside `theme.toml` * Use `terminfo` crate to detect whether the terminal supports true color and, if the user has no theme configured and their terminal does not support true color, load the alt default theme instead of the normal default. Remove `terminfo` dependency, use `COLORTERM` env instead Prevent user from switching to an unsupported theme Add `true-color-override` option If the terminal is wrongly detected to not support true color, `true-color-override = true` will override the detection. Rename `true-color-override` to `true-color` --- base16_theme.toml | 41 +++++++++++++++++++++++++++++++++++++ book/src/configuration.md | 1 + helix-term/src/application.rs | 28 +++++++++++++++++-------- helix-term/src/commands.rs | 14 +++++++++++-- helix-term/src/lib.rs | 6 ++++++ helix-term/src/ui/mod.rs | 1 + helix-view/src/editor.rs | 12 +++-------- helix-view/src/theme.rs | 20 ++++++++++++++++++ runtime/themes/base16_terminal.toml | 41 ------------------------------------- 9 files changed, 103 insertions(+), 61 deletions(-) create mode 100644 base16_theme.toml delete mode 100644 runtime/themes/base16_terminal.toml (limited to 'runtime') diff --git a/base16_theme.toml b/base16_theme.toml new file mode 100644 index 00000000..bf3c73f1 --- /dev/null +++ b/base16_theme.toml @@ -0,0 +1,41 @@ +# Author: NNB + +"ui.menu" = "black" +"ui.menu.selected" = { fg = "white", bg = "black" } +"ui.linenr" = { fg = "light-gray", bg = "black" } +"ui.popup" = { bg = "black" } +"ui.window" = { bg = "black" } +"ui.linenr.selected" = { fg = "white", bg = "black", modifiers = ["bold"] } +"ui.selection" = { fg = "gray", modifiers = ["reversed"] } +"comment" = { fg = "light-gray", modifiers = ["italic"] } +"ui.statusline" = { fg = "white", bg = "black" } +"ui.help" = { fg = "white", bg = "black" } +"ui.cursor" = { fg = "light-gray", modifiers = ["reversed"] } +"ui.cursor.primary" = { fg = "white", modifiers = ["reversed"] } #FIXME +"ui.text" = "white" #FIXME +"operator" = "white" #FIXME +"ui.text.focus" = "white" #FIXME +"variable" = "light-red" +"constant.numeric" = "yellow" +"constant" = "yellow" +"attributes" = "yellow" +"type" = "light-yellow" +"ui.cursor.match" = { fg = "light-yellow", modifiers = ["underlined"] } +"string" = "light-green" +"variable.other.member" = "light-green" +"constant.character.escape" = "light-cyan" +"function" = "light-blue" +"constructor" = "light-blue" +"special" = "light-blue" +"keyword" = "light-magenta" +"label" = "light-magenta" +"namespace" = "light-magenta" +"ui.popup" = { bg = "black" } +"ui.window" = { bg = "base00" } +"ui.help" = { fg = "white", bg = "black" } + +"info" = "light-gray" +"hint" = "light-gray" +"debug" = "light-gray" +"diagnostic" = "light-gray" +"error" = "light-magenta" diff --git a/book/src/configuration.md b/book/src/configuration.md index 2ed48d51..33a933b2 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -23,6 +23,7 @@ To override global configuration parameters, create a `config.toml` file located | `idle-timeout` | Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. | `400` | | `completion-trigger-len` | The min-length of word under cursor to trigger autocompletion | `2` | | `auto-info` | Whether to display infoboxes | `true` | +| `true-color` | Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative. | `false` | `[editor.filepicker]` section of the config. Sets options for file picker and global search. All but the last key listed in the default file-picker configuration below are IgnoreOptions: whether hidden files and files listed within ignore files are ignored by (not visible in) the helix file picker and global search. There is also one other key, `max-depth` available, which is not defined by default. diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 90330751..3e0b6d59 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -76,17 +76,27 @@ impl Application { None => Ok(def_lang_conf), }; - let theme = if let Some(theme) = &config.theme { - match theme_loader.load(theme) { - Ok(theme) => theme, - Err(e) => { - log::warn!("failed to load theme `{}` - {}", theme, e); + let true_color = config.editor.true_color || crate::true_color(); + let theme = config + .theme + .as_ref() + .and_then(|theme| { + theme_loader + .load(theme) + .map_err(|e| { + log::warn!("failed to load theme `{}` - {}", theme, e); + e + }) + .ok() + .filter(|theme| (true_color || theme.is_16_color())) + }) + .unwrap_or_else(|| { + if true_color { theme_loader.default() + } else { + theme_loader.base16_default() } - } - } else { - theme_loader.default() - }; + }); let syn_loader_conf: helix_core::syntax::Configuration = lang_conf .and_then(|conf| conf.try_into()) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 0ae225e9..22c23043 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2366,8 +2366,18 @@ pub mod cmd { args: &[Cow], _event: PromptEvent, ) -> anyhow::Result<()> { - let theme = args.first().context("theme not provided")?; - cx.editor.set_theme_from_name(theme) + let theme = args.first().context("Theme not provided")?; + let theme = cx + .editor + .theme_loader + .load(theme) + .with_context(|| format!("Failed setting theme {}", theme))?; + let true_color = cx.editor.config.true_color || crate::true_color(); + if !(true_color || theme.is_16_color()) { + bail!("Unsupported theme: theme requires true color support"); + } + cx.editor.set_theme(theme); + Ok(()) } fn yank_main_selection_to_clipboard( diff --git a/helix-term/src/lib.rs b/helix-term/src/lib.rs index f5e3a8cd..4fe76cd5 100644 --- a/helix-term/src/lib.rs +++ b/helix-term/src/lib.rs @@ -9,3 +9,9 @@ pub mod config; pub mod job; pub mod keymap; pub mod ui; + +fn true_color() -> bool { + std::env::var("COLORTERM") + .map(|v| matches!(v.as_str(), "truecolor" | "24bit")) + .unwrap_or(false) +} diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index cdf42311..f57e2e2b 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -186,6 +186,7 @@ pub mod completers { &helix_core::config_dir().join("themes"), )); names.push("default".into()); + names.push("base16_default".into()); let mut names: Vec<_> = names .into_iter() diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index dcbcbe4f..753defa1 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -105,6 +105,8 @@ pub struct Config { /// Whether to display infoboxes. Defaults to true. pub auto_info: bool, pub file_picker: FilePickerConfig, + /// Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative. Defaults to `false`. + pub true_color: bool, } #[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize)] @@ -137,6 +139,7 @@ impl Default for Config { completion_trigger_len: 2, auto_info: true, file_picker: FilePickerConfig::default(), + true_color: false, } } } @@ -265,15 +268,6 @@ impl Editor { self._refresh(); } - pub fn set_theme_from_name(&mut self, theme: &str) -> anyhow::Result<()> { - let theme = self - .theme_loader - .load(theme.as_ref()) - .with_context(|| format!("failed setting theme `{}`", theme))?; - self.set_theme(theme); - Ok(()) - } - /// Refreshes the language server for a given document pub fn refresh_language_server(&mut self, doc_id: DocumentId) -> Option<()> { let doc = self.documents.get_mut(&doc_id)?; diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs index 47fc6262..ddcdad99 100644 --- a/helix-view/src/theme.rs +++ b/helix-view/src/theme.rs @@ -15,6 +15,10 @@ pub use crate::graphics::{Color, Modifier, Style}; pub static DEFAULT_THEME: Lazy = Lazy::new(|| { toml::from_slice(include_bytes!("../../theme.toml")).expect("Failed to parse default theme") }); +pub static BASE16_DEFAULT_THEME: Lazy = Lazy::new(|| { + toml::from_slice(include_bytes!("../../base16_theme.toml")) + .expect("Failed to parse base 16 default theme") +}); #[derive(Clone, Debug)] pub struct Loader { @@ -35,6 +39,9 @@ impl Loader { if name == "default" { return Ok(self.default()); } + if name == "base16_default" { + return Ok(self.base16_default()); + } let filename = format!("{}.toml", name); let user_path = self.user_dir.join(&filename); @@ -74,6 +81,11 @@ impl Loader { pub fn default(&self) -> Theme { DEFAULT_THEME.clone() } + + /// Returns the alternative 16-color default theme + pub fn base16_default(&self) -> Theme { + BASE16_DEFAULT_THEME.clone() + } } #[derive(Clone, Debug)] @@ -154,6 +166,14 @@ impl Theme { pub fn find_scope_index(&self, scope: &str) -> Option { self.scopes().iter().position(|s| s == scope) } + + pub fn is_16_color(&self) -> bool { + self.styles.iter().all(|(_, style)| { + [style.fg, style.bg] + .into_iter() + .all(|color| !matches!(color, Some(Color::Rgb(..)))) + }) + } } struct ThemePalette { diff --git a/runtime/themes/base16_terminal.toml b/runtime/themes/base16_terminal.toml deleted file mode 100644 index bf3c73f1..00000000 --- a/runtime/themes/base16_terminal.toml +++ /dev/null @@ -1,41 +0,0 @@ -# Author: NNB - -"ui.menu" = "black" -"ui.menu.selected" = { fg = "white", bg = "black" } -"ui.linenr" = { fg = "light-gray", bg = "black" } -"ui.popup" = { bg = "black" } -"ui.window" = { bg = "black" } -"ui.linenr.selected" = { fg = "white", bg = "black", modifiers = ["bold"] } -"ui.selection" = { fg = "gray", modifiers = ["reversed"] } -"comment" = { fg = "light-gray", modifiers = ["italic"] } -"ui.statusline" = { fg = "white", bg = "black" } -"ui.help" = { fg = "white", bg = "black" } -"ui.cursor" = { fg = "light-gray", modifiers = ["reversed"] } -"ui.cursor.primary" = { fg = "white", modifiers = ["reversed"] } #FIXME -"ui.text" = "white" #FIXME -"operator" = "white" #FIXME -"ui.text.focus" = "white" #FIXME -"variable" = "light-red" -"constant.numeric" = "yellow" -"constant" = "yellow" -"attributes" = "yellow" -"type" = "light-yellow" -"ui.cursor.match" = { fg = "light-yellow", modifiers = ["underlined"] } -"string" = "light-green" -"variable.other.member" = "light-green" -"constant.character.escape" = "light-cyan" -"function" = "light-blue" -"constructor" = "light-blue" -"special" = "light-blue" -"keyword" = "light-magenta" -"label" = "light-magenta" -"namespace" = "light-magenta" -"ui.popup" = { bg = "black" } -"ui.window" = { bg = "base00" } -"ui.help" = { fg = "white", bg = "black" } - -"info" = "light-gray" -"hint" = "light-gray" -"debug" = "light-gray" -"diagnostic" = "light-gray" -"error" = "light-magenta" -- cgit v1.2.3-70-g09d2 From 3080be82687548e06a05e517e09a36721b769f03 Mon Sep 17 00:00:00 2001 From: NNB Date: Thu, 2 Dec 2021 17:22:27 +0700 Subject: Fix error color, add tty theme --- base16_terminal.toml | 2 +- runtime/themes/base16_default_dark.toml | 2 +- runtime/themes/base16_default_light.toml | 2 +- runtime/themes/base16_tty.toml | 41 ++++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 runtime/themes/base16_tty.toml (limited to 'runtime') diff --git a/base16_terminal.toml b/base16_terminal.toml index bf3c73f1..e613526f 100644 --- a/base16_terminal.toml +++ b/base16_terminal.toml @@ -38,4 +38,4 @@ "hint" = "light-gray" "debug" = "light-gray" "diagnostic" = "light-gray" -"error" = "light-magenta" +"error" = "light-red" diff --git a/runtime/themes/base16_default_dark.toml b/runtime/themes/base16_default_dark.toml index 15c094a6..3472162b 100644 --- a/runtime/themes/base16_default_dark.toml +++ b/runtime/themes/base16_default_dark.toml @@ -39,7 +39,7 @@ "hint" = "base03" "debug" = "base03" "diagnostic" = "base03" -"error" = "base0E" +"error" = "base08" [palette] base00 = "#181818" # Default Background diff --git a/runtime/themes/base16_default_light.toml b/runtime/themes/base16_default_light.toml index d9f1e0ba..d864fd5f 100644 --- a/runtime/themes/base16_default_light.toml +++ b/runtime/themes/base16_default_light.toml @@ -39,7 +39,7 @@ "hint" = "base03" "debug" = "base03" "diagnostic" = "base03" -"error" = "base0E" +"error" = "base08" [palette] base00 = "#f8f8f8" # Default Background diff --git a/runtime/themes/base16_tty.toml b/runtime/themes/base16_tty.toml new file mode 100644 index 00000000..480bcd9c --- /dev/null +++ b/runtime/themes/base16_tty.toml @@ -0,0 +1,41 @@ +# Author: NNB + +"ui.menu" = "black" +"ui.menu.selected" = { fg = "white", bg = "black" } +"ui.linenr" = { fg = "gray", bg = "black" } +"ui.popup" = { bg = "black" } +"ui.window" = { bg = "black" } +"ui.linenr.selected" = { fg = "white", bg = "black", modifiers = ["bold"] } +"ui.selection" = { fg = "black", bg = "blue" } +"ui.selection.primary" = { fg = "white", bg = "blue" } +"comment" = { fg = "gray" } +"ui.statusline" = { fg = "white", bg = "black" } +"ui.help" = { fg = "white", bg = "black" } +"ui.cursor" = { fg = "white", modifiers = ["reversed"] } #FIXME +"ui.text" = "white" #FIXME +"operator" = "white" #FIXME +"ui.text.focus" = "white" #FIXME +"variable" = "red" +"constant.numeric" = "yellow" +"constant" = "yellow" +"attributes" = "yellow" +"type" = "yellow" +"ui.cursor.match" = { fg = "yellow", modifiers = ["underlined"] } +"string" = "green" +"variable.other.member" = "green" +"constant.character.escape" = "cyan" +"function" = "blue" +"constructor" = "blue" +"special" = "blue" +"keyword" = "magenta" +"label" = "magenta" +"namespace" = "magenta" +"ui.popup" = { bg = "black" } +"ui.window" = { bg = "base00" } +"ui.help" = { fg = "white", bg = "black" } + +"info" = "gray" +"hint" = "gray" +"debug" = "gray" +"diagnostic" = "gray" +"error" = "red" -- cgit v1.2.3-70-g09d2 From d9727868dd7a496d33a321faeacfcd02d8c1c06e Mon Sep 17 00:00:00 2001 From: NNB Date: Thu, 2 Dec 2021 19:33:31 +0700 Subject: change to .unwrap_or_default() and fix ui.window and ui.statusline --- base16_terminal.toml | 10 +++------- helix-view/src/theme.rs | 2 +- runtime/themes/base16_default_dark.toml | 4 +--- runtime/themes/base16_default_light.toml | 4 +--- runtime/themes/base16_tty.toml | 17 ++++++----------- 5 files changed, 12 insertions(+), 25 deletions(-) (limited to 'runtime') diff --git a/base16_terminal.toml b/base16_terminal.toml index e613526f..a76cfd7e 100644 --- a/base16_terminal.toml +++ b/base16_terminal.toml @@ -1,7 +1,7 @@ # Author: NNB "ui.menu" = "black" -"ui.menu.selected" = { fg = "white", bg = "black" } +"ui.menu.selected" = { modifiers = ["reversed"] } "ui.linenr" = { fg = "light-gray", bg = "black" } "ui.popup" = { bg = "black" } "ui.window" = { bg = "black" } @@ -9,12 +9,10 @@ "ui.selection" = { fg = "gray", modifiers = ["reversed"] } "comment" = { fg = "light-gray", modifiers = ["italic"] } "ui.statusline" = { fg = "white", bg = "black" } +"ui.statusline.inactive" = { fg = "gray", bg = "black" } "ui.help" = { fg = "white", bg = "black" } "ui.cursor" = { fg = "light-gray", modifiers = ["reversed"] } -"ui.cursor.primary" = { fg = "white", modifiers = ["reversed"] } #FIXME -"ui.text" = "white" #FIXME -"operator" = "white" #FIXME -"ui.text.focus" = "white" #FIXME +"ui.cursor.primary" = { modifiers = ["reversed"] } "variable" = "light-red" "constant.numeric" = "yellow" "constant" = "yellow" @@ -30,8 +28,6 @@ "keyword" = "light-magenta" "label" = "light-magenta" "namespace" = "light-magenta" -"ui.popup" = { bg = "black" } -"ui.window" = { bg = "base00" } "ui.help" = { fg = "white", bg = "black" } "info" = "light-gray" diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs index a5dc0609..6ca021a9 100644 --- a/helix-view/src/theme.rs +++ b/helix-view/src/theme.rs @@ -151,7 +151,7 @@ impl Theme { pub fn get(&self, scope: &str) -> Style { self.try_get(scope) - .unwrap_or_else(|| Style::default().fg(Color::Rgb(0, 0, 255))) + .unwrap_or_default() } pub fn try_get(&self, scope: &str) -> Option