Skip to content

Commit 88b4e2e

Browse files
authored
nvim: support nvim v0.7.0 APIs (#137)
* nvim: add BufferText * nvim: go generate * nvim: add BufferText testcase * nvim: add autocmd relate apis * nvim: add testAutocmd testcase * nvim: add nvim-path flag for testing * nvim: fix version related testcases * nvim: change eval NVIM_LISTEN_ADDRESS to use v:servername * nvim: nvim flag default to nvim on testing * nvim: add -nvim flag for api_tool.go * nvim: add skip TestAPI/Key/Nvim/KeyMap until v0.9.0 * codecov: relax patch.default.target * nvim: run gofmt * nvim: add skipBetweenVersion and skip TestAPI/Key/{Nvim,Batch}/KeyMap * nvim: remove experimental nvim__set_hl_ns api Renamed by neovim/neovim#13457. * nvim: fix missig error handling on testAutocmd * nvim: add DeleteAugroupByName and ExecAutocmds testcase
1 parent ef8a8cf commit 88b4e2e

File tree

7 files changed

+779
-143
lines changed

7 files changed

+779
-143
lines changed

.codecov.yml renamed to .codecov.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ coverage:
2222

2323
patch:
2424
default:
25-
target: 50%
25+
target: auto
2626
threshold: 10.0
2727
only_pulls: true
2828
if_not_found: failure

nvim/api.go

Lines changed: 133 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nvim/api_def.go

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,6 @@ func SetHighlight(nsID int, name string, val *HLAttrs) {
8181
name(nvim_set_hl)
8282
}
8383

84-
// SetHighlightNameSpace set active namespace for highlights.
85-
//
86-
// nsID is the namespace to activate.
87-
func SetHighlightNameSpace(nsID int) {
88-
name(nvim__set_hl_ns)
89-
}
90-
9184
// FeedKeys input-keys to Nvim, subject to various quirks controlled by "mode"
9285
// flags. Unlike Input, this is a blocking call.
9386
//
@@ -990,6 +983,20 @@ func SetBufferText(buffer Buffer, startRow, startCol, endRow, endCol int, replac
990983
name(nvim_buf_set_text)
991984
}
992985

986+
// BufferText gets a range from the buffer.
987+
//
988+
// This differs from BufferLines in that it allows retrieving only
989+
// portions of a line.
990+
//
991+
// Indexing is zero-based. Column indices are end-exclusive.
992+
//
993+
// Prefer BufferLines when retrieving entire lines.
994+
//
995+
// opts is optional parameters. Currently unused.
996+
func BufferText(buffer Buffer, startRow, startCol, endRow, endCol int, opts map[string]interface{}) [][]byte {
997+
name(nvim_buf_get_text)
998+
}
999+
9931000
// BufferOffset returns the byte offset of a line (0-indexed).
9941001
//
9951002
// Line 1 (index=0) has offset 0. UTF-8 bytes are counted. EOL is one byte.
@@ -1502,6 +1509,58 @@ func IsTabpageValid(tabpage Tabpage) (valid bool) {
15021509
name(nvim_tabpage_is_valid)
15031510
}
15041511

1512+
// autocmd.c
1513+
1514+
// Autocmds get all autocommands that match the corresponding {opts}.
1515+
//
1516+
// Note that when multiple patterns or events are provided, it will find all the autocommands that
1517+
// match any combination of them.
1518+
func Autocmds(opts map[string]interface{}) (result []*AutocmdType) {
1519+
name(nvim_get_autocmds)
1520+
}
1521+
1522+
// CreateAutocmd create an autocommand.
1523+
//
1524+
// The API allows for two (mutually exclusive) types of actions to be executed when the autocommand
1525+
// triggers: a callback function (Lua or Vimscript), or a command (like regular autocommands).
1526+
func CreateAutocmd(event interface{}, opts map[string]interface{}) (id int) {
1527+
name(nvim_create_autocmd)
1528+
}
1529+
1530+
// DeleteAutocmd delete an autocommand by id.
1531+
//
1532+
// NOTE: Only autocommands created via the API have an id.
1533+
func DeleteAutocmd(id int) {
1534+
name(nvim_del_autocmd)
1535+
}
1536+
1537+
// ClearAutocmds clear all autocommands that match the corresponding {opts}.
1538+
//
1539+
// To delete a particular autocmd, see DeleteAutocmd.
1540+
func ClearAutocmds(opts map[string]interface{}) {
1541+
name(nvim_clear_autocmds)
1542+
}
1543+
1544+
// CreateAugroup create or get an autocommand group(autocmd-groups).
1545+
func CreateAugroup(name string, opts map[string]interface{}) (id int) {
1546+
name(nvim_create_augroup)
1547+
}
1548+
1549+
// DeleteAugroupByID delete an autocommand group by id.
1550+
func DeleteAugroupByID(id int) {
1551+
name(nvim_del_augroup_by_id)
1552+
}
1553+
1554+
// DeleteAugroupByID delete an autocommand group by name.
1555+
func DeleteAugroupByName(name string) {
1556+
name(nvim_del_augroup_by_name)
1557+
}
1558+
1559+
// ExecAutocmds execute all autocommands for {event} that match the corresponding {opts} autocmd-execute.
1560+
func ExecAutocmds(event interface{}, opts map[string]interface{}) {
1561+
name(nvim_exec_autocmds)
1562+
}
1563+
15051564
// ui.c
15061565

15071566
// AttachUI registers the client as a remote UI. After this method is called,

0 commit comments

Comments
 (0)