Using directory local environment for language servers and other functionality
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 30/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- swift
- Ambito
- developer-experience, tooling
Direzione di ricerca
Inizia con il design proposto del protocollo EnvironmentProvider e di EnvironmentProviderStore; nell’issue non sono indicati file CodeEdit o test. Usa come contesto i riferimenti collegati di Zed shell_env.rs e environment.rs, quindi suddividi il lavoro nelle due fasi indicate. Il lavoro è completato quando gli ambienti locali alla directory supportano direnv, venv, asdf e dotenv, vengono passati ai processi pertinenti e possono essere estesi in seguito tramite un’API per le estensioni.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
Environment providers.
I propose a new struct: EnvironmentProviderStore, for the environment providers, which would be used to get the environment for the current directory. This should be implemented in two stages:
a) Implement the API inside of CodeEdit to iron out rough edges, implement support for direnv, venv, asdf and dotenv using it.
b) Create an extension API allowing users to extend CodeEdit with their own environment providers, move existing ones to the extensions
The protocol is as follows:
protocol EnvironmentProvider {
var displayName { get }
func update_env(_ env: [String : String], for directory: FilePath) async throws -> [String: String]
}
Then, based on this protocol, projects should use functions reliant on it to find binaries in path, as well as passing the environment to executed processes
Alternatives Considered
Install everything globally
Additional Context
An example implementation for direnv
import Foundation
struct DirenvProvider: EnvironmentProvider {
let displayName = "direnv"
func update_env(_ env: [String: String], for directory: FilePath) async throws -> [String: String] {
let process = Process()
process.executableURL = URL(fileURLWithPath: "/usr/bin/env")
process.arguments = ["direnv", "export", "json"]
process.currentDirectoryURL = URL(fileURLWithPath: directory.string)
process.environment = env
let pipe = Pipe()
process.standardOutput = pipe
process.standardError = Pipe()
try process.run()
process.waitUntilExit()
guard process.terminationStatus == 0 else {
throw DirenvError.commandFailed(exitCode: process.terminationStatus)
}
let data = pipe.fileHandleForReading.readDataToEndOfFile()
guard let jsonString = String(data: data, encoding: .utf8) else {
throw DirenvError.invalidOutput
}
guard let jsonData = jsonString.data(using: .utf8),
let exportedEnv = try JSONSerialization.jsonObject(with: jsonData) as? [String: String] else {
throw DirenvError.jsonParsingFailed
}
var updatedEnv = env
for (key, value) in exportedEnv {
updatedEnv[key] = value
}
return updatedEnv
}
}
enum DirenvError: Error, LocalizedError {
case commandFailed(exitCode: Int32)
case invalidOutput
case jsonParsingFailed
var errorDescription: String? {
switch self {
case .commandFailed(let exitCode):
return "direnv command failed with exit code \(exitCode)"
case .invalidOutput:
return "direnv produced invalid output"
case .jsonParsingFailed:
return "Failed to parse direnv JSON output"
}
}
}
This should of course be made to asynchronously execute the direnv process but that's mostly details
Zed implementation for reference (it hardcodes direnv and relies on a shell hook for everything else which is explicitly not what I want to do here:
https://github.com/zed-industries/zed/blob/main/crates/util/src/shell_env.rs
https://github.com/zed-industries/zed/blob/main/crates/project/src/environment.rs#L178
Screenshots
No response
- Lingua principale
- Swift
- Stelle
- 23k
- Fork
- 1.2k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di CodeEditApp/CodeEdit
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
CodeEditApp/CodeEdit#2190 ·
-
Is this project dead? Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 15/100
CodeEditApp/CodeEdit#2195 · 5 reazioni ·
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
CodeEditApp/CodeEdit#2185 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
CodeEditApp/CodeEdit#2181 ·
-
creashes on starting Apertabug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
CodeEditApp/CodeEdit#2180 ·
Tutte le issue di CodeEditApp/CodeEdit
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
manaflow-ai/cmux#13763 ·
-
type: feature request
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
googleapis/google-cloud-swift#1036 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
wultra/mtoken-sdk-ios#253 ·
-
The correction-threshold rationale says 17 restraint cases collide; the current corpus has 16 Apertaarea:dictation documentation P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
uttrflow/uttrflow-swift#1180 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100