Skip to content

Graphic preview

100%
Page type: how-to

Editor and shell setup

Enable shell completion and the Ptah language server, and check that each one works.

Edge documents the current development build and may describe unreleased behavior. To use those commands, build Ptah from master. For an installed release, select its version in the header.

Both are optional and both are quick. Neither changes what Ptah does; they change how much you have to remember while using it. The Go-only scope below is the language server’s, not Ptah’s – every other source works the same from a plain terminal, and Work with a source is the source-neutral path.

ptah completion generates a script for bash, zsh, fish or powershell:

Terminal window
ptah completion zsh > "${fpath[1]}/_ptah"

The exact line differs by shell and platform, and the binary prints the one for yours rather than this page guessing: ptah completion zsh --help gives the current-session form, the every-session form, and the Homebrew path on macOS. Read it there, because it moves with the shell rather than with Ptah.

Start a new shell afterwards. To check it took, type this and press Tab:

ptah mig

Completion should offer migrations. If nothing happens, the script was written somewhere the shell does not read, and the shell’s own completion system has to be enabled first – ptah completion zsh --help says how for zsh.

ptah-ls serves hover documentation, attribute completion and diagnostics for //ptah: annotations in Go source, from the same directive metadata as the annotation reference. Build it:

Terminal window
go build -o bin/ptah-ls ./cmd/ptah-ls

It speaks the Language Server Protocol over stdio and takes no arguments in serve mode, so any LSP-capable editor can run it directly. For Visual Studio Code, the extension in editors/vscode starts it for Go files; point ptah.languageServer.path at the binary you built.

To check it is running, open a Go file with an annotated struct and:

  • hover a directive such as //ptah:schema:index – its documentation appears;
  • type //ptah:schema:index and ask for completion – the attribute names are offered;
  • misspell an attribute – a diagnostic marks it, which is the same rejection the parser makes at build time.

If all three are silent the editor is not starting the binary; if only the diagnostic is missing the file is probably not part of a package the server resolved.

A language server for SQL, HCL, YAML or DBML schema files. It reads //ptah: annotations in Go source and nothing else. Those formats are edited with whatever your editor already does for them, and ptah schema validate is the check that replaces a language server for them.