Skip to content

Commit

Permalink
Format with stylua
Browse files Browse the repository at this point in the history
  • Loading branch information
molleweide authored and github-actions[bot] committed Jan 9, 2023
1 parent 910213a commit d629fc2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 27 deletions.
9 changes: 6 additions & 3 deletions lua/luasnip/extras/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,13 @@ local function match(index, _match, _then, _else)
end

local function jump_to_snip(snip)
local meta_data = require("luasnip.session.snippet_collection").get_meta_data_by_snip_id(snip.id)
local meta_data =
require("luasnip.session.snippet_collection").get_meta_data_by_snip_id(
snip.id
)
local source = meta_data.source
if source then
vim.cmd("edit " .. source)
if source then
vim.cmd("edit " .. source)
if snip.name then
local feed_str = vim.api.nvim_replace_termcodes(
"/" .. snip.name .. "<CR>",
Expand Down
4 changes: 2 additions & 2 deletions lua/luasnip/loaders/from_lua.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ local function load_files(ft, files, add_opts)
ft,
file_snippets,
vim.tbl_extend("keep", {
source = file,
source = file,
type = "snippets",
key = "__snippets_" .. file,
-- prevent refresh here, will be done outside loop.
Expand All @@ -94,7 +94,7 @@ local function load_files(ft, files, add_opts)
ft,
file_autosnippets,
vim.tbl_extend("keep", {
source = file,
source = file,
type = "autosnippets",
key = "__autosnippets_" .. file,
-- prevent refresh here, will be done outside loop.
Expand Down
39 changes: 17 additions & 22 deletions lua/luasnip/session/snippet_collection.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,27 +137,23 @@ local by_id = setmetatable({}, {
local snippets_meta_data = {}
local snip_id_to_meta_map = {}


local function initialize_snippet_meta_data(opts)
-- If we use two funcs one for module and one for each snip then the following
-- block would obviously have to be modified to work with that
--
-- config.store_snippets_data = {
-- get_module_module_data = function(opts) return { source = opts.source },
-- for_each_snippet = function(ft, snip, opts) ... end
-- }


-- func / table
-- If we use two funcs one for module and one for each snip then the following
-- block would obviously have to be modified to work with that
--
-- config.store_snippets_data = {
-- get_module_module_data = function(opts) return { source = opts.source },
-- for_each_snippet = function(ft, snip, opts) ... end
-- }

-- func / table
if type(session.config.store_meta_data) == "function" then
-- NOTE: use function is still a bit wip
table.insert(snippets_meta_data, session.config.store_meta_data(opts))
-- NOTE: use function is still a bit wip
table.insert(snippets_meta_data, session.config.store_meta_data(opts))


-- if bool
-- if bool
elseif session.config.store_meta_data then
table.insert(snippets_meta_data, { source = opts.source })

table.insert(snippets_meta_data, { source = opts.source })
end
end

Expand Down Expand Up @@ -276,9 +272,8 @@ local current_id = 0
-- opts.source = path to snip module which is assigned in
-- `from_lua.load`
function M.add_snippets(snippets, opts)

if session.config.store_meta_data then
initialize_snippet_meta_data(opts)
if session.config.store_meta_data then
initialize_snippet_meta_data(opts)
end

for ft, ft_snippets in pairs(snippets) do
Expand Down Expand Up @@ -317,7 +312,7 @@ function M.add_snippets(snippets, opts)
-- TODO: (wip) following line would store single snippet specific data
-- we are not sure yet how this would be done but I leave it here
-- for reference
-- snippets_meta_data[#snippets_meta_data].snippet_specific[snip.id] = session.config.store_meta_data.each_snippet(ft, snip, opts)
-- snippets_meta_data[#snippets_meta_data].snippet_specific[snip.id] = session.config.store_meta_data.each_snippet(ft, snip, opts)
end
end
end
Expand Down Expand Up @@ -361,7 +356,7 @@ function M.get_id_snippet(id)
end

function M.get_meta_data_by_snip_id(id)
return snippets_meta_data[snip_id_to_meta_map[id]]
return snippets_meta_data[snip_id_to_meta_map[id]]
end

return M

0 comments on commit d629fc2

Please sign in to comment.