Skip to content

Commit

Permalink
feat(node-client): add extmarks related methods
Browse files Browse the repository at this point in the history
  • Loading branch information
chemzqm committed Dec 25, 2021
1 parent f63df8e commit 50e4afe
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"vscode-languageserver": "7.0.0"
},
"dependencies": {
"@chemzqm/neovim": "^5.4.0",
"@chemzqm/neovim": "^5.5.2",
"bytes": "^3.1.0",
"tslib": "^2.0.3",
"ansi-styles": "^5.0.0",
Expand Down
96 changes: 96 additions & 0 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,38 @@ declare module 'coc.nvim' {
col: number
}

export interface ExtmarkOptions {
id?: number
// 0-based inclusive.
end_line?: number
// 0-based exclusive.
end_col?: number
// name of the highlight group used to highlight this mark.
hl_group?: string
hl_mode?: 'replace' | 'combine' | 'blend'
hl_eol?: boolean
// A list of [text, highlight] tuples
virt_text?: [string, string | string[]][]
virt_text_pos?: 'eol' | 'overlay' | 'right_align'
virt_text_win_col?: number
virt_text_hide?: boolean
virt_lines?: [string, string | string[]][][]
virt_lines_above?: boolean
virt_lines_leftcol?: boolean
right_gravity?: boolean
end_right_gravity?: boolean
priority?: number
}

export interface ExtmarkDetails {
end_col: number
end_row: number
priority: number
hl_group?: string
virt_text?: [string, string][]
virt_lines?: [string, string | string][][]
}

export interface NvimProc {
ppid: number
name: string
Expand Down Expand Up @@ -2660,6 +2692,60 @@ declare module 'coc.nvim' {
*/
setKeymap(mode: string, lhs: string, rhs: string, opts?: BufferKeymapOption): void

/**
* Removes an ext mark by notification.
*
* @public
* @param {number} ns_id - Namespace id
* @param {number} id - Extmark id
*/
deleteExtMark(ns_id: number, id: number): void

/**
* Gets the position (0-indexed) of an extmark.
*
* @param {number} ns_id - Namespace id
* @param {number} id - Extmark id
* @param {Object} opts - Optional parameters.
* @returns {Promise<[] | [number, number] | [number, number, ExtmarkDetails]>}
*/
getExtMarkById(ns_id: number, id: number, opts?: {
details?: boolean
}): Promise<[] | [number, number] | [number, number, ExtmarkDetails]>

/**
* Gets extmarks in "traversal order" from a |charwise| region defined by
* buffer positions (inclusive, 0-indexed |api-indexing|).
*
* Region can be given as (row,col) tuples, or valid extmark ids (whose
* positions define the bounds). 0 and -1 are understood as (0,0) and (-1,-1)
* respectively, thus the following are equivalent:
*
* nvim_buf_get_extmarks(0, my_ns, 0, -1, {})
* nvim_buf_get_extmarks(0, my_ns, [0,0], [-1,-1], {})
*
* @param {number} ns_id - Namespace id
* @param {[number, number] | number} start
* @param {[number, number] | number} end
* @param {Object} opts
* @returns {Promise<[number, number, number, ExtmarkDetails?][]>}
*/
getExtMarks(ns_id: number, start: [number, number] | number, end: [number, number] | number, opts?: {
details?: boolean
limit?: number
}): Promise<[number, number, number, ExtmarkDetails?][]>

/**
* Creates or updates an extmark by notification, `:h nvim_buf_set_extmark`.
*
* @param {number} ns_id
* @param {number} line
* @param {number} col
* @param {ExtmarkOptions} opts
* @returns {void}
*/
setExtMark(ns_id: number, line: number, col: number, opts?: ExtmarkOptions): void

/**
* Add sign to buffer by notification.
*
Expand Down Expand Up @@ -6349,6 +6435,16 @@ declare module 'coc.nvim' {
*/
export function createNameSpace(name: string): number

/**
* Like vim's has(), but for version check only.
* Check patch on neovim and check nvim on vim would return false.
*
* For example:
* - has('nvim-0.6.0')
* - has('patch-7.4.248')
*/
export function has(feature: string): boolean

/**
* Register autocmd on vim.
*
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,10 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==

"@chemzqm/neovim@^5.4.0":
version "5.4.0"
resolved "https://registry.yarnpkg.com/@chemzqm/neovim/-/neovim-5.4.0.tgz#ca7261d963507b4843db0efaa76df238203d2055"
integrity sha512-BjOAR5sliE2kp3EGZsyUmrYwTMRrxvXe6WBQTxL0m5uRIvfxShRaWyKOGbqoe0+sHCfgT67QsMevUAjB1Ovskw==
"@chemzqm/neovim@^5.5.2":
version "5.5.2"
resolved "https://registry.yarnpkg.com/@chemzqm/neovim/-/neovim-5.5.2.tgz#663d7c8b97ac25844f104bdcce6a284bd43108f0"
integrity sha512-ozgBaKLo0SBo38KyqVU8lmPUCAs7AMUhrt3ak2LUKaTvAMDRjB25rb+LGWjNV4oGHL8QbjyfZkvIBYaWeef7Tw==
dependencies:
msgpack-lite "^0.1.26"

Expand Down

0 comments on commit 50e4afe

Please sign in to comment.