nvim_testing

package
v0.0.0-...-2491a15 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BazelTmpDir

func BazelTmpDir(t *testing.T) string

func DeleteCommentAtCurrentLine

func DeleteCommentAtCurrentLine(cl *nvim.Nvim) error

func EditFile

func EditFile(cl *nvim.Nvim, filename string) error

func GetAllLines

func GetAllLines(cl *nvim.Nvim, buf nvim.Buffer) ([]string, error)

func GetComment

func GetComment(cl *nvim.Nvim) (string, error)

GetComment gets a comment for current line of text.

func GetEventChannel

func GetEventChannel(eventName string, cl *nvim.Nvim, pattern string) (chan struct{}, error)

GetEventChannel returns a channel that is closed when a LspAttach event happens. This is the only go-client example for handling this that I am aware of. For details, see: https://github.com/neovim/neovim/discussions/27371

GetEventChannel configures the Neovim client `cl` to close the returned channel when it gets the specified event. It seems that there is no automated way to connect nvim events such that the notifications to a go client happen automatically. Instead, we configure it ourselves.

Other subtleties are that you must ensure that you get the channel here strictly *before* sending any commands that could result in this notification. Otherwise, you can sometimes *miss* that event. For example, if you load a file from command line in Neovim, you might miss most, or all of the events emitted as a result of opening that file.

Args:

  • eventName: the name of the event to get a notification for, such as 'FileType'.
  • cl: a neovim client. Get one from `nvim.NewChildProcess`, for example.
  • pattern: the autocmd pattern, for example, "text", or "*".

Returns: a channel that gets closed when the event is received.

func GetLspAttachEvent

func GetLspAttachEvent(cl *nvim.Nvim, pattern string) (chan struct{}, error)

GetLspAttachEvent returns a channel that gets closed on receipt of a `LspAttach` event.

func InsertText

func InsertText(cl *nvim.Nvim, buf nvim.Buffer, line int, text string) error

func LogAllLines

func LogAllLines(t *testing.T, lines []string)

func MoveToLine

func MoveToLine(cl *nvim.Nvim, line int) error

func NewNeovim

func NewNeovim(dbfile string, args ...string) (*nvim.Nvim, error)

NewNeovim creates a new Neovim child process for testing.

The created Neovim is a hermetic instance.

func NotEmpty

func NotEmpty(s string) string

func RemoveTextLines

func RemoveTextLines(cl *nvim.Nvim, buf nvim.Buffer, begin, count int) error

func RunDBQuery

func RunDBQuery(dbFilename, query string) (*sql.DB, func(), error)

RunDBQuery creates a database and runs a SQL query on it to populate it.

func SetComment

func SetComment(cl *nvim.Nvim, content string) error

SetComment sets a comment for current line of text.

func WaitForAnn

func WaitForAnn(ctx context.Context, cl *nvim.Nvim, text string) error

func WaitForAnns

func WaitForAnns(ctx context.Context, db *sql.DB, ws lsp.URI, file string, anns []pkg.Ann) error

WaitForAnns waits for annotations. Returns error if the exact annotations are not found.

func WaitForLine

func WaitForLine(ctx context.Context, cl *nvim.Nvim, buf nvim.Buffer, line int, text string) error

func WaitForNs

func WaitForNs(ctx context.Context, cl *nvim.Nvim, ns string) (int, error)

WaitForNs waits for the namespace with `name` to appear in the nvim client `cl`.

func WaitForNsBuf

func WaitForNsBuf(ctx context.Context, cl *nvim.Nvim, buf nvim.Buffer, name string) (int, error)

WaitForNsBuf waits for the namespace with `name` to appear in the nvim client `cl`.

Types

This section is empty.

Jump to

Keyboard shortcuts

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