A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/L3MON4D3/LuaSnip below:

L3MON4D3/LuaSnip: Snippet Engine for Neovim written in Lua.

javadoc.mp4

Neovim >= 0.7 (extmarks) jsregexp for lsp-snippet-transformations (see here for some tips on installing it).

Note

On Windows, you need a C compiler and make to install jsregexp. If your compiler choice is not gcc, clang, or zig, you need to explicitly specify the CC variable in the build command: make install_jsregexp CC=your_compiler_program. Also, make sure %GIT%/bin directory is added in the $PATH so that make can use %GIT%/bin/sh.exe.

In Vim script, with <Tab> for jumping forward/expanding a snippet, <Shift-Tab> for jumping backward, and <Ctrl-E> for changing the current choice when in a choiceNode...

" press <Tab> to expand or jump in a snippet. These can also be mapped separately
" via <Plug>luasnip-expand-snippet and <Plug>luasnip-jump-next.
imap <silent><expr> <Tab> luasnip#expand_or_jumpable() ? '<Plug>luasnip-expand-or-jump' : '<Tab>'
" -1 for jumping backwards.
inoremap <silent> <S-Tab> <cmd>lua require'luasnip'.jump(-1)<Cr>

snoremap <silent> <Tab> <cmd>lua require('luasnip').jump(1)<Cr>
snoremap <silent> <S-Tab> <cmd>lua require('luasnip').jump(-1)<Cr>

" For changing choices in choiceNodes (not strictly necessary for a basic setup).
imap <silent><expr> <C-E> luasnip#choice_active() ? '<Plug>luasnip-next-choice' : '<C-E>'
smap <silent><expr> <C-E> luasnip#choice_active() ? '<Plug>luasnip-next-choice' : '<C-E>'

... or in Lua, with a different set of keys: <Ctrl-K> for expanding, <Ctrl-L> for jumping forward, <Ctrl-J> for jumping backward, and <Ctrl-E> for changing the active choice.

local ls = require("luasnip")

vim.keymap.set({"i"}, "<C-K>", function() ls.expand() end, {silent = true})
vim.keymap.set({"i", "s"}, "<C-L>", function() ls.jump( 1) end, {silent = true})
vim.keymap.set({"i", "s"}, "<C-J>", function() ls.jump(-1) end, {silent = true})

vim.keymap.set({"i", "s"}, "<C-E>", function()
	if ls.choice_active() then
		ls.change_choice(1)
	end
end, {silent = true})

nvim-cmp's wiki also contains an example for setting up a super-tab-like mapping.

Check out the doc for a general explanation of the loaders and their benefits. The following list serves only as a short overview.

There's also a repository collecting snippets for various languages, molleweide/LuaSnip-snippets.nvim

You have two main choices: use SnipMate/VS Code snippets (easier) or write snippets in Lua (more complex but also more feature-rich). Here are some suggestions for getting started in either case:

Official docs and examples

Note: instead of immediately reading the official documentation, you may want to check out the Resources for new users section below since the docs are written more as a reference manual than as a tutorial for new users.

【中文版】DOC in Chinese is here.

Here are some LuaSnip videos and tutorials on the Web:

Inspired by vsnip.vim


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4