Skip to content

Commit

Permalink
fix: fix nvim installer
Browse files Browse the repository at this point in the history
  • Loading branch information
pablobfonseca committed Mar 3, 2024
1 parent be6b847 commit 17eec51
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 26 deletions.
6 changes: 3 additions & 3 deletions cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/pablobfonseca/dotfiles/cmd/emacs"
"github.com/pablobfonseca/dotfiles/cmd/homebrew"
"github.com/pablobfonseca/dotfiles/cmd/vim"
"github.com/pablobfonseca/dotfiles/cmd/nvim"
"github.com/pablobfonseca/dotfiles/cmd/zsh"
"github.com/pablobfonseca/dotfiles/src/config"
"github.com/pablobfonseca/dotfiles/src/utils"
Expand All @@ -15,7 +15,7 @@ import (
var installCmd = &cobra.Command{
Use: "install",
Short: "Install the dotfiles",
Example: "dotfiles install vim",
Example: "dotfiles install nvim",
Long: "Install the dotfiles. You can install all the dotfiles or just some of them.",
Run: func(cmd *cobra.Command, args []string) {
p := mpb.New()
Expand All @@ -39,7 +39,7 @@ var installCmd = &cobra.Command{
func init() {
rootCmd.AddCommand(installCmd)

installCmd.AddCommand(vim.InstallVimCmd)
installCmd.AddCommand(nvim.InstallNvimCmd)
installCmd.AddCommand(emacs.InstallEmacsCmd)
installCmd.AddCommand(zsh.InstallZshCmd)
installCmd.AddCommand(homebrew.InstallHomebrewCmd)
Expand Down
28 changes: 11 additions & 17 deletions cmd/vim/install.go → cmd/nvim/install.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vim
package nvim

import (
"os"
Expand All @@ -10,11 +10,9 @@ import (
"github.com/vbauerster/mpb/v7"
)

const NVCHAD_REPO = "/~https://github.com/NvChad/NvChad"

var InstallVimCmd = &cobra.Command{
Use: "vim",
Short: "Install vim files",
var InstallNvimCmd = &cobra.Command{
Use: "nvim",
Short: "Install nvim files",
Run: func(cmd *cobra.Command, args []string) {
p := mpb.New()

Expand All @@ -23,11 +21,11 @@ var InstallVimCmd = &cobra.Command{
if utils.CommandExists("nvim") {
utils.SkipMessage("nvim already installed")
} else {
installNvimBar := utils.NewBar("Installing nvim", 1, p)
if err := utils.ExecuteCommand(verbose, "brew", "install", "neovim"); err != nil {
InstallNvimBar := utils.NewBar("Installing nvim", 1, p)
if err := utils.ExecuteCommand(verbose, "brew", "install", "nvim"); err != nil {
utils.ErrorMessage("Error installing nvim", err)
}
installNvimBar.Increment()
InstallNvimBar.Increment()
}

utils.CloneRepoIfNotExists(verbose)
Expand All @@ -36,20 +34,16 @@ var InstallVimCmd = &cobra.Command{
utils.SkipMessage("nvim files already exists")
return
}
installNvChadBar := utils.NewBar("Installing NvChad", 1, p)

if err := utils.ExecuteCommand(verbose, "git", "clone", "--depth", "1", NVCHAD_REPO, config.NvimConfigDir()); err != nil {
utils.ErrorMessage("Error cloning the repository", err)
}
installNvChadBar.Increment()

symlinkBar := utils.NewBar("Symlinking files", 1, p)

src := path.Join(config.DotfilesConfigDir(), "nvim", "custom")
dest := path.Join(config.NvimConfigDir(), "lua", "custom")
src := path.Join(config.DotfilesConfigDir(), "nvim")
dest := path.Join(config.NvimConfigDir())
if err := os.Symlink(src, dest); err != nil {
utils.ErrorMessage("Error creating symlink", err)
}
symlinkBar.Increment()

utils.SuccessMessage("nvim files synced")
},
}
8 changes: 4 additions & 4 deletions cmd/vim/uninstall.go → cmd/nvim/uninstall.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vim
package nvim

import (
"github.com/pablobfonseca/dotfiles/src/config"
Expand All @@ -7,9 +7,9 @@ import (
"github.com/vbauerster/mpb/v7"
)

var UninstallVimCmd = &cobra.Command{
Use: "vim",
Short: "Uninstall vim files",
var UnInstallNvimCmd = &cobra.Command{
Use: "nvim",
Short: "Uninstall nvim files",
Run: func(cmd *cobra.Command, args []string) {
p := mpb.New()

Expand Down
4 changes: 2 additions & 2 deletions cmd/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/vbauerster/mpb/v7"

"github.com/pablobfonseca/dotfiles/cmd/emacs"
"github.com/pablobfonseca/dotfiles/cmd/vim"
"github.com/pablobfonseca/dotfiles/cmd/nvim"
"github.com/pablobfonseca/dotfiles/src/config"
"github.com/pablobfonseca/dotfiles/src/utils"
)
Expand Down Expand Up @@ -35,6 +35,6 @@ func init() {

uninstallCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Verbose output")

uninstallCmd.AddCommand(vim.UninstallVimCmd)
uninstallCmd.AddCommand(nvim.UnInstallNvimCmd)
uninstallCmd.AddCommand(emacs.UninstallEmacsCmd)
}

0 comments on commit 17eec51

Please sign in to comment.