Skip to content

Commit

Permalink
files/nvim: construct necessary intermediate dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmmetz committed Mar 21, 2021
1 parent e5ecf50 commit d7b5141
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions files.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ func (f Files) Ensure(ctx context.Context) error {
return err
}
}
if err := os.MkdirAll(filepath.Dir(m.Dst), 0755); err != nil {
return fmt.Errorf("error making intermediate directories for %s: %w", m.Dst, err)
}
fmt.Printf("symlinking %s to %s\n", m.Src, m.Dst)
if err := os.Symlink(m.Src, m.Dst); err != nil {
return fmt.Errorf("error writing symlink from %s to %s: %w", m.Src, m.Dst, err)
Expand Down
3 changes: 3 additions & 0 deletions nvim.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ func (v Nvim) ensureInitVim() error {
return fmt.Errorf("unable to determine home dir: %w", err)
}
cfgPath := filepath.Join(home, ".config", "nvim", "init.vim")
if err := os.MkdirAll(filepath.Dir(cfgPath), 0755); err != nil {
return fmt.Errorf("error making intermediate directories for %s: %w", cfgPath, err)
}
fmt.Println("writing vim config to", cfgPath)
return ioutil.WriteFile(cfgPath, []byte(v.initVim()), 0755)
}
Expand Down

0 comments on commit d7b5141

Please sign in to comment.