Skip to content

Commit

Permalink
docs: luasnip setup example
Browse files Browse the repository at this point in the history
closes #345
  • Loading branch information
Saghen committed Nov 21, 2024
1 parent 653b262 commit 94754f6
Showing 1 changed file with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ MiniDeps.add({

</details>

## Configuration

<details>
<summary><strong>Highlight groups</strong></summary>

Expand Down Expand Up @@ -246,10 +248,9 @@ MiniDeps.add({

accept = {
create_undo_point = true,
-- Function used to expand snippets, some possible values:
-- require('luasnip').lsp_expand -- For `luasnip` users.
-- require('snippy').expand_snippet -- For `snippy` users.
-- vim.fn["UltiSnips#Anon"] -- For `ultisnips` users.
-- Function used to expand snippets, for luasnip users, you may use::
-- function(...) require('luasnip').lsp_expand(...) end
-- See the "Luasnip" section for info on setting up the luasnip source
expand_snippet = vim.snippet.expand,

auto_brackets = {
Expand Down Expand Up @@ -604,6 +605,46 @@ MiniDeps.add({

</details>

### Luasnip

There's currently no `blink.cmp` native source for [luasnip](https://github.com/L3MON4D3/LuaSnip). You may use [blink.compat](https://github.com/saghen/blink.compat) plugin with the [cmp-luasnip](https://github.com/saadparwaiz1/cmp_luasnip) nvim-cmp source in the meantime.

```lua
{
'saghen/blink.cmp',
dependencies = {
'L3MON4D3/LuaSnip',
'saadparwaiz1/cmp_luasnip',
{ 'saghen/blink.compat', opts = { impersonate_nvim_cmp = true } } },
opts = {
accept = {
expand_snippet = function(...) require('luasnip').lsp_expand(...) end,
}
sources = {
completion = {
-- WARN: add the rest of your providers here, unless you're using `opts_extend`
-- and defining this outside of your primary `blink.cmp` config
-- see the default configuration for the default providers
enabled_providers = { 'luasnip' },
},
providers = {
luasnip = {
name = 'luasnip',
module = 'blink.compat.source',

score_offset = -3,

opts = {
use_show_condition = false,
show_autosnippets = true,
},
},
},
},
}
}
```

## How it works

The plugin use a 4 stage pipeline: trigger -> sources -> fuzzy -> render
Expand Down

0 comments on commit 94754f6

Please sign in to comment.