diff options
| author | Maria José Solano <majosolano99@gmail.com> | 2023-10-20 23:51:26 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-21 08:51:26 +0200 |
| commit | f1775da07fe48da629468bcfcc2a8a6c4c3f40ed (patch) | |
| tree | f268521a16f35ed9a58acc758a87e791d0dd6d6e /runtime/doc | |
| parent | 330444994616e48e5e4d15bbf72d7c5346943565 (diff) | |
| download | rneovim-f1775da07fe48da629468bcfcc2a8a6c4c3f40ed.tar.gz rneovim-f1775da07fe48da629468bcfcc2a8a6c4c3f40ed.tar.bz2 rneovim-f1775da07fe48da629468bcfcc2a8a6c4c3f40ed.zip | |
feat(lsp): add snippet API (#25301)
Diffstat (limited to 'runtime/doc')
| -rw-r--r-- | runtime/doc/lua.txt | 59 | ||||
| -rw-r--r-- | runtime/doc/news.txt | 2 |
2 files changed, 61 insertions, 0 deletions
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 7e888a2375..1d69b1cc91 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -3670,4 +3670,63 @@ totable({f}, {...}) *vim.iter.totable()* Return: ~ (table) + +============================================================================== +Lua module: vim.snippet *vim.snippet* + +active() *snippet.active()* + Returns `true` if there's an active snippet in the current buffer. + + Return: ~ + (boolean) + +exit() *snippet.exit()* + Exits the current snippet. + +expand({input}) *snippet.expand()* + Expands the given snippet text. Refer to https://microsoft.github.io/language-server-protocol/specification/#snippet_syntax for the specification of valid input. + + Tabstops are highlighted with hl-SnippetTabstop. + + Parameters: ~ + • {input} (string) + +jump({direction}) *snippet.jump()* + Jumps within the active snippet in the given direction. If the jump isn't + possible, the function call does nothing. + + You can use this function to navigate a snippet as follows: >lua + vim.keymap.set({ 'i', 's' }, '<Tab>', function() + if vim.snippet.jumpable(1) then + return '<cmd>lua vim.snippet.jump(1)<cr>' + else + return '<Tab>' + end + end, { expr = true }) +< + + Parameters: ~ + • {direction} (vim.snippet.Direction) Navigation direction. -1 for + previous, 1 for next. + +jumpable({direction}) *snippet.jumpable()* + Returns `true` if there is an active snippet which can be jumped in the + given direction. You can use this function to navigate a snippet as + follows: >lua + vim.keymap.set({ 'i', 's' }, '<Tab>', function() + if vim.snippet.jumpable(1) then + return '<cmd>lua vim.snippet.jump(1)<cr>' + else + return '<Tab>' + end + end, { expr = true }) +< + + Parameters: ~ + • {direction} (vim.snippet.Direction) Navigation direction. -1 for + previous, 1 for next. + + Return: ~ + (boolean) + vim:tw=78:ts=8:sw=4:sts=4:et:ft=help:norl: diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index d55f43ce89..0fe675c285 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -193,6 +193,8 @@ The following new APIs and features were added. • Added |:fclose| command. +• Added |vim.snippet| for snippet expansion support. + ============================================================================== CHANGED FEATURES *news-changed* |