Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can you provide sample code for client ? #4

Open
wellcomez opened this issue Jul 23, 2024 · 0 comments
Open

can you provide sample code for client ? #4

wellcomez opened this issue Jul 23, 2024 · 0 comments

Comments

@wellcomez
Copy link

I pass pipestdin and stdout to newclient.
request can be sent ,but no respone revieved .

func Test_new_client(t *testing.T) {
	cmd := exec.Command("clangd", "--log=verbose")
	stdin, err := cmd.StdinPipe()
	if err != nil {
		log.Fatal(err)
	}
	stdout, err := cmd.StdoutPipe()
	if err != nil {
		log.Fatal(err)
	}
	if err := cmd.Start(); err != nil {
		log.Fatal(err)
	}
	var rw = readwriter{w: stdin, r: stdout}
	var handle = servhandle{}
	client := lsp.NewClient(rw, rw, handle, func(e error) {})
	var path = "/home/z/dev/lsp/pylspclient/tests"
	initializationOptions := map[string]interface{}{
		"clangdFileStatus": true,
	}

	capabilities := map[string]interface{}{
		"window": map[string]bool{
			"workDoneProgress": true,
		},
		"textDocument": map[string]interface{}{
			"completion": map[string]interface{}{
				"completionItem": map[string]bool{
					"commitCharactersSupport": true,
					"snippetSupport":          true,
				},
			},
		},
	}
	var ProcessID = -1
	client.Run()
	result, err_resp, err := client.Initialize(context.Background(),
		&lsp.InitializeParams{
			ProcessID:             &ProcessID,
			RootURI:               lsp.NewDocumentURI(path),
			InitializationOptions: initializationOptions,
			Capabilities:          capabilities,
		},
	)

	fmt.Printf("%v%v", err_resp, err)
	fmt.Printf("clangd initialized: %+v %+v\n", result.ServerInfo.Name, result.ServerInfo.Version)

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant