File tree Expand file tree Collapse file tree 3 files changed +45
-9
lines changed
Expand file tree Collapse file tree 3 files changed +45
-9
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,9 @@ var defaultCommonSettings = map[string]interface{}{
7070 "hltrailingws" : false ,
7171 "ignorecase" : true ,
7272 "incsearch" : true ,
73- "indentchar" : " " ,
73+ "indenttabchar" : " " ,
74+ "indentspacechar" : " " ,
75+ "spacechar" : " " ,
7476 "keepautoindent" : false ,
7577 "matchbrace" : true ,
7678 "matchbraceleft" : true ,
@@ -213,6 +215,13 @@ func validateParsedSettings() error {
213215 }
214216 continue
215217 }
218+
219+ if k == "indentchar" {
220+ // migrate to "indenttabchar" from "indentchar"
221+ parsedSettings ["indenttabchar" ] = v
222+ err = errors .New ("indentchar has been deprecated, use indenttabchar instead" )
223+ }
224+
216225 if _ , ok := defaults [k ]; ok {
217226 if e := verifySetting (k , v , defaults [k ]); e != nil {
218227 err = e
Original file line number Diff line number Diff line change @@ -572,8 +572,25 @@ func (w *BufWindow) displayBuffer() {
572572 }
573573 }
574574
575- if r == '\t' {
576- indentrunes := []rune (b .Settings ["indentchar" ].(string ))
575+ if r == '\t' || (r == ' ' && bloc .X < blineLen ) {
576+ var indentrunes []rune
577+ switch r {
578+ case '\t' :
579+ indentrunes = []rune (b .Settings ["indentchar" ].(string ))
580+ case ' ' :
581+ if bloc .X % tabsize == 0 && bloc .X < leadingwsEnd {
582+ indentrunes = []rune (b .Settings ["indentspacechar" ].(string ))
583+ } else {
584+ indentrunes = []rune (b .Settings ["spacechar" ].(string ))
585+ }
586+ }
587+
588+ if len (indentrunes ) == 0 {
589+ r = ' '
590+ } else {
591+ r = indentrunes [0 ]
592+ }
593+
577594 // if empty indentchar settings, use space
578595 if len (indentrunes ) == 0 {
579596 indentrunes = []rune {' ' }
Original file line number Diff line number Diff line change @@ -203,12 +203,22 @@ Here are the available options:
203203
204204 default value: ` true `
205205
206- * ` indentchar ` : sets the indentation character. This will not be inserted into
207- files; it is only a visual indicator that whitespace is present. If set to a
208- printing character, it functions as a subset of the "show invisibles"
209- setting available in many other text editors. The color of this character is
210- determined by the ` indent-char ` field in the current theme rather than the
211- default text color.
206+ * ` indenttabchar ` : sets the indentation character for tabs. This will not be
207+ inserted into files; it is only a visual indicator that whitespace is present.
208+ If set to a printing character, it functions as a subset of the
209+ "show invisibles" setting available in many other text editors. The color of
210+ this character is determined by the ` indent-char ` field in the current theme
211+ rather than the default text color.
212+
213+ default value: ` ` (space)
214+
215+ * ` indentspacechar ` : same as ` indenttabchar ` except for spaces that are at
216+ locations that are divisible by ` tabsize ` .
217+
218+ default value: ` ` (space)
219+
220+ * ` spacechar ` : same as ` indenttabchar ` but for all spaces. ` indentspacechar `
221+ takes precedence over this option.
212222
213223 default value: ` ` (space)
214224
You can’t perform that action at this time.
0 commit comments