Syntax checker does not work with workspaces in PowerShell

Aperta
#495 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
vim
Ambito
tooling

Direzione di ricerca

Start with syntax_checkers/rust/cargo.vim, especially the workspace command construction around the lines linked in the issue, and inspect how the Vim shell setting identifies PowerShell. Reproduce the failure using the provided PowerShell configuration and a Rust workspace. Done when workspace syntax checking chains commands in a way PowerShell accepts while preserving the existing behavior for other shells.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

  • 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.
Lingua principale
Vim Script
Stelle
4.2k
Fork
323
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rust-lang/rust.vim

Tutte le issue di rust-lang/rust.vim

Issue simili

Altre issue su DevTools

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.