keeping this up.
feedback ?

> This is a plugin for Vim (tested with Vim v7.1) to follow the OpenBSD style(9)
> indentation.  It registers a macro (see below) for changing a buffer's
> indentation rules but does not change the indentation of existing code.

Index: Makefile
===================================================================
RCS file: /cvs/ports/editors/vim/Makefile,v
retrieving revision 1.123
diff -u -p -r1.123 Makefile
--- Makefile    2 Dec 2011 14:36:14 -0000       1.123
+++ Makefile    30 Oct 2012 15:05:58 -0000
@@ -9,7 +9,7 @@ VERSION=        7.3.${REV}
 # keep PKGNAME for full version number
 PKGNAME=       vim-${VERSION}
 PKGNAME-main=  vim-${VERSION}
-REVISION-main= 2
+REVISION-main= 3
 PKGNAME-lang=  vim-lang-${VERSION}
 REVISION-lang = 0
 P=             ${DISTNAME:C/[-\.]//g}
@@ -135,6 +135,7 @@ post-configure:
        touch ${WRKBUILD}/auto/config.mk
 
 post-install:
+       ${INSTALL_DATA} ${FILESDIR}/openbsd.vim ${PREFIX}/share/vim/${P}/syntax
        ${INSTALL_DATA} ${FILESDIR}/pf.vim ${PREFIX}/share/vim/${P}/syntax
 
 .include <bsd.port.mk>
Index: files/openbsd.vim
===================================================================
RCS file: files/openbsd.vim
diff -N files/openbsd.vim
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ files/openbsd.vim   30 Oct 2012 15:05:59 -0000
@@ -0,0 +1,70 @@
+" $OpenBSD$
+
+" Copyright (c) 2007-2008 Sean C. Farley <[email protected]>
+" All rights reserved.
+"
+" Redistribution and use in source and binary forms, with or without
+" modification, are permitted provided that the following conditions
+" are met:
+" 1. Redistributions of source code must retain the above copyright
+"    notice, this list of conditions and the following disclaimer,
+"    without modification, immediately at the beginning of the file.
+" 2. Redistributions in binary form must reproduce the above copyright
+"    notice, this list of conditions and the following disclaimer in the
+"    documentation and/or other materials provided with the distribution.
+"
+" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+"
+" $FreeBSD: src/tools/tools/editing/freebsd.vim,v 1.2.6.1.4.1 2012/08/05 
23:54:33 kensmith Exp $
+
+" This is a plugin for Vim (tested with Vim v7.1) to follow the OpenBSD 
style(9)
+" indentation.  It registers a macro (see below) for changing a buffer's
+" indentation rules but does not change the indentation of existing code.
+
+" Load only once.
+if exists('loaded_OpenBSD')
+    finish
+endif
+let loaded_OpenBSD = 1
+
+
+" OpenBSD mapping to switch current buffer to style(9).  This is generally 
'\f'.
+nmap <silent> <Leader>f :call OpenBSD_Style()<CR>
+
+
+" Ignore indents caused by parentheses in OpenBSD style.
+function! IgnoreParenIndent()
+    let indent = cindent(v:lnum)
+
+    if indent > 4000
+        if cindent(v:lnum - 1) > 4000
+            return indent(v:lnum - 1)
+        else
+            return indent(v:lnum - 1) + 4
+        endif
+    else
+        return (indent)
+    endif
+endfun
+
+
+" Follow the OpenBSD style(9).
+function! OpenBSD_Style()
+    setlocal cindent
+    setlocal cinoptions=(4200,u4200,+0.5s,*500,:0,t0,U4200
+    setlocal indentexpr=IgnoreParenIndent()
+    setlocal indentkeys=0{,0},0),:,0#,!^F,o,O,e
+    setlocal noexpandtab
+    setlocal shiftwidth=8
+    setlocal tabstop=8
+    setlocal textwidth=80
+endfun
Index: pkg/PLIST-main
===================================================================
RCS file: /cvs/ports/editors/vim/pkg/PLIST-main,v
retrieving revision 1.7
diff -u -p -r1.7 PLIST-main
--- pkg/PLIST-main      9 Sep 2010 22:29:29 -0000       1.7
+++ pkg/PLIST-main      30 Oct 2012 15:05:59 -0000
@@ -1164,6 +1164,7 @@ share/vim/${P}/syntax/objcpp.vim
 share/vim/${P}/syntax/ocaml.vim
 share/vim/${P}/syntax/occam.vim
 share/vim/${P}/syntax/omnimark.vim
+share/vim/${P}/syntax/openbsd.vim
 share/vim/${P}/syntax/openroad.vim
 share/vim/${P}/syntax/opl.vim
 share/vim/${P}/syntax/ora.vim

Reply via email to