A collection of useful snippets for Svelte(Kit) development in Neovim using LuaSnip with TypeScript syntax.
Using lazy.nvim:
{
"nvim-svelte/nvim-svelte-snippets",
dependencies = "L3MON4D3/LuaSnip",
opts = {
-- your configuration comes here
-- or leave empty for defaults
}
}
You can configure the plugin by passing options to the setup function:
{
"nvim-svelte/nvim-svelte-snippets",
dependencies = "L3MON4D3/LuaSnip",
opts = {
enabled = true, -- Enable/disable snippets globally
auto_detect = true, -- Only load in SvelteKit projects
prefix = "sk" -- Prefix for TypeScript snippets (e.g., sk-load)
}
}
enabled
: Enable or disable snippets globally (default: true
)auto_detect
: Only load snippets in detected SvelteKit projects (default: true
)prefix
: Add prefix to TypeScript snippets (default: "sk"
):ToggleSvelteKitSnippets
- Toggle SvelteKit snippets on/off in TypeScript filespage
: Creates a new SvelteKit page componenteach
: Creates a Svelte each blocksk-cload
: Creates a client-side load functionsk-sload
: Creates a server-side load functionsk-actions
: Creates form actions templateDefault LuaSnip keybindings for navigating snippets:
<Tab>
: Jump forward to next snippet position<S-Tab>
: Jump backward to previous snippet position<C-n>
: Next choice in choice node<C-p>
: Previous choice in choice nodeTo develop and test the plugin locally:
git clone https://github.com/nvim-svelte/nvim-svelte-snippets ~/YOUR_LOCAL_DEV_FOLDER/nvim-svelte-snippets
{
dir = "~/YOUR_LOCAL_DEV_FOLDER/nvim-svelte-snippets",
dependencies = "L3MON4D3/LuaSnip",
opts = {},
dev = true
}
:Lazy reload nvim-svelte-snippets
MIT