Documentation ¶
Overview ¶
Package nvimutil provides wrapper functions of nvim go-client.
Index ¶
- Constants
- Variables
- func ByteOffset(n *nvim.Nvim, b nvim.Buffer, w nvim.Window) (int, error)
- func ClearErrorlist(v *nvim.Nvim, close bool) error
- func ClearMsg(v *nvim.Nvim) error
- func CloseLoclist(v *nvim.Nvim) error
- func CloseQuickfix(v *nvim.Nvim) error
- func CompleteFiles(v *nvim.Nvim, a *nvim.CommandCompletionArgs, dir string) (filelist []string, err error)
- func Echo(v *nvim.Nvim, format string, a ...interface{}) error
- func EchoProgress(v *nvim.Nvim, prefix, format string, a ...interface{}) error
- func EchoRaw(v *nvim.Nvim, a string) error
- func EchoSuccess(v *nvim.Nvim, prefix string, msg string) error
- func Echoerr(v *nvim.Nvim, format string, a ...interface{}) error
- func EchohlAfter(v *nvim.Nvim, prefix string, highlight string, format string, a ...interface{}) error
- func EchohlBefore(v *nvim.Nvim, prefix string, highlight string, format string, a ...interface{}) error
- func Echomsg(v *nvim.Nvim, a ...interface{}) error
- func ErrorList(v *nvim.Nvim, errors map[string][]*nvim.QuickfixError, keep bool) error
- func ErrorWrap(v *nvim.Nvim, err error) error
- func GotoPos(v *nvim.Nvim, w nvim.Window, pos token.Position, cwd string) error
- func IsBufExists(n *nvim.Nvim, bufnr int) bool
- func IsBufferContains(n *nvim.Nvim, b nvim.Buffer) bool
- func IsBufferValid(n *nvim.Nvim, b nvim.Buffer) bool
- func IsVisible(n *nvim.Nvim, filetype string) bool
- func Modifiable(n *nvim.Nvim, b nvim.Buffer) func()
- func Notify(n *nvim.Nvim, method string, args ...string) error
- func OpenLoclist(v *nvim.Nvim, w nvim.Window, loclist []*nvim.QuickfixError, keep bool) error
- func OpenOuickfix(b *nvim.Batch, w nvim.Window, keep bool) error
- func ParseError(ctx context.Context, errmsg []byte, cwd string, bctxt *buildctxt.Build, ...) ([]*nvim.QuickfixError, error)
- func Profile(ctx context.Context, start time.Time, name ...string)
- func SetErrorlist(v *nvim.Nvim, errlist []*nvim.QuickfixError) error
- func SetLoclist(v *nvim.Nvim, loclist []*nvim.QuickfixError) error
- func SetQuickfix(b *nvim.Batch, qflist []*nvim.QuickfixError) error
- func SplitPos(pos string, cwd string) (string, int, int)
- func StrToByteSlice(s string) []byte
- func TestNvim(t *testing.T, file ...string) *nvim.Nvim
- func ToBufferLines(byt []byte) [][]byte
- func ToByteSlice(byt [][]byte) []byte
- func ToMixedCase(s string) string
- func ToPascalCase(s string) string
- type Buffer
- func (b *Buffer) Buffer() nvim.Buffer
- func (b *Buffer) BufferLines(start, end int, strict bool)
- func (b *Buffer) Create(name, filetype, mode string, option map[NvimOption]map[string]interface{}) error
- func (b *Buffer) GetBufferContext() error
- func (b *Buffer) Reset()
- func (b *Buffer) SetBufferLines(start, end int, strict bool, replacement []byte) error
- func (b *Buffer) SetBufferLinesAll(replacement []byte) error
- func (b *Buffer) SetLocalMapping(mode string, mapping map[string]string) error
- func (b *Buffer) Truncate(n int)
- func (b *Buffer) UpdateSyntax(syntax string)
- func (b *Buffer) Write(p []byte) (int, error)
- func (b *Buffer) WriteString(s string) error
- type BufferName
- type ErrorListType
- type Fade
- type NvimOption
- type Sign
- type TabpageContext
- type Terminal
- type WindowContext
Constants ¶
const ( // Map map key mapping type. Map = "map" // MapNormal nmap that normal mode key mapping. MapNormal = "nmap" // MapVisualSelect vmap that visual-select mode key mapping. MapVisualSelect = "vmap" // MapSelect smap that select mode key mapping. MapSelect = "smap" // MapVisual xmap that visual mode key mapping. MapVisual = "xmap" // MapOperator omap that operator mode key mapping. MapOperator = "omap" // MapInsert imap that insert mode key mapping. MapInsert = "imap" // MapCommandLine cmap that command line mode key mapping. MapCommandLine = "cmap" // MapTerminal tmap that terminal mode key mapping. MapTerminal = "tmap" // Noremap map key mapping type with no remap. Noremap = "noremap" // NoremapNormal nnoremap that normal mode key mapping with no remap. NoremapNormal = "nnoremap" // NoremapVisualSelect vmap that visual-select mode key mapping with no remap. NoremapVisualSelect = "vnoremap" // NoremapSelect snoremap that select mode key mapping with no remap. NoremapSelect = "snoremap" // NoremapVisual xnoremap that visual mode key mapping with no remap. NoremapVisual = "xnoremap" // NoremapOperator onoremap that operator mode key mapping with no remap. NoremapOperator = "onoremap" // NoremapInsert inoremap that insert mode key mapping with no remap. NoremapInsert = "inoremap" // NoremapCommandLine cnoremap that command line mode key mapping with no remap. NoremapCommandLine = "cnoremap" // NoremapTerminal tmap that terminal mode key mapping with no remap. NoremapTerminal = "tnoremap" )
const ( // string // BufOptionBuflisted represents a buflisted. BufOptionBuflisted = "buflisted" // bool // BufOptionBuftype represents a buftype. BufOptionBuftype = "buftype" // string // BufOptionFiletype represents a filetype. BufOptionFiletype = "filetype" // string // BufOptionModifiable represents a modifiable. BufOptionModifiable = "modifiable" // bool // BufOptionModified represents a modified. BufOptionModified = "modified" // bool // BufOptionSwapfile represents a swapfile. BufOptionSwapfile = "swapfile" // bool // BufVarColorcolumn represents a colorcolumn. BufVarColorcolumn = "colorcolumn" // string // WinOptionList represents a list. WinOptionList = "list" // bool // WinOptionNumber represents a number. WinOptionNumber = "number" // bool // WinOptionRelativenumber represents a relativenumbers. WinOptionRelativenumber = "relativenumber" // bool // WinOptionWinfixheight represents a winfixheight. WinOptionWinfixheight = "winfixheight" // bool )BufOptionBufhidden = "bufhidden"
const ( // BuftypeAcwrite buffer which will always be written with BufWriteCmd autocommands. BuftypeAcwrite = "acwrite" // BuftypeHelp help buffer (you are not supposed to set this manually). BuftypeHelp = "help" // BuftypeNofile buffer which is not related to a file and will not be written. BuftypeNofile = "nofile" // BuftypeNowrite buffer which will not be written. BuftypeNowrite = "nowrite" // BuftypeQuickfix quickfix buffer, contains list of errors :cwindow or list of locations :lwindow. BuftypeQuickfix = "quickfix" // BuftypeTerminal terminal buffer, this is set automatically when a terminal is created. See nvim-terminal-emulator for more information. BuftypeTerminal = "terminal" )BufhiddenDelete = "delete" BufhiddenHide = "hide" BufhiddenUnload = "unload" BufhiddenWipe = "wipe"
const ( // FiletypeAsm represents a asm filetype. FiletypeAsm = "asm" // FiletypeC represents a c filetype. FiletypeC = "c" // FiletypeCpp represents a cpp filetype. FiletypeCpp = "cpp" // FiletypeDelve represents a delve filetype. FiletypeDelve = "delve" // FiletypeGas represents a gas filetype. FiletypeGas = "gas" // FiletypeGo represents a go filetype. FiletypeGo = "go" // FiletypeSh represents a sh filetype. FiletypeSh = "sh" // FiletypeTerminal represents a terminal filetype. FiletypeTerminal = "terminal" // FiletypeGoTerminal represents a go-terminal filetype. FiletypeGoTerminal = "goterminal" )
const ( // BreakpointSymbol symbol of breakpoint. // // ● BLACK CIRCLE (U+25CF) BreakpointSymbol = "\u25cf" // BreakpointSymbolLarge symbol of breakpoint with large. // // ⬤ BLACK LARGE CIRCLE (U+2B24) BreakpointSymbolLarge = "\u2b24" // TracepointSymbol symbol of tracepoint. // // ◆ BLACK DIAMOND (U+25C6) TracepointSymbol = "\u25c6" // TracepointSymbolMidium symbol of tracepoint with midium. // // ⬥ BLACK DIAMOND SUIT (U+2B25) TracepointSymbolMidium = "\u2b25" // ProgramCounterSymbol symbol of program counter. // // ◎ BULLSEYE (U+25CE) ProgramCounterSymbol = "\u25ce" // ProgramCounterSymbolRing symbol of program counter with ring. // // ⏣ BENZENE RING WITH CIRCLE (U+23e3) ProgramCounterSymbolRing = "\u23e3" // ErrorSymbol symbol of error. // // ⃠ COMBINING ENCLOSING CIRCLE BACKSLASH (U+20E0) ErrorSymbol = "\u20e0" // RestartSymbol symbol of restart. // ⟲ ANTICLOCKWISE GAPPED CIRCLE ARROW (U+27F2) RestartSymbol = "\u27f2" )
Variables ¶
var ( // ErrorColor highlight error message use Identifier syntax color. ErrorColor = "Identifier" // ProgressColor highlight progress message use Identifier syntax color. ProgressColor = "Identifier" // SuccessColor highlight success message use Identifier syntax color. SuccessColor = "Function" )
Functions ¶
func ByteOffset ¶
ByteOffset calculates the byte-offset of current cursor position.
func ClearErrorlist ¶
ClearErrorlist clear the Neovim error list.
func CloseLoclist ¶
CloseLoclist close the current buffer's locationlist window.
func CloseQuickfix ¶
CloseQuickfix close the quickfix list window.
func CompleteFiles ¶
func CompleteFiles(v *nvim.Nvim, a *nvim.CommandCompletionArgs, dir string) (filelist []string, err error)
CompleteFiles provides a "-complete=file" completion exclude the non go files.
func EchoProgress ¶
EchoProgress displays a command progress message to echo area.
func EchoSuccess ¶
EchoSuccess displays the success of the command to echo area.
func EchohlAfter ¶
func EchohlAfter(v *nvim.Nvim, prefix string, highlight string, format string, a ...interface{}) error
EchohlAfter provide the vim 'echo' command with the 'echohl' highlighting message text.
func EchohlBefore ¶
func EchohlBefore(v *nvim.Nvim, prefix string, highlight string, format string, a ...interface{}) error
EchohlBefore provide the vim 'echo' command with the 'echohl' highlighting prefix text.
func ErrorWrap ¶
ErrorWrap splits the errors.Wrap's cause and error messages, and provide the vim 'echo' message with 'echohl' highlighting to cause text.
func IsBufExists ¶
IsBufExists reports whether buffer list is within bufnr use vim bufexists function.
func IsBufferContains ¶
IsBufferContains reports whether buffer list is within b.
func IsBufferValid ¶
IsBufferValid wrapper of nvim.IsBufferValid function.
func IsVisible ¶
IsVisible reports whether buffer list within buffer that &ft has filetype. Useful for Check qf, preview or any specific buffer is whether the opened.
func Modifiable ¶
Modifiable sets modifiable to true, The returned function restores modifiable to false.
func OpenLoclist ¶
OpenLoclist open or close the current buffer's locationlist window.
func OpenOuickfix ¶
OpenOuickfix open the quickfix list window.
func ParseError ¶
func ParseError(ctx context.Context, errmsg []byte, cwd string, bctxt *buildctxt.Build, ignoreDirs []string) ([]*nvim.QuickfixError, error)
ParseError parses a typical Go tools error messages.
func Profile ¶
Profile measurement of the time it took to any func and output log file.
Usage: defer nvim.Profile(time.Now(), "name", "...")
func SetErrorlist ¶
func SetErrorlist(v *nvim.Nvim, errlist []*nvim.QuickfixError) error
SetErrorlist set the error results data to Neovim error list.
func SetLoclist ¶
func SetLoclist(v *nvim.Nvim, loclist []*nvim.QuickfixError) error
SetLoclist set the error results data to current buffer's locationlist.
func SetQuickfix ¶
func SetQuickfix(b *nvim.Batch, qflist []*nvim.QuickfixError) error
SetQuickfix set the error results data to quickfix list.
func SplitPos ¶
SplitPos parses a string of form 'token.Pos', and return the relative filepath from the current working directory path.
func StrToByteSlice ¶
StrToByteSlice convert string to byte slice use unsafe. https://gist.github.com/dgryski/65d632958e4d88c7f79aaa7e1d2b10c0
func ToBufferLines ¶
ToBufferLines converts the byte slice to the 2D byte slice of Neovim buffer data.
func ToByteSlice ¶
ToByteSlice converts the 2D buffer byte data to sigle byte slice.
func ToMixedCase ¶
ToMixedCase convert s to mixedCase. This function assumes that the character of the beginning is A-Z.
func ToPascalCase ¶
ToPascalCase convert s to PascalCase. This function assumes that the character of the beginning is a-z.
Types ¶
type Buffer ¶
type Buffer struct { Name string Filetype string Bufnr int Mode string Height int Width int Data []byte WindowContext TabpageContext // contains filtered or unexported fields }
Buffer represents a Neovim buffer.
func (*Buffer) BufferLines ¶
BufferLines gets the current buffer lines.
func (*Buffer) Create ¶
func (b *Buffer) Create(name, filetype, mode string, option map[NvimOption]map[string]interface{}) error
Create creates the new buffer and return the Buffer structure type.
func (*Buffer) GetBufferContext ¶
GetBufferContext gets the current buffers context.
func (*Buffer) Reset ¶
func (b *Buffer) Reset()
Reset resets the Neovim buffer to be empty, but it retains the underlying storage for use by future writes. Reset is the same as Truncate(0).
func (*Buffer) SetBufferLines ¶
SetBufferLines sets the replacement to current buffer.
func (*Buffer) SetBufferLinesAll ¶
SetBufferLinesAll wrapper of SetBufferLines with all lines.
func (*Buffer) SetLocalMapping ¶
SetLocalMapping sets buffer local mapping. 'mapping' arg: [key]{destination}
func (*Buffer) Truncate ¶
Truncate discards all but the first n unread bytes from the Neovim buffer but continues to use the same allocated storage.
func (*Buffer) UpdateSyntax ¶
UpdateSyntax updates the syntax highlight of the buffer.
func (*Buffer) WriteString ¶
WriteString appends the contents of s to the Neovim buffer.
type ErrorListType ¶
type ErrorListType string
ErrorListType represents a neovim error list type.
const ( // Quickfix quickfix error list type. Quickfix ErrorListType = "quickfix" // LocationList locationlist error list type. LocationList = "locationlist" )
type Fade ¶
type Fade struct {
// contains filtered or unexported fields
}
Fade represents a Fade highlighting.
func NewFader ¶
func NewFader(n *nvim.Nvim, buffer nvim.Buffer, hlGroup string, startLine, endLine, startCol, endCol int, duration int) *Fade
NewFader returns a new Fade.
func (*Fade) SetHighlight ¶
SetHighlight sets the highlight to at once.
type NvimOption ¶
type NvimOption int
NvimOption represents a Neovim buffer, window and tabpage options.
const ( // BufferOption buffer option type. BufferOption NvimOption = iota // BufferVar buffer var type. BufferVar // WindowOption window option type. WindowOption // WindowVar window var type. WindowVar // TabpageVar tabpage var type. TabpageVar )
type Sign ¶
type Sign struct { Name string Text string Texthl string Linehl string LastID int LastLine int LastFile string }
Sign represents a Neovim sign.
type TabpageContext ¶
TabpageContext represents a Neovim tabpage context.
type Terminal ¶
type Terminal struct { // Name terminal buffer name. Name string // Dir specifies the working directory of the command on terminal. Dir string // Size open the terminal window size. Size int Nvim *nvim.Nvim Batch *nvim.Batch *Buffer // contains filtered or unexported fields }
Terminal represents a Neovim terminal.
func NewTerminal ¶
NewTerminal return the Neovim terminal buffer.
type WindowContext ¶
WindowContext represents a Neovim window context.