]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Local Vim config with GNU formatting.
authorYury Gribov <ygribov@gcc.gnu.org>
Tue, 9 Dec 2014 13:45:47 +0000 (13:45 +0000)
committerYury Gribov <ygribov@gcc.gnu.org>
Tue, 9 Dec 2014 13:45:47 +0000 (13:45 +0000)
2014-12-09  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
    Yury Gribov  <y.gribov@samsung.com>

/
* .gitignore: Added .local.vimrc and .lvimrc.
* Makefile.tpl (vimrc, .lvimrc, .local.vimrc): New targets.
* Makefile.in: Regenerate.

contrib/
* vimrc: New file.

From-SVN: r218514

.gitignore
ChangeLog
Makefile.in
Makefile.tpl
contrib/ChangeLog
contrib/vimrc [new file with mode: 0644]

index e9b56be604edebd495b9c26cee383fa04aa1abda..ab97ac67cb41081c8175516daa64e5dc23e8e1fe 100644 (file)
@@ -32,6 +32,9 @@ POTFILES
 TAGS
 TAGS.sub
 
+.local.vimrc
+.lvimrc
+
 .gdbinit
 .gdb_history
 
index 2052b67e9a3c5d5f38247150736a0cf282defb35..e94514f5c8bc6a2eebbea8d9dca15c1069d0a047 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,11 @@
-2014-12-04     Jack Howarth  <howarth@bromo.med.uc.edu>
+2014-12-09  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+           Yury Gribov  <y.gribov@samsung.com>
+
+       * .gitignore: Added .local.vimrc and .lvimrc.
+       * Makefile.tpl (vimrc, .lvimrc, .local.vimrc): New targets.
+       * Makefile.in: Regenerate.
+
+2014-12-04  Jack Howarth  <howarth@bromo.med.uc.edu>
 
        * config/isl.m4: Don't pass -DCLOOG_INT_GMP on islinc.
        * configure: Regenerated.
index 182e1fd7c50cc94a3e3a2299d25d387b0969148d..ba5ae4c2ecb23535da040fec1ccd3e2e23cf7c87 100644 (file)
@@ -2392,6 +2392,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
index 884e02db9af7ce563808b710f3b5ab13da9c8d14..dcbc6b1b1435dbcac7b0eb5d09429306c8c9d0ea 100644 (file)
@@ -861,6 +861,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
index edcf6b74cb0888ce34122f00081c5803ab0344a7..7984108089bd6d23ba9c1b20aa0ac06bdca57abd 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-09  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+           Yury Gribov  <y.gribov@samsung.com>
+
+       * vimrc: New file.
+
 2014-12-04  Thomas Preud'homme  <thomas.preudhomme@arm.com>
 
        * check_GNU_style.sh: Warn for incorrect number of spaces in function
diff --git a/contrib/vimrc b/contrib/vimrc
new file mode 100644 (file)
index 0000000..34e8f35
--- /dev/null
@@ -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()