git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
	Emily Shaffer <emilyshaffer@google.com>,
	"Brian M. Carlson" <sandals@crustytoothpaste.net>,
	Aaron Schrab <aaron@schrab.com>,
	Denton Liu <liu.denton@gmail.com>,
	Christian Couder <christian.couder@gmail.com>,
	Felipe Contreras <felipe.contreras@gmail.com>
Subject: [PATCH v2 2/2] contrib: vim: add sharness syntax file
Date: Wed,  9 Dec 2020 00:55:37 -0600	[thread overview]
Message-ID: <20201209065537.48802-3-felipe.contreras@gmail.com> (raw)
In-Reply-To: <20201209065537.48802-1-felipe.contreras@gmail.com>

It gets a bit tedious to see all the tests in the same color, so I
wrote a vim syntax file to relax my eyes.

I've tried to make it work in as many situations as possible, yet there
are still some issues with HEREDOC strings.

Much better than nothing though.

This can be enabled with the following pattern:

  au BufRead,BufNewFile */t/*.sh set filetype=sh.sharness

Whoever, that's already added to the project .vimrc.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 .vimrc                          |  1 +
 contrib/vim/syntax/sharness.vim | 34 +++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)
 create mode 100644 contrib/vim/syntax/sharness.vim

diff --git a/.vimrc b/.vimrc
index 602c746477..31600aaeca 100644
--- a/.vimrc
+++ b/.vimrc
@@ -11,6 +11,7 @@
 "
 
 augroup git
+	au BufRead,BufNewFile */t/*.sh set filetype=sh.sharness
 	au BufRead,BufNewFile */Documentation/*.txt set filetype=asciidoc
 
 	au FileType c setl noexpandtab tabstop=8 shiftwidth=0 cino=(s,:0,l1,t0
diff --git a/contrib/vim/syntax/sharness.vim b/contrib/vim/syntax/sharness.vim
new file mode 100644
index 0000000000..6ffc64ff06
--- /dev/null
+++ b/contrib/vim/syntax/sharness.vim
@@ -0,0 +1,34 @@
+let b:is_bash=1
+runtime! syntax/sh.vim
+
+syn keyword shsStatement test_done
+syn keyword shsStatement test_set_editor test_set_index_version test_decode_color lf_to_nul nul_to_q q_to_nul q_to_cr q_to_tab qz_to_tab_space append_cr remove_cr generate_zero_bytes sane_unset test_tick test_pause debug test_commit test_merge test_commit_bulk test_chmod test_modebits test_unconfig test_config test_config_global write_script test_unset_prereq test_set_prereq test_have_prereq test_declared_prereq test_verify_prereq test_external test_external_without_stderr test_path_is_file test_path_is_dir test_path_exists test_dir_is_empty test_file_not_empty test_path_is_missing test_line_count test_file_size list_contains test_must_fail_acceptable test_must_fail test_might_fail test_expect_code test_i18ncmp test_i18ngrep verbose test_must_be_empty test_cmp_rev test_cmp_fspath test_seq test_when_finished test_atexit test_create_repo test_ln_s_add test_write_lines perl test_bool_env test_skip_or_die mingw_test_cmp test_env test_match_signal test_copy_bytes nongit depacketize hex2oct test_set_hash test_detect_hash test_oid_init test_oid_cache test_oid test_oid_to_path test_set_port test_bitmap_traversal test_path_is_hidden test_subcommand
+syn keyword shsStatement test_cmp test_cmp_config test_cmp_bin packetize
+
+syn region shsTest fold start="\<test_expect_\w\+\>" end="$" contains=shsTestTitle
+syn region shsTest fold start="\<test_expect_\w\+\>\s\+\<[A-Z_,]\+\>" end="$" contains=shsPrereq
+syn region shsTest fold start="\<test_lazy_prereq\>\s\+\<[A-Z_,]\+\>" end="$" contains=shsPrereqLazy
+
+syn keyword shsTestStatement contained containedin=shsTest test_expect_success test_expect_failure test_expect_unstable test_lazy_prereq
+
+syn region shsTestTitle contained start=' 'hs=s+1 end=' 'me=e-1 nextgroup=shsTestBody contains=shSingleQuote,shDoubleQuote
+
+" multiple line body
+syn region shsTestBody contained transparent excludenl matchgroup=shQuote start=+ '$+hs=s+1,rs=e end=+'$+ contains=@shSubShList
+syn region shsTestBody contained transparent excludenl matchgroup=shQuote start=+ "$+hs=s+1,rs=e end=+"$+ contains=@shSubShList
+
+" single line body
+syn region shsTestBody contained oneline transparent excludenl keepend matchgroup=shQuote start=+ '+hs=s+1 end=+'$+ contains=@shSubShList
+syn region shsTestBody contained oneline transparent excludenl keepend matchgroup=shQuote start=+ "+hs=s+1 end=+"$+ contains=@shSubShList
+
+syn match shsPrereq contained "\<[A-Z_,]\+\>" nextgroup=shsTestTitle
+syn match shsPrereqLazy contained "\<[A-Z_,]\+\>" nextgroup=shsTestBody
+
+syn cluster shCommandSubList add=shsTest,shsStatement
+
+hi def link shsStatement Statement
+hi def link shsTestStatement Function
+hi def link shsPrereq Identifier
+hi def link shsPrereqLazy shsPrereq
+
+let b:current_syntax='sharness'
-- 
2.29.2


  parent reply	other threads:[~2020-12-09  6:56 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-09  6:55 [PATCH v2 0/2] vim: configuration and sharness syntax Felipe Contreras
2020-12-09  6:55 ` [PATCH v2 1/2] Add project-wide .vimrc configuration Felipe Contreras
2020-12-09  8:53   ` Christian Brabandt
2020-12-09 10:29     ` Felipe Contreras
2020-12-09 10:45       ` Christian Brabandt
2020-12-09 17:27   ` Jeff King
2020-12-10  1:55     ` Felipe Contreras
2020-12-10 15:27       ` Jeff King
2020-12-11  0:43         ` Felipe Contreras
2020-12-10  3:50   ` brian m. carlson
2020-12-11  1:08     ` Felipe Contreras
2020-12-11  2:56       ` brian m. carlson
2020-12-11  4:37         ` Felipe Contreras
2020-12-15  1:39         ` Jeff King
2020-12-15  3:03           ` Felipe Contreras
2020-12-15  5:28             ` Jeff King
2020-12-15  6:56               ` Felipe Contreras
2020-12-09  6:55 ` Felipe Contreras [this message]
2020-12-09  7:05   ` [PATCH v2 2/2] contrib: vim: add sharness syntax file Eric Sunshine
2020-12-09 10:39     ` Felipe Contreras
2020-12-09 17:11 ` [PATCH v2 0/2] vim: configuration and sharness syntax Jeff King
2020-12-10  3:25   ` Felipe Contreras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201209065537.48802-3-felipe.contreras@gmail.com \
    --to=felipe.contreras@gmail.com \
    --cc=aaron@schrab.com \
    --cc=christian.couder@gmail.com \
    --cc=emilyshaffer@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=liu.denton@gmail.com \
    --cc=peff@peff.net \
    --cc=sandals@crustytoothpaste.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).