diff --git a/.gitmodules b/.gitmodules index 51d3ee3c..45907e2c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "pylsp"] path = pylsp - url = git@github.com:Hoblovski/python-lsp-server.git + url = https://github.com/Hoblovski/python-lsp-server.git branch = abc diff --git a/README.md b/README.md index 867c06ef..4e363f0c 100644 --- a/README.md +++ b/README.md @@ -117,13 +117,14 @@ $ exit ABCoder currently supports the following languages: -| Language | Parser | Writer | -| -------- | ----------- | ----------- | -| Go | ✅ | ✅ | -| Rust | ✅ | Coming Soon | -| C | ✅ | Coming Soon | -| Python | ✅ | Coming Soon | -| TypeScript | ✅ | Coming Soon | +| Language | Parser | Writer | +| -------- | ------ | ----------- | +| Go | ✅ | ✅ | +| Rust | ✅ | Coming Soon | +| C | ✅ | Coming Soon | +| Python | ✅ | Coming Soon | +| JS/TS | ✅ | Coming Soon | +| Java | ✅ | Coming Soon | # Getting Involved diff --git a/docs/lsp-installation-en.md b/docs/lsp-installation-en.md index 13b6862f..4046e464 100644 --- a/docs/lsp-installation-en.md +++ b/docs/lsp-installation-en.md @@ -4,12 +4,14 @@ To parse dependencies between symbols in a repository, the abcoder parser requir The mapping between languages and language servers is as follows: -| Language | Language Server | Executable | -| -------- | ------------------------- | --------------- | -| Go | Does not use LSP, uses built-in parser | / | -| Rust | rust-analyzer | rust-analyzer | -| Python | (Modified) python-lsp-server | pylsp | -| C | clangd-18 | clangd-18 | +| Language | Language Server | Essential Environment | +| ---------- | ------------------------------------------------------------------ | --------------------- | +| Go | NA | golang 1.23+ | +| TypeScript | NA | node.js 20+ | +| Rust | rust-analyzer (official) | rust-toolchain | +| Python | pylsp ([modified](https://github.com/Hoblovski/python-lsp-server)) | Python 3.9+ | +| C | clangd-18 (official) | clang 18+ | +| Java | eclipse-jdtls (official) | java 17+ | Ensure the corresponding executable is in PATH before running abcoder. diff --git a/docs/lsp-installation-zh.md b/docs/lsp-installation-zh.md index 5e9d7553..f3503fbd 100644 --- a/docs/lsp-installation-zh.md +++ b/docs/lsp-installation-zh.md @@ -4,12 +4,14 @@ 语言和 language server 的对应关系如下 -| 语言 | Language server | 可执行文件 | -| --- | --- | --- | -| Go | 不使用 LSP,使用内置 parser | / | -| Rust | rust-analyzer | rust-analyzer | -| Python | (修改后的) python-lsp-server | pylsp | -| C | clangd-18 | clangd-18 | +| 语言 | Language server | 必要运行环境 | +| ---------- | -------------------------------------------------------------- | -------------- | +| Go | NA | golang 1.23+ | +| TypeScript | NA | node.js 20+ | +| Rust | rust-analyzer (官方) | rust-toolchain | +| Python | pylsp ([修改](https://github.com/Hoblovski/python-lsp-server)) | python 3.9+ | +| C | clangd-18 (官方) | clang 18+ | +| Java | eclipse-jdtls (官方) | java 17+ | 按如下教程完成安装后,在运行 abcoder 前请确保 PATH 中有对应可执行文件 diff --git a/lang/parse.go b/lang/parse.go index 7dcc22d5..ba7acd51 100644 --- a/lang/parse.go +++ b/lang/parse.go @@ -192,6 +192,8 @@ func installLanguageServer(language uniast.Language) (string, error) { return cxx.InstallLanguageServer() case uniast.Python: return python.InstallLanguageServer() + case uniast.Rust: + return rust.InstallLanguageServer() default: return "", fmt.Errorf("auto installation not supported for language: %s", language) } diff --git a/lang/python/lib.go b/lang/python/lib.go index 17b15a91..9b93288b 100644 --- a/lang/python/lib.go +++ b/lang/python/lib.go @@ -66,19 +66,14 @@ func InstallLanguageServer() (string, error) { } // git submodule init log.Error("Installing pylsp...") - if err := exec.Command("git", "submodule", "init").Run(); err != nil { - log.Error("git submodule init failed: %v", err) - return "", err - } - // git submodule update - if err := exec.Command("git", "submodule", "update").Run(); err != nil { - log.Error("git submodule update failed: %v", err) + if err := exec.Command("git", "submodule", "update", "--remote", "--init", "-f").Run(); err != nil { + log.Error("git clone failed: %v", err) return "", err } // python -m pip install -e projectRoot/pylsp log.Error("Running `python3 -m pip install -e pylsp/` .\nThis might take some time, make sure the network connection is ok.") - if err := exec.Command("python3", "-m", "pip", "install", "-e", "pylsp/").Run(); err != nil { - log.Error("python -m pip install failed: %v", err) + if err := exec.Command("python3", "-m", "pip", "install", "--break-system-packages", "-e", "pylsp/").Run(); err != nil { + log.Error("python3 -m pip install failed: %v", err) return "", err } if err := exec.Command("pylsp", "--version").Run(); err != nil { diff --git a/lang/rust/repo.go b/lang/rust/repo.go index 0bf2c041..21e69b7f 100644 --- a/lang/rust/repo.go +++ b/lang/rust/repo.go @@ -29,6 +29,18 @@ import ( const MaxWaitDuration = 5 * time.Minute +func InstallLanguageServer() (string, error) { + log.Info("Installing rust-analyzer...") + // check rustup exe exists + if _, err := exec.LookPath("rustup"); err != nil { + return "", fmt.Errorf("failed to find rustup, please install rustup first: https://rustup.rs") + } + if err := RunCmdInDir(".", "rustup", "component", "add", "rust-analyzer"); err != nil { + return "", fmt.Errorf("failed to install rust-analyzer: %w", err) + } + return "rust-analyzer", nil +} + func CheckRepo(repo string) (string, time.Duration) { // NOTICE: open the Cargo.toml file is required for Rust projects openfile := utils.FirstFile(repo, ".rs", filepath.Join(repo, "target")) diff --git a/main.go b/main.go index 83885554..762aa38b 100644 --- a/main.go +++ b/main.go @@ -57,10 +57,12 @@ Action: agent run as an Agent for all repo ASTs (*.json) in the specific directory. WIP: only support code-analyzing at present. version print the version of abcoder Language: + go for golang codes rust for rust codes cxx for c codes (cpp support is on the way) - go for golang codes python for python codes + ts for typescript codes + js for javascript codes java for java codes ` diff --git a/version.go b/version.go index cfba6b04..29c9c209 100644 --- a/version.go +++ b/version.go @@ -17,5 +17,5 @@ package main const ( - Version = "0.1.0" + Version = "0.2.0" )