govim: Index | Files | Directories

package govim

import ""

Package govim implements a Vim8 channel-based plugin host that can be used to write plugins.


Package Files

channel_cmds.go command.go const.go event.go event_queue.go gen_stringers_stringer.go govim.go viewport.go


var (
    ErrShuttingDown = errors.New("govim shutting down")
var Flavors = []Flavor{

func ParseVimVersion Uses

func ParseVimVersion(b []byte) (string, error)

ParseVimVersion takes b which is assumed to be the output from :version or --version and returns the equivalent semver version.

TODO when the minimum Vim version we require is >= v8.1.1526, then we can drop the legacy version parsing

type CommAttr Uses

type CommAttr interface {
    // contains filtered or unexported methods

type CommMod Uses

type CommMod string
const (
    CommModAboveLeft    CommMod = "aboveleft"
    CommModBelowRight   CommMod = "belowright"
    CommModBotRight     CommMod = "botright"
    CommModBrowse       CommMod = "browse"
    CommModConfirm      CommMod = "confirm"
    CommModHide         CommMod = "hide"
    CommModKeepAlt      CommMod = "keepalt"
    CommModKeepJumps    CommMod = "keepjumps"
    CommModKeepMarks    CommMod = "keepmarks"
    CommModKeepPatterns CommMod = "keeppatterns"
    CommModLeftAbove    CommMod = "leftabove"
    CommModLockMarks    CommMod = "lockmarks"
    CommModNoSwapfile   CommMod = "noswapfile"
    CommModRightBelow   CommMod = "rightbelow"
    CommModSilent       CommMod = "silent"
    CommModTab          CommMod = "tab"
    CommModTopLeft      CommMod = "topleft"
    CommModVerbose      CommMod = "verbose"
    CommModVertical     CommMod = "vertical"

type CommModList Uses

type CommModList []CommMod

func (CommModList) String Uses

func (c CommModList) String() string

type CommandFlags Uses

type CommandFlags struct {
    Line1 *int
    Line2 *int
    Range *int
    Count *int
    Bang  *bool
    Reg   *string
    Mods  CommModList

func (*CommandFlags) UnmarshalJSON Uses

func (c *CommandFlags) UnmarshalJSON(b []byte) error

type Complete Uses

type Complete uint
const (
    CompleteArglist      Complete = iota // -complete=arglist
    CompleteAugroup                      // -complete=augroup
    CompleteBuffer                       // -complete=buffer
    CompleteBehave                       // -complete=behave
    CompleteColor                        // -complete=color
    CompleteCommand                      // -complete=command
    CompleteCompiler                     // -complete=compiler
    CompleteCscope                       // -complete=cscope
    CompleteDir                          // -complete=dir
    CompleteEnvironment                  // -complete=environment
    CompleteEvent                        // -complete=event
    CompleteExpression                   // -complete=expression
    CompleteFile                         // -complete=file
    CompleteFileInPath                   // -complete=file_in_path
    CompleteFiletype                     // -complete=filetype
    CompleteFunction                     // -complete=function
    CompleteHelp                         // -complete=help
    CompleteHighlight                    // -complete=highlight
    CompleteHistory                      // -complete=history
    CompleteLocale                       // -complete=locale
    CompleteMapclear                     // -complete=mapclear
    CompleteMapping                      // -complete=mapping
    CompleteMenu                         // -complete=menu
    CompleteMessages                     // -complete=messages
    CompleteOption                       // -complete=option
    CompletePackadd                      // -complete=packadd
    CompleteShellCmd                     // -complete=shellcmd
    CompleteSign                         // -complete=sign
    CompleteSyntax                       // -complete=syntax
    CompleteSyntime                      // -complete=syntime
    CompleteTag                          // -complete=tag
    CompleteTagListFiles                 // -complete=tag_listfiles
    CompleteUser                         // -complete=user
    CompleteVar                          // -complete=var

func (Complete) String Uses

func (i Complete) String() string

type CompleteCustom Uses

type CompleteCustom string

func (CompleteCustom) String Uses

func (c CompleteCustom) String() string

type CompleteCustomList Uses

type CompleteCustomList string

func (CompleteCustomList) String Uses

func (c CompleteCustomList) String() string

type CountN Uses

type CountN int

func (CountN) String Uses

func (c CountN) String() string

type Event Uses

type Event uint
const (
    EventBufNewFile           Event = iota // BufNewFile
    EventBufReadPre                        // BufReadPre
    EventBufRead                           // BufRead
    EventBufReadPost                       // BufReadPost
    EventBufReadCmd                        // BufReadCmd
    EventFileReadPre                       // FileReadPre
    EventFileReadPost                      // FileReadPost
    EventFileReadCmd                       // FileReadCmd
    EventFilterReadPre                     // FilterReadPre
    EventFilterReadPost                    // FilterReadPost
    EventStdinReadPre                      // StdinReadPre
    EventStdinReadPost                     // StdinReadPost
    EventBufWrite                          // BufWrite
    EventBufWritePre                       // BufWritePre
    EventBufWritePost                      // BufWritePost
    EventBufWriteCmd                       // BufWriteCmd
    EventFileWritePre                      // FileWritePre
    EventFileWritePost                     // FileWritePost
    EventFileWriteCmd                      // FileWriteCmd
    EventFileAppendPre                     // FileAppendPre
    EventFileAppendPost                    // FileAppendPost
    EventFileAppendCmd                     // FileAppendCmd
    EventFilterWritePre                    // FilterWritePre
    EventFilterWritePost                   // FilterWritePost
    EventBufAdd                            // BufAdd
    EventBufCreate                         // BufCreate
    EventBufDelete                         // BufDelete
    EventBufWipeout                        // BufWipeout
    EventTerminalOpen                      // TerminalOpen
    EventBufFilePre                        // BufFilePre
    EventBufFilePost                       // BufFilePost
    EventBufEnter                          // BufEnter
    EventBufLeave                          // BufLeave
    EventBufWinEnter                       // BufWinEnter
    EventBufWinLeave                       // BufWinLeave
    EventBufUnload                         // BufUnload
    EventBufHidden                         // BufHidden
    EventBufNew                            // BufNew
    EventSwapExists                        // SwapExists
    EventFileType                          // FileType
    EventSyntax                            // Syntax
    EventEncodingChanged                   // EncodingChanged
    EventTermChanged                       // TermChanged
    EventOptionSet                         // OptionSet
    EventVimEnter                          // VimEnter
    EventGUIEnter                          // GUIEnter
    EventGUIFailed                         // GUIFailed
    EventTermResponse                      // TermResponse
    EventQuitPre                           // QuitPre
    EventExitPre                           // ExitPre
    EventVimLeavePre                       // VimLeavePre
    EventVimLeave                          // VimLeave
    EventFileChangedShell                  // FileChangedShell
    EventFileChangedShellPost              // FileChangedShellPost
    EventFileChangedRO                     // FileChangedRO
    EventDiffUpdated                       // DiffUpdated
    EventDirChanged                        // DirChanged
    EventShellCmdPost                      // ShellCmdPost
    EventShellFilterPost                   // ShellFilterPost
    EventCmdUndefined                      // CmdUndefined
    EventFuncUndefined                     // FuncUndefined
    EventSpellFileMissing                  // SpellFileMissing
    EventSourcePre                         // SourcePre
    EventSourcePost                        // SourcePost
    EventSourceCmd                         // SourceCmd
    EventVimResized                        // VimResized
    EventFocusGained                       // FocusGained
    EventFocusLost                         // FocusLost
    EventCursorHold                        // CursorHold
    EventCursorHoldI                       // CursorHoldI
    EventCursorMoved                       // CursorMoved
    EventCursorMovedI                      // CursorMovedI
    EventWinNew                            // WinNew
    EventTabNew                            // TabNew
    EventTabClosed                         // TabClosed
    EventWinEnter                          // WinEnter
    EventWinLeave                          // WinLeave
    EventTabEnter                          // TabEnter
    EventTabLeave                          // TabLeave
    EventCmdwinEnter                       // CmdwinEnter
    EventCmdwinLeave                       // CmdwinLeave
    EventCmdlineChanged                    // CmdlineChanged
    EventCmdlineEnter                      // CmdlineEnter
    EventCmdlineLeave                      // CmdlineLeave
    EventInsertEnter                       // InsertEnter
    EventInsertChange                      // InsertChange
    EventInsertLeave                       // InsertLeave
    EventInsertCharPre                     // InsertCharPre
    EventTextChanged                       // TextChanged
    EventTextChangedI                      // TextChangedI
    EventTextChangedP                      // TextChangedP
    EventTextYankPost                      // TextYankPost
    EventColorSchemePre                    // ColorSchemePre
    EventColorScheme                       // ColorScheme
    EventRemoteReply                       // RemoteReply
    EventQuickFixCmdPre                    // QuickFixCmdPre
    EventQuickFixCmdPost                   // QuickFixCmdPost
    EventSessionLoadPost                   // SessionLoadPost
    EventMenuPopup                         // MenuPopup
    EventCompleteDone                      // CompleteDone

func (Event) String Uses

func (i Event) String() string

type Events Uses

type Events []Event

type Flavor Uses

type Flavor uint
const (
    FlavorVim    Flavor = iota // vim
    FlavorGvim                 // gvim
    FlavorNeovim               // neovim

func (Flavor) String Uses

func (i Flavor) String() string

type GenAttr Uses

type GenAttr uint
const (
    AttrBang     GenAttr = iota // -bang
    AttrBar                     // -bar
    AttrRegister                // -register
    AttrBuffer                  // -buffer

func (GenAttr) String Uses

func (i GenAttr) String() string

type Govim Uses

type Govim interface {
    // ChannelEx executes a ex command in Vim
    ChannelEx(expr string) error

    // ChannelExpr evaluates and returns the result of expr in Vim
    ChannelExpr(expr string) (json.RawMessage, error)

    // ChannelNormal run a command in normal mode in Vim
    ChannelNormal(expr string) error

    // ChannelCall evaluates and returns the result of call in Vim
    ChannelCall(fn string, args ...interface{}) (json.RawMessage, error)

    // ChannelRedraw performs a redraw in Vim
    ChannelRedraw(force bool) error

    // DefineFunction defines the named function in Vim. name must begin with a capital
    // letter. params is the parameters that will be used in the Vim function delcaration.
    // If params is nil, then "..." is assumed.
    DefineFunction(name string, params []string, f VimFunction) error

    // DefineRangeFunction defines the named function as range-based in Vim. name
    // must begin with a capital letter. params is the parameters that will be used
    // in the Vim function delcaration.  If params is nil, then "..." is assumed.
    DefineRangeFunction(name string, params []string, f VimRangeFunction) error

    // DefineCommand defines the named command in Vim. name must begin with a
    // capital letter. attrs is a series of attributes for the command; see :help
    // E174 in Vim for more details.
    DefineCommand(name string, f VimCommandFunction, attrs ...CommAttr) error

    // DefineAutoCommand defines an autocmd for events for files matching patterns.
    DefineAutoCommand(group string, events Events, patts Patterns, nested bool, f VimAutoCommandFunction, exprs ...string) error

    // Run is a user-friendly run wrapper
    Run() error

    // DoProto is used as a wrapper around function calls that jump the "interface"
    // between the user and protocol aspects of govim.
    DoProto(f func() error) error

    // Viewport returns the active Vim viewport
    Viewport() (Viewport, error)

    // Errorf raises a formatted fatal error
    Errorf(format string, args ...interface{})

    // Logf logs a formatted message to the logger
    Logf(format string, args ...interface{})

    // Scheduled returns the event queue Govim interface
    Scheduled() Govim

    // Schedule schdules f to run in the event queue
    Schedule(func(Govim) error) chan struct{}

    // Flavor returns the flavor of the editor to which the Govim instance is
    // connected
    Flavor() Flavor

    // Version returns the semver version of the editor to which the Govim
    // instance is connected
    Version() string

    // Loaded returns a channel that can be used to wait until a Govim instance
    // has finished loading. The Init phase will follow a successful load.
    Loaded() chan struct{}

    // Initialized returns a channel that can be used to wait until a Govim
    // instance has completed the init phase, post loading.
    Initialized() chan struct{}

    // Shutdown returns a channel that can be used to wait until a Govim
    // instance has completed the shutdown phase.
    Shutdown() chan struct{}

func NewGovim Uses

func NewGovim(plug Plugin, in io.Reader, out io.Writer, log io.Writer) (Govim, error)

type NArgs Uses

type NArgs uint
const (
    NArgs0          NArgs = iota // -nargs=0
    NArgs1                       // -nargs=1
    NArgsZeroOrMore              // -nargs=*
    NArgsZeroOrOne               // -nargs=?
    NArgsOneOrMore               // -nargs=+

func (NArgs) String Uses

func (i NArgs) String() string

type Pattern Uses

type Pattern string

type Patterns Uses

type Patterns []Pattern

type Plugin Uses

type Plugin interface {
    Init(Govim, chan error) error
    Shutdown() error

Plugin defines the contract between and a plugin.

type Range Uses

type Range uint
const (
    RangeLine Range = iota // -range
    RangeFile              // -range=%

func (Range) String Uses

func (i Range) String() string

type RangeN Uses

type RangeN int

func (RangeN) String Uses

func (r RangeN) String() string

type SwitchBufMode Uses

type SwitchBufMode string

SwitchBufValue typed constants define the set of values that the Vim setting switchbuf can take. See :help switchbuf for more details and definitions of each value.

const (
    SwitchBufUseOpen SwitchBufMode = "useopen"
    SwitchBufUseTag  SwitchBufMode = "usetab"
    SwitchBufSplit   SwitchBufMode = "split"
    SwitchBufVsplit  SwitchBufMode = "vsplit"
    SwitchBufNewTab  SwitchBufMode = "newtab"

func ParseSwitchBufModes Uses

func ParseSwitchBufModes(vs string) ([]SwitchBufMode, error)

ParseSwitchBufModes assumes vs is a valid value for &switchbuf

type Viewport Uses

type Viewport struct {
    Current WinInfo
    Windows []WinInfo

type VimAutoCommandFunction Uses

type VimAutoCommandFunction func(g Govim, args ...json.RawMessage) error

VimAutoCommandFunction is the signature of a callback from a defined autocmd

type VimCommandFunction Uses

type VimCommandFunction func(g Govim, flags CommandFlags, args ...string) error

VimCommandFunction is the signature of a callback from a defined command

type VimFunction Uses

type VimFunction func(g Govim, args ...json.RawMessage) (interface{}, error)

VimFunction is the signature of a callback from a defined function

type VimRangeFunction Uses

type VimRangeFunction func(g Govim, line1, line2 int, args ...json.RawMessage) (interface{}, error)

VimRangeFunction is the signature of a callback from a defined range-based function

type WinInfo Uses

type WinInfo struct {
    WinNr    int
    BotLine  int
    Height   int
    BufNr    int
    WinBar   int
    Width    int
    TabNr    int
    QuickFix bool
    TopLine  int
    LocList  bool
    WinCol   int
    WinRow   int
    WinID    int
    Terminal bool

func (*WinInfo) UnmarshalJSON Uses

func (wi *WinInfo) UnmarshalJSON(b []byte) error


cmd/govimCommand govim is a Vim8 channel-based plugin, written in Go, to support the writing of Go code in Vim8
cmd/govim/configPackage config declares the configuration variables, functions and commands used by govim
cmd/govim/internal/fastwalkPackage fastwalk provides a faster version of filepath.Walk for file system scanning tools.
cmd/govim/internal/gopathwalkPackage gopathwalk is like filepath.Walk but specialized for finding Go packages, particularly in $GOPATH and $GOROOT.
cmd/govim/internal/importsPackage imports implements a Go pretty-printer (like package "go/format") that also adds or removes import statements as necessary.
cmd/govim/internal/jsonrpc2Package jsonrpc2 is a minimal implementation of the JSON RPC 2 spec.
cmd/govim/internal/lsp/browserPackage browser provides utilities for interacting with users' browsers.
cmd/govim/internal/lsp/cmdPackage cmd handles the gopls command line.
cmd/govim/internal/lsp/diffPackage diff implements the Myers diff algorithm.
cmd/govim/internal/lsp/fuzzyPackage fuzzy implements a fuzzy matching algorithm.
cmd/govim/internal/lsp/protocolPackage protocol contains the structs that map directly to the wire format of the "Language Server Protocol".
cmd/govim/internal/lsp/snippetPackage snippet implements the specification for the LSP snippet format.
cmd/govim/internal/lsp/sourcePackage source provides core features for use by Go editors and tools.
cmd/govim/internal/lsp/telemetryPackage telemetry provides the hooks and adapters to allow use of telemetry throughout gopls.
cmd/govim/internal/lsp/telemetry/statsPackage stats provides support for recording telemetry statistics.
cmd/govim/internal/lsp/telemetry/tagPackage tag adds support for telemetry tags.
cmd/govim/internal/lsp/telemetry/tracePackage tag adds support for telemetry tracins.
cmd/govim/internal/memoizePackage memoize supports memoizing the return values of functions with idempotent results that are expensive to compute.
cmd/govim/internal/modulePackage module defines the module.Version type along with support code.
cmd/govim/internal/semverPackage semver implements comparison of semantic version strings.
cmd/govim/internal/toolPackage tool is an opinionated harness for writing Go tools.
cmd/govim/internal/txtarPackage txtar implements a trivial text-based file archive format.
testdriverPackage testdriver is a support package for plugins written using

Package govim imports 18 packages (graph) and is imported by 5 packages. Updated 2019-07-23. Refresh now. Tools for package owners.