neovim configuration using rocks.nvim plugin manager

feat(snippets): cool ranged-tag snippets

boltless.me f09d1e84 6b53d151

verified
+29 -6
+29 -6
lua/snippets/norg.lua
··· 6 local i = ls.insert_node 7 local f = ls.function_node 8 local d = ls.dynamic_node 9 local k = require("luasnip.nodes.key_indexer").new_key 10 local rep = require("luasnip.extras").rep 11 local fmt = require("luasnip.extras.fmt").fmt ··· 20 local function btime_fn() 21 local path = vim.fn.expand("%") 22 local stat = vim.uv.fs_stat(path) 23 - local btime = stat.birthtime or stat.mtime 24 - btime = btime.sec 25 return os.date(DATE_FORMAT, btime) 26 end 27 28 local function mtime_fn() 29 local path = vim.fn.expand("%") 30 local stat = vim.uv.fs_stat(path) 31 - local mtime = stat.mtime 32 - mtime = mtime.sec 33 return os.date(DATE_FORMAT, mtime) 34 end 35 ··· 61 d(1, file_index_fn), 62 f(btime_fn), 63 f(mtime_fn), 64 - -- t"", 65 - -- t"", 66 } 67 )), 68 })
··· 6 local i = ls.insert_node 7 local f = ls.function_node 8 local d = ls.dynamic_node 9 + local t = ls.text_node 10 local k = require("luasnip.nodes.key_indexer").new_key 11 local rep = require("luasnip.extras").rep 12 local fmt = require("luasnip.extras.fmt").fmt ··· 21 local function btime_fn() 22 local path = vim.fn.expand("%") 23 local stat = vim.uv.fs_stat(path) 24 + assert(stat) 25 + local btime = (stat.birthtime or stat.mtime).sec 26 return os.date(DATE_FORMAT, btime) 27 end 28 29 local function mtime_fn() 30 local path = vim.fn.expand("%") 31 local stat = vim.uv.fs_stat(path) 32 + assert(stat) 33 + local mtime = stat.mtime.sec 34 return os.date(DATE_FORMAT, mtime) 35 end 36 ··· 62 d(1, file_index_fn), 63 f(btime_fn), 64 f(mtime_fn), 65 } 66 )), 67 + -- cool ranged-tag snippet 68 + s( 69 + { trig = "(@+)([a-z\\-]+)", regTrig = true, wordTrig = false, name = "Dynamic Code Trigger" }, 70 + { 71 + f(function(_, snip) 72 + return snip.captures[1] 73 + end, {}, { key = "prefix" }), 74 + f(function(_, snip) 75 + return snip.captures[2] 76 + end), 77 + i(1), 78 + t{"", ""}, 79 + f(function(_, snip) 80 + local current_line = snip.env.TM_CURRENT_LINE 81 + local trigger_column = current_line:find(snip.trigger, 1, true) 82 + return string.rep(" ", trigger_column - 1) 83 + end, {}, { key = "indent" }), 84 + i(2), 85 + t{"", ""}, 86 + rep(k("indent")), 87 + rep(k("prefix")), 88 + t{"end", ""}, 89 + } 90 + ), 91 })