Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git commit message highlighting #1338

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,12 @@
[submodule "helix-syntax/languages/tree-sitter-dockerfile"]
path = helix-syntax/languages/tree-sitter-dockerfile
url = https://github.com/camdencheek/tree-sitter-dockerfile.git
shallow = true
shallow = true
[submodule "helix-syntax/languages/tree-sitter-fish"]
path = helix-syntax/languages/tree-sitter-fish
url = https://github.com/ram02z/tree-sitter-fish
shallow = true
[submodule "helix-syntax/languages/tree-sitter-git-commit"]
path = helix-syntax/languages/tree-sitter-git-commit
url = https://github.com/the-mikedavis/tree-sitter-git-commit.git
shallow = true
4 changes: 4 additions & 0 deletions base16_theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
"namespace" = "magenta"
"ui.help" = { fg = "white", bg = "black" }

"diff.plus" = "green"
"diff.delta" = "yellow"
"diff.minus" = "red"

"diagnostic" = { modifiers = ["underlined"] }
"ui.gutter" = { bg = "black" }
"info" = "blue"
Expand Down
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
| dockerfile | ✓ | | | `docker-langserver` |
| elixir | ✓ | | | `elixir-ls` |
| fish | ✓ | ✓ | ✓ | |
| git-commit | ✓ | | | |
| glsl | ✓ | | ✓ | |
| go | ✓ | ✓ | ✓ | `gopls` |
| html | ✓ | | | |
Expand Down
6 changes: 6 additions & 0 deletions book/src/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ We use a similar set of scopes as
- `inline`
- `block`

- `diff` - version control changes
- `plus` - additions
- `minus` - deletions
- `delta` - modifications
- `moved` - renamed or moved files/changes

#### Interface

These scopes are used for theming the editor interface.
Expand Down
1 change: 1 addition & 0 deletions helix-syntax/languages/tree-sitter-git-commit
Submodule tree-sitter-git-commit added at 5cd477
8 changes: 8 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -473,3 +473,11 @@ file-types = ["Dockerfile", "dockerfile"]
comment-token = "#"
indent = { tab-width = 2, unit = " " }
language-server = { command = "docker-langserver", args = ["--stdio"] }

[[language]]
name = "git-commit"
scope = "git.commitmsg"
roots = []
file-types = ["COMMIT_EDITMSG"]
comment-token = "#"
indent = { tab-width = 2, unit = " " }
19 changes: 19 additions & 0 deletions runtime/queries/git-commit/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(subject) @markup.heading
(path) @string.special.path
(branch) @string.special.symbol
(commit) @constant
(item) @markup.link.url
(header) @tag
(rebase_command) @markup.raw

(change kind: "new file" @diff.plus)
(change kind: "deleted" @diff.minus)
(change kind: "modified" @diff.delta)
(change kind: "renamed" @diff.delta.moved)

[":" "->"] @punctuation.delimeter
(comment) @comment

; once we have diff injections, @comment should become @none
((comment (scissors))
(message)+ @comment)
15 changes: 15 additions & 0 deletions runtime/queries/git-commit/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
; once a diff grammar is available, we can inject diff highlighting into the
; trailer after scissors (git commit --verbose)
; see https://github.com/helix-editor/helix/pull/1338#issuecomment-1000013539
;
; ((comment (scissors))
; (message) @injection.content
; (#set! injection.language "diff"))

; ---

; once a rebase grammar is available, we can inject rebase highlighting into
; interactive rebase summary sections like so:
;
; ((rebase_command) @injection.content
; (#set! injection.language "git-rebase"))
4 changes: 4 additions & 0 deletions runtime/themes/base16_default_dark.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
"namespace" = "base0E"
"ui.help" = { fg = "base06", bg = "base01" }

"diff.plus" = "base0B"
"diff.delta" = "base09"
"diff.minus" = "base08"

"diagnostic" = { modifiers = ["underlined"] }
"ui.gutter" = { bg = "base01" }
"info" = "base0D"
Expand Down
4 changes: 4 additions & 0 deletions runtime/themes/base16_default_light.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
"namespace" = "base0E"
"ui.help" = { fg = "base06", bg = "base01" }

"diff.plus" = "base0B"
"diff.delta" = "base09"
"diff.minus" = "base08"

"diagnostic" = { modifiers = ["underlined"] }
"ui.gutter" = { bg = "base01" }
"info" = "base0D"
Expand Down
4 changes: 4 additions & 0 deletions runtime/themes/base16_terminal.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
"namespace" = "light-magenta"
"ui.help" = { fg = "white", bg = "black" }

"diff.plus" = "light-green"
"diff.delta" = "yellow"
"diff.minus" = "light-red"

"diagnostic" = { modifiers = ["underlined"] }
"ui.gutter" = { bg = "black" }
"info" = "light-blue"
Expand Down
4 changes: 4 additions & 0 deletions runtime/themes/bogster.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@

"module" = "#d32c5d"

"diff.plus" = "#59dcb7"
"diff.delta" = "#dc7759"
"diff.minus" = "#dc597f"

"ui.background" = { bg = "#161c23" }
"ui.linenr" = { fg = "#415367" }
"ui.linenr.selected" = { fg = "#e5ded6" } # TODO
Expand Down
4 changes: 4 additions & 0 deletions runtime/themes/dark_plus.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
"constant.numeric" = { fg = "pale_green" }
"constant.character.escape" = { fg = "gold" }

"diff.plus" = { fg = "pale_green" }
"diff.delta" = { fg = "gold" }
"diff.minus" = { fg = "red" }

"ui.background" = { fg = "light_gray", bg = "dark_gray2" }

"ui.window" = { bg = "widget" }
Expand Down
4 changes: 4 additions & 0 deletions runtime/themes/dracula.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"variable.builtin" = { fg = "cyan", modifiers = ["italic"] }
"variable.parameter" = { fg ="orange", modifiers = ["italic"] }

"diff.plus" = { fg = "green" }
"diff.delta" = { fg = "orange" }
"diff.minus" = { fg = "red" }

"ui.background" = { fg = "foreground", bg = "background" }
"ui.cursor" = { fg = "background", bg = "orange", modifiers = ["dim"] }
"ui.cursor.match" = { fg = "green", modifiers = ["underlined"] }
Expand Down
4 changes: 4 additions & 0 deletions runtime/themes/everforest_dark.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
"module" = "blue"
"special" = "orange"

"diff.plus" = "green"
"diff.delta" = "orange"
"diff.minus" = "red"

"ui.background" = { bg = "bg0" }
"ui.cursor" = { fg = "bg0", bg = "fg" }
"ui.cursor.match" = { fg = "orange", bg = "bg_yellow" }
Expand Down
4 changes: 4 additions & 0 deletions runtime/themes/gruvbox.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
"label" = "aqua1"
"module" = "aqua1"

"diff.plus" = "green1"
"diff.delta" = "orange1"
"diff.minus" = "red1"

"warning" = { fg = "orange1", bg = "bg1" }
"error" = { fg = "red1", bg = "bg1" }
"info" = { fg = "aqua1", bg = "bg1" }
Expand Down
4 changes: 4 additions & 0 deletions runtime/themes/ingrid.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@

"module" = "#839A53"

"diff.plus" = "#839A53"
"diff.delta" = "#D4A520"
"diff.minus" = "#D74E50"

"ui.background" = { bg = "#FFFCFD" }
"ui.linenr" = { fg = "#bbbbbb" }
"ui.linenr.selected" = { fg = "#F3EAE9" } # TODO
Expand Down
6 changes: 5 additions & 1 deletion runtime/themes/monokai.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
"constant.numeric" = { fg = "#ae81ff" }
"constant.character.escape" = { fg = "#ae81ff" }

"diff.plus" = { fg = "#a6e22e" }
"diff.delta" = { fg = "#fd971f" }
"diff.minus" = { fg = "#f92672" }

"ui.background" = { fg = "text", bg = "background" }

"ui.window" = { bg = "widget" }
Expand All @@ -65,7 +69,7 @@
"warning" = { fg = "#cca700" }
"error" = { fg = "#f48771" }
"info" = { fg = "#75beff" }
"hint" = { fg = "#eeeeeeb3" }
"hint" = { fg = "#eeeeeb3" }

diagnostic = { modifiers = ["underlined"] }

Expand Down
5 changes: 5 additions & 0 deletions runtime/themes/monokai_pro.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
# integer, floating point
"constant.numeric" = "purple"

# vcs
"diff.plus" = "green"
"diff.delta" = "orange"
"diff.minus" = "red"

# make diagnostic underlined, to distinguish with selection text.
diagnostic = { modifiers = ["underlined"] }

Expand Down
5 changes: 5 additions & 0 deletions runtime/themes/monokai_pro_machine.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
# integer, floating point
"constant.numeric" = "purple"

# vcs
"diff.plus" = "green"
"diff.delta" = "orange"
"diff.minus" = "red"

# make diagnostic underlined, to distinguish with selection text.
diagnostic = { modifiers = ["underlined"] }

Expand Down
5 changes: 5 additions & 0 deletions runtime/themes/monokai_pro_octagon.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
# integer, floating point
"constant.numeric" = "purple"

# vcs
"diff.plus" = "green"
"diff.delta" = "orange"
"diff.minus" = "red"

# make diagnostic underlined, to distinguish with selection text.
diagnostic = { modifiers = ["underlined"] }

Expand Down
5 changes: 5 additions & 0 deletions runtime/themes/monokai_pro_ristretto.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
# integer, floating point
"constant.numeric" = "purple"

# vcs
"diff.plus" = "green"
"diff.delta" = "orange"
"diff.minus" = "red"

# make diagnostic underlined, to distinguish with selection text.
diagnostic = { modifiers = ["underlined"] }

Expand Down
5 changes: 5 additions & 0 deletions runtime/themes/monokai_pro_spectrum.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
# integer, floating point
"constant.numeric" = "purple"

# vcs
"diff.plus" = "green"
"diff.delta" = "orange"
"diff.minus" = "red"

# make diagnostic underlined, to distinguish with selection text.
diagnostic = { modifiers = ["underlined"] }

Expand Down
5 changes: 5 additions & 0 deletions runtime/themes/nord.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
# nord15 - integer, floating point
"constant.numeric" = "nord15"

# vcs
"diff.plus" = "nord14"
"diff.delta" = "nord12"
"diff.minus" = "nord11"

[palette]
nord0 = "#2e3440"
nord1 = "#3b4252"
Expand Down
4 changes: 4 additions & 0 deletions runtime/themes/onedark.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
"markup.link.url" = { fg = "cyan", modifiers = ["underlined"]}
"markup.link.label" = { fg = "purple" }

"diff.plus" = "green"
"diff.delta" = "gold"
"diff.minus" = "red"

diagnostic = { modifiers = ["underlined"] }
"info" = { fg = "blue", modifiers = ["bold"] }
"hint" = { fg = "green", modifiers = ["bold"] }
Expand Down
3 changes: 3 additions & 0 deletions runtime/themes/rose_pine.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
"ui.window" = { bg = "base" }
"ui.help" = { bg = "overlay", fg = "foam" }
"text" = "text"
"diff.plus" = "foam"
"diff.delta" = "rose"
"diff.minus" = "love"

"info" = "gold"
"hint" = "gold"
Expand Down
3 changes: 3 additions & 0 deletions runtime/themes/rose_pine_dawn.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
"ui.window" = { bg = "base" }
"ui.help" = { bg = "overlay", fg = "foam" }
"text" = "text"
"diff.plus" = "foam"
"diff.delta" = "rose"
"diff.minus" = "love"

"info" = "gold"
"hint" = "gold"
Expand Down
4 changes: 4 additions & 0 deletions runtime/themes/solarized_dark.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
"module" = { fg = "violet" }
"tag" = { fg = "magenta" }

"diff.plus" = { fg = "green" }
"diff.delta" = { fg = "orange" }
"diff.minus" = { fg = "red" }

# 背景
"ui.background" = { bg = "base03" }

Expand Down
4 changes: 4 additions & 0 deletions runtime/themes/solarized_light.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
"module" = { fg = "violet" }
"tag" = { fg = "magenta" }

"diff.plus" = { fg = "green" }
"diff.delta" = { fg = "orange" }
"diff.minus" = { fg = "red" }

# 背景
"ui.background" = { bg = "base03" }

Expand Down
4 changes: 4 additions & 0 deletions runtime/themes/spacebones_light.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
"label" = "#b1951d"
"module" = "#b1951d"

"diff.plus" = "#2d9574"
"diff.delta" = "#715ab1"
"diff.minus" = "#ba2f59"

"warning" = { fg = "#da8b55" }
"error" = { fg = "#e0211d" }
"info" = { fg = "#b1951d" }
Expand Down
4 changes: 4 additions & 0 deletions theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ label = "honey"
"markup.link.url" = { fg = "silver", modifiers = ["underlined"] }
"markup.raw" = "almond"

"diff.plus" = "#35bf86"
"diff.minus" = "#f22c86"
"diff.delta" = "#6f44f0"

# TODO: diferentiate doc comment
# concat (ERROR) @error.syntax and "MISSING ;" selectors for errors

Expand Down