Hi all,

This patch adds a Vim config (.local.vimrc) to root folder. This would allow automatic setup of GNU formatting for C/C++/Java/Lex files in GCC (similar to what we already have for Emacs via .dir-locals.el). The formatting is borrowed from https://gcc.gnu.org/wiki/FormattingCodeForGCC

Ok to commit?

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

    2014-09-04  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..58e6ad3
--- /dev/null
+++ b/.local.vimrc
@@ -0,0 +1,36 @@
+" 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()
+" TODO: filter out non-GNU sources e.g. libsanitizer?
+let l:fname = expand("%:p")
+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 cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1
+  setlocal shiftwidth=2
+  setlocal softtabstop=2
+  setlocal textwidth=79
+  setlocal fo-=ro fo+=cql
+endif
+endfunction
+
+call SetStyle()

Reply via email to