Skip to content
Draft
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
3 changes: 3 additions & 0 deletions lang/collect/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
. "github.com/cloudwego/abcoder/lang/lsp"
"github.com/cloudwego/abcoder/lang/python"
"github.com/cloudwego/abcoder/lang/rust"
"github.com/cloudwego/abcoder/lang/typescript"

Check failure on line 32 in lang/collect/collect.go

View workflow job for this annotation

GitHub Actions / Run go test

no required module provides package github.com/cloudwego/abcoder/lang/typescript; to add it:
"github.com/cloudwego/abcoder/lang/uniast"
)

Expand Down Expand Up @@ -91,6 +92,8 @@
return cxx.NewCxxSpec()
case uniast.Python:
return python.NewPythonSpec()
case uniast.Typescript:
return typescript.NewTypescriptSpec()
default:
panic(fmt.Sprintf("unsupported language %s", l))
}
Expand Down
9 changes: 8 additions & 1 deletion lang/lsp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,14 @@ func (rwc rwc) Close() error {
// start a LSP process and return its io
func startLSPSever(path string) (io.ReadWriteCloser, error) {
// Launch rust-analyzer
cmd := exec.Command(path)
cmd := exec.Command(path, "--stdio")
cmd.Env = append(os.Environ(), "PATH=/usr/local/bin/:"+os.Getenv("PATH"))
abc, err := exec.LookPath("typescript-language-server")
if err != nil {
fmt.Println("未找到 typescript-language-server 命令:", err)
} else {
fmt.Println("找到 typescript-language-server 命令在:", abc)
}

stdin, err := cmd.StdinPipe()
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions lang/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/cloudwego/abcoder/lang/lsp"
"github.com/cloudwego/abcoder/lang/python"
"github.com/cloudwego/abcoder/lang/rust"
"github.com/cloudwego/abcoder/lang/typescript"
"github.com/cloudwego/abcoder/lang/uniast"
)

Expand Down Expand Up @@ -109,6 +110,8 @@ func checkRepoPath(repoPath string, language uniast.Language) (openfile string,
openfile, wait = cxx.CheckRepo(repoPath)
case uniast.Python:
openfile, wait = python.CheckRepo(repoPath)
case uniast.Typescript:
openfile, wait = typescript.CheckRepo(repoPath)
default:
openfile = ""
wait = 0
Expand All @@ -126,6 +129,8 @@ func checkLSP(language uniast.Language, lspPath string) (l uniast.Language, s st
l, s = cxx.GetDefaultLSP()
case uniast.Python:
l, s = python.GetDefaultLSP()
case uniast.Typescript:
l, s = typescript.GetDefaultLSP()
case uniast.Golang:
l = uniast.Golang
s = ""
Expand Down
15 changes: 10 additions & 5 deletions lang/uniast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ import (
type Language string

const (
Golang Language = "go"
Rust Language = "rust"
Cxx Language = "cxx"
Python Language = "python"
Unknown Language = ""
Golang Language = "go"
Rust Language = "rust"
Cxx Language = "cxx"
Python Language = "python"
Typescript Language = "typescript"
Unknown Language = ""
)

func (l Language) String() string {
Expand All @@ -44,6 +45,8 @@ func (l Language) String() string {
return "cxx"
case Python:
return "python"
case Typescript:
return "typescript"
default:
return string(l)
}
Expand All @@ -64,6 +67,8 @@ func NewLanguage(lang string) (l Language) {
return Cxx
case "python":
return Python
case "typescript":
return Typescript
default:
return Unknown
}
Expand Down
Loading