public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Yury Gribov <y.gribov@samsung.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Laurynas Biveinis <laurynas.biveinis@gmail.com>,
	Jeff Law <law@redhat.com>,
	Segher Boessenkool <segher@kernel.crashing.org>,
	Richard Biener <richard.guenther@gmail.com>,
	Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>,
	Trevor Saunders <tsaunders@mozilla.com>,
	Mike Stump <mikestump@comcast.net>
Subject: [PATCHv5] Vimrc config with GNU formatting
Date: Thu, 02 Oct 2014 17:14:00 -0000	[thread overview]
Message-ID: <542D87DB.1080907@samsung.com> (raw)
In-Reply-To: <5419C01C.2040404@samsung.com>

[-- Attachment #1: Type: text/plain, Size: 1358 bytes --]

On 09/17/2014 09:08 PM, Yury Gribov wrote:
 > On 09/16/2014 08:38 PM, Yury Gribov wrote:
 >> Hi all,
 >>
 >> This is the third version of the patch. A list of changes since last
 >> version:
 >> * move config to contrib so that it's _not_ enabled by default (current
 >> score is 2/1 in favor of no Vim config by default)
 >> * update Makefile.in to make .local.vimrc if developer asks for it
 >> * disable autoformatting for flex files
 >> * fix filtering of non-GNU sources (libsanitizer)
 >> * added some small fixes in cinoptions based on feedback from community
 >>
 >> As noted by Richard, the config does not do a good job of formatting
 >> unbound {} blocks e.g.
 >> void
 >> foo ()
 >> {
 >>    int x;
 >>      {
 >>        // I'm an example of bad bad formatting
 >>      }
 >> }
 >> but it seems to be the best we can get with Vim's cindent
 >> (and I don't think anyone seriously considers writing a custom
 >> indentexpr).
 >>
 >> Ok to commit?
 >
 > New vesion with support for another popular local .vimrc plugin.

Hi all,

Here is a new vesion of vimrc patch. Hope I got email settings right 
this time.

Changes since v4:
* fixed and enhanced docs
* added support for .lvimrc in Makefile
* minor fixes in cinoptions and formatoptions (reported by Segher)
* removed shiftwidth settings (as it does not really relate to code 
formatting)

-Y


[-- Attachment #2: local-vimrc-5.diff --]
[-- Type: text/x-patch, Size: 3602 bytes --]

commit 3f560e9dd16a5e914b6f2ba82edffe13dfde944c
Author: Yury Gribov <y.gribov@samsung.com>
Date:   Thu Oct 2 15:50:52 2014 +0400

    2014-10-02  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
    	    Yury Gribov  <y.gribov@samsung.com>
    
    Vim config with GNU formatting.
    
    contrib/
    	* vimrc: New file.
    
    /
    	* .gitignore: Added .local.vimrc and .lvimrc.
    	* Makefile.tpl (vimrc, .lvimrc, .local.vimrc): New targets.
    	* Makefile.in: Regenerate.

diff --git a/.gitignore b/.gitignore
index e9b56be..ab97ac6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,6 +32,9 @@ POTFILES
 TAGS
 TAGS.sub
 
+.local.vimrc
+.lvimrc
+
 .gdbinit
 .gdb_history
 
diff --git a/Makefile.in b/Makefile.in
index d6105b3..f3a34af 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -2384,6 +2384,18 @@ mail-report-with-warnings.log: warning.log
 	chmod +x $@
 	echo If you really want to send e-mail, run ./$@ now
 
+# Local Vim config
+
+$(srcdir)/.local.vimrc:
+	$(LN_S) $(srcdir)/contrib/vimrc $@
+
+$(srcdir)/.lvimrc:
+	$(LN_S) $(srcdir)/contrib/vimrc $@
+
+vimrc: $(srcdir)/.local.vimrc $(srcdir)/.lvimrc
+
+.PHONY: vimrc
+
 # Installation targets.
 
 .PHONY: install uninstall
diff --git a/Makefile.tpl b/Makefile.tpl
index f7c7e38..b98930c 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -867,6 +867,18 @@ mail-report-with-warnings.log: warning.log
 	chmod +x $@
 	echo If you really want to send e-mail, run ./$@ now
 
+# Local Vim config
+
+$(srcdir)/.local.vimrc:
+	$(LN_S) $(srcdir)/contrib/vimrc $@
+
+$(srcdir)/.lvimrc:
+	$(LN_S) $(srcdir)/contrib/vimrc $@
+
+vimrc: $(srcdir)/.local.vimrc $(srcdir)/.lvimrc
+
+.PHONY: vimrc
+
 # Installation targets.
 
 .PHONY: install uninstall
diff --git a/contrib/vimrc b/contrib/vimrc
new file mode 100644
index 0000000..34e8f35
--- /dev/null
+++ b/contrib/vimrc
@@ -0,0 +1,45 @@
+" Code formatting settings for Vim.
+"
+" To enable this for GCC files by default, you can either source this file
+" in your .vimrc via autocmd:
+"   :au BufNewFile,BufReadPost path/to/gcc/* :so path/to/gcc/contrib/vimrc
+" or source the script manually for each newly opened file:
+"   :so contrib/vimrc
+" You could also use numerous plugins that enable local vimrc e.g.
+" mbr's localvimrc or thinca's vim-localrc (but note that the latter
+" is much less secure). To install local vimrc config, run
+"   $ make vimrc
+" from GCC build folder.
+" 
+" Copyright (C) 2014 Free Software Foundation, Inc.
+"
+" This program is free software; you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation; either version 3 of the License, or
+" (at your option) any later version.
+"
+" This program is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+function! SetStyle()
+  let l:fname = expand("%:p")
+  if stridx(l:fname, 'libsanitizer') != -1
+    return
+  endif
+  let l:ext = fnamemodify(l:fname, ":e")
+  let l:c_exts = ['c', 'h', 'cpp', 'cc', 'C', 'H', 'def', 'java']
+  if index(l:c_exts, l:ext) != -1
+    setlocal cindent
+    setlocal softtabstop=2
+    setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,f0,h2,p4,t0,+2,(0,u0,w1,m0
+    setlocal textwidth=80
+    setlocal formatoptions-=ro formatoptions+=cqlt
+  endif
+endfunction
+
+call SetStyle()

  parent reply	other threads:[~2014-10-02 17:14 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-04 13:06 Yury Gribov
2014-09-04 13:22 ` Richard Biener
2014-09-04 20:23   ` Bernhard Reutner-Fischer
2014-09-05 15:10     ` Yury Gribov
2014-09-05 16:46       ` Bernhard Reutner-Fischer
2014-09-06 16:33         ` Yury Gribov
2014-09-05 17:35       ` Segher Boessenkool
2014-09-06 15:40         ` Yury Gribov
2014-09-06 18:21           ` Trevor Saunders
2014-09-06 19:35           ` Segher Boessenkool
2014-09-07  4:18             ` Yuri Gribov
2014-09-07  4:48               ` Yuri Gribov
2014-09-07 13:33               ` Segher Boessenkool
2014-09-05 15:04   ` Yury Gribov
2014-09-10  8:09 ` [PATCHv2] " Yury Gribov
2014-09-10  8:17   ` Yury Gribov
2014-09-10 19:17   ` Segher Boessenkool
2014-09-11  4:47     ` Yury Gribov
2014-09-11  9:14       ` pinskia
2014-09-11  9:35         ` Yury Gribov
2014-09-11  9:06   ` Richard Biener
2014-09-11  9:18     ` Richard Biener
2014-09-11 10:10       ` Yury Gribov
2014-09-11 16:07         ` Yury Gribov
2014-09-14 10:32           ` Alexander Monakov
2014-09-15  9:54             ` Yury Gribov
2014-09-16 16:38   ` [PATCHv3] " Yury Gribov
2014-09-16 21:59     ` Trevor Saunders
2014-09-17 13:02       ` Segher Boessenkool
2014-09-17 14:05         ` Yury Gribov
2014-09-17 14:10           ` Yury Gribov
2014-09-17 17:08     ` [PATCHv4] " Yury Gribov
2014-09-18  3:54       ` Segher Boessenkool
2014-09-18  8:39         ` Yury Gribov
2014-09-18 15:37           ` Mike Stump
2014-09-18 17:20           ` Segher Boessenkool
2014-09-19  4:17             ` Yury Gribov
2014-09-19 11:11               ` Segher Boessenkool
2014-10-02 17:14       ` Yury Gribov [this message]
2014-10-13 10:33         ` [PATCHv5][PING] " Yury Gribov
2014-10-21 15:24           ` [PATCHv5][PING^2] " Yury Gribov
2014-11-06 10:31             ` [PATCHv5][PING^3] " Yury Gribov
2014-11-28 18:00               ` [PATCHv5][PING^4] " Yury Gribov
2014-12-08 21:46                 ` Jeff Law

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=542D87DB.1080907@samsung.com \
    --to=y.gribov@samsung.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=laurynas.biveinis@gmail.com \
    --cc=law@redhat.com \
    --cc=mikestump@comcast.net \
    --cc=rep.dot.nop@gmail.com \
    --cc=richard.guenther@gmail.com \
    --cc=segher@kernel.crashing.org \
    --cc=tsaunders@mozilla.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).