Syntax checker does not work with workspaces in PowerShell

Abierto
#495 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
vim
Área
tooling

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

  • 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.
Lenguaje dominante
Vim Script
Estrellas
4.2k
Forks
323
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de rust-lang/rust.vim

Todos los issues de rust-lang/rust.vim

Issues similares

Más issues de DevTools

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.