diff options
-rw-r--r-- | snippets/chartjs_simple_bar_chart | 18 | ||||
-rw-r--r-- | snippets/html_details (renamed from snippets/html/details) | 0 | ||||
-rw-r--r-- | snippets/html_with_basic_head (renamed from snippets/html/html_with_basic_head) | 0 | ||||
-rw-r--r-- | snippets/lua_function (renamed from snippets/lua/function) | 0 | ||||
-rw-r--r-- | snippets/lua_keymap (renamed from snippets/lua/keymap) | 0 | ||||
-rw-r--r-- | snippets/markdown_table (renamed from snippets/markdown/table) | 0 | ||||
-rw-r--r-- | snippets/mermaid_simple_diagram | 8 | ||||
-rw-r--r-- | vim/lua/mappings.lua | 21 |
8 files changed, 32 insertions, 15 deletions
diff --git a/snippets/chartjs_simple_bar_chart b/snippets/chartjs_simple_bar_chart new file mode 100644 index 0000000..0e581cb --- /dev/null +++ b/snippets/chartjs_simple_bar_chart | |||
@@ -0,0 +1,18 @@ | |||
1 | { | ||
2 | "type": "bar", | ||
3 | "data": { | ||
4 | "labels": ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], | ||
5 | "datasets": [{ | ||
6 | "label": "# of Votes", | ||
7 | "data": [12, 19, 3, 5, 2, 3], | ||
8 | "borderWidth": 1 | ||
9 | }] | ||
10 | }, | ||
11 | "options": { | ||
12 | "scales": { | ||
13 | "y": { | ||
14 | "beginAtZero": true | ||
15 | } | ||
16 | } | ||
17 | } | ||
18 | } | ||
diff --git a/snippets/html/details b/snippets/html_details index 26ecaa6..26ecaa6 100644 --- a/snippets/html/details +++ b/snippets/html_details | |||
diff --git a/snippets/html/html_with_basic_head b/snippets/html_with_basic_head index 219bae2..219bae2 100644 --- a/snippets/html/html_with_basic_head +++ b/snippets/html_with_basic_head | |||
diff --git a/snippets/lua/function b/snippets/lua_function index 4a0ea5e..4a0ea5e 100644 --- a/snippets/lua/function +++ b/snippets/lua_function | |||
diff --git a/snippets/lua/keymap b/snippets/lua_keymap index 255fe49..255fe49 100644 --- a/snippets/lua/keymap +++ b/snippets/lua_keymap | |||
diff --git a/snippets/markdown/table b/snippets/markdown_table index cb95fd4..cb95fd4 100644 --- a/snippets/markdown/table +++ b/snippets/markdown_table | |||
diff --git a/snippets/mermaid_simple_diagram b/snippets/mermaid_simple_diagram new file mode 100644 index 0000000..9a7d25d --- /dev/null +++ b/snippets/mermaid_simple_diagram | |||
@@ -0,0 +1,8 @@ | |||
1 | graph TD | ||
2 | A[Enter Chart Definition] --> B(Preview) | ||
3 | B --> C{decide} | ||
4 | C --> D[Keep] | ||
5 | C --> E[Edit Definition] | ||
6 | E --> B | ||
7 | D --> F[Save Image and Code] | ||
8 | F --> B | ||
diff --git a/vim/lua/mappings.lua b/vim/lua/mappings.lua index 401c0f8..45c44ec 100644 --- a/vim/lua/mappings.lua +++ b/vim/lua/mappings.lua | |||
@@ -54,9 +54,10 @@ vim.keymap.set("n", "<leader>pt", "<cmd>Telescope terms<CR>", { desc = "telescop | |||
54 | 54 | ||
55 | vim.keymap.set('n', '<leader>ss', function() | 55 | vim.keymap.set('n', '<leader>ss', function() |
56 | local current_filetype = vim.bo.filetype | 56 | local current_filetype = vim.bo.filetype |
57 | local cwd = os.getenv("HOME") .. '/snippets/' .. current_filetype | 57 | local cwd = os.getenv("HOME") .. '/snippets' |
58 | require('telescope.builtin').find_files { | 58 | require('telescope.builtin').find_files { |
59 | prompt_title = 'Select a snippet for ' .. current_filetype, | 59 | prompt_title = 'Select a snippet for ' .. current_filetype, |
60 | default_text = current_filetype .. "_", | ||
60 | cwd = cwd, | 61 | cwd = cwd, |
61 | attach_mappings = function(prompt_bufnr, map) | 62 | attach_mappings = function(prompt_bufnr, map) |
62 | local insert_selected_snippet = function() | 63 | local insert_selected_snippet = function() |
@@ -95,20 +96,10 @@ vim.keymap.set('n', '<leader>sd', function() | |||
95 | end, { desc = 'Search Directory' }) | 96 | end, { desc = 'Search Directory' }) |
96 | 97 | ||
97 | vim.keymap.set('n', '<leader>sn', function() | 98 | vim.keymap.set('n', '<leader>sn', function() |
98 | vim.ui.input({ prompt = 'Snippet Name: ' }, function(snippet_path) | 99 | local current_filetype = vim.bo.filetype |
99 | local current_filetype | 100 | vim.ui.input({ prompt = 'Snippet Name: ', default = current_filetype .. "_" }, function(snippet) |
100 | local snippet | 101 | vim.cmd("cd ~/snippets") |
101 | if string.find(snippet_path, "/") then | 102 | vim.cmd("e " .. snippet) |
102 | current_filetype = string.match(snippet_path, "^(.-)/") | ||
103 | snippet = string.match(snippet_path, "/(.-)$") | ||
104 | else | ||
105 | current_filetype = vim.bo.filetype | ||
106 | snippet = snippet_path | ||
107 | end | ||
108 | local dir = os.getenv("HOME") .. '/snippets/' .. current_filetype | ||
109 | local path = dir .. '/' .. snippet | ||
110 | vim.cmd("!mkdir -p" .. dir) | ||
111 | vim.cmd("e " .. path) | ||
112 | vim.cmd("set filetype=" .. current_filetype) | 103 | vim.cmd("set filetype=" .. current_filetype) |
113 | vim.cmd("set filetype?") | 104 | vim.cmd("set filetype?") |
114 | end) | 105 | end) |