vscode

package module
v0.0.0-...-5c2c9c4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 18 Imported by: 1

README

go-vscode

VSCode as a Go library. Embed an editor in your Go programs.

Set up vscode.Workbench with a terminal factory and filesystem (both of which can be virtual), then you can serve it as an HTTP handler to access your custom VSCode editor in the browser. Use with a webview window library to give the editor its own native window.

func main() {
	cwd, _ := os.Getwd()
	fsys := workingpathfs.New(osfs.New(), cwd)

	wb := &vscode.Workbench{
		ProductConfiguration: product.Configuration{
			NameLong: "My Custom Editor",
		},
		MakePTY: func() (io.ReadWriteCloser, error) {
			cmd := exec.Command("/bin/bash")
			return pty.Start(cmd)
		},
		FS: fsys,
	}

	log.Println("editor serving on :8080 ...")
	if err := http.ListenAndServe(":8080", wb); err != nil {
		log.Fatal(err)
	}

}

Let me know what else you'd like to customize from Go!

Requires Git LFS

This Go module embeds a 17MB release artifact of vscode-web stored with Git LFS, which doesn't quite work with go get seamlessly yet.

You must have Git LFS installed and you must also set export GOPRIVATE=github.com/progrium/go-vscode as a workaround before running go mod tidy or go get github.com/progrium/go-vscode. Otherwise your built project will panic with zip: not a valid zip file.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type URIComponents

type URIComponents struct {
	Scheme    string `json:"scheme"`
	Authority string `json:"authority,omitempty"`
	Path      string `json:"path,omitempty"`
	Query     string `json:"query,omitempty"`
	Fragment  string `json:"fragment,omitempty"`
}

type Workbench

type Workbench struct {
	ProductConfiguration        product.Configuration `json:"productConfiguration"`
	AdditionalBuiltinExtensions []URIComponents       `json:"additionalBuiltinExtensions,omitempty"`
	FolderURI                   *URIComponents        `json:"folderUri,omitempty"`

	FS      fs.FS                              `json:"-"`
	MakePTY func() (io.ReadWriteCloser, error) `json:"-"`
}

func (*Workbench) ServeHTTP

func (wb *Workbench) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis
internal
The product package provides data structures to configure a VSCode product.
The product package provides data structures to configure a VSCode product.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL