@@ -39,15 +39,15 @@ set wildignore+=*.ko,*.mod.c,*.order,modules.builtin
39
39
augroup linuxsty
40
40
autocmd !
41
41
42
- autocmd FileType c,cpp call s : LinuxConfigure ()
42
+ autocmd FileType c,cpp call g : LinuxConfigure (" settings_only " )
43
43
autocmd FileType diff setlocal ts = 8
44
44
autocmd FileType rst setlocal ts = 8 sw = 8 sts = 8 noet
45
45
autocmd FileType kconfig setlocal ts = 8 sw = 8 sts = 8 noet
46
46
autocmd FileType dts setlocal ts = 8 sw = 8 sts = 8 noet
47
47
autocmd FileType make setlocal ts = 8 sw = 8 sts = 8 noet
48
48
augroup END
49
49
50
- function s : LinuxConfigure ()
50
+ function g : LinuxConfigure (what )
51
51
let apply_style = 0
52
52
53
53
if exists (" g:linuxsty_patterns" )
@@ -63,17 +63,22 @@ function s:LinuxConfigure()
63
63
endif
64
64
65
65
if apply_style
66
- call s: LinuxCodingStyle ()
66
+ call s: LinuxCodingStyle (a: what )
67
67
endif
68
68
endfunction
69
69
70
- command ! LinuxCodingStyle call s: LinuxCodingStyle ()
70
+ command ! LinuxCodingStyle call s: LinuxCodingStyle (" all " )
71
71
72
- function ! s: LinuxCodingStyle ()
73
- call s: LinuxFormatting ()
74
- call s: LinuxKeywords ()
75
- call s: LinuxHighlighting ()
76
- call s: LinuxSavePath ()
72
+ function ! s: LinuxCodingStyle (what)
73
+ if a: what != " settings_only"
74
+ call s: LinuxSyntax ()
75
+ endif
76
+
77
+ if a: what != " syntax_only"
78
+ call s: LinuxFormatting ()
79
+ call s: LinuxHighlighting ()
80
+ call s: LinuxSavePath ()
81
+ endif
77
82
endfunction
78
83
79
84
function s: LinuxFormatting ()
@@ -87,7 +92,7 @@ function s:LinuxFormatting()
87
92
setlocal cinoptions = :0 ,l1,t0,g0,(0
88
93
endfunction
89
94
90
- function s: LinuxKeywords ()
95
+ function s: LinuxSyntax ()
91
96
syn keyword cStatement fallthrough return_ptr
92
97
syn keyword cStorageClass noinline __always_inline __must_check
93
98
syn keyword cStorageClass __pure __weak __noclone
@@ -98,11 +103,6 @@ function s:LinuxKeywords()
98
103
syn keyword cType __u8 __u16 __u32 __u64 __s8 __s16 __s32 __s64
99
104
syn keyword cType __le16 __le32 __le64 __be16 __be32 __be64
100
105
syn keyword LinuxGuard guard scoped_guard scoped_cond_guard
101
- endfunction
102
-
103
- function s: LinuxHighlighting ()
104
- highlight default link LinuxError ErrorMsg
105
- highlight default link LinuxGuard cConditional
106
106
107
107
syn match LinuxError / \+\z e\t / " spaces before tab
108
108
syn match LinuxError / \% >100v[^()\{\}\[\] <>]\+ / " virtual column 101 and more
@@ -114,6 +114,11 @@ function s:LinuxHighlighting()
114
114
" highlight various for_each() variants
115
115
syn match cRepeat / \v ^\s *\z s((h)?list_|device_)?for_each(_\w +)?(\( )@=/
116
116
117
+ highlight default link LinuxError ErrorMsg
118
+ highlight default link LinuxGuard cConditional
119
+ endfunction
120
+
121
+ function s: LinuxHighlighting ()
117
122
" Highlight trailing whitespace, unless we're in insert mode and the
118
123
" cursor's placed right after the whitespace. This prevents us from having
119
124
" to put up with whitespace being highlighted in the middle of typing
@@ -151,7 +156,7 @@ endfunction
151
156
152
157
if g: linuxsty_save_path
153
158
if s: PathExistInCacheFile (s: path_cache_file , s: path )
154
- call s: LinuxCodingStyle ()
159
+ call s: LinuxCodingStyle (" all " )
155
160
endif
156
161
endif
157
162
0 commit comments