Skip to content

Commit 977fe02

Browse files
committed
feat: added auto completion
1 parent 3f507c1 commit 977fe02

3 files changed

Lines changed: 20 additions & 11 deletions

File tree

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ Using [lazy.nvim](https://github.com/folke/lazy.nvim):
1818

1919
```lua
2020
{
21-
"yourname/nvim-note-templates",
21+
"cmdblock/nvim-note-templates",
2222
dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" },
2323
config = function()
2424
require("note_templates").setup({
2525
-- Default configuration
26-
templates_dir = vim.fn.stdpath("config") .. "/templates",
26+
templates_dir = vim.fn.stdpath("config") .. "/note-templates",
2727
})
2828
end,
2929
keys = {
@@ -52,14 +52,14 @@ require("note_templates").setup({
5252

5353
You can use these in your `.md` templates:
5454

55-
| Variable | Description | Example Output |
56-
| :--- | :--- | :--- |
57-
| `{{title}}` / `<% tp.file.title %>` | Filename (without extension) | `My Note` |
58-
| `{{date}}` / `<% tp.date.now() %>` | Current date | `2026-03-12` |
59-
| `{{time}}` | Current time | `14:30` |
60-
| `{{modified}}` / `<% tp.file.last_modified_date() %>` | Current Date & Time | `2026-03-12 14:30` |
61-
| `<% tp.date.yesterday() %>` | Yesterday's date | `2026-03-11` |
62-
| `<% tp.date.tomorrow() %>` | Tomorrow's date | `2026-03-13` |
55+
| Variable | Description | Example Output |
56+
| :---------------------------------------------------- | :--------------------------- | :----------------- |
57+
| `{{title}}` / `<% tp.file.title %>` | Filename (without extension) | `My Note` |
58+
| `{{date}}` / `<% tp.date.now() %>` | Current date | `2026-03-12` |
59+
| `{{time}}` | Current time | `14:30` |
60+
| `{{modified}}` / `<% tp.file.last_modified_date() %>` | Current Date & Time | `2026-03-12 14:30` |
61+
| `<% tp.date.yesterday() %>` | Yesterday's date | `2026-03-11` |
62+
| `<% tp.date.tomorrow() %>` | Tomorrow's date | `2026-03-13` |
6363

6464
## 📄 License
6565

lua/note_templates/init.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ M.config = {
66

77
function M.setup(opts)
88
M.config = vim.tbl_deep_extend("force", M.config, opts or {})
9+
-- Expand path to handle ~ and environment variables
10+
M.config.templates_dir = vim.fn.expand(M.config.templates_dir)
911
end
1012

1113
function M.render(lines)

plugin/note_templates.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
local nt = require("note_templates")
22

3+
-- Enhanced command with auto-completion
34
vim.api.nvim_create_user_command("NoteTemplate", function(opts)
45
nt.insert_template(opts.args)
5-
end, { nargs = 1 })
6+
end, {
7+
nargs = 1,
8+
complete = function()
9+
-- This provides auto-completion for the template names
10+
return nt.list_templates()
11+
end,
12+
})
613

714
vim.api.nvim_create_user_command("NoteTemplatePick", function()
815
require("note_templates.telescope").pick()

0 commit comments

Comments
 (0)