Documentation
¶
Overview ¶
Package lsp is mdsh's language server: for the markdown files mdsh runs, it completes fences' attributes and depends= names, explains an attribute on hover and reports mistakes in them as diagnostics. It speaks the Language Server Protocol over a stream, as `mdsh lsp` and mdsh-gui's Neovim pane run it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Help ¶
Help is the attribute at line (from 0) and col (bytes) of text, with where it is in the line, or ok is false.
func ListFiles ¶
ListFiles lists the regular files under dir, as sorted slash paths relative to it. It leaves out hidden files and folders, node_modules, vendor and .assets folders (res:// paths name what is in those), goes at most maxListDepth folders down and stops at maxListFiles. It is empty if dir doesn't exist.
Types ¶
type Diagnostic ¶
Diagnostic is a problem at a place in a document: Line counts from 0 and the columns are bytes in that line.
func Check ¶
func Check(text string) []Diagnostic
Check checks every fence's attributes in text: unknown or misused ones, depends= names that aren't a block that runs, and a var= bound twice.
type Item ¶
type Item struct {
Label string
Insert string
Detail string
Doc string
Kind string // keyword, property, enum, variable, constant, text
}
Item is a completion: Label is shown, Insert replaces the text from the token's start to the cursor.
type Names ¶
type Names struct {
IDs []string
Envs []string
Assets []string
Files []string
// AssetsDir is the assets folder's name, <doc>.assets.
AssetsDir string
}
Names are what completion offers besides the attributes: block ids, for conditions, env names, and files for paths: those in the document's assets folder, for res:// paths, and those beside the document.
type Problem ¶
Problem is something wrong in a fence's info string. From and To are byte offsets in the info string.
type SourceBlock ¶
type SourceBlock struct {
// Line is the line its opening fence is on, from 1.
Line int
ID string
// Runs says whether depends= can name it: an input never runs.
Runs bool
// Env is its env=, if any.
Env string
}
SourceBlock is a block in a document's text, for completing and checking depends=.
func SourceBlocks ¶
func SourceBlocks(text string) []SourceBlock
SourceBlocks lists the blocks in text, in order, leaving out includes and tapes, which have no name. It is nil if text doesn't parse.