NvChad / ui

Lightweight & high performance UI plugin for nvchad
GNU General Public License v3.0
208 stars 124 forks source link

Fix terminal shell with spaces #330

Closed RoboG-11 closed 1 month ago

RoboG-11 commented 1 month ago

Hello, I am a Windows user, and I use PowerShell with NeoVim configured through NvChad. I've customized my PowerShell setup and wanted to use these configurations in NvChad, but NvTerm defaults to cmd, which I don't prefer. So, I decided to modify the NvChad setup to manually configure it to use PowerShell instead.

However, there is an issue with spacing on Windows that prevented me from using PowerShell with NvChad's integrated terminal.

Usecase

image

I tried to fix the error, and while I found a workaround, it resulted in two shells continuously opening.

Configuration

-- lua\options.lua
vim.o.shell = "C:\\Program Files\\PowerShell\\7\\pwsh.exe"
-- lua\configs\mappings\terminal.lua
map({ "n", "t" }, "<A-i>", function()
  require("nvchad.term").toggle {
    pos = "float",
    id = "floatTerm",

    float_opts = {
      relative = "editor",
      width = 0.75,
      height = 0.80,
      row = 0.050,
      col = 0.10,
      border = "double",
    },

    cmd = 'C:\\"Program Files"\\PowerShell\\7\\pwsh.exe'
}
end, { desc = "terminal toggle floating term" })

Usecase

image

Solution

No solution was found to fix this new bug by modifying the NvChad configuration, so I forked the repository and located the bug in the line that was modified in the PR. This resolved the issue, and now the integrated terminals in NvChad work correctly.

-- lua\plugins\init.lua
  {
    "NvChad/ui",
    url = "https://github.com/RoboG-11/ui",
  },
-- lua/nvchad/term/init.lua
  if opts.cmd and opts.buf then
    cmd = { shell, "-c", format_cmd(opts.cmd) .. "; " .. shell }
  else
    cmd = { shell }
  end

Usecase

image