annotate runtime/indent/cmake.vim @ 7962:3e5cb57171f2

Added tag v7.4.1276 for changeset a7e58c6e4e9ae3e05f23f3a74327ea09f1913ac3
author Christian Brabandt <cb@256bit.org>
date Sun, 07 Feb 2016 15:15:04 +0100
parents dd6c2497c997
children 63b0b7b79b25
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
836
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
1 " Vim indent file
2249
6d3d35ff2c2b Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
2 " Program: CMake - Cross-Platform Makefile Generator
6d3d35ff2c2b Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
3 " Module: $RCSfile: cmake-indent.vim,v $
836
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
4 " Language: CMake (ft=cmake)
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
5 " Author: Andy Cedilnik <andy.cedilnik@kitware.com>
2249
6d3d35ff2c2b Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
6 " Maintainer: Karthik Krishnan <karthik.krishnan@kitware.com>
6d3d35ff2c2b Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
7 " Last Change: $Date: 2008-01-16 16:53:53 $
6d3d35ff2c2b Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
8 " Version: $Revision: 1.9 $
836
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
9 "
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
10 " Licence: The CMake license applies to this file. See
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
11 " http://www.cmake.org/HTML/Copyright.html
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
12 " This implies that distribution with Vim is allowed
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
13
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
14 if exists("b:did_indent")
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
15 finish
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
16 endif
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
17 let b:did_indent = 1
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
18
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
19 setlocal indentexpr=CMakeGetIndent(v:lnum)
2249
6d3d35ff2c2b Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
20 setlocal indentkeys+==ENDIF(,ENDFOREACH(,ENDMACRO(,ELSE(,ELSEIF(,ENDWHILE(
836
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
21
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
22 " Only define the function once.
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
23 if exists("*CMakeGetIndent")
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
24 finish
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
25 endif
3526
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2249
diff changeset
26 let s:keepcpo= &cpo
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2249
diff changeset
27 set cpo&vim
836
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
28
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
29 fun! CMakeGetIndent(lnum)
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
30 let this_line = getline(a:lnum)
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
31
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
32 " Find a non-blank line above the current line.
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
33 let lnum = a:lnum
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
34 let lnum = prevnonblank(lnum - 1)
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
35 let previous_line = getline(lnum)
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
36
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
37 " Hit the start of the file, use zero indent.
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
38 if lnum == 0
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
39 return 0
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
40 endif
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
41
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
42 let ind = indent(lnum)
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
43
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
44 let or = '\|'
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
45 " Regular expressions used by line indentation function.
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
46 let cmake_regex_comment = '#.*'
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
47 let cmake_regex_identifier = '[A-Za-z][A-Za-z0-9_]*'
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
48 let cmake_regex_quoted = '"\([^"\\]\|\\.\)*"'
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
49 let cmake_regex_arguments = '\(' . cmake_regex_quoted .
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
50 \ or . '\$(' . cmake_regex_identifier . ')' .
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
51 \ or . '[^()\\#"]' . or . '\\.' . '\)*'
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
52
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
53 let cmake_indent_comment_line = '^\s*' . cmake_regex_comment
839
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 836
diff changeset
54 let cmake_indent_blank_regex = '^\s*$'
836
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
55 let cmake_indent_open_regex = '^\s*' . cmake_regex_identifier .
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
56 \ '\s*(' . cmake_regex_arguments .
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
57 \ '\(' . cmake_regex_comment . '\)\?$'
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
58
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
59 let cmake_indent_close_regex = '^' . cmake_regex_arguments .
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
60 \ ')\s*' .
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
61 \ '\(' . cmake_regex_comment . '\)\?$'
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
62
2249
6d3d35ff2c2b Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
63 let cmake_indent_begin_regex = '^\s*\(IF\|MACRO\|FOREACH\|ELSE\|ELSEIF\|WHILE\|FUNCTION\)\s*('
6d3d35ff2c2b Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
64 let cmake_indent_end_regex = '^\s*\(ENDIF\|ENDFOREACH\|ENDMACRO\|ELSE\|ELSEIF\|ENDWHILE\|ENDFUNCTION\)\s*('
836
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
65
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
66 " Add
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
67 if previous_line =~? cmake_indent_comment_line " Handle comments
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
68 let ind = ind
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
69 else
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
70 if previous_line =~? cmake_indent_begin_regex
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
71 let ind = ind + &sw
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
72 endif
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
73 if previous_line =~? cmake_indent_open_regex
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
74 let ind = ind + &sw
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
75 endif
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
76 endif
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
77
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
78 " Subtract
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
79 if this_line =~? cmake_indent_end_regex
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
80 let ind = ind - &sw
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
81 endif
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
82 if previous_line =~? cmake_indent_close_regex
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
83 let ind = ind - &sw
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
84 endif
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
85
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
86 return ind
5a7843c57316 updated for version 7.0e02
vimboss
parents:
diff changeset
87 endfun
3526
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2249
diff changeset
88
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2249
diff changeset
89 let &cpo = s:keepcpo
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2249
diff changeset
90 unlet s:keepcpo