Skip to content

Commit 78ec390

Browse files
committed
auto merge of #16527 : kballard/rust/vim_fold, r=chris
We shouldn't be setting any settings in the syntax file. Better to put them in the ftplugin, where they won't be pulled in by :syn-include and can be cleaned up when changing the filetype.
2 parents cf71f1c + ab65869 commit 78ec390

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/etc/vim/ftplugin/rust.vim

+14
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ if exists("g:loaded_delimitMate")
5656
let b:delimitMate_excluded_regions = delimitMate#Get("excluded_regions") . ',rustLifetimeCandidate,rustGenericLifetimeCandidate'
5757
endif
5858

59+
if has("folding") && exists('g:rust_fold') && g:rust_fold != 0
60+
let b:rust_set_foldmethod=1
61+
setlocal foldmethod=syntax
62+
if g:rust_fold == 2
63+
setlocal foldlevel<
64+
else
65+
setlocal foldlevel=99
66+
endif
67+
endif
68+
5969
if has('conceal') && exists('g:rust_conceal')
6070
let b:rust_set_conceallevel=1
6171
setlocal conceallevel=2
@@ -108,6 +118,10 @@ let b:undo_ftplugin = "
108118
\|else
109119
\|unlet! b:delimitMate_excluded_regions
110120
\|endif
121+
\|if exists('b:rust_set_foldmethod')
122+
\|setlocal foldmethod< foldlevel<
123+
\|unlet b:rust_set_foldmethod
124+
\|endif
111125
\|if exists('b:rust_set_conceallevel')
112126
\|setlocal conceallevel<
113127
\|unlet b:rust_set_conceallevel

src/etc/vim/syntax/rust.vim

-11
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,6 @@ elseif exists("b:current_syntax")
1111
finish
1212
endif
1313

14-
" Fold settings {{{1
15-
16-
if has("folding") && exists('g:rust_fold') && g:rust_fold != 0
17-
setlocal foldmethod=syntax
18-
if g:rust_fold == 2
19-
setlocal foldlevel<
20-
else
21-
setlocal foldlevel=99
22-
endif
23-
endif
24-
2514
" Syntax definitions {{{1
2615
" Basic keywords {{{2
2716
syn keyword rustConditional match if else

0 commit comments

Comments
 (0)