(reloadFiletype bool)
| 13 | ) |
| 14 | |
| 15 | func (b *Buffer) ReloadSettings(reloadFiletype bool) { |
| 16 | settings := config.ParsedSettings() |
| 17 | config.UpdatePathGlobLocals(settings, b.AbsPath) |
| 18 | |
| 19 | oldFiletype := b.Settings["filetype"].(string) |
| 20 | |
| 21 | _, local := b.LocalSettings["filetype"] |
| 22 | _, volatile := config.VolatileSettings["filetype"] |
| 23 | if reloadFiletype && !local && !volatile { |
| 24 | // need to update filetype before updating other settings based on it |
| 25 | b.Settings["filetype"] = "unknown" |
| 26 | if v, ok := settings["filetype"]; ok { |
| 27 | b.Settings["filetype"] = v |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | // update syntax rules, which will also update filetype if needed |
| 32 | b.UpdateRules() |
| 33 | |
| 34 | curFiletype := b.Settings["filetype"].(string) |
| 35 | if oldFiletype != curFiletype { |
| 36 | b.doCallbacks("filetype", oldFiletype, curFiletype) |
| 37 | } |
| 38 | |
| 39 | config.UpdateFileTypeLocals(settings, curFiletype) |
| 40 | |
| 41 | for k, v := range config.DefaultCommonSettings() { |
| 42 | if k == "filetype" { |
| 43 | // prevent recursion |
| 44 | continue |
| 45 | } |
| 46 | if _, ok := config.VolatileSettings[k]; ok { |
| 47 | // reload should not override volatile settings |
| 48 | continue |
| 49 | } |
| 50 | if _, ok := b.LocalSettings[k]; ok { |
| 51 | // reload should not override local settings |
| 52 | continue |
| 53 | } |
| 54 | if _, ok := settings[k]; ok { |
| 55 | b.DoSetOptionNative(k, settings[k]) |
| 56 | } else { |
| 57 | b.DoSetOptionNative(k, v) |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | func (b *Buffer) DoSetOptionNative(option string, nativeValue any) { |
| 63 | oldValue := b.Settings[option] |
no test coverage detected