lsp-start "rust-analyzer"

map normal <space>b :<space>build<enter>
map normal <space>t :<space>test<enter>

if @platform() == windows @{
    command build @{
        open scratch "build.log"
        enqueue-keys aad
        replace-with-output "cmd /c cargo build 2>&1"
    }
    command test @{
        open scratch "test.log"
        enqueue-keys aad
        replace-with-output "cmd /c cargo test --workspace 2>&1"
    }
}

if @platform() == linux @{
    command build @{
        open scratch "build.log"
        enqueue-keys aad
        replace-with-output "sh -c 'cargo build 2<greater>&1'"
    }
    command test @{
        open scratch "test.log"
        enqueue-keys aad
        replace-with-output "sh -c 'cargo test --workspace 2<greater>&1'"
    }
}

