Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -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
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions docs/lsp-installation-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
14 changes: 8 additions & 6 deletions docs/lsp-installation-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 中有对应可执行文件

Expand Down
2 changes: 2 additions & 0 deletions lang/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
13 changes: 4 additions & 9 deletions lang/python/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions lang/rust/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
`

Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
package main

const (
Version = "0.1.0"
Version = "0.2.0"
)
Loading