Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax checker does not work with workspaces in PowerShell #495

Open
fleetingbytes opened this issue Mar 18, 2023 · 0 comments
Open

Syntax checker does not work with workspaces in PowerShell #495

fleetingbytes opened this issue Mar 18, 2023 · 0 comments

Comments

@fleetingbytes
Copy link

fleetingbytes commented Mar 18, 2023

  • rust.vim version: current

Steps to reproduce:

  • have MS PowerShell as the shell in which vim runs (e.g. $Env:ComSpec=C:\WINDOWS\SysWOW64\WindowsPowerShell\v1.0\powershell.exe)
" in .vimrc
" Set Powershell as the shell of choice
let &shell = has('win32') ? 'powershell' : 'pwsh'
let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;'
let &shellredir = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode'
let &shellpipe = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode'
set shellquote=\" shellxquote=
set noshelltemp
  • have a rust project with a workspace
  • edit a file inside the workspace (e.g. a .rs file inside the embedded library) so that syntax-checkers/rust/cargo.vim would have to enter this fork of the cargo.vim script
  • save the .rs source file so that rust syntax-checker runs

Expected vs. actual behavior:

Actual:
2023-03-18 09_47_51-lib rs (C__Users_ssiegmun_src_serial2-updater_sulib_src) (3 of 6) - GVIM2

  • This happens because PowerShell does not chain commands with && like other shells, so it errors out at (cd <path> && cargo check)

Expected:

  • Chain commands with ; if Powershell is used.
  • I corrected it for myself like this (replaced && with ) ; () in here:
    if rust#GetConfigVar('rust_cargo_avoid_whole_workspace', 1)
        if l:root_cargo_toml !=# l:nearest_cargo_toml
            let makeprg = "cd " . fnamemodify(l:nearest_cargo_toml, ":p:h")
                        \ . ") ; (" . makeprg
        endif
    else
        let makeprg = "cd " . fnamemodify(l:root_cargo_toml, ":p:h")
                    \ . ") ; (" . makeprg
    endif
  • a mere ; is not enough because then you'd end one powershell command without closing the parenthesis.
  • The script needs some logic to do this type of command chaining only when PowerShell is used as shell.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant