diff options
| author | moxie <moxie@3kgcat.fi> | 2026-03-15 06:41:37 +0200 |
|---|---|---|
| committer | moxie <moxie@3kgcat.fi> | 2026-03-15 10:05:06 +0200 |
| commit | 49c1e9d1fc3d6bf8748756a8543d8c1b7287940f (patch) | |
| tree | 8e03c663f10c2a0a17b44bef6a3dbf575582fb2c /lua/muwiki/template.lua | |
| parent | c8dc1635f8a921269f714117f414bbc7ba24f9fd (diff) | |
refactor: move template/mkdir features to user-configured autocmds
- Remove auto-mkdir autocmd from init.lua (now user-configured)
- Remove template system entirely (now user-configured)
- Rename io.lua -> utils.lua
- Inline single-use functions (handle_web_link, handle_file_link, etc.)
- Remove security warnings for external files
- Remove unused config options: use_template, template, date_fmt
- Simplify utils.resolve() without wiki root validation
- Update all documentation examples
BREAKING CHANGE: Users must now add their own autocmds for:
- Auto-creating directories on save (BufWritePre)
- Applying templates to new files (BufNewFile)
See README.md for updated configuration examples.
Diffstat (limited to 'lua/muwiki/template.lua')
| -rw-r--r-- | lua/muwiki/template.lua | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/lua/muwiki/template.lua b/lua/muwiki/template.lua deleted file mode 100644 index d8eca16..0000000 --- a/lua/muwiki/template.lua +++ /dev/null @@ -1,35 +0,0 @@ -local config = require('muwiki.config') -local io_module = require('muwiki.io') - -local M = {} - -local function process_template(template, title) - local date_fmt = config.options.date_fmt or '%Y-%m-%d' - local date = os.date(date_fmt) - local result = template:gsub('${title}', title):gsub('${date}', date) - - if not result:match('\n$') then - result = result .. '\n' - end - - return result -end - -function M.init_file(bufnr, filepath) - if io_module.file_exists(filepath) then - return - end - - local filename = vim.fs.basename(filepath) - - if config.options.use_template then - local title = filename:gsub('%.md$', ''):gsub('_', ' ') - local content = process_template(config.options.template, title) - local lines = vim.split(content, '\n', { plain = true }) - vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines) - end - - vim.notify(string.format('%s (unsaved)', filename), vim.log.levels.INFO) -end - -return M |
