diff options
| author | srdusr <trevorgray@srdusr.com> | 2025-09-24 04:19:28 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2025-09-24 04:19:28 +0200 |
| commit | 7ed2303648bf83bb081d9bd863660ebf2344ce47 (patch) | |
| tree | 702f5f832796b572d0faee31c0eb15507e91f49a /lua/plugins/snippets.lua | |
| parent | 2a8020a2e9b7ef2ee77ddee14892127a4eb95187 (diff) | |
| download | dotfiles-7ed2303648bf83bb081d9bd863660ebf2344ce47.tar.gz dotfiles-7ed2303648bf83bb081d9bd863660ebf2344ce47.zip | |
Squashed 'common/config/nvim/' changes from 2a8020a..966d12a
966d12a Update/Overhaul
git-subtree-dir: common/config/nvim
git-subtree-split: 966d12ac730c83da90d60ab24eae539b2ea69441
Diffstat (limited to 'lua/plugins/snippets.lua')
| -rwxr-xr-x[-rw-r--r--] | lua/plugins/snippets.lua | 89 |
1 files changed, 27 insertions, 62 deletions
diff --git a/lua/plugins/snippets.lua b/lua/plugins/snippets.lua index 7df6b2f..989ad8a 100644..100755 --- a/lua/plugins/snippets.lua +++ b/lua/plugins/snippets.lua @@ -1,68 +1,33 @@ -local ls = require "luasnip" -- +local M = {} -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" } }, - }, - }, - }, -} - ---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) +function M.setup() + local ok, ls = pcall(require, "luasnip") + if not ok or not ls then + return false end -end) -keymap({ "i", "s"}, "<c-k>", function() - if ls.jumpable(-1) then - ls.jump(-1) - end -end) + -- Safely load snippets + pcall(function() require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets/" }) end) + pcall(function() require("luasnip.loaders.from_vscode").lazy_load() end) + pcall(function() require("luasnip.loaders.from_snipmate").lazy_load() end) -keymap({ "i", "s"}, "<c-c>", function() - if ls.choice_active() then - ls.change_choice(1) - end -end) + ls.config.set_config { + history = true, + updateevents = "TextChanged,TextChangedI", + enable_autosnippets = true, + region_check_events = "InsertEnter", + delete_check_events = "TextChanged", + store_selection_keys = "<Tab>", + ext_opts = { + [require("luasnip.util.types").choiceNode] = { + active = { + virt_text = { { "«", "GruvboxOrange" } }, + }, + }, + }, + } -keymap({ "i", "s"}, "<a-c>", function() - if ls.choice_active() then - ls.change_choice(-1) - end -end) + return true +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 +return M |
