nvim-svelte-snippets Svelte Themes

Nvim Svelte Snippets

Snippets for Svelte and SvelteKit for Neovim powered by Luasnip

Svelte Snippets for Neovim

A collection of useful snippets for Svelte(Kit) development in Neovim using LuaSnip with TypeScript syntax.

Prerequisites

Installation

Using lazy.nvim:

{
    "nvim-svelte/nvim-svelte-snippets",
    dependencies = "L3MON4D3/LuaSnip",
    opts = {
        -- your configuration comes here
        -- or leave empty for defaults
    }
}

Configuration

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)
    }
}

Configuration Options

  • 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")

Commands

  • :ToggleSvelteKitSnippets - Toggle SvelteKit snippets on/off in TypeScript files

Available Snippets

Svelte Snippets (.svelte files)

  • page: Creates a new SvelteKit page component
  • each: Creates a Svelte each block

TypeScript Snippets (+page.ts/+page.server.ts)

  • sk-cload: Creates a client-side load function
  • sk-sload: Creates a server-side load function
  • sk-actions: Creates form actions template

Keybindings

Default 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 node

Development

To develop and test the plugin locally:

  1. Clone the repository:
git clone https://github.com/nvim-svelte/nvim-svelte-snippets ~/YOUR_LOCAL_DEV_FOLDER/nvim-svelte-snippets
  1. Add the local plugin to your Neovim config (in your lazy.nvim plugins setup):
{
    dir = "~/YOUR_LOCAL_DEV_FOLDER/nvim-svelte-snippets",
    dependencies = "L3MON4D3/LuaSnip",
    opts = {},
    dev = true
}
  1. Reload the plugin after making changes:
    • Save your changes
    • In Neovim, run: :Lazy reload nvim-svelte-snippets
    • Test in a .svelte file

License

MIT

Top categories

svelte logo

Need a Svelte website built?

Hire a professional Svelte developer today.
Loading Svelte Themes