Skip to content

Commit

Permalink
Add gitnote syntax highlighter, for git notes add format
Browse files Browse the repository at this point in the history
  • Loading branch information
craigbarnes committed Dec 24, 2024
1 parent 96facb9 commit 81464a7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
2 changes: 1 addition & 1 deletion config/rc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ft -f dte '/(\.|dot_)?dte/(config/)?(rc|((syntax|color|binding|compiler)/.*))$'
ft -f mail '/tmpmsg-.*\.txt$|pico\.[0-9]+|/tmp/mutt(ng)?-'

# Don't remember cursor position for git temporary files
option gitcommit,gitrebase file-history false
option gitcommit,gitnote,gitrebase file-history false
option -r '/\.git/.*\.diff$' file-history false

# Try to detect indent settings based on existing file contents
Expand Down
27 changes: 27 additions & 0 deletions config/syntax/gitnote
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Highlighter for NOTES_EDITMSG files (`git notes add` format)
syntax gitnote

state start text
char # comment-start
noeat text

state text
char "\n" start
eat this

state comment-start comment
char "\n" start
str ' commit ' commit-id commit-prefix
eat comment

state comment
char "\n" start
eat this

state commit-id
char 0-9A-Fa-f this
char "\n" start
noeat comment

default string commit-id
default comment commit-prefix
10 changes: 5 additions & 5 deletions mk/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ VERSION = $(shell mk/version.sh 1.11.1)

BUILTIN_SYNTAX_FILES ?= \
awk c coccinelle config css ctags d diff docker dte gcode gitblame \
gitcommit gitignore gitlog gitrebase gitstash go gomod html haskell \
ini java javascript json lisp lua mail make markdown meson nftables \
nginx ninja php python robotstxt roff ruby scheme sed sh sql tex \
texmfcnf tmux vala weechatlog xml xresources zig inc/c-comment \
inc/c-uchar inc/diff
gitcommit gitignore gitlog gitnote gitrebase gitstash go gomod html \
haskell ini java javascript json lisp lua mail make markdown meson \
nftables nginx ninja php python robotstxt roff ruby scheme sed sh \
sql tex texmfcnf tmux vala weechatlog xml xresources zig \
inc/c-comment inc/c-uchar inc/diff

BUILTIN_CONFIGS = $(addprefix config/, \
rc binding/default compiler/gcc compiler/go \
Expand Down
1 change: 1 addition & 0 deletions src/filetype/basenames.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ static const struct FileBasenameMap {
{"Makefile", MAKE, false},
{"Makefile.am", MAKE, false},
{"Makefile.in", MAKE, false},
{"NOTES_EDITMSG", GITNOTE, false},
{"PKGBUILD", SH, false},
{"Pipfile", TOML, false},
{"Pipfile.lock", JSON, false},
Expand Down
2 changes: 2 additions & 0 deletions src/filetype/names.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ typedef enum {
GITCOMMIT,
GITIGNORE,
GITLOG,
GITNOTE,
GITREBASE,
GITSTASH,
GLSL,
Expand Down Expand Up @@ -158,6 +159,7 @@ static const char builtin_filetype_names[NR_BUILTIN_FILETYPES][12] = {
[GITCOMMIT] = "gitcommit",
[GITIGNORE] = "gitignore",
[GITLOG] = "gitlog",
[GITNOTE] = "gitnote",
[GITREBASE] = "gitrebase",
[GITSTASH] = "gitstash",
[GLSL] = "glsl",
Expand Down

0 comments on commit 81464a7

Please sign in to comment.