diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2024-05-17 00:14:37 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2024-05-17 00:14:37 +0200 |
commit | 51d1f5835aaa4491025769fd635dd262aa3ce55d (patch) | |
tree | abb266437e4b901104b567d184cd2ca3e78530bd /fnl | |
parent | 29471e411aeed0186bfa72b0c299794f593f20e5 (diff) |
Improve cmp
Diffstat (limited to 'fnl')
-rw-r--r-- | fnl/plugins/cmp.fnl | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/fnl/plugins/cmp.fnl b/fnl/plugins/cmp.fnl index 24beee0..1745191 100644 --- a/fnl/plugins/cmp.fnl +++ b/fnl/plugins/cmp.fnl @@ -12,15 +12,15 @@ (fn config [] (let [cmp (require :cmp) lspkind (require :lspkind) - luasnip (require :luasnip) luasnip-vscode (require :luasnip.loaders.from_vscode)] (luasnip-vscode.lazy_load) (lspkind.init) - (cmp.setup {:snippet {:expand (fn [args] - (luasnip.lsp_expand args.body))} + (cmp.setup {:snippet {:expand (lambda [args] + (let [luasnip (require :luasnip)] + (luasnip.lsp_expand args.body)))} :completion {:completopt "menu,menuone,noinsert"} - :mapping (cmp.mapping.preset.insert {:<c-k> (cmp.mapping.select_prev_item {:behavior cmp.SelectBehavior.Insert}) - :<c-j> (cmp.mapping.select_next_item {:behavior cmp.SelectBehavior.Insert}) + :mapping (cmp.mapping.preset.insert {:<c-n> (cmp.mapping.select_prev_item {:behavior cmp.SelectBehavior.Insert}) + :<c-e> (cmp.mapping.select_next_item {:behavior cmp.SelectBehavior.Insert}) :<c-y> (cmp.mapping (cmp.mapping.confirm {:behavior cmp.SelectBehavior.Insert :select true} [:i @@ -54,6 +54,19 @@ {:mapping (cmp.mapping.preset.cmdline) :sources [{:name :path} {:name :cmdline - :option {:ignore_cmds [:Man "!"]}}]}))) + :option {:ignore_cmds [:Man "!"]}}]}) + (let [luasnip (require :luasnip)] + (luasnip.config.set_config {:history false + :updateevents "TextChanged,TextChangedI"}) + (vim.keymap.set [:i :s] :<c-k> + (lambda [] + (when (luasnip.expand_or_jumpable) + (luasnip.expand_or_jump))) + {:silent true}) + (vim.keymap.set [:i :s] :<c-j> + (lambda [] + (when (luasnip.jumpable -1) + (luasnip.jump -1)) + {:silent true}))))) {1 :hrsh7th/nvim-cmp : dependencies :event :InsertEnter : config} |