]> git.lizzy.rs Git - micro.git/commitdiff
plugins: load directories that are symlinks (#2214)
authorDaniel Lee Harple <dlh@harple.com>
Sun, 24 Jul 2022 21:13:46 +0000 (17:13 -0400)
committerGitHub <noreply@github.com>
Sun, 24 Jul 2022 21:13:46 +0000 (14:13 -0700)
Fix issue where symlinked plugin directories were ignored. For example

    $ file ~/.config/micro/plug/example
    example: symbolic link to <target directory>

This allows plugins to be managed in a user's "dotfiles" repository, and
be symlinked into micro's plugin directory.

internal/config/rtfiles.go

index 397a85398dc049624b653c2d622e347c0a483625..fb4497e668f94839cc353a9f5ae207e3db280409 100644 (file)
@@ -186,8 +186,9 @@ func InitRuntimeFiles() {
        isID := regexp.MustCompile(`^[_A-Za-z0-9]+$`).MatchString
 
        for _, d := range files {
-               if d.IsDir() {
-                       srcs, _ := ioutil.ReadDir(filepath.Join(plugdir, d.Name()))
+               plugpath := filepath.Join(plugdir, d.Name())
+               if stat, err := os.Stat(plugpath); err == nil && stat.IsDir() {
+                       srcs, _ := ioutil.ReadDir(plugpath)
                        p := new(Plugin)
                        p.Name = d.Name()
                        p.DirName = d.Name()