diff --git a/README.md b/README.md index 0f2dfc5..d09bee6 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Reduce your boilerplate code the lazy-bones way. ## What is `esqueleto`?

- +

`esqueleto.nvim` is a lua-based plugin that intends to make the use of templates @@ -154,7 +154,7 @@ The default options of `esqueleto` are the following: autouse = true, -- whether to auto-use a template if it's the only one for a pattern -- Wild-card options - wildcards = { + wildcards = { expand = true, -- whether to expand wild-cards lookup = { -- wild-cards look-up table -- File-specific @@ -193,7 +193,7 @@ For more information regarding `esqueleto.nvim` options, refer to docs (`:h esqu ### Triggers -As previously showcased, `esqueleto.nvim` has two types of triggers: (i) file type and (ii) +As previously showcased, `esqueleto.nvim` has two types of triggers: (i) file type and (ii) file name triggers. This correspond to the backbone of `esqueleto`, therefore is essential to correctly understand how the plugin works for proper creation and organization of templates. @@ -221,7 +221,7 @@ require("esqueleto").setup( ) ``` -Then, instead of creating a new file, we will create a softlink to the template we already +Then, instead of creating a new file, we will create a softlink to the template we already have in the `python` directory. From this, we should obtain the following structure: ``` @@ -239,7 +239,7 @@ and now we will trigger template insertion for empty (i) `python` type, (ii) `LI (iii) `cli.py` named files:

- +

Finally, the command `EsqueletoNew` provides of a user-friendly way for creating new diff --git a/doc/esqueleto.txt b/doc/esqueleto.txt index e5cc3c7..11e53d5 100644 --- a/doc/esqueleto.txt +++ b/doc/esqueleto.txt @@ -115,26 +115,57 @@ python:~ *functions* *esqueleto.setup()* -setup({patterns}, {directory}) +setup({config}) - Setup for specific file {patterns} using the templates inside a - given {directory}. + Setup the plugin using the given {config} table. Defaults: > - esqueleto.setup( - { - directories = {vim.fn.stdpath("config") .. "/skeletons"}, - patterns = { }, - advanced = { ignore = {}, ignore_os_files = true }, - } - ) + { + autouse = true, + directories = { vim.fn.stdpath("config") .. "/skeletons" }, + patterns = function(dir) return vim.fn.readdir(dir) end, + wildcards = { + expand = true, + lookup = { + -- File + ["filename"] = function() return vim.fn.expand("%:t:r") end, + ["fileabspath"] = function() return vim.fn.expand("%:p") end, + ["filerelpath"] = function() return vim.fn.expand("%:p:~") end, + ["fileext"] = function() return vim.fn.expand("%:e") end, + ["filetype"] = function() return vim.bo.filetype end, + + -- Date and time + ["date"] = function() return os.date("%Y%m%d", os.time()) end, + ["year"] = function() return os.date("%Y", os.time()) end, + ["month"] = function() return os.date("%m", os.time()) end, + ["day"] = function() return os.date("%d", os.time()) end, + ["time"] = function() return os.date("%T", os.time()) end, + + -- System + ["host"] = function() return utils.capture("hostname", false) end, + ["user"] = function() return os.getenv("USER") end, + + -- Github + ["gh-email"] = function() return utils.capture("git config user.email", false) end, + ["gh-user"] = function() return utils.capture("git config user.name", false) end, + }, + }, + advanced = { ignored = {}, ignore_os_files = true }, + } < Parameters: ~ - • {patterns} (table) File names or patterns to match - • {directory} (string) An absolute or relative path to the directory - with templates. - • {advanced} (table) Advanced options, including: + • {autouse} (boolean) Whether to auto-use a template if it's the only + one for a pattern. + • {directories} (table) An absolute or relative path to the directories + with templates. + • {patterns} (table) File names or patterns to match. File name + trigger has priority. + • {wildcards} (table) Wildcards options, including: + • {expand} (boolean) Whether to expand + wild-cards. + • {lookup} (table) Wild-cards look-up table. + • {advanced} (table) Advanced options, including: • {ignore} (table|function) List of glob patterns of files to be ignored; alternatively, a predicate that determines if a file @@ -148,11 +179,14 @@ setup({patterns}, {directory}) *ex-commands* *Esqueleto* -Esqueleto +EsqueletoInsert Prompt template insertion for current file, prioritizing patterns matching over file name then over file type. +EsqueletoNew + + Prompt template creation for current file. ============================================================================== *changelog*