Installed eclim + remved autocomplete plugins
This commit is contained in:
73
vim/bundle/eclim/indent/css.vim
Normal file
73
vim/bundle/eclim/indent/css.vim
Normal file
@@ -0,0 +1,73 @@
|
||||
" Author: Eric Van Dewoestine
|
||||
"
|
||||
" Description: {{{
|
||||
" Css indent file using IndentAnything.
|
||||
"
|
||||
" License:
|
||||
"
|
||||
" Copyright (C) 2005 - 2012 Eric Van Dewoestine
|
||||
"
|
||||
" 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/>.
|
||||
"
|
||||
" }}}
|
||||
|
||||
let b:did_indent = 1
|
||||
if &indentexpr =~ 'EclimGetCssIndent' ||
|
||||
\ (!exists('b:disableOverride') && exists('g:EclimCssIndentDisabled'))
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime eclim/indent/indentanything.vim
|
||||
|
||||
setlocal indentexpr=EclimGetCssIndent(v:lnum)
|
||||
setlocal indentkeys=0{,0},!^F,o,O
|
||||
|
||||
" EclimGetCssIndent(lnum) {{{
|
||||
function! EclimGetCssIndent(lnum)
|
||||
let adj = 0
|
||||
let prevline = prevnonblank(a:lnum - 1)
|
||||
|
||||
" handle case where previous line is a multi-line comment (/* */) on one
|
||||
" line, which IndentAnything doesn't handle properly.
|
||||
if getline(prevline) =~ '^\s\+/\*.\{-}\*/\s*$'
|
||||
let adj = indent(prevline)
|
||||
endif
|
||||
|
||||
return IndentAnything() + adj
|
||||
endfunction " }}}
|
||||
|
||||
" CssIndentAnythingSettings() {{{
|
||||
function! CssIndentAnythingSettings()
|
||||
" Syntax name REs for comments and strings.
|
||||
let b:commentRE = 'cssComment'
|
||||
let b:lineCommentRE = 'cssComment'
|
||||
let b:blockCommentRE = 'cssComment'
|
||||
let b:stringRE = 'cssStringQ\(Q\)\?'
|
||||
|
||||
" Setup for C-style comment indentation.
|
||||
let b:blockCommentStartRE = '/\*'
|
||||
let b:blockCommentMiddleRE = '\*'
|
||||
let b:blockCommentEndRE = '\*/'
|
||||
let b:blockCommentMiddleExtra = 1
|
||||
|
||||
" Indent another level for each non-closed paren/'(' and brace/'{' on the
|
||||
" previous line.
|
||||
let b:indentTrios = [
|
||||
\ [ '{', '', '}' ]
|
||||
\ ]
|
||||
endfunction " }}}
|
||||
|
||||
call CssIndentAnythingSettings()
|
||||
|
||||
" vim:ft=vim:fdm=marker
|
||||
73
vim/bundle/eclim/indent/dtd.vim
Normal file
73
vim/bundle/eclim/indent/dtd.vim
Normal file
@@ -0,0 +1,73 @@
|
||||
" Author: Eric Van Dewoestine
|
||||
"
|
||||
" Description: {{{
|
||||
" Dtd indent file using IndentAnything.
|
||||
"
|
||||
" License:
|
||||
"
|
||||
" Copyright (C) 2005 - 2012 Eric Van Dewoestine
|
||||
"
|
||||
" 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/>.
|
||||
"
|
||||
" }}}
|
||||
|
||||
let b:did_indent = 1
|
||||
if &indentexpr =~ 'EclimGetDtdIndent' ||
|
||||
\ (!exists('b:disableOverride') && exists('g:EclimDtdIndentDisabled'))
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime eclim/indent/indentanything.vim
|
||||
|
||||
setlocal indentexpr=EclimGetDtdIndent(v:lnum)
|
||||
setlocal indentkeys=o,O,*<Return>,<>>,<<>
|
||||
|
||||
" EclimGetDtdIndent(lnum) {{{
|
||||
function! EclimGetDtdIndent(lnum)
|
||||
let adj = 0
|
||||
" handle case where previous line is a multi-line comment (<!-- -->) on one
|
||||
" line, which IndentAnything doesn't handle properly.
|
||||
let prevline = prevnonblank(a:lnum - 1)
|
||||
if getline(prevline) =~ '^\s\+<!--.\{-}-->'
|
||||
let adj = indent(prevline)
|
||||
endif
|
||||
return IndentAnything() + adj
|
||||
endfunction " }}}
|
||||
|
||||
" DtdIndentAnythingSettings() {{{
|
||||
function! DtdIndentAnythingSettings()
|
||||
" Syntax name REs for comments and strings.
|
||||
let b:blockCommentRE = 'dtdComment\|xmlComment'
|
||||
let b:commentRE = b:blockCommentRE
|
||||
let b:lineCommentRE = b:blockCommentRE
|
||||
let b:stringRE = 'dtdString\|xmlString'
|
||||
let b:singleQuoteStringRE = b:stringRE
|
||||
let b:doubleQuoteStringRE = b:stringRE
|
||||
|
||||
setlocal comments=sr:<!--,m:-,e:-->
|
||||
let b:blockCommentStartRE = '<!--'
|
||||
let b:blockCommentMiddleRE = '-'
|
||||
let b:blockCommentEndRE = '-->'
|
||||
let b:blockCommentMiddleExtra = 2
|
||||
|
||||
" Indent another level for each non-closed element tag.
|
||||
let b:indentTrios = [
|
||||
\ [ '<\!\w', '', '>' ],
|
||||
\ [ '(', '', ')' ],
|
||||
\ ]
|
||||
endfunction " }}}
|
||||
|
||||
call DtdIndentAnythingSettings()
|
||||
|
||||
" vim:ft=vim:fdm=marker
|
||||
180
vim/bundle/eclim/indent/html.vim
Normal file
180
vim/bundle/eclim/indent/html.vim
Normal file
@@ -0,0 +1,180 @@
|
||||
" Author: Eric Van Dewoestine
|
||||
"
|
||||
" Description: {{{
|
||||
" Html indent file using IndentAnything.
|
||||
"
|
||||
" License:
|
||||
"
|
||||
" Copyright (C) 2005 - 2014 Eric Van Dewoestine
|
||||
"
|
||||
" 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/>.
|
||||
"
|
||||
" }}}
|
||||
|
||||
if &indentexpr =~ 'EclimGetHtmlIndent' ||
|
||||
\ (!exists('b:disableOverride') && exists('g:EclimHtmlIndentDisabled'))
|
||||
finish
|
||||
endif
|
||||
|
||||
let b:disableOverride = 1
|
||||
runtime! indent/javascript.vim
|
||||
runtime! indent/css.vim
|
||||
|
||||
setlocal indentexpr=EclimGetHtmlIndent(v:lnum)
|
||||
setlocal indentkeys+=>,},0),0},),;,0{,!^F,o,O
|
||||
|
||||
if !exists('g:EclimHtmlUnclosedTags')
|
||||
let g:EclimHtmlUnclosedTags = ['br', 'img', 'input']
|
||||
endif
|
||||
|
||||
" EclimGetHtmlIndent(lnum) {{{
|
||||
function! EclimGetHtmlIndent(lnum)
|
||||
let line = line('.')
|
||||
let col = line('.')
|
||||
|
||||
let adj = 0
|
||||
|
||||
let scriptstart = search('<script\>', 'bcW')
|
||||
if scriptstart > 0
|
||||
let scriptstart = search('>', 'cW', scriptstart)
|
||||
let scriptend = search('</script\s*>', 'cW')
|
||||
endif
|
||||
call cursor(line, col)
|
||||
|
||||
let stylestart = search('<style\>', 'bcW')
|
||||
if stylestart > 0
|
||||
let stylestart = search('>', 'cW', stylestart)
|
||||
let styleend = search('</style\s*>', 'cW')
|
||||
endif
|
||||
call cursor(line, col)
|
||||
|
||||
" Inside <script> tags... let javascript indent file do the work.
|
||||
let line = getline(scriptstart)
|
||||
let js_type = "type\\s*=\\s*['\"]\\(text\\|application\\)/\\(java\\|ecma\\)script['\"]"
|
||||
if scriptstart > 0 && scriptstart < a:lnum &&
|
||||
\ (scriptend == 0 || (scriptend > scriptstart && a:lnum < scriptend)) &&
|
||||
\ (line !~ 'type\s*=' || line =~ js_type)
|
||||
call JavascriptIndentAnythingSettings()
|
||||
if a:lnum == scriptstart + 1
|
||||
let adj = &sw
|
||||
endif
|
||||
return EclimGetJavascriptIndent(a:lnum) + adj
|
||||
|
||||
" Inside <style> tags... let css indent file do the work.
|
||||
elseif stylestart > 0 && stylestart < a:lnum &&
|
||||
\ (styleend == 0 || (styleend > stylestart && a:lnum < styleend))
|
||||
call CssIndentAnythingSettings()
|
||||
if a:lnum == stylestart + 1
|
||||
let adj = &sw
|
||||
endif
|
||||
return EclimGetCssIndent(a:lnum) + adj
|
||||
|
||||
" Indenting html code, do our work.
|
||||
else
|
||||
let l:Settings = exists('b:indent_settings') ?
|
||||
\ function(b:indent_settings) : function('HtmlIndentAnythingSettings')
|
||||
call l:Settings()
|
||||
let adj = s:HtmlIndentAttributeWrap(a:lnum) * &sw
|
||||
|
||||
let prevlnum = prevnonblank(a:lnum - 1)
|
||||
let prevline = getline(prevlnum)
|
||||
|
||||
" handle case where previous line is a multi-line comment (<!-- -->) on one
|
||||
" line, which IndentAnything doesn't handle properly.
|
||||
if prevline =~ '^\s\+<!--.\{-}-->'
|
||||
let adj = indent(prevlnum)
|
||||
endif
|
||||
|
||||
" handle non-parent tags without '/>'
|
||||
" NOTE: the '?' in this regex is to combat issues with php
|
||||
let noindent = exists('b:EclimHtmlUnclosedTags') ?
|
||||
\ b:EclimHtmlUnclosedTags : g:EclimHtmlUnclosedTags
|
||||
let noindent_pattern = '<\(' . join(noindent, '\|') . '\)[^/?]\{-}>'
|
||||
if prevline =~? noindent_pattern
|
||||
let line = tolower(prevline)
|
||||
let occurrences = 0
|
||||
while line =~ noindent_pattern
|
||||
let occurrences += 1
|
||||
let line = substitute(line, noindent_pattern, '', '')
|
||||
endwhile
|
||||
let adj = 0 - (&sw * occurrences)
|
||||
endif
|
||||
endif
|
||||
return IndentAnything() + adj
|
||||
endfunction " }}}
|
||||
|
||||
" HtmlIndentAnythingSettings() {{{
|
||||
function! HtmlIndentAnythingSettings()
|
||||
" Syntax name REs for comments and strings.
|
||||
let b:blockCommentRE = 'htmlComment'
|
||||
let b:commentRE = b:blockCommentRE
|
||||
let b:stringRE = 'htmlString'
|
||||
let b:singleQuoteStringRE = b:stringRE
|
||||
let b:doubleQuoteStringRE = b:stringRE
|
||||
|
||||
" Overwrites option for other filetypes that have html indenting (eg. php)
|
||||
"setlocal comments=sr:<!--,m:-,e:-->
|
||||
"let b:blockCommentStartRE = '<!--'
|
||||
"let b:blockCommentMiddleRE = '-'
|
||||
"let b:blockCommentEndRE = '-->'
|
||||
"let b:blockCommentMiddleExtra = 2
|
||||
|
||||
" Indent another level for each non-closed element tag.
|
||||
let b:indentTrios = [
|
||||
\ [ '<\w', '', '\(/>\|</\)' ],
|
||||
\ ]
|
||||
|
||||
"let b:lineContList = [
|
||||
" \ {'pattern' : '^<!DOCTYPE.*[^>]\s*$' },
|
||||
" \ ]
|
||||
endfunction " }}}
|
||||
|
||||
" HtmlIndentAttributeWrap(lnum) {{{
|
||||
" Function which indents line continued attributes an extra level for
|
||||
" readability.
|
||||
function! <SID>HtmlIndentAttributeWrap(lnum)
|
||||
let line = line('.')
|
||||
let col = col('.')
|
||||
let adj = 0
|
||||
try
|
||||
" mover cursor to start of line to avoid matching start tag on first line
|
||||
" of nested content.
|
||||
call cursor(line, 1)
|
||||
let open = search('<\w\|<!DOCTYPE', 'bW')
|
||||
if open > 0
|
||||
let close = search('>', 'cW')
|
||||
if open != close
|
||||
" continuation line
|
||||
if close == 0 || close >= a:lnum
|
||||
" first continuation line
|
||||
if a:lnum == open + 1
|
||||
return 1
|
||||
endif
|
||||
" additional continuation lines
|
||||
return 0
|
||||
endif
|
||||
|
||||
" line after last continuation line
|
||||
if close != 0 && a:lnum == close + 1
|
||||
" inner content
|
||||
return -1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
finally
|
||||
call cursor(line, col)
|
||||
endtry
|
||||
endfunction " }}}
|
||||
|
||||
" vim:ft=vim:fdm=marker
|
||||
683
vim/bundle/eclim/indent/indentanything.vim
Normal file
683
vim/bundle/eclim/indent/indentanything.vim
Normal file
@@ -0,0 +1,683 @@
|
||||
"
|
||||
" Copyright 2006 Tye Zdrojewski
|
||||
"
|
||||
" Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
" use this file except in compliance with the License. You may obtain a copy of
|
||||
" the License at
|
||||
"
|
||||
" http://www.apache.org/licenses/LICENSE-2.0
|
||||
"
|
||||
" Unless required by applicable law or agreed to in writing, software distributed
|
||||
" under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
" CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
" specific language governing permissions and limitations under the License.
|
||||
"
|
||||
"
|
||||
" Plugin:
|
||||
"
|
||||
" Indent Anything
|
||||
"
|
||||
" Version: 1.2
|
||||
"
|
||||
" Description:
|
||||
"
|
||||
" This is an indentation script that calculates the indent level based
|
||||
" on begin/end syntax pairs and line-continuation patterns. It allows one
|
||||
" to create an indent script without writing any code, taking it's
|
||||
" instruction from configurable values.
|
||||
"
|
||||
" Included with this script is Javascript indentation, an example that
|
||||
" explains the configurable values.
|
||||
"
|
||||
"
|
||||
" Installation:
|
||||
"
|
||||
" Place this file in your home directory under ~/.vim/indent/, or replace
|
||||
" the system indent/javascript.vim file to affect all users.
|
||||
"
|
||||
" Maintainer: Tye Z. < z d r o @ y a h o o . c o m >
|
||||
"
|
||||
" Customization:
|
||||
"
|
||||
" The only thing that can really be customized at this point is whether or
|
||||
" not a line is echoed explaining the indentation result. To turn this on,
|
||||
" set the following variable like so:
|
||||
"
|
||||
" let b:indent_anything_echo = 1
|
||||
"
|
||||
"
|
||||
" History:
|
||||
"
|
||||
" 1.2 - made some functions script-local to prevent naming collisions
|
||||
" - fixed some broken indentation in the middle of a block comment,
|
||||
" which showed up in Javascript indentation.
|
||||
"
|
||||
|
||||
let s:supportedVimVersion = 700
|
||||
|
||||
if version < s:supportedVimVersion
|
||||
echoerr "IndentAnything only supported for Vim " . s:supportedVimVersion . " and up."
|
||||
finish
|
||||
endif
|
||||
|
||||
|
||||
"
|
||||
" Initialize everything needed by this script. Only set those values that are
|
||||
" not set already.
|
||||
"
|
||||
function! s:IndentAnythingInit()
|
||||
let b:IndentAnythingInitialized = 1
|
||||
" Start with a regular expression that will never match. Matching
|
||||
" will influence behavior, which the defaults should not do.
|
||||
let s:nonMatcher = '[x]\&[^x]'
|
||||
if !exists('b:commentRE')
|
||||
let b:commentRE = s:nonMatcher
|
||||
endif
|
||||
if !exists('b:lineCommentRE')
|
||||
let b:lineCommentRE = s:nonMatcher
|
||||
endif
|
||||
if !exists('b:blockCommentRE')
|
||||
let b:blockCommentRE = s:nonMatcher
|
||||
endif
|
||||
if !exists('b:stringRE')
|
||||
let b:stringRE = s:nonMatcher
|
||||
endif
|
||||
if !exists('b:singleQuoteStringRE')
|
||||
let b:singleQuoteStringRE = s:nonMatcher
|
||||
endif
|
||||
if !exists('b:doubleQuoteStringRE')
|
||||
let b:doubleQuoteStringRE = s:nonMatcher
|
||||
endif
|
||||
|
||||
if !exists('b:blockCommentStartRE')
|
||||
let b:blockCommentStartRE = s:nonMatcher
|
||||
endif
|
||||
if !exists('b:blockCommentMiddleRE')
|
||||
let b:blockCommentMiddleRE = s:nonMatcher
|
||||
endif
|
||||
if !exists('b:blockCommentEndRE')
|
||||
let b:blockCommentEndRE = s:nonMatcher
|
||||
endif
|
||||
if !exists('b:blockCommentMiddleExtra')
|
||||
let b:blockCommentMiddleExtra = 0
|
||||
endif
|
||||
|
||||
if !exists('b:indentTrios')
|
||||
let b:indentTrios = []
|
||||
endif
|
||||
if !exists('b:lineContList')
|
||||
let b:lineContList = []
|
||||
endif
|
||||
|
||||
if !exists('b:contTraversesLineComments')
|
||||
let b:contTraversesLineComments = 1
|
||||
endif
|
||||
|
||||
if !exists('b:indent_anything_echo')
|
||||
let b:indent_anything_echo = 0
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:SynHere()
|
||||
return synIDattr(synID(line('.'), col('.'), 1), "name")
|
||||
endfunction
|
||||
"
|
||||
" Returns true if the cursor is currently inside a comment or a string
|
||||
"
|
||||
function! InCommentOrString()
|
||||
let syn = synIDattr(synID(line("."), col("."), 1), "name")
|
||||
if syn =~ b:commentRE || syn =~ b:stringRE
|
||||
return 1
|
||||
endif
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
" Returns true if the given line is a comment line (b:lineCommentRE)
|
||||
"
|
||||
function! s:IsLineComment(linenum)
|
||||
let cursor = getpos('.')
|
||||
exec a:linenum
|
||||
normal! ^
|
||||
let l:iscomment = 0
|
||||
let l:syn = synIDattr(synID(line('.'), col('.'), 1), "name")
|
||||
if l:syn =~ b:lineCommentRE " b:commentRE || l:syn =~ b:stringRE
|
||||
let l:iscomment = 1
|
||||
endif
|
||||
call setpos('.', cursor)
|
||||
return l:iscomment
|
||||
endfunction
|
||||
|
||||
"
|
||||
" Returns true if the given line is a comment line (b:lineCommentRE)
|
||||
"
|
||||
function! s:IsComment(linenum)
|
||||
let cursor = getpos('.')
|
||||
exec a:linenum
|
||||
normal! ^
|
||||
let l:iscomment = 0
|
||||
let l:syn = synIDattr(synID(line('.'), col('.'), 1), "name")
|
||||
if l:syn =~ b:commentRE " b:commentRE || l:syn =~ b:stringRE
|
||||
let l:iscomment = 1
|
||||
endif
|
||||
call setpos('.', cursor)
|
||||
return l:iscomment
|
||||
endfunction
|
||||
|
||||
"
|
||||
" Returns true if the given line is a comment line (b:lineCommentRE)
|
||||
"
|
||||
function! s:IsBlockComment(linenum)
|
||||
let cursor = getpos('.')
|
||||
exec a:linenum
|
||||
normal! ^
|
||||
let l:iscomment = 0
|
||||
let l:syn = synIDattr(synID(line('.'), col('.'), 1), "name")
|
||||
if l:syn =~ b:blockCommentRE " b:commentRE || l:syn =~ b:stringRE
|
||||
let l:iscomment = 1
|
||||
endif
|
||||
call setpos('.', cursor)
|
||||
return l:iscomment
|
||||
endfunction
|
||||
|
||||
"
|
||||
" Get the first line at or on the given line that is not blank and is not a
|
||||
" comment line.
|
||||
"
|
||||
function! s:GetPrevNonBlankNonComment(begin)
|
||||
let cursor = getpos('.')
|
||||
|
||||
let l:prevbegin = a:begin
|
||||
while 1
|
||||
let l:lnum = prevnonblank(l:prevbegin)
|
||||
if l:lnum == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
"if s:IsLineComment(l:lnum)
|
||||
if s:IsComment(l:lnum)
|
||||
let l:prevbegin -= 1
|
||||
continue
|
||||
endif
|
||||
|
||||
break
|
||||
endwhile
|
||||
|
||||
" Restore original cursor location
|
||||
call setpos('.', cursor)
|
||||
return l:lnum
|
||||
endfunction
|
||||
|
||||
"
|
||||
" This does all the work. Does indentation for:
|
||||
"
|
||||
" - All pairs defined in b:indentTrios
|
||||
" - All line continuations in b:lineContList
|
||||
" - Block comments
|
||||
"
|
||||
function! IndentAnything()
|
||||
|
||||
if !exists('b:IndentAnythingInitialized')
|
||||
call s:IndentAnythingInit()
|
||||
endif
|
||||
|
||||
let adj = 0 " Adjustment
|
||||
|
||||
let g:lastindent = ""
|
||||
let b:hardindent = -1
|
||||
let currlnum = v:lnum
|
||||
let currlnum = line('.')
|
||||
let currline = getline(currlnum)
|
||||
let lastline = ''
|
||||
let prevline = ''
|
||||
|
||||
" Find non-blank lines above the current line.
|
||||
let lastlnum = prevnonblank(currlnum - 1)
|
||||
let prevlnum = prevnonblank(lastlnum - 1)
|
||||
if lastlnum != 0
|
||||
let lastline = getline(lastlnum)
|
||||
endif
|
||||
if prevlnum != 0
|
||||
let prevline = getline(prevlnum)
|
||||
endif
|
||||
if b:contTraversesLineComments
|
||||
let lastcodelnum = s:GetPrevNonBlankNonComment(currlnum - 1)
|
||||
let prevcodelnum = s:GetPrevNonBlankNonComment(lastcodelnum - 1)
|
||||
if lastcodelnum !=0
|
||||
let lastcodeline = getline(lastcodelnum)
|
||||
endif
|
||||
endif
|
||||
|
||||
" Start from the first char on the line. Vim doesn't seem to consistently
|
||||
" place the cursor there before calling the indent routines.
|
||||
call cursor(0, 1)
|
||||
call search('\S', 'W')
|
||||
|
||||
let l:cur = getpos('.')
|
||||
|
||||
"
|
||||
" Call indentation adjustment functions.
|
||||
"
|
||||
|
||||
"
|
||||
" Block comments
|
||||
"
|
||||
let l:BlockCommentAdj = 0
|
||||
let l:BlockCommentAdj += s:GetBlockCommentIndent(currlnum, lastlnum)
|
||||
let adj += l:BlockCommentAdj
|
||||
|
||||
"
|
||||
" Pairs
|
||||
"
|
||||
let b:lastclosed = { 'at' : 0 }
|
||||
let b:pairadj = 0
|
||||
if !l:BlockCommentAdj
|
||||
" If we're not in the middle of a block comment (because we haven't
|
||||
" made any adjustments for that), then process block indentation.
|
||||
for trio in b:indentTrios
|
||||
let b:pairadj += s:GetPairIndent(currline, lastline, lastlnum,
|
||||
\ trio[0], trio[1], trio[2])
|
||||
endfor
|
||||
endif
|
||||
let adj += b:pairadj
|
||||
|
||||
"
|
||||
" Line continuations
|
||||
"
|
||||
let contadj = 0
|
||||
let isBlockCommentStart = currline =~ '^\s*' . b:blockCommentStartRE
|
||||
let isBlockCommentMid = (s:IsBlockComment(currlnum) && !isBlockCommentStart)
|
||||
if !isBlockCommentMid
|
||||
" If the current line is not the middle of a block comment, then
|
||||
" process line continuations.
|
||||
for ContRule in b:lineContList
|
||||
if b:contTraversesLineComments "&& !isBlockCommentStart
|
||||
let contadj = s:GetContIndent(ContRule, currline, lastcodeline, lastcodelnum, prevcodelnum)
|
||||
else
|
||||
let contadj = s:GetContIndent(ContRule, currline, lastline, lastlnum, prevlnum)
|
||||
endif
|
||||
" This is for line continuation patterns, of which there can be only
|
||||
" one per line to indicate continuation
|
||||
if contadj
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
let adj += contadj
|
||||
endif
|
||||
|
||||
|
||||
"
|
||||
" Find the previous indent to which we will add the adjustment
|
||||
"
|
||||
let prevind = indent(lastlnum)
|
||||
|
||||
if l:BlockCommentAdj
|
||||
let g:lastindent .= " indent (prevblockcomment: " . prevind . " at " . lastcodelnum . ") "
|
||||
elseif contadj && b:contTraversesLineComments
|
||||
" If we have adjusted for line continuation, then use the indentation
|
||||
" for the previous code line
|
||||
let prevind = indent(lastcodelnum)
|
||||
let g:lastindent .= " indent (prevcode: " . prevind . " at " . lastcodelnum . ") "
|
||||
|
||||
elseif (isBlockCommentStart || !s:IsBlockComment(currlnum)) && s:IsBlockComment(lastlnum)
|
||||
" If this is the first line after a block comment, then add the
|
||||
" adjustment to the line where the block comment started.
|
||||
let prevind = s:GetPostBlockCommentIndent(lastlnum)
|
||||
let g:lastindent .= " indent (prevblock: " . prevind . " at " . lastlnum . ") "
|
||||
|
||||
elseif exists("b:defaultIndentExpr")
|
||||
let g:lastindent .= " using defaultIndentExpr (" . b:defaultIndentExpr . ") "
|
||||
exec "let prevind = " . b:defaultIndentExpr
|
||||
else
|
||||
" Default to adjusting the previous line's indent.
|
||||
let g:lastindent .= " indent (prev: " . prevind . " at " . lastlnum . ") "
|
||||
endif
|
||||
|
||||
" Just in case there is no previous indent.
|
||||
let prevind = (prevind == -1 ? 0 : prevind)
|
||||
|
||||
if b:indent_anything_echo
|
||||
echom g:lastindent
|
||||
endif
|
||||
|
||||
call setpos('.', l:cur)
|
||||
|
||||
return adj + prevind
|
||||
|
||||
endfunction
|
||||
|
||||
"
|
||||
" Get the adjustment for the second line of a block comment. The second line
|
||||
" will be aligned under the start of the block, even if it is not at the
|
||||
" beginning of the line. Extra adjustment (b:blockCommentMiddleExtra) will
|
||||
" be added.
|
||||
"
|
||||
function! s:GetBlockCommentIndent(CurrLNum, LastLNum)
|
||||
let l:cursor = getpos('.')
|
||||
let l:adj = 0
|
||||
if a:LastLNum == searchpair(b:blockCommentStartRE, '', b:blockCommentEndRE, 'bWr')
|
||||
\ && a:LastLNum > 0
|
||||
let l:adj = col('.') + b:blockCommentMiddleExtra
|
||||
normal! ^
|
||||
let l:adj -= col('.')
|
||||
endif
|
||||
call setpos('.', l:cursor)
|
||||
return l:adj
|
||||
endfunction
|
||||
|
||||
function! s:GetPostBlockCommentIndent(LNum)
|
||||
|
||||
let l:cursor = getpos('.')
|
||||
let l:ind = 0
|
||||
|
||||
" Find beginning of block comment containing the start of line LNum
|
||||
exec a:LNum
|
||||
normal! ^
|
||||
let l:ind = indent(searchpair(b:blockCommentStartRE, '', b:blockCommentEndRE, 'bWr'))
|
||||
|
||||
if 1 || l:ind != 0 && b:indent_anything_echo
|
||||
let g:lastindent = g:lastindent .
|
||||
\ "GetBlockCommentIndent: " . l:ind
|
||||
endif
|
||||
|
||||
call setpos('.', l:cursor)
|
||||
|
||||
"return l:ind
|
||||
return l:ind > 0 ? l:ind : 0
|
||||
|
||||
endfunction
|
||||
|
||||
" EV ADDED
|
||||
" Function which determines if there are equal number of opening and closing
|
||||
" patterns on the supplied line.
|
||||
function! s:EqualPairs(Line, LNum, Head, Tail)
|
||||
let lnum = line('.')
|
||||
let cnum = col('.')
|
||||
call cursor(a:LNum, 1)
|
||||
try
|
||||
let head_matches = search('\(' . a:Head . '\)', 'ncp', a:LNum)
|
||||
let tail_matches = search('\(' . a:Tail . '\)', 'ncp', a:LNum)
|
||||
if head_matches == tail_matches
|
||||
call cursor(a:LNum, col('$'))
|
||||
let last_head = searchpos('\(' . a:Head . '\)', 'bcn', a:LNum)
|
||||
call cursor(a:LNum, col('$'))
|
||||
let last_tail = searchpos('\(' . a:Tail . '\)', 'bcn', a:LNum)
|
||||
return last_tail[1] > last_head[1]
|
||||
endif
|
||||
return 0
|
||||
finally
|
||||
call cursor(lnum, cnum)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
"
|
||||
" Get additional indentation based on blocks of code, as defined by the Head
|
||||
" and Tail patterns.
|
||||
"
|
||||
function! s:GetPairIndent(CurrLine, LastLine, LastLNum, Head, Mid, Tail)
|
||||
|
||||
let levels = 0
|
||||
let adj = 0
|
||||
let origcol = col(".")
|
||||
let origline = line(".")
|
||||
|
||||
|
||||
"
|
||||
" How many levels were started on the last line? Search backwards for
|
||||
" pair starters until we're not on the last nonblank. If the last line
|
||||
" doesn't contain the pair-starter, then don't bother with searchpair();
|
||||
" it's a performance bottleneck because (I think) it will always search
|
||||
" all the way back until it finds a match or can't search any more.
|
||||
"
|
||||
"
|
||||
if a:LastLine =~ a:Head
|
||||
while 1
|
||||
" EV ADDED
|
||||
if s:EqualPairs(a:LastLine, a:LastLNum, a:Head, a:Tail)
|
||||
break
|
||||
endif
|
||||
" END EV ADDED
|
||||
|
||||
"
|
||||
" Include the limit of the search to be the last line. BIG
|
||||
" performance booster! That also means we only have to see *if*
|
||||
" there was a match, and not worry about where it is.
|
||||
"
|
||||
"let pairstart = searchpair(a:Head, a:Mid, a:Tail, 'Wb')
|
||||
"if pairstart == 0 || pairstart != a:LastLNum
|
||||
let pairstart = searchpair(a:Head, a:Mid, a:Tail, 'Wb', '', a:LastLNum)
|
||||
if pairstart == 0 "|| pairstart != a:LastLNum
|
||||
break
|
||||
endif
|
||||
let syn = synIDattr(synID(line("."), col("."), 1), "name")
|
||||
" Also continue on the off chance that we find the match on the
|
||||
" current line. This shouldn't happen, but the pattern might
|
||||
" start with whitespace.
|
||||
if syn =~ b:commentRE || syn =~ b:stringRE || pairstart == origline
|
||||
continue
|
||||
endif
|
||||
let levels += 1
|
||||
endwhile
|
||||
endif
|
||||
|
||||
" If we aren't within a level that was started on the last line, then
|
||||
" check how many levels were closed on the last line.
|
||||
"
|
||||
if levels == 0
|
||||
|
||||
" Move to the beginning of the last line
|
||||
call cursor(a:LastLNum,0)
|
||||
normal! ^
|
||||
|
||||
" If the line starts with an open, The close shouldn't be counted as
|
||||
" such, because we're looking for closes that didn't start on this
|
||||
" line.
|
||||
if a:LastLine =~ '^\s*' . a:Head ||
|
||||
\ (a:Mid != '' && a:LastLine =~ '^\s*' . a:Mid)
|
||||
let levels = 1
|
||||
endif
|
||||
|
||||
"
|
||||
" Count the closes on the last line (i.e. LastLNum), stopping once
|
||||
" we've hit comments. If the line doesn't even contain the end of the
|
||||
" pair, don't bother with searchpair() (same aforementioned
|
||||
" rationale).
|
||||
"
|
||||
if a:LastLine =~ a:Tail
|
||||
while 1
|
||||
"
|
||||
" Include the limit of the search to be the last line. BIG
|
||||
" performance booster! That also means we only have to see
|
||||
" *if* there was a match, and not worry about where it is.
|
||||
"
|
||||
"let pairend = searchpair(a:Head, a:Mid, a:Tail, 'W')
|
||||
"if pairend == 0 || a:LastLNum != pairend
|
||||
"let pairend = searchpair(a:Head, a:Mid, a:Tail, 'W', '', a:LastLNum)
|
||||
let pairend = searchpair(a:Head, a:Mid, a:Tail, 'W',
|
||||
\'InCommentOrString()', a:LastLNum)
|
||||
if pairend == 0 "|| a:LastLNum != pairend
|
||||
|
||||
" STARTS with a:Tail, since we already know the line
|
||||
" matches it.
|
||||
if b:lastclosed.at < col('.') && (
|
||||
\ a:LastLine =~ '^\s*' . a:Tail
|
||||
\ || (a:Mid != '' && a:LastLine =~ '^\s*' . a:Mid) )
|
||||
let b:lastclosed = {
|
||||
\ 'at' : col('.'),
|
||||
\ 'head' : a:Head,
|
||||
\ 'mid' : a:Mid,
|
||||
\ 'tail' : a:Tail }
|
||||
endif
|
||||
|
||||
|
||||
break
|
||||
endif
|
||||
" This might not be needed with the expr included in the
|
||||
" search call.
|
||||
"let syn = synIDattr(synID(line("."), col("."), 1), "name")
|
||||
"if syn =~ b:commentRE || syn =~ b:stringRE || syn == ''
|
||||
" break
|
||||
"endif
|
||||
let levels -= 1
|
||||
|
||||
" Track the last close to try to match pairs that start on
|
||||
" line continuations
|
||||
if b:lastclosed.at < col('.')
|
||||
let b:lastclosed = {
|
||||
\ 'at' : col('.'),
|
||||
\ 'head' : a:Head,
|
||||
\ 'mid' : a:Mid,
|
||||
\ 'tail' : a:Tail }
|
||||
endif
|
||||
endwhile
|
||||
endif
|
||||
endif
|
||||
|
||||
" This is redundant, as per above
|
||||
" If the current line starts with a close, count it. It won't effect the
|
||||
" indentation of the next line because it is the first thing on the line
|
||||
" and won't be counted as a "close on the last line".
|
||||
if a:CurrLine =~ '^\s*' . a:Tail
|
||||
\ || (a:Mid != '' && a:CurrLine =~ '^\s*' . a:Mid)
|
||||
let levels -= 1
|
||||
endif
|
||||
|
||||
" Restore original cursor location
|
||||
call cursor(origline, origcol)
|
||||
|
||||
let adj = &sw*levels
|
||||
if adj != 0 && b:indent_anything_echo
|
||||
let g:lastindent = g:lastindent .
|
||||
\ "GetPairIndent(" . a:Head . "/" . b:lastclosed.at . "):" . adj . " "
|
||||
endif
|
||||
|
||||
return adj
|
||||
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:GetContIndent(Rule, CurrLine, LastLine, LastLNum, PrevLNum)
|
||||
|
||||
let adj = 0
|
||||
let origcol = col(".")
|
||||
let origline = line(".")
|
||||
let lastcont = 0
|
||||
let prevcont = 0
|
||||
|
||||
let l:lastlnum = a:LastLNum
|
||||
let l:prevlnum = a:PrevLNum
|
||||
|
||||
let l:preblockstart = -1
|
||||
|
||||
" Get the last matching line number. If the match occurs w/in a comment
|
||||
" or string, then it's a non-match.
|
||||
"
|
||||
"let lastmatchlnum = search(a:Rule.pattern, 'Wb', a:PrevLNum)
|
||||
let lastmatchlnum = search(a:Rule.pattern, 'Wb', a:LastLNum)
|
||||
let syn = synIDattr(synID(line("."), col("."), 1), "name")
|
||||
|
||||
"if syn =~ b:commentRE || syn =~ b:stringRE
|
||||
if syn =~ b:commentRE || syn =~ b:stringRE || b:lastclosed.at > 0
|
||||
let lastmatchlnum = 0
|
||||
endif
|
||||
|
||||
" Should be able to just search to the line....
|
||||
" " Figure out the last and previous continuation status
|
||||
" if lastmatchlnum && lastmatchlnum == a:LastLNum
|
||||
" let lastcont = 1
|
||||
" endif
|
||||
if lastmatchlnum == a:LastLNum
|
||||
let lastcont = 1
|
||||
endif
|
||||
|
||||
" start checking at the start of the block that ended on the prev line
|
||||
if b:lastclosed.at > 0
|
||||
call cursor(a:LastLNum, b:lastclosed.at)
|
||||
" TODO: add 'skip' to skip comments
|
||||
let l:preblockstart = searchpair(b:lastclosed.head, b:lastclosed.mid, b:lastclosed.tail, 'bW')
|
||||
let g:lastindent .= ' postpair ("' . b:lastclosed.head . '"): '
|
||||
\ . l:preblockstart . '/' . col('.') . ' '
|
||||
|
||||
if b:contTraversesLineComments
|
||||
let l:prevlnum = s:GetPrevNonBlankNonComment(line('.') - 1)
|
||||
else
|
||||
let l:prevlnum = prevnonblank(line('.') - 1)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
" Get the previous matching line number. If the match occurs w/in a
|
||||
" comment or string, then it's a non-match. Use the adjusted, local
|
||||
" prevlnum as the limit of the search, since we don't care about matches
|
||||
" beyond that.
|
||||
let prevmatchlnum = search(a:Rule.pattern, 'Wb', l:prevlnum)
|
||||
|
||||
|
||||
let syn = synIDattr(synID(line("."), col("."), 1), "name")
|
||||
" Handle:
|
||||
" if ()
|
||||
" if () {
|
||||
" this_line; // should not be reduced
|
||||
"if syn =~ b:commentRE || syn =~ b:stringRE
|
||||
if syn =~ b:commentRE || syn =~ b:stringRE
|
||||
let prevmatchlnum = 0
|
||||
endif
|
||||
|
||||
" Should be able to just search to the line....
|
||||
" if ( lastmatchlnum && lastmatchlnum == a:PrevLNum )
|
||||
" \ || ( prevmatchlnum && prevmatchlnum == l:prevlnum )
|
||||
" let prevcont = 1
|
||||
" endif
|
||||
"
|
||||
" If there is a previous line, it is a continued line, and we haven't
|
||||
" already done a positive adjustment for a pair/block, then reduce.
|
||||
" Don't undo a positive adjustment for a pair because the previous line
|
||||
" was a continued line. That will happen after the end of the block.
|
||||
"if prevmatchlnum == l:prevlnum && b:pairadj <= 0
|
||||
if l:prevlnum && prevmatchlnum == l:prevlnum && b:pairadj <= 0
|
||||
let prevcont = 1
|
||||
endif
|
||||
|
||||
"echom "lastcont: " . lastcont .
|
||||
" \ ", prevcont: " . prevcont .
|
||||
" \ ", lastmatchlnum: " . lastmatchlnum .
|
||||
" \ ", prevmatchlnum: " . prevmatchlnum .
|
||||
" \ ", lastlnum: " . a:LastLNum .
|
||||
" \ ", PrevLNum: " . a:PrevLNum
|
||||
let firstcont = (lastcont && !prevcont)
|
||||
let firstcont = ((lastcont && !prevcont) || (lastcont && b:pairadj))
|
||||
|
||||
" If we are adjusting the current line for a pair, then don't count this
|
||||
" line as a post-continuation line. The post continuation line will be
|
||||
" after the close of said pair.
|
||||
let postcont = (!lastcont && prevcont)
|
||||
"let postcont = (!lastcont && prevcont && !b:pairadj )
|
||||
|
||||
let g:lastindent .= 'lastcont (' . lastcont . '), prevcont (' . prevcont . ') '
|
||||
|
||||
|
||||
"if firstcont && a:CurrLine !~ '^\s*{'
|
||||
if firstcont
|
||||
if has_key(a:Rule, 'ignore') && a:CurrLine =~ a:Rule.ignore
|
||||
let g:lastindent .= "(ignoring '" . a:Rule.ignore . "') "
|
||||
else
|
||||
let adj = adj + &sw
|
||||
endif
|
||||
"elseif postcont && a:LastLine !~ '^\s*{' "&& !b:pairadj
|
||||
elseif postcont
|
||||
if has_key(a:Rule, 'ignore') && a:LastLine =~ a:Rule.ignore
|
||||
let g:lastindent .= "(ignoring '" . a:Rule.ignore . "') "
|
||||
else
|
||||
let adj = adj - &sw
|
||||
endif
|
||||
endif
|
||||
|
||||
call cursor(origline, origcol)
|
||||
|
||||
if adj != 0 && b:indent_anything_echo
|
||||
let g:lastindent = g:lastindent .
|
||||
\ "GetContIndent('" . a:Rule.pattern . "'):" . adj . " "
|
||||
endif
|
||||
return adj
|
||||
|
||||
endfunction
|
||||
146
vim/bundle/eclim/indent/javascript.vim
Normal file
146
vim/bundle/eclim/indent/javascript.vim
Normal file
@@ -0,0 +1,146 @@
|
||||
" Author: Eric Van Dewoestine
|
||||
"
|
||||
" Description: {{{
|
||||
" Javascript indent file using IndentAnything.
|
||||
" Based on initial version developed by:
|
||||
" Tye Z. <zdro@yahoo.com>
|
||||
" The version accounts for a couple edge cases not handled in the ideal
|
||||
" manner by IndentAnything.
|
||||
"
|
||||
" License:
|
||||
"
|
||||
" Copyright (C) 2005 - 2012 Eric Van Dewoestine
|
||||
"
|
||||
" 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/>.
|
||||
"
|
||||
" }}}
|
||||
|
||||
let b:did_indent = 1
|
||||
if &indentexpr =~ 'EclimGetJavascriptIndent' ||
|
||||
\ (!exists('b:disableOverride') && exists('g:EclimJavascriptIndentDisabled'))
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime eclim/indent/indentanything.vim
|
||||
|
||||
setlocal indentexpr=EclimGetJavascriptIndent(v:lnum)
|
||||
setlocal indentkeys+=0),0},),;
|
||||
|
||||
" EclimGetJavascriptIndent(lnum) {{{
|
||||
function! EclimGetJavascriptIndent(lnum)
|
||||
let line = getline(a:lnum)
|
||||
let prevlnum = prevnonblank(a:lnum - 1)
|
||||
let prevline = getline(prevlnum)
|
||||
let pattern_heads = '\(' . join(map(copy(b:indentTrios), 'v:val[0]'), '\|') . '\)'
|
||||
|
||||
for trio in b:indentTrios
|
||||
" if the current line starts with any of the ending trios, then set the
|
||||
" current line indent to the same indent as the line starting that trio.
|
||||
if line =~ '^\s*' . trio[2]
|
||||
let col = col('.')
|
||||
call cursor(0, col('$'))
|
||||
|
||||
let matchstart = 0
|
||||
while search(')\|}\|\]', 'bcW', line('.')) && col('.') != 1
|
||||
let end = line[col('.') - 1]
|
||||
let start = ''
|
||||
for trio in b:indentTrios
|
||||
if trio[2] == end
|
||||
let start = trio[0]
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
let matchstart = searchpair(start, '', end, 'bnW', 'InCommentOrString()')
|
||||
if matchstart > 0 && matchstart < line('.')
|
||||
break
|
||||
endif
|
||||
call cursor(0, col('.') - 1)
|
||||
endwhile
|
||||
|
||||
call cursor(0, col)
|
||||
|
||||
if matchstart > 0
|
||||
return indent(matchstart)
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
for trio in b:indentTrios
|
||||
" if the previous line starts with any of the ending trios, then indent
|
||||
" one level to compensate for our adjustment above.
|
||||
if prevline =~ '^\s*' . trio[2] && prevline !~ pattern_heads . '$'
|
||||
let col = col('.')
|
||||
call cursor(a:lnum - 1, 1)
|
||||
let matchstart = searchpair(trio[0], '', trio[2], 'bnW', 'InCommentOrString()')
|
||||
call cursor(0, col)
|
||||
|
||||
" if the matching opener is on it's own line, then use the previous line
|
||||
" indent.
|
||||
if matchstart > 0 && getline(matchstart) =~ '^\s*' . trio[0]
|
||||
return indent(prevnonblank(matchstart - 1))
|
||||
endif
|
||||
return indent(prevlnum)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return IndentAnything()
|
||||
endfunction " }}}
|
||||
|
||||
" JavascriptIndentAnythingSettings() {{{
|
||||
function! JavascriptIndentAnythingSettings()
|
||||
" Syntax name REs for comments and strings.
|
||||
let b:commentRE = 'javaScript\(Line\)\?Comment'
|
||||
let b:lineCommentRE = 'javaScriptLineComment'
|
||||
let b:blockCommentRE = 'javaScriptComment'
|
||||
let b:stringRE = 'javaScript\(String\(S\|D\)\|RegexpString\|Special\)'
|
||||
let b:singleQuoteStringRE = 'javaScriptStringS'
|
||||
let b:doubleQuoteStringRE = 'javaScriptStringD'
|
||||
|
||||
" Setup for C-style comment indentation.
|
||||
let b:blockCommentStartRE = '/\*'
|
||||
let b:blockCommentMiddleRE = '\*'
|
||||
let b:blockCommentEndRE = '\*/'
|
||||
let b:blockCommentMiddleExtra = 1
|
||||
|
||||
" Indent another level for each non-closed paren/'(' and brace/'{' on the
|
||||
" previous line.
|
||||
let b:indentTrios = [
|
||||
\ [ '(', '', ')' ],
|
||||
\ [ '\[', '', '\]' ],
|
||||
\ [ '{', '\(default:\|case.*:\)', '}' ]
|
||||
\]
|
||||
|
||||
|
||||
" Line continuations. Lines that are continued on the next line are
|
||||
" if/for/while statements that are NOT followed by a '{' block and operators
|
||||
" at the end of a line.
|
||||
let b:lineContList = [
|
||||
\ { 'pattern' : '^\s*\(if\|for\|while\)\s*(.*)\s*\(\(//.*\)\|/\*.*\*/\s*\)\?\_$\(\_s*{\)\@!' },
|
||||
\ { 'pattern' : '^\s*else' . '\s*\(\(//.*\)\|/\*.*\*/\s*\)\?\_$\(\_s*{\)\@!' },
|
||||
\ { 'pattern' : '\(+\|=\|+=\|-=\)\s*\(\(//.*\)\|/\*.*\*/\s*\)\?$' }
|
||||
\]
|
||||
|
||||
" If a continued line and its continuation can have line-comments between
|
||||
" them, then this should be true. For example,
|
||||
"
|
||||
" if (x)
|
||||
" // comment here
|
||||
" statement
|
||||
"
|
||||
let b:contTraversesLineComments = 1
|
||||
endfunction " }}}
|
||||
|
||||
call JavascriptIndentAnythingSettings()
|
||||
|
||||
" vim:ft=vim:fdm=marker
|
||||
169
vim/bundle/eclim/indent/xml.vim
Normal file
169
vim/bundle/eclim/indent/xml.vim
Normal file
@@ -0,0 +1,169 @@
|
||||
" Author: Eric Van Dewoestine
|
||||
"
|
||||
" Description: {{{
|
||||
" Xml indent file using IndentAnything.
|
||||
"
|
||||
" License:
|
||||
"
|
||||
" Copyright (C) 2005 - 2012 Eric Van Dewoestine
|
||||
"
|
||||
" 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/>.
|
||||
"
|
||||
" }}}
|
||||
|
||||
if &indentexpr =~ 'EclimGetXmlIndent' ||
|
||||
\ (!exists('b:disableOverride') && exists('g:EclimXmlIndentDisabled'))
|
||||
finish
|
||||
endif
|
||||
|
||||
let b:did_indent = 1
|
||||
let b:disableOverride = 1
|
||||
runtime eclim/indent/indentanything.vim
|
||||
runtime! indent/dtd.vim
|
||||
|
||||
setlocal indentexpr=EclimGetXmlIndent(v:lnum)
|
||||
setlocal indentkeys=o,O,*<Return>,<>>,<<>,/,{,}
|
||||
|
||||
" EclimGetXmlIndent(lnum) {{{
|
||||
function! EclimGetXmlIndent(lnum)
|
||||
let line = line('.')
|
||||
let col = line('.')
|
||||
|
||||
let adj = 0
|
||||
|
||||
let doctypestart = search('<!DOCTYPE\>', 'bcW')
|
||||
if doctypestart > 0
|
||||
let doctypestart = search('\[', 'cW', doctypestart)
|
||||
let doctypeend = search('\]>', 'cW')
|
||||
endif
|
||||
call cursor(line, col)
|
||||
|
||||
let cdatastart = search('<!\[CDATA\[', 'bcW')
|
||||
if cdatastart > 0
|
||||
let cdatastart = search('\[', 'cW', cdatastart)
|
||||
let cdataend = search('\]\]>', 'cW')
|
||||
endif
|
||||
call cursor(line, col)
|
||||
|
||||
" Inside <DOCTYPE, let dtd indent do the work.
|
||||
if doctypestart > 0 && doctypestart < a:lnum &&
|
||||
\ (doctypeend == 0 || (doctypeend > doctypestart && a:lnum <= doctypeend))
|
||||
if a:lnum < doctypeend
|
||||
call DtdIndentAnythingSettings()
|
||||
return EclimGetDtdIndent(a:lnum)
|
||||
elseif a:lnum == doctypeend
|
||||
return indent(a:lnum) - &sw
|
||||
endif
|
||||
else
|
||||
" in a <[CDATA[ section
|
||||
if cdatastart > 0 && cdatastart < a:lnum &&
|
||||
\ (cdataend == 0 || (cdataend >= cdatastart && a:lnum <= cdataend))
|
||||
" only indent if nested text looks like xml
|
||||
if getline(a:lnum) =~ '^\s*<'
|
||||
if a:lnum == cdatastart + 1
|
||||
return indent(cdatastart) + &sw
|
||||
endif
|
||||
else
|
||||
return indent(a:lnum)
|
||||
endif
|
||||
|
||||
" make sure the closing of the CDATA lines up with the opening.
|
||||
if a:lnum == cdataend
|
||||
return indent(cdatastart)
|
||||
endif
|
||||
" make sure that tag following close of CDATA is properly indented.
|
||||
elseif cdatastart > 0 && cdatastart < a:lnum &&
|
||||
\ (cdataend >= cdatastart && prevnonblank(a:lnum - 1) == cdataend)
|
||||
return indent(cdatastart) - &sw
|
||||
endif
|
||||
|
||||
call XmlIndentAnythingSettings()
|
||||
let adj = s:XmlIndentAttributeWrap(a:lnum) * &sw
|
||||
|
||||
" handle case where previous line is a multi-line comment (<!-- -->) on one
|
||||
" line.
|
||||
let prevline = prevnonblank(a:lnum - 1)
|
||||
if getline(prevline) =~ '^\s\+<!--.\{-}-->'
|
||||
let adj = indent(prevline)
|
||||
endif
|
||||
|
||||
" handle case where comment end is on its own line.
|
||||
if getline(line) =~ '^\s*-->'
|
||||
let adj -= &sw
|
||||
endif
|
||||
endif
|
||||
|
||||
return IndentAnything() + adj
|
||||
endfunction " }}}
|
||||
|
||||
" XmlIndentAnythingSettings() {{{
|
||||
function! XmlIndentAnythingSettings()
|
||||
" Syntax name REs for comments and strings.
|
||||
let b:blockCommentRE = 'xmlComment'
|
||||
let b:commentRE = b:blockCommentRE
|
||||
let b:lineCommentRE = 'xmlComment'
|
||||
let b:stringRE = 'xmlString'
|
||||
let b:singleQuoteStringRE = b:stringRE
|
||||
let b:doubleQuoteStringRE = b:stringRE
|
||||
|
||||
setlocal comments=sr:<!--,mb:\ ,ex0:-->
|
||||
let b:blockCommentStartRE = '<!--'
|
||||
let b:blockCommentMiddleRE = ''
|
||||
let b:blockCommentEndRE = '-->'
|
||||
let b:blockCommentMiddleExtra = 2
|
||||
|
||||
" Indent another level for each non-closed element tag.
|
||||
let b:indentTrios = [
|
||||
\ [ '<\w', '', '\%(/>\|</\)' ],
|
||||
\ ]
|
||||
endfunction " }}}
|
||||
|
||||
" XmlIndentAttributeWrap(lnum) {{{
|
||||
" Function which indents line continued attributes an extra level for
|
||||
" readability.
|
||||
function! <SID>XmlIndentAttributeWrap(lnum)
|
||||
let line = line('.')
|
||||
let col = col('.')
|
||||
let adj = 0
|
||||
try
|
||||
" mover cursor to start of line to avoid matching start tag on first line
|
||||
" of nested content.
|
||||
call cursor(line, 1)
|
||||
let open = search('<\w\|<!DOCTYPE', 'bW')
|
||||
if open > 0
|
||||
let close = search('>', 'cW')
|
||||
if open != close
|
||||
" continuation line
|
||||
if close == 0 || close >= a:lnum
|
||||
" first continuation line
|
||||
if a:lnum == open + 1
|
||||
return 1
|
||||
endif
|
||||
" additional continuation lines
|
||||
return 0
|
||||
endif
|
||||
|
||||
" line after last continuation line
|
||||
if close == prevnonblank(a:lnum - 1)
|
||||
" inner content
|
||||
return -1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
finally
|
||||
call cursor(line, col)
|
||||
endtry
|
||||
endfunction " }}}
|
||||
|
||||
" vim:ft=vim:fdm=marker
|
||||
Reference in New Issue
Block a user