Hi all,

This is a second version of patch which adds a Vim config (.local.vimrc)
to root folder to allow automatic setup of GNU formatting for C/C++/Java/Lex GCC files.

I've updated the code with comments from Richard and Bernhard (which fixed formatting
of lonely closing bracket).

The patch caused a lively debate with Segher who wanted .local.vimrc to not be enabled
by default. We basically have two options:
1) put .local.vimrc to root (just like .dir-locals.el config for Emacs)
2) put both .local.vimrc and .dir-locals.el to contrib and add Makefile targets
to create symlinks in root folder per user's request
I personally prefer 2) because this would IMHO improve the quality of patches
(e.g. no more silly tab-whitespace formatting bugs).

Thoughts? Ok to commit?

-Y



commit 879cd3e9bdcab780a9b96aff759ef684e3597d0c
Author: Yury Gribov <y.gri...@samsung.com>
Date:   Thu Sep 4 16:55:44 2014 +0400

    2014-09-10  Laurynas Biveinis  <laurynas.bivei...@gmail.com>
    	    Yury Gribov  <y.gri...@samsung.com>
    
    	* .local.vimrc: New file.

diff --git a/.local.vimrc b/.local.vimrc
new file mode 100644
index 0000000..98f3135
--- /dev/null
+++ b/.local.vimrc
@@ -0,0 +1,39 @@
+" Vim settings.
+"
+" To autorun install thinca's localrc plugin. Otherwise just source via
+" :so .local.vimrc
+
+" 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")
+  let l:non_gnu_dirs = ['libsanitizer']
+  if index(l:non_gnu_dirs, l:fname) != -1
+    return
+  endif
+  let l:ext = fnamemodify(l:fname, ":e")
+  let l:c_exts = ['c', 'h', 'cpp', 'cc', 'C', 'H', 'def', 'java', 'l']
+  if index(l:c_exts, l:ext) != -1
+    setlocal cindent
+    setlocal shiftwidth=2
+    setlocal softtabstop=2
+    setlocal cinoptions=>2s,n-s,{s,^-s,:s,=s,g0,hs,p5,t0,+s,(0,u0,w1,m0
+    setlocal textwidth=79
+    setlocal fo-=ro fo+=cql
+  endif
+endfunction
+
+call SetStyle()

Reply via email to