From patchwork Wed Dec 9 06:55:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11960621 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE27FC4167B for ; Wed, 9 Dec 2020 06:56:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AFCAB23B87 for ; Wed, 9 Dec 2020 06:56:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728294AbgLIG4a (ORCPT ); Wed, 9 Dec 2020 01:56:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728203AbgLIG4V (ORCPT ); Wed, 9 Dec 2020 01:56:21 -0500 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9009C0613D6 for ; Tue, 8 Dec 2020 22:55:41 -0800 (PST) Received: by mail-ot1-x343.google.com with SMTP id x13so379880oto.8 for ; Tue, 08 Dec 2020 22:55:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GfYHWyRvIh2oUB6/eVHCclMi+/CNBRGdLL5osas3gIE=; b=txt9jzbBXJmdBwor26fPXbRDUUGosQHbPF7ebDTZ3Y6jsEbKn4+WgCyoYyx5UFAi7H WAsok5TJC+T+Zl9tcJ7PCY8wYZ8jbJKeztanbw6t5+3Rp8yJd1VnpW5Izl4sJ1LIsi1b I1RIFfGaz3bjFRwXzZtIQeLI7c+q5JuUTM0rLlqWl+BXKR4AR20HFprN+H5062FSC+Fb DABHq7Vwzz95zhV9MoTN4YrpjW7FQzU0FFoq6KOQdnBF5czFwi1grK3ONsag9PbQRdIV hIlX4TlzXAKnPU8wXSWw0PPp/yy9pGPF76T3GX+qH4W70DRa4wn/ZsVTXoliNiNiUZz9 +Gbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GfYHWyRvIh2oUB6/eVHCclMi+/CNBRGdLL5osas3gIE=; b=rUMDz46f2Pe/iJZQRcVBOTPCW8QagOdVWBWVl2w/CR/jjcP2RzdYwcPg8mOfJC+GWx sKTnvazyGzCs4xI7RJPjE8Xa8u+49Gt7n8vLPiq22lDUX+kNL/QLfwttS7SeH3TYSvpg qa5GCAMJNELrzDjh3wgk4MJoZdBnTP6fdhUvI5qe4Job6XymX7l3tDNzwVWNPv6sqfNT qm9DQzlwunF+rz/U7PMMOw8/AucJ43U3QefG0M7RTLhSnMXkkaLMx3OtdsIryGtyXH5l IN8BgcmoLTz51f8c3f+AceM+7+vUf8PzZ44R94U36OP7U/ydCPuXi9AwngNiDnMKw2iz L+AQ== X-Gm-Message-State: AOAM53241weDg1s6fjL/wX6N+ZY1MU/x4nadO3LwY5NweawVvCvEWUkY f3OtEMJj4c8ns7b8yPyzu/JUiGOGIvlVrw== X-Google-Smtp-Source: ABdhPJwzYyHjj427ulR8eGMTX78gQ1xltTj25fjzh2Ugu0iyzmCIzqgBJnHnFuCw8GS9JCpjaWjj2w== X-Received: by 2002:a9d:802:: with SMTP id 2mr636279oty.62.1607496940973; Tue, 08 Dec 2020 22:55:40 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id f10sm215959oti.11.2020.12.08.22.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 22:55:40 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Emily Shaffer , "Brian M. Carlson" , Aaron Schrab , Denton Liu , Christian Couder , Felipe Contreras Subject: [PATCH v2 1/2] Add project-wide .vimrc configuration Date: Wed, 9 Dec 2020 00:55:36 -0600 Message-Id: <20201209065537.48802-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201209065537.48802-1-felipe.contreras@gmail.com> References: <20201209065537.48802-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org It's not efficient that everyone must set specific configurations in all their ~/.vimrc files; we can have a project-wide .vimrc that everyone can use. There's different ways to load this configuration, for example with vim-addon-local-vimrc [1], but we don't need much of the complexity of these solutions. Instead I created a simple loader that is in the contrib area, which can be installed with: cp -aT contrib/vim ~/.vim/pack/plugins/start/git Then, add the location of the Git repository to your ~/.vimrc: let g:gitvimrc_whitelist = [ expand('$HOME') . '/dev/git' ] Then the project-wide configuration will be loaded, which sets the correct filetype for the documentation, and also the default indentation of c, sh, perl, and asciidoc files. These default configurations can be overridden in the typical way (by adding the corresponding file in ~/.vim/after/ftplugin). We could add the vim modelines at the bottom of every file, like other projects do, but this seems more sensible. [1] https://github.com/MarcWeber/vim-addon-local-vimrc Signed-off-by: Felipe Contreras --- .vimrc | 22 ++++++++++++++++++++++ contrib/vim/plugin/gitvimrc.vim | 21 +++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 .vimrc create mode 100644 contrib/vim/plugin/gitvimrc.vim diff --git a/.vimrc b/.vimrc new file mode 100644 index 0000000000..602c746477 --- /dev/null +++ b/.vimrc @@ -0,0 +1,22 @@ +" To make use of these configurations install the git plugin provided in +" the contrib section: +" +" cp -aT contrib/vim ~/.vim/pack/plugins/start/git +" +" Then whitelist the location of this directory to your ~/.vimrc: +" +" let g:gitvimrc_whitelist = [ expand('$HOME') . '/dev/git' ] +" +" You can add multiple locations, or specify a regexp pattern. +" + +augroup git + au BufRead,BufNewFile */Documentation/*.txt set filetype=asciidoc + + au FileType c setl noexpandtab tabstop=8 shiftwidth=0 cino=(s,:0,l1,t0 + au FileType sh setl noexpandtab tabstop=8 shiftwidth=0 + au FileType perl setl noexpandtab tabstop=8 shiftwidth=0 + au FileType asciidoc setl noexpandtab tabstop=8 shiftwidth=0 autoindent +augroup END + +" vim: noexpandtab tabstop=8 shiftwidth=0 diff --git a/contrib/vim/plugin/gitvimrc.vim b/contrib/vim/plugin/gitvimrc.vim new file mode 100644 index 0000000000..c3946e5410 --- /dev/null +++ b/contrib/vim/plugin/gitvimrc.vim @@ -0,0 +1,21 @@ +let s:gitvimrc_whitelist = get(g:, 'gitvimrc_whitelist', []) + +function LoadGitVimrc() + let l:top = trim(system('git rev-parse --show-toplevel')) + if l:top == '' | return | endif + let l:file = l:top . '/.vimrc' + if !filereadable(l:file) | return | endif + + let l:found = 0 + for l:pattern in s:gitvimrc_whitelist + if (match(l:top, l:pattern) != -1) + let l:found = 1 + break + endif + endfor + if !l:found | return | endif + + exec 'source ' . fnameescape(l:file) +endf + +call LoadGitVimrc() From patchwork Wed Dec 9 06:55:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11960623 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15603C4361B for ; Wed, 9 Dec 2020 06:56:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D557523B84 for ; Wed, 9 Dec 2020 06:56:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728290AbgLIG4a (ORCPT ); Wed, 9 Dec 2020 01:56:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728287AbgLIG4Y (ORCPT ); Wed, 9 Dec 2020 01:56:24 -0500 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8970C061793 for ; Tue, 8 Dec 2020 22:55:43 -0800 (PST) Received: by mail-ot1-x344.google.com with SMTP id b18so405765ots.0 for ; Tue, 08 Dec 2020 22:55:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6XcDULwjuUAB1ZjqP9P+uO0FTelX6YwLh029u9+CV5o=; b=Qo9kWJRjWH8jhgzdGoywMhBrWMWSFNjxCYupdxnDlC/U1VSxJ/N82GigyHKcOx0U4y UM7P/4KQrbkKG73zGfVsF+02mj/joHQF42jQoC0HtFanqbMFlnXRT52ct5vgdHE+Ect7 3//35HJc7dSRjJ7t9/31w1qBqb96sWazmFZMnSvORG9B0qf9kJgf0fwSC/ehYCZxPvIC pPlyFw4LTOQACIeRPKa40IHQVF+yejXj6jDPoZYija07oAFt0Wb9+EVP/rbTiYqNYHbO Rz6mpcBl4W6/28EJxntY7JmT2I7dAx7r2jqysmRqkzMnPoQA5Y3wsL570heVgGEP/Wa8 fbOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6XcDULwjuUAB1ZjqP9P+uO0FTelX6YwLh029u9+CV5o=; b=mC3sVLaMExeRps8YU3oF8aQ/zgoZ7DaoIsS/bxZ5iwQqdump1ds9T4fyFQSnBJoZhF Kyy2QyOuHsZWoGzXmGz3jrG8QNUMANhc+vM/794Ei74sIW0MiT0xEn0/rO46By7GWjGI 5jsBBdTwWW3wFbDSyF0Mey6Io5jjZWUkDzbF6WF+wvs809m0hCGA3vzaEktSEa3Tb7uv AbudbfPhGCO79eJGCADZrLzhIoQ7vB1/E7NusaR5fxDeaBuBeWKt93OMdlw98Ne43bd1 7aHLKktlb6/xm6rn1Us098xgCpoE2M3+lHMIxTS6tRkF+88x/+Gpu7JBz6LfQe/kloVx Q6Ew== X-Gm-Message-State: AOAM533pAT47T2yHuna6g7UdTvCsa/OwWUbNdbKUKtgRE18z9LnSp8OA mg6KtvU1HZ+zJY3cTPFSEME8W4CksQ32PA== X-Google-Smtp-Source: ABdhPJx7qfFRjRjOi5dvCU5VLZnLdXt8XmsymwJWn+qD1pSRK8yg95wZOxp71bqIBFz16Qfyco2Mkg== X-Received: by 2002:a9d:39f5:: with SMTP id y108mr597805otb.63.1607496943061; Tue, 08 Dec 2020 22:55:43 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id a24sm156857oop.40.2020.12.08.22.55.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 22:55:42 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Emily Shaffer , "Brian M. Carlson" , Aaron Schrab , Denton Liu , Christian Couder , Felipe Contreras Subject: [PATCH v2 2/2] contrib: vim: add sharness syntax file Date: Wed, 9 Dec 2020 00:55:37 -0600 Message-Id: <20201209065537.48802-3-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201209065537.48802-1-felipe.contreras@gmail.com> References: <20201209065537.48802-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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 --- .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="\" end="$" contains=shsTestTitle +syn region shsTest fold start="\\s\+\<[A-Z_,]\+\>" end="$" contains=shsPrereq +syn region shsTest fold start="\\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'