Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Using directory local environment for language servers and other functionality

オープン
#2,069 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
30/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
swift

調査の方向性

提案されている EnvironmentProvider プロトコルと EnvironmentProviderStore の設計から始めます。issue では CodeEdit のファイルやテストは指定されていません。リンクされている Zed の shell_env.rs と environment.rs の参照をコンテキストとして使用し、その後、作業を記載された 2 つの段階に分けます。完了とは、ディレクトリ単位の環境が direnv、venv、asdf、dotenv をサポートし、関連するプロセスに渡され、後から拡張 API を通じて拡張できることです。

索引モデルが issue の本文から書いたものです。

説明

enhancement extensions workspace
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

主要言語
Swift
スター
23k
フォーク
1.2k
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

CodeEditApp/CodeEdit のほかの issue

CodeEditApp/CodeEdit の issue をすべて見る

似ている issue

Swift の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。