diff options
| author | Florian Walch <florian@fwalch.com> | 2014-12-27 14:55:02 +0100 |
|---|---|---|
| committer | Florian Walch <florian@fwalch.com> | 2014-12-30 13:51:39 +0100 |
| commit | 272f1064c74c745af4ac97ca1e46015fc7a6934d (patch) | |
| tree | aa5023538237b1fdc8f2e505ded84939bd69106b /runtime/indent | |
| parent | a31bcfb98afbe4d845911b4d90255c18769f197a (diff) | |
| download | rneovim-272f1064c74c745af4ac97ca1e46015fc7a6934d.tar.gz rneovim-272f1064c74c745af4ac97ca1e46015fc7a6934d.tar.bz2 rneovim-272f1064c74c745af4ac97ca1e46015fc7a6934d.zip | |
vim-patch:1e8ebf8
Updated runtime files.
https://code.google.com/p/vim/source/detail?r=1e8ebf870720e7b671f98f22d653009826304c4f
Diffstat (limited to 'runtime/indent')
| -rw-r--r-- | runtime/indent/go.vim | 78 | ||||
| -rw-r--r-- | runtime/indent/sh.vim | 6 | ||||
| -rw-r--r-- | runtime/indent/vroom.vim | 2 |
3 files changed, 83 insertions, 3 deletions
diff --git a/runtime/indent/go.vim b/runtime/indent/go.vim new file mode 100644 index 0000000000..412ac871c4 --- /dev/null +++ b/runtime/indent/go.vim @@ -0,0 +1,78 @@ +" Vim indent file +" Language: Go +" Maintainer: David Barnett (https://github.com/google/vim-ft-go) +" Last Change: 2014 Aug 16 +" +" TODO: +" - function invocations split across lines +" - general line splits (line ends in an operator) + +if exists('b:did_indent') + finish +endif +let b:did_indent = 1 + +" C indentation is too far off useful, mainly due to Go's := operator. +" Let's just define our own. +setlocal nolisp +setlocal autoindent +setlocal indentexpr=GoIndent(v:lnum) +setlocal indentkeys+=<:>,0=},0=) + +if exists('*GoIndent') + finish +endif + +" The shiftwidth() function is relatively new. +" Don't require it to exist. +if exists('*shiftwidth') + function s:sw() abort + return shiftwidth() + endfunction +else + function s:sw() abort + return &shiftwidth + endfunction +endif + +function! GoIndent(lnum) + let l:prevlnum = prevnonblank(a:lnum-1) + if l:prevlnum == 0 + " top of file + return 0 + endif + + " grab the previous and current line, stripping comments. + let l:prevl = substitute(getline(l:prevlnum), '//.*$', '', '') + let l:thisl = substitute(getline(a:lnum), '//.*$', '', '') + let l:previ = indent(l:prevlnum) + + let l:ind = l:previ + + if l:prevl =~ '[({]\s*$' + " previous line opened a block + let l:ind += s:sw() + endif + if l:prevl =~# '^\s*\(case .*\|default\):$' + " previous line is part of a switch statement + let l:ind += s:sw() + endif + " TODO: handle if the previous line is a label. + + if l:thisl =~ '^\s*[)}]' + " this line closed a block + let l:ind -= s:sw() + endif + + " Colons are tricky. + " We want to outdent if it's part of a switch ("case foo:" or "default:"). + " We ignore trying to deal with jump labels because (a) they're rare, and + " (b) they're hard to disambiguate from a composite literal key. + if l:thisl =~# '^\s*\(case .*\|default\):$' + let l:ind -= s:sw() + endif + + return l:ind +endfunction + +" vim: sw=2 sts=2 et diff --git a/runtime/indent/sh.vim b/runtime/indent/sh.vim index 68f764ee69..0394ee22e8 100644 --- a/runtime/indent/sh.vim +++ b/runtime/indent/sh.vim @@ -2,7 +2,7 @@ " Language: Shell Script " Maintainer: Peter Aronoff <telemachus@arpinum.org> " Original Author: Nikolai Weibull <now@bitwi.se> -" Latest Revision: 2013-11-28 +" Latest Revision: 2014-08-22 if exists("b:did_indent") finish @@ -91,7 +91,9 @@ function! GetShIndent() if s:is_case(pine) let ind = indent(lnum) + s:indent_value('case-labels') else - let ind -= s:indent_value('case-statements') - s:indent_value('case-breaks') + let ind -= (s:is_case_label(pine, lnum) && s:is_case_ended(pine) ? + \ 0 : s:indent_value('case-statements')) - + \ s:indent_value('case-breaks') endif elseif s:is_case_break(line) let ind -= s:indent_value('case-breaks') diff --git a/runtime/indent/vroom.vim b/runtime/indent/vroom.vim index 10efb0eb90..d333e2c14e 100644 --- a/runtime/indent/vroom.vim +++ b/runtime/indent/vroom.vim @@ -1,6 +1,6 @@ " Vim indent file " Language: Vroom (vim testing and executable documentation) -" Maintainer: David Barnett (https://github.com/google/vim-ft.vroom) +" Maintainer: David Barnett (https://github.com/google/vim-ft-vroom) " Last Change: 2014 Jul 23 if exists('b:did_indent') |