47 lines
1.8 KiB
Fennel
47 lines
1.8 KiB
Fennel
;; Autocompletion and Snippets with nvim-cmp and luasnip
|
|
(let
|
|
[cmp (require :cmp)
|
|
luasnip (require :luasnip)
|
|
vscode-snips (require :luasnip.loaders.from_vscode)
|
|
]
|
|
(vscode-snips.lazy_load)
|
|
(luasnip.config.setup)
|
|
(cmp.setup
|
|
{:snippet {:expand #(luasnip $1)}
|
|
:mapping (cmp.mapping.preset.insert
|
|
{:<C-j> (cmp.mapping.select_next_item)
|
|
:<C-k> (cmp.mapping.select_prev_item)
|
|
:<C-d> (cmp.mapping.scroll_docs -4)
|
|
:<C-f> (cmp.mapping.scroll_docs 4)
|
|
:<C-Space> (cmp.mapping.complete)
|
|
:<CR> (cmp.mapping.confirm {:behavior cmp.ConfirmBehavior.Replace :select true})
|
|
:<Tab> (cmp.mapping (fn [fallback]
|
|
(if (cmp.visible) (cmp.select_prev_item)
|
|
(luasnip.expand_or_locally_jumpable) (luasnip.expand_or_jump)
|
|
(fallback))) [:i :s])
|
|
:<S-Tab> (cmp.mapping (fn [fallback]
|
|
(if (cmp.visible) (cmp.select_prev_item)
|
|
(luasnip.locally_jumpable -1) (luasnip.jump -1)
|
|
(fallback))) [:i :s])})
|
|
:sources (cmp.config.sources
|
|
[{:name :nvim_lsp}
|
|
{:name :luasnip}
|
|
{:name :buffer}
|
|
])})
|
|
(cmp.setup.cmdline ["/" "?"]
|
|
{:mapping (cmp.mapping.preset.cmdline)
|
|
:sources
|
|
[{:name :buffer}]
|
|
})
|
|
(cmp.setup.cmdline [":"]
|
|
{:mapping (cmp.mapping.preset.cmdline)
|
|
:sources (cmp.config.sources
|
|
[{:name :path}
|
|
{:name :cmdline}])})
|
|
(cmp.setup.filetype [:gitcommit]
|
|
{:mapping (cmp.mapping.preset.cmdline)
|
|
:sources (cmp.config.sources
|
|
[{:name :git}
|
|
{:name :buffer}])
|
|
}))
|