types

package
v0.0.35 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DiagnosticTextPropID = 0
	ReferencesTextPropID = 1
)

Variables

SeverityHighlight returns corresponding highlight name for a severity.

SeverityHoverHighlight returns corresponding hover highlight name for a severity.

View Source
var SeverityPriority = map[Severity]int{
	SeverityErr:  14,
	SeverityWarn: 12,
	SeverityInfo: 10,
	SeverityHint: 8,
}

SeverityPriority is used when placing signs and text property highlights. Values are based on the default value for signs, 10.

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	Num  int
	Name string

	Version int32

	// Listener is the ID of the listener for the buffer. Listeners number from
	// 1 so the zero value indicates this buffer does not have a listener.
	Listener int

	// Loaded reflects vim's "loaded" buffer state. See :help bufloaded() for details.
	Loaded bool

	// Fset is the fileset used in parsing the buffer contents. Access to Fset
	// must be guarded by a receive on ASTWait.
	Fset *token.FileSet

	// AST is the parsed result of the Buffer. Access to Fset must be guarded by
	// a receive on ASTWait.
	AST *ast.File

	// ASTWait is used to sychronise access to AST and Fset.
	ASTWait chan bool
	// contains filtered or unexported fields
}

A Buffer is govim's representation of the current state of a buffer in Vim i.e. it is versioned.

TODO: we need to reflect somehow whether a buffer is file-based or not. A preview window is not, for example.

func NewBuffer

func NewBuffer(num int, name string, contents []byte, loaded bool) *Buffer

func (*Buffer) Contents

func (b *Buffer) Contents() []byte

Contents returns a Buffer's contents. These contents must not be mutated. To update a Buffer's contents, call SetContents

func (*Buffer) Line

func (b *Buffer) Line(n int) (string, error)

Line returns the 1-indexed line contents of b

func (*Buffer) SetContents

func (b *Buffer) SetContents(byts []byte)

SetContents updates a Buffer's contents to byts

func (*Buffer) ToTextDocumentIdentifier

func (b *Buffer) ToTextDocumentIdentifier() protocol.TextDocumentIdentifier

ToTextDocumentIdentifier converts b to a protocol.TextDocumentIdentifier

func (*Buffer) URI

func (b *Buffer) URI() span.URI

URI returns the b's Name as a span.URI, assuming it is a file.

TODO: we should panic here is this is not a file-based buffer

type CursorPosition added in v0.0.31

type CursorPosition struct {
	*Point

	BufNr         int
	WinNr         int
	WinID         int
	ScreenRow     int
	ScreenCol     int
	ScreenEndCol  int
	ScreenCursCol int
}

CursorPosition represents a cursor position within a window

type Diagnostic added in v0.0.25

type Diagnostic struct {
	Filename string
	Source   string
	Range    Range
	Text     string
	Buf      int
	Severity Severity
}

Diagnostic is the govim internal representation of a LSP diagnostic, used to populate quickfix list, place signs, highlight text ranges etc.

type Point

type Point struct {
	// contains filtered or unexported fields
}

Point represents a position within a Buffer

func PointFromOffset added in v0.0.31

func PointFromOffset(b *Buffer, offset int) (Point, error)

func PointFromPosition

func PointFromPosition(b *Buffer, pos protocol.Position) (Point, error)

func PointFromVim

func PointFromVim(b *Buffer, line, col int) (Point, error)

func VisualPointFromPosition added in v0.0.27

func VisualPointFromPosition(b *Buffer, pos protocol.Position) (Point, error)

func (Point) Buffer added in v0.0.31

func (p Point) Buffer() *Buffer

Buffer is the buffer corresponding to the Point

func (Point) Col

func (p Point) Col() int

Col refers to the byte index (1-based) in Line() in the buffer. This is often referred to as the column number, but is definitely not the visual column as seen on screen. This is how Vim refers to column positions.

func (Point) GoplsChar

func (p Point) GoplsChar() uint32

GoplsChar is the 0-index character offset in a buffer.

func (Point) GoplsLine

func (p Point) GoplsLine() uint32

GoplsLine is the 0-index line in the buffer, returned as a float64 value. This is how gopls refers to lines.

func (Point) IsWithin added in v0.0.27

func (p Point) IsWithin(r Range) bool

IsWithin returns true if a point is within the given range

func (Point) Line

func (p Point) Line() int

Line refers to the 1-indexed line in the buffer. This is how Vim refers to line numbers.

func (Point) Offset

func (p Point) Offset() int

Offset represents the byte offset (0-indexed) of p within p.Buffer()

func (Point) ToPosition

func (p Point) ToPosition() protocol.Position

ToPosition converts p to a protocol.Position

type PopupLine added in v0.0.32

type PopupLine struct {
	Text  string      `json:"text"`
	Props []PopupProp `json:"props"`
}

PopupLine is the internal representation of a single text line with text propertiesin a vim popup. When creating popups using popup_create, the first arg can be either a buffer number, a string, a list of strings or a list of text lines with text properties.

type PopupProp added in v0.0.32

type PopupProp struct {
	Type string `json:"type"`
	Col  int    `json:"col"`
	Len  int    `json:"length"`
}

PopupProp is the internal representation of a single text property used in a popup line. It describes where on that line the property begin (where Col is 1-indexed) and the length. Type must be an existing text property type (defined by calling prop_type_add in vim).

type ProgressInitiator added in v0.0.33

type ProgressInitiator string
const (
	GoTest                 ProgressInitiator = "GoTest"
	WorkDoneProgressCreate ProgressInitiator = "WorkDoneProgressCreate"
)

type ProgressPopup added in v0.0.32

type ProgressPopup struct {
	ID        int
	Text      strings.Builder
	LinePos   int
	Initiator ProgressInitiator
}

ProgressPopup represents a vim popup placed in the upper right corner used to show LSP progress. LinePos is used to stack multiple visible progress popups. Initiator is a optional field used to describe who initiated this progress (if known), e.g. "GoTest" when running GOVIMGoTest. This allow us to handle text from different commands to be handled differently (or even suppressed).

type Range

type Range struct {
	Start Point
	End   Point
}

Range represents a range within a Buffer. Create ranges using NewRange

type Severity added in v0.0.25

type Severity int

Severity is the govim internal representation of the LSP DiagnosticSeverites

type TextPropID added in v0.0.28

type TextPropID int

TextPropID is the govim internal mapping of ID used when adding/removing text properties

type WatchedFile

type WatchedFile struct {
	Path     string
	Version  int
	Contents []byte
}

A WatchedFile is a file we are watching but that is not loaded as a buffer in Vim

func (*WatchedFile) URI

func (w *WatchedFile) URI() span.URI

Jump to

Keyboard shortcuts

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