annotate runtime/indent/sass.vim @ 9287:af25a1a875db v7.4.1926

commit https://github.com/vim/vim/commit/a890f5e34887bff7616bdb4b9ee0bf98c8d2a8f0 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 12 23:03:19 2016 +0200 patch 7.4.1926 Problem: Possible crash with many history items. Solution: Avoid the index going past the last item.
author Christian Brabandt <cb@256bit.org>
date Sun, 12 Jun 2016 23:15:07 +0200
parents 2eb30f341e8d
children 43efa4f5a8ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
1 " Vim indent file
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1668
diff changeset
2 " Language: Sass
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1668
diff changeset
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2202
diff changeset
4 " Last Change: 2013 May 30
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
5
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
6 if exists("b:did_indent")
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
7 finish
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
8 endif
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
9 let b:did_indent = 1
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
10
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
11 setlocal autoindent sw=2 et
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
12 setlocal indentexpr=GetSassIndent()
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
13 setlocal indentkeys=o,O,*<Return>,<:>,!^F
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
14
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
15 " Only define the function once.
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
16 if exists("*GetSassIndent")
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
17 finish
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
18 endif
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
19
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2202
diff changeset
20 let s:property = '^\s*:\|^\s*[[:alnum:]#{}-]\+\%(:\|\s*=\)'
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2202
diff changeset
21 let s:extend = '^\s*\%(@extend\|@include\|+\)'
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
22
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
23 function! GetSassIndent()
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
24 let lnum = prevnonblank(v:lnum-1)
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
25 let line = substitute(getline(lnum),'\s\+$','','')
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
26 let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','')
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
27 let lastcol = strlen(line)
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
28 let line = substitute(line,'^\s\+','','')
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
29 let indent = indent(lnum)
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
30 let cindent = indent(v:lnum)
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2202
diff changeset
31 if line !~ s:property && line !~ s:extend && cline =~ s:property
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
32 return indent + &sw
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
33 "elseif line =~ s:property && cline !~ s:property
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
34 "return indent - &sw
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
35 else
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
36 return -1
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
37 endif
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
38 endfunction
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
39
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
40 " vim:set sw=2: