Add reload setting - finalization of #2627 (#2845)

* Add reload setting

Can be set to:

* auto - Automatically reload files that changed
* disabled - Do not reload files
* prompt - Prompt the user about reloading the file.

* option: Add default value for reload option and documentation

---------

Co-authored-by: Wilberto Morales <wilbertomorales777@gmail.com>
This commit is contained in:
Jöran Karl
2023-10-22 00:18:41 +02:00
committed by GitHub
parent 9da6af91c8
commit f7244d09c6
3 changed files with 47 additions and 10 deletions

View File

@@ -52,6 +52,7 @@ var optionValidators = map[string]optionValidator{
"fileformat": validateLineEnding,
"encoding": validateEncoding,
"multiopen": validateMultiOpen,
"reload": validateReload,
}
func ReadSettings() error {
@@ -294,6 +295,7 @@ var defaultCommonSettings = map[string]interface{}{
"mkparents": false,
"permbackup": false,
"readonly": false,
"reload": "prompt",
"rmtrailingws": false,
"ruler": true,
"relativeruler": false,
@@ -526,3 +528,19 @@ func validateMultiOpen(option string, value interface{}) error {
return nil
}
func validateReload(option string, value interface{}) error {
val, ok := value.(string)
if !ok {
return errors.New("Expected string type for reload")
}
switch val {
case "prompt", "auto", "disabled":
default:
return errors.New(option + " must be 'prompt', 'auto' or 'disabled'")
}
return nil
}