Skip to content

Commit baca0e5

Browse files
committed
Add param to InitRuntimeFiles() to init built-in files only
1 parent d67ce73 commit baca0e5

File tree

7 files changed

+13
-9
lines changed

7 files changed

+13
-9
lines changed

cmd/micro/micro.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ func main() {
254254
screen.TermMessage(err)
255255
}
256256

257-
config.InitRuntimeFiles()
257+
config.InitRuntimeFiles(true)
258258
config.InitPlugins()
259259

260260
err = config.ReadSettings()

cmd/micro/micro_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func startup(args []string) (tcell.SimulationScreen, error) {
3535
return nil, err
3636
}
3737

38-
config.InitRuntimeFiles()
38+
config.InitRuntimeFiles(true)
3939
config.InitPlugins()
4040

4141
err = config.ReadSettings()

internal/action/command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ func reloadRuntime(reloadPlugins bool) {
348348
}
349349
}
350350

351-
config.InitRuntimeFiles()
351+
config.InitRuntimeFiles(true)
352352

353353
if reloadPlugins {
354354
config.InitPlugins()

internal/buffer/buffer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type operation struct {
2020

2121
func init() {
2222
ulua.L = lua.NewState()
23-
config.InitRuntimeFiles()
23+
config.InitRuntimeFiles(true)
2424
config.InitGlobalSettings()
2525
config.GlobalSettings["backup"] = false
2626
config.GlobalSettings["fastdirty"] = true

internal/buffer/settings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func (b *Buffer) SetOptionNative(option string, nativeValue interface{}) error {
2020
} else if option == "statusline" {
2121
screen.Redraw()
2222
} else if option == "filetype" {
23-
config.InitRuntimeFiles()
23+
config.InitRuntimeFiles(true)
2424
err := config.ReadSettings()
2525
if err != nil {
2626
screen.TermMessage(err)

internal/config/rtfiles.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,14 @@ func ListRealRuntimeFiles(fileType RTFiletype) []RuntimeFile {
166166
return realFiles[fileType]
167167
}
168168

169-
// InitRuntimeFiles initializes all assets file and the config directory
170-
func InitRuntimeFiles() {
169+
// InitRuntimeFiles initializes all assets files and the config directory.
170+
// If `user` is false, InitRuntimeFiles ignores the config directory and
171+
// initializes asset files only.
172+
func InitRuntimeFiles(user bool) {
171173
add := func(fileType RTFiletype, dir, pattern string) {
172-
AddRuntimeFilesFromDirectory(fileType, filepath.Join(ConfigDir, dir), pattern)
174+
if user {
175+
AddRuntimeFilesFromDirectory(fileType, filepath.Join(ConfigDir, dir), pattern)
176+
}
173177
AddRuntimeFilesFromAssets(fileType, path.Join("runtime", dir), pattern)
174178
}
175179

internal/config/rtfiles_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
func init() {
10-
InitRuntimeFiles()
10+
InitRuntimeFiles(true)
1111
}
1212

1313
func TestAddFile(t *testing.T) {

0 commit comments

Comments
 (0)