Skip to content

About

Neovim plugin. Telescope.nvim extension that adds LuaSnip integration.

Resources

Stars

1 star

Watchers

0 watching

Forks

 
 

Repository files navigation

telescope-luasnip

This plugin adds a LuaSnip snippet source picker to the already-awesome Neovim Telescope plugin.

Shows snippets loaded from files (via loaders_store_source = true) for the current buffer's filetype — uses the same filetype logic as luasnip.available(), respecting ft_func, filetype_extend, and treesitter injection languages.

Selecting a snippet jumps directly to its source file and line.

This is a port of fhill2/telescope-ultisnips.nvim from Ultisnips to LuaSnip. Thanks for the simple great idea!

telescope-luasnip.nvim in action

Requirements

Setup

Install the plugin using your favourite package manager.

-- lazy.nvim
{
  "benfowler/telescope-luasnip.nvim",
  dependencies = { "L3MON4D3/LuaSnip", "nvim-telescope/telescope.nvim" },
}

Then load the extension after require('telescope').setup():

require('telescope').load_extension('luasnip')

Important: source tracking must be enabled

The picker relies on loaders_store_source = true in LuaSnip to know where each snippet came from:

require("luasnip").config.setup({
  loaders_store_source = true,
})

Usage

:Telescope luasnip
require('telescope').extensions.luasnip.luasnip {}

Configuration

The plugin works fine as-is and requires no further configuration.

Search customization

You can provide a custom search function to control what text is used for fuzzy matching. The function receives an entry with these fields:

Field Description
snippet LuaSnip snippet object
ft "snip" or "auto"
filetype The filetype the snippet belongs to
filename Source file path
lnum Source line number

Example:

require('telescope').setup {
  extensions = {
    luasnip = {
      search = function(entry)
        return entry.snippet.trigger .. " " .. entry.filetype
      end,
    },
  },
}

Default search text is: trigger + name + ft + description.

Theme

require('telescope').setup {
  luasnip = require("telescope.themes").get_dropdown({
    border  = false,
    preview = { check_mime_type = true },
  }),
}

Help!

Is there something not quite right or could be improved? Log an issue with a minimal reproduction, or better yet, raise a PR.

About

Neovim plugin. Telescope.nvim extension that adds LuaSnip integration.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages