summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2024-07-24 23:52:59 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2024-07-24 23:52:59 +0200
commit77b60223fdc2af9ebcb39f563fee6f7b21294d27 (patch)
tree41fa6a8c61ae616144c26fb07af32a32de206eeb
parent23cf10e11632e2acc23c33a665bc40e0b2a60bc8 (diff)
Refactor snippets
-rw-r--r--fnl/aktersnurra.fnl1
-rw-r--r--fnl/plugins/cmp.fnl33
-rw-r--r--fnl/plugins/snippets/init.fnl31
-rw-r--r--fnl/plugins/snippets/org.fnl13
-rw-r--r--lazy-lock.json20
5 files changed, 57 insertions, 41 deletions
diff --git a/fnl/aktersnurra.fnl b/fnl/aktersnurra.fnl
index b0634a0..f86c2a2 100644
--- a/fnl/aktersnurra.fnl
+++ b/fnl/aktersnurra.fnl
@@ -7,6 +7,7 @@
(if (not= fname nil)
(table.insert plugins (require (.. :plugins. fname))))))
(table.insert plugins (require :plugins.lsp))
+ (table.insert plugins (require :plugins.snippets))
plugins))
(local icons (require :settings.icons))
diff --git a/fnl/plugins/cmp.fnl b/fnl/plugins/cmp.fnl
index 2a8d280..f3c0211 100644
--- a/fnl/plugins/cmp.fnl
+++ b/fnl/plugins/cmp.fnl
@@ -6,14 +6,11 @@
:hrsh7th/cmp-cmdline
:hrsh7th/cmp-path
:onsails/lspkind.nvim
- :rafamadriz/friendly-snippets
:saadparwaiz1/cmp_luasnip])
(fn config []
(let [cmp (require :cmp)
- lspkind (require :lspkind)
- luasnip-vscode (require :luasnip.loaders.from_vscode)]
- (luasnip-vscode.lazy_load)
+ lspkind (require :lspkind)]
(lspkind.init)
(cmp.setup {:snippet {:expand (lambda [args]
(let [luasnip (require :luasnip)]
@@ -60,32 +57,6 @@
{:mapping (cmp.mapping.preset.cmdline)
:sources [{:name :path}
{:name :cmdline
- :option {:ignore_cmds [:Man "!"]}}]})
- (let [ls (require :luasnip)
- fmt (require :luasnip.extras.fmt)]
- (ls.config.set_config {:history false
- :updateevents "TextChanged,TextChangedI"})
- (let [s ls.s
- i ls.insert_node
- fmt fmt.fmt]
- (ls.add_snippets :org
- [(s :be
- (fmt "#+begin_src {}\n{}\n#+end_src"
- [(i 1) (i 2)]))]))
- (vim.keymap.set [:i :s] :<c-k>
- (lambda []
- (when (ls.expand_or_jumpable)
- (ls.expand_or_jump)))
- {:silent true})
- (vim.keymap.set [:i :s] :<c-j>
- (lambda []
- (when (ls.jumpable -1)
- (ls.jump -1))
- {:silent true}))
- (vim.keymap.set [:i] :<c-l>
- (lambda []
- (when (ls.choice_active)
- (ls.change_choice 1)))
- {:silent true}))))
+ :option {:ignore_cmds [:Man "!"]}}]})))
{1 :hrsh7th/nvim-cmp : dependencies :event :InsertEnter : config}
diff --git a/fnl/plugins/snippets/init.fnl b/fnl/plugins/snippets/init.fnl
new file mode 100644
index 0000000..b586d76
--- /dev/null
+++ b/fnl/plugins/snippets/init.fnl
@@ -0,0 +1,31 @@
+;; Snippets functionality.
+
+(local dependencies [:rafamadriz/friendly-snippets])
+
+(fn add-snippets []
+ (let [org (require :plugins.snippets.org)]
+ (org.add-snippets)))
+
+(fn config []
+ (let [ls (require :luasnip)
+ luasnip-vscode (require :luasnip.loaders.from_vscode)]
+ (luasnip-vscode.lazy_load)
+ (add-snippets)
+ (ls.config.set_config {:history false
+ :updateevents "TextChanged,TextChangedI"})
+ (vim.keymap.set [:i :s] :<c-k>
+ (lambda []
+ (when (ls.expand_or_jumpable)
+ (ls.expand_or_jump))) {:silent true})
+ (vim.keymap.set [:i :s] :<c-j>
+ (lambda []
+ (when (ls.jumpable -1)
+ (ls.jump -1))
+ {:silent true}))
+ (vim.keymap.set [:i] :<c-l>
+ (lambda []
+ (when (ls.choice_active)
+ (ls.change_choice 1)))
+ {:silent true})))
+
+{1 :L3MON4D3/LuaSnip :event :InsertEnter : config : dependencies}
diff --git a/fnl/plugins/snippets/org.fnl b/fnl/plugins/snippets/org.fnl
new file mode 100644
index 0000000..a2b2e46
--- /dev/null
+++ b/fnl/plugins/snippets/org.fnl
@@ -0,0 +1,13 @@
+;; Snippets for org files.
+
+(fn add-snippets []
+ (let [ls (require :luasnip)
+ fmt (require :luasnip.extras.fmt)]
+ (let [s ls.s
+ i ls.insert_node
+ fmt fmt.fmt]
+ (ls.add_snippets :org
+ [(s :be
+ (fmt "#+begin_src {}\n{}\n#+end_src" [(i 1) (i 2)]))]))))
+
+{: add-snippets}
diff --git a/lazy-lock.json b/lazy-lock.json
index 1e5fbaa..ded90fc 100644
--- a/lazy-lock.json
+++ b/lazy-lock.json
@@ -15,12 +15,12 @@
"friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" },
"git-conflict.nvim": { "branch": "main", "commit": "bfd9fe6fba9a161fc199771d85996236a0d0faad" },
"git-worktree.nvim": { "branch": "master", "commit": "666f84ba8dd9172f0a7b45c9f7c24bc5e55f6fc2" },
- "gitsigns.nvim": { "branch": "main", "commit": "f4928ba14eb6c667786ac7d69927f6aee6719f1e" },
- "grug-far.nvim": { "branch": "main", "commit": "529b561143f9350ce41cd44f05f103c7f277cdab" },
+ "gitsigns.nvim": { "branch": "main", "commit": "b29cb58126663569f6f34401fab513c2375e95d3" },
+ "grug-far.nvim": { "branch": "main", "commit": "77326be6bc1a78f8281101f2d31d730c1be3c035" },
"harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" },
"hotpot.nvim": { "branch": "master", "commit": "5462d3eb5c191ab380ca911e1e931836d27f6a79" },
"inc-rename.nvim": { "branch": "main", "commit": "8ba77017ca468f3029bf88ef409c2d20476ea66b" },
- "lazy.nvim": { "branch": "main", "commit": "c02268ac6e6aab92249d020d75efc588bd9d24fa" },
+ "lazy.nvim": { "branch": "main", "commit": "4496b4cad69a862199bb3ad452d3c4988bb925a1" },
"leap-spooky.nvim": { "branch": "main", "commit": "5f44a1f63dc1c4ce50244e92da5bc0d8d1f6eb47" },
"leap.nvim": { "branch": "main", "commit": "437bccd18c933e97c69f2f7d300f1b9d56678bfd" },
"lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" },
@@ -36,9 +36,9 @@
"nvim-cmp": { "branch": "main", "commit": "d818fd0624205b34e14888358037fb6f5dc51234" },
"nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" },
"nvim-lint": { "branch": "master", "commit": "efc6fc83f0772283e064c53a8f9fb5645bde0bc0" },
- "nvim-lspconfig": { "branch": "master", "commit": "fa6c2a64100c6f692bbec29bbbc8ec2663c9e869" },
+ "nvim-lspconfig": { "branch": "master", "commit": "3cceca5a79b66d735cbacbf05fa0bce5f8b716ca" },
"nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" },
- "nvim-treesitter": { "branch": "master", "commit": "9d252d00210ed8d43197ef048daa94e6dc821bd6" },
+ "nvim-treesitter": { "branch": "master", "commit": "96c5cb23342db3e51994680781da54b45d7e0c9b" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" },
"nvim-various-textobjs": { "branch": "main", "commit": "6cc4433fd35bc44ec7699cf8456d43161b0fd83b" },
"nvim-web-devicons": { "branch": "master", "commit": "e612de3d3a41a6b7be47f51e956dddabcbf419d9" },
@@ -46,27 +46,27 @@
"oil.nvim": { "branch": "master", "commit": "71c972fbd218723a3c15afcb70421f67340f5a6d" },
"org-bullets.nvim": { "branch": "main", "commit": "7e76e04827ac3fb13fc645a6309ac14203c4ca6a" },
"org-roam.nvim": { "branch": "main", "commit": "45153562e7bfe806d84747d6518cad714c63ca2e" },
- "orgmode": { "branch": "master", "commit": "947850abb1ae38430c4c6e882be2ebbe6d9ce0ee" },
+ "orgmode": { "branch": "master", "commit": "ab24c847538f3c36cbc0da33210cb3eba32e69b9" },
"persistence.nvim": { "branch": "main", "commit": "f6aad7dde7fcf54148ccfc5f622c6d5badd0cc3d" },
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
"popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" },
"project.nvim": { "branch": "main", "commit": "8c6bad7d22eef1b71144b401c9f74ed01526a4fb" },
"rest.nvim": { "branch": "fix/getregtype", "commit": "7d6de91881a1b702fca2fe1e7f5ae88670a42b2a" },
- "schemastore.nvim": { "branch": "main", "commit": "4abc1ab13ad5031049864cba0bfaec06a908e7e5" },
+ "schemastore.nvim": { "branch": "main", "commit": "bb370d8ea2055ec3807205367a91d12b9c13dae9" },
"sqlite.lua": { "branch": "master", "commit": "d0ffd703b56d090d213b497ed4eb840495f14a11" },
"stay-in-place.nvim": { "branch": "main", "commit": "0628b6db8970fc731abf9608d6f80659b58932c9" },
"telescope-frecency.nvim": { "branch": "master", "commit": "bb2c63ee5375ede81c1945b58638412af42b2d62" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },
"telescope-orgmode.nvim": { "branch": "main", "commit": "a8478496911e378868f44bd9fd5fd5ce5eeec57b" },
- "telescope.nvim": { "branch": "master", "commit": "79552ef8488cb492e0f9d2bf3b4e808f57515e35" },
+ "telescope.nvim": { "branch": "master", "commit": "bc4e7e450397970ab741d0f489e370ec4ce4d57c" },
"trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" },
- "ts-comments.nvim": { "branch": "main", "commit": "0090cacf89bc52e4eddb911bc6c33b12411b95f7" },
+ "ts-comments.nvim": { "branch": "main", "commit": "98d7d4dec0af1312d38e288f800bbf6ff562b6ab" },
"undotree": { "branch": "master", "commit": "56c684a805fe948936cda0d1b19505b84ad7e065" },
"venn.nvim": { "branch": "main", "commit": "b09c2f36ddf70b498281845109bedcf08a7e0de0" },
"vim-dadbod": { "branch": "master", "commit": "7888cb7164d69783d3dce4e0283decd26b82538b" },
"vim-dadbod-completion": { "branch": "master", "commit": "c3a56c652af9367c5a7b658ed7ed4dc494f430b0" },
"vim-dadbod-ui": { "branch": "master", "commit": "0f51d8de368c8c6220973e8acd156d17da746f4c" },
"vim-dotenv": { "branch": "master", "commit": "5c51cfcf8d87280d6414e03cd6b253eb70ecb800" },
- "which-key.nvim": { "branch": "main", "commit": "c1b062ae95c3ca3e6eb87c075da991523605d79b" },
+ "which-key.nvim": { "branch": "main", "commit": "058486e5b001f11ef48f180dd57ae3088f5bb6dc" },
"zen-mode.nvim": { "branch": "main", "commit": "29b292bdc58b76a6c8f294c961a8bf92c5a6ebd6" }
}