diff options
| author | srdusr <trevorgray@srdusr.com> | 2023-05-17 23:32:04 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2023-05-17 23:32:04 +0200 |
| commit | 12573adf414a0074d79a333bac4961c3a78ea176 (patch) | |
| tree | f8aacad2ea22f9d6ae8b6318b6d1bc0748c9ff59 | |
| parent | 79166b0310c2f652958a7d52ed1fbd76333bfa4e (diff) | |
| download | dotfiles-12573adf414a0074d79a333bac4961c3a78ea176.tar.gz dotfiles-12573adf414a0074d79a333bac4961c3a78ea176.zip | |
Add old luasnip configuration to here
| -rw-r--r-- | lua/plugins/snippets.lua | 85 |
1 files changed, 65 insertions, 20 deletions
diff --git a/lua/plugins/snippets.lua b/lua/plugins/snippets.lua index 104bda8..7df6b2f 100644 --- a/lua/plugins/snippets.lua +++ b/lua/plugins/snippets.lua @@ -1,23 +1,68 @@ -return { - { - "L3MON4D3/LuaSnip", - opts = { - history = true, - -- Allow autotrigger snippets - enable_autosnippets = true, - -- For equivalent of UltiSnips visual selection - store_selection_keys = "<Tab>", - -- Event on which to check for exiting a snippet's region - region_check_events = "InsertEnter", - -- ejmastnak uses InsertLeave, perhaps because he has history=false - delete_check_events = "TextChanged", - -- When to trigger update of active nodes' dependents, e.g. repeat nodes - update_events = "TextChanged,TextChangedI", +local ls = require "luasnip" -- + +require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets/" }) +--local options = { +ls.config.set_config { + history = true, + updateevents = "TextChanged,TextChangedI", + -- Autosnippets: + enable_autosnippets = true, -- + region_check_events = "InsertEnter", + delete_check_events = "TextChanged", + update_events = "TextChanged,TextChangedI", + store_selection_keys = "<Tab>", + ext_opts = { -- + [require("luasnip.util.types").choiceNode] = { + active = { + virt_text = { { "«", "GruvboxOrange" } }, + }, }, - config = function(_, opts) - require("luasnip").setup(opts) - -- TODO: better way to detect this relative to config dir? - require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets/" }) - end, }, } + +--local keymap = vim.keymap +--local keymap = vim.api.nvim_set_keymap +local keymap = vim.keymap.set +--keymap('i', '<c-f>', 'luasnip#expand_or_jumpable() ? "<Plug>luasnip-expand-or-jump" : "<Tab>"', {expr = true, silent = true}) +keymap({ "i", "s"}, "<c-f>", function() + if ls.expand_or_jumpable() then + ls.expand() + end +end) + +keymap({ "i", "s"}, "<c-j>", function() + if ls.jumpable(1) then + ls.jump(1) + end +end) + +keymap({ "i", "s"}, "<c-k>", function() + if ls.jumpable(-1) then + ls.jump(-1) + end +end) + +keymap({ "i", "s"}, "<c-c>", function() + if ls.choice_active() then + ls.change_choice(1) + end +end) + +keymap({ "i", "s"}, "<a-c>", function() + if ls.choice_active() then + ls.change_choice(-1) + end +end) + +-- Character class Matching +-- %a letters (A-Z, a-z) +-- %c control characters (\n, \t, \r, ...) +-- %d digits (0-9) +-- %l lower-case letter (a-z) +-- %p punctuation characters (!, ?, &, ...) +-- %s space characters +-- %u upper-case letters +-- %w alphanumeric characters (A-Z, a-z, 0-9) +-- %x hexadecimal digits (\3, \4, ...) +-- %z the character with representation 0 +-- . Matches any character |
