Skip to content

Commit

Permalink
Escape command to run in shell for Neovim on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhamlett committed Feb 7, 2024
1 parent cae21a1 commit a4c66fa
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions plugin/wakatime.vim
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ let s:VERSION = '11.1.1'
\ 'callback': {channel, output -> s:AsyncInstallHandler(output)}})
elseif s:nvim_async
if s:IsWindows()
let job_cmd = cmd
let job_cmd = s:JoinArgs(cmd)
else
let job_cmd = [&shell, &shellcmdflag, s:JoinArgs(cmd)]
endif
Expand Down Expand Up @@ -278,7 +278,7 @@ EOF
let job = job_start(job_cmd, {'stoponexit': ''})
elseif s:nvim_async
if s:IsWindows()
let job_cmd = cmd
let job_cmd = s:JoinArgs(cmd)
else
let job_cmd = [&shell, &shellcmdflag, s:JoinArgs(cmd)]
endif
Expand Down Expand Up @@ -589,7 +589,7 @@ EOF
endif
elseif s:nvim_async
if s:IsWindows()
let job_cmd = cmd
let job_cmd = s:JoinArgs(cmd)
else
let job_cmd = [&shell, &shellcmdflag, s:JoinArgs(cmd)]
endif
Expand Down Expand Up @@ -822,7 +822,7 @@ EOF
\ 'callback': {channel, output -> s:AsyncTodayHandler(output, cmd)}})
elseif s:nvim_async
if s:IsWindows()
let job_cmd = cmd
let job_cmd = s:JoinArgs(cmd)
else
let job_cmd = [&shell, &shellcmdflag, s:JoinArgs(cmd)]
endif
Expand Down Expand Up @@ -865,7 +865,7 @@ EOF
\ 'callback': {channel, output -> s:AsyncFileExpertHandler(output, cmd)}})
elseif s:nvim_async
if s:IsWindows()
let job_cmd = cmd
let job_cmd = s:JoinArgs(cmd)
else
let job_cmd = [&shell, &shellcmdflag, s:JoinArgs(cmd)]
endif
Expand Down Expand Up @@ -912,7 +912,7 @@ EOF
\ 'callback': {channel, output -> s:AsyncVersionHandler(output, cmd)}})
elseif s:nvim_async
if s:IsWindows()
let job_cmd = cmd
let job_cmd = s:JoinArgs(cmd)
else
let job_cmd = [&shell, &shellcmdflag, s:JoinArgs(cmd)]
endif
Expand Down

2 comments on commit a4c66fa

@vonPB
Copy link

@vonPB vonPB commented on a4c66fa Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alanhamlett this commit broke my wakatime btw. Missing a few days now, but thats ok. Just checked out the previous commit again, and its working.

Running nvim (either stable or nightly, same issue) on windows 11 in powershell 7.4.1.

vim.opt.shell         = vim.fn.executable "pwsh" and "pwsh" or "powershell"
vim.opt.shellcmdflag  =
"-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;"
vim.opt.shellredir    = "-RedirectStandardOutput %s -NoNewWindow -Wait"
vim.opt.shellpipe     = "2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode"
vim.opt.shellquote    = ""
vim.opt.shellxquote   = ""

Error when running :WakaTimeToday :

^[[31;1mParserError: ^[[0m
^[[31;1m^[[36;1mLine |^[[0m
^[[31;1m^[[36;1m^[[36;1m   1 | ^[[0m . e]::OutputEncoding=[System.Text.Encoding]::UTF8; "wakatime" ^[[36;1m"--today"^[[0m
^[[31;1m^[[36;1m^[[36;1m^[[0m^[[36;1m^[[0m^[[36;1m     | ^[[31;1m                                                               ~~~~~~~~~^[[0m
^[[31;1m^[[36;1m^[[36;1m^[[0m^[[36;1m^[[0m^[[36;1m^[[31;1m^[[31;1m^[[36;1m     | ^[[31;1mUnexpected token '"--today"' in expression or statement.^[[0m
Press ENTER or type command to continue```

Happy to open an issue, but dont really mind just using the previous commit from now on :)

@alanhamlett
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted with 285c2e4.

That means need to re-open #180 and find the correct fix.

Please sign in to comment.