feat: Add API to get template

This commit is contained in:
danymat
2022-02-01 18:55:18 +01:00
parent f02e883651
commit ac7caed0c5

View File

@@ -107,7 +107,7 @@ end
--- ---
--- Neogen provides those defaults, and you can change them to suit your needs --- Neogen provides those defaults, and you can change them to suit your needs
---@eval return MiniDoc.afterlines_to_code(MiniDoc.current.eval_section) ---@eval return MiniDoc.afterlines_to_code(MiniDoc.current.eval_section)
---@test # Notes~ ---@text # Notes~
--- ---
--- - to configure a language, just add your configurations in the `languages` table --- - to configure a language, just add your configurations in the `languages` table
--- For example, for the `lua` lang: --- For example, for the `lua` lang:
@@ -278,6 +278,21 @@ end
-- Expose match_commands for `:Neogen` completion -- Expose match_commands for `:Neogen` completion
neogen.match_commands = helpers.match_commands neogen.match_commands = helpers.match_commands
--- Get a template for a particular filetype
---@param filetype string
---@return neogen.TemplateConfig|nil
neogen.get_template = function(filetype)
if not neogen.configuration.languages[filetype] then
return
end
if not neogen.configuration.languages[filetype].template then
return
end
return neogen.configuration.languages[filetype].template
end
-- Required for use with completion engine ===================================== -- Required for use with completion engine =====================================
--- Jumps to the next cursor template position --- Jumps to the next cursor template position