1*2931b524SSascha Wildner" Copyright (c) 2007-2008 Sean C. Farley <scf@FreeBSD.org> 2*2931b524SSascha Wildner" All rights reserved. 3*2931b524SSascha Wildner" 4*2931b524SSascha Wildner" Redistribution and use in source and binary forms, with or without 5*2931b524SSascha Wildner" modification, are permitted provided that the following conditions 6*2931b524SSascha Wildner" are met: 7*2931b524SSascha Wildner" 1. Redistributions of source code must retain the above copyright 8*2931b524SSascha Wildner" notice, this list of conditions and the following disclaimer, 9*2931b524SSascha Wildner" without modification, immediately at the beginning of the file. 10*2931b524SSascha Wildner" 2. Redistributions in binary form must reproduce the above copyright 11*2931b524SSascha Wildner" notice, this list of conditions and the following disclaimer in the 12*2931b524SSascha Wildner" documentation and/or other materials provided with the distribution. 13*2931b524SSascha Wildner" 14*2931b524SSascha Wildner" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15*2931b524SSascha Wildner" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16*2931b524SSascha Wildner" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17*2931b524SSascha Wildner" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18*2931b524SSascha Wildner" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19*2931b524SSascha Wildner" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20*2931b524SSascha Wildner" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21*2931b524SSascha Wildner" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22*2931b524SSascha Wildner" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23*2931b524SSascha Wildner" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24*2931b524SSascha Wildner" 25*2931b524SSascha Wildner" $FreeBSD: src/tools/tools/editing/freebsd.vim,v 1.2 2008/07/30 03:34:23 scf Exp $ 26*2931b524SSascha Wildner 27*2931b524SSascha Wildner" This is a plugin for Vim (tested with Vim v7.1) to follow the DragonFly style(9) 28*2931b524SSascha Wildner" indentation. It registers a macro (see below) for changing a buffer's 29*2931b524SSascha Wildner" indentation rules but does not change the indentation of existing code. 30*2931b524SSascha Wildner 31*2931b524SSascha Wildner" Load only once. 32*2931b524SSascha Wildnerif exists('loaded_DragonFly') 33*2931b524SSascha Wildner finish 34*2931b524SSascha Wildnerendif 35*2931b524SSascha Wildnerlet loaded_DragonFly = 1 36*2931b524SSascha Wildner 37*2931b524SSascha Wildner 38*2931b524SSascha Wildner" DragonFly mapping to switch current buffer to style(9). This is generally '\f'. 39*2931b524SSascha Wildnernmap <silent> <Leader>f :call DragonFly_Style()<CR> 40*2931b524SSascha Wildner 41*2931b524SSascha Wildner 42*2931b524SSascha Wildner" Ignore indents caused by parentheses in DragonFly style. 43*2931b524SSascha Wildnerfunction! IgnoreParenIndent() 44*2931b524SSascha Wildner let indent = cindent(v:lnum) 45*2931b524SSascha Wildner 46*2931b524SSascha Wildner if indent > 4000 47*2931b524SSascha Wildner if cindent(v:lnum - 1) > 4000 48*2931b524SSascha Wildner return indent(v:lnum - 1) 49*2931b524SSascha Wildner else 50*2931b524SSascha Wildner return indent(v:lnum - 1) + 4 51*2931b524SSascha Wildner endif 52*2931b524SSascha Wildner else 53*2931b524SSascha Wildner return (indent) 54*2931b524SSascha Wildner endif 55*2931b524SSascha Wildnerendfun 56*2931b524SSascha Wildner 57*2931b524SSascha Wildner 58*2931b524SSascha Wildner" Follow the DragonFly style(9). 59*2931b524SSascha Wildnerfunction! DragonFly_Style() 60*2931b524SSascha Wildner setlocal cindent 61*2931b524SSascha Wildner setlocal cinoptions=(4200,u4200,+0.5s,*500,:0,t0,U4200 62*2931b524SSascha Wildner setlocal indentexpr=IgnoreParenIndent() 63*2931b524SSascha Wildner setlocal indentkeys=0{,0},0),:,0#,!^F,o,O,e 64*2931b524SSascha Wildner setlocal noexpandtab 65*2931b524SSascha Wildner setlocal shiftwidth=8 66*2931b524SSascha Wildner setlocal tabstop=8 67*2931b524SSascha Wildner setlocal textwidth=80 68*2931b524SSascha Wildnerendfun 69