summaryrefslogtreecommitdiff
path: root/ar/.config/TheSiahxyz/lua/thesiahxyz/snippets
diff options
context:
space:
mode:
Diffstat (limited to 'ar/.config/TheSiahxyz/lua/thesiahxyz/snippets')
-rw-r--r--ar/.config/TheSiahxyz/lua/thesiahxyz/snippets/markdown.lua187
-rw-r--r--ar/.config/TheSiahxyz/lua/thesiahxyz/snippets/neetcode1.lua103
-rw-r--r--ar/.config/TheSiahxyz/lua/thesiahxyz/snippets/neetcode2.lua104
-rw-r--r--ar/.config/TheSiahxyz/lua/thesiahxyz/snippets/quarto.lua28
-rw-r--r--ar/.config/TheSiahxyz/lua/thesiahxyz/snippets/whichkey.lua18
5 files changed, 0 insertions, 440 deletions
diff --git a/ar/.config/TheSiahxyz/lua/thesiahxyz/snippets/markdown.lua b/ar/.config/TheSiahxyz/lua/thesiahxyz/snippets/markdown.lua
deleted file mode 100644
index 7d91fab..0000000
--- a/ar/.config/TheSiahxyz/lua/thesiahxyz/snippets/markdown.lua
+++ /dev/null
@@ -1,187 +0,0 @@
-local ls = require("luasnip")
-
-local s = ls.snippet
-local t = ls.text_node
-local i = ls.insert_node
-local f = ls.function_node
-
-local function clipboard()
- return vim.fn.getreg("+")
-end
-
--- #####################################################################
--- Markdown
--- #####################################################################
-
--- Helper function to create code block snippets
-local function create_code_block_snippet(lang)
- return s(lang, {
- t({ "```" .. lang, "" }),
- i(1),
- t({ "", "```" }),
- })
-end
-
--- Define languages for code blocks
-local languages = {
- "txt",
- "lua",
- "sql",
- "go",
- "regex",
- "bash",
- "markdown",
- "markdown_inline",
- "yaml",
- "json",
- "jsonc",
- "cpp",
- "csv",
- "java",
- "javascript",
- "python",
- "dockerfile",
- "html",
- "css",
- "templ",
- "php",
-}
-
--- Generate snippets for all languages
-local snippets = {}
-
-for _, lang in ipairs(languages) do
- table.insert(snippets, create_code_block_snippet(lang))
-end
-
-table.insert(
- snippets,
- s({
- trig = "chirpy",
- name = "Disable markdownlint and prettier for chirpy",
- }, {
- t({
- " ",
- "<!-- markdownlint-disable -->",
- "<!-- prettier-ignore-start -->",
- " ",
- "<!-- tip=green, info=blue, warning=yellow, danger=red -->",
- " ",
- "> ",
- }),
- i(1),
- t({
- "",
- "{: .prompt-",
- }),
- -- In case you want to add a default value "tip" here, but I'm having
- -- issues with autosave
- -- i(2, "tip"),
- i(2),
- t({
- " }",
- " ",
- "<!-- prettier-ignore-end -->",
- "<!-- markdownlint-restore -->",
- }),
- })
-)
-
-table.insert(
- snippets,
- s({
- trig = "markdownlint",
- name = "Add markdownlint disable and restore headings",
- }, {
- t({
- " ",
- "<!-- markdownlint-disable -->",
- " ",
- "> ",
- }),
- i(1),
- t({
- " ",
- " ",
- "<!-- markdownlint-restore -->",
- }),
- })
-)
-
-table.insert(
- snippets,
- s({
- trig = "prettierignore",
- name = "Add prettier ignore start and end headings",
- }, {
- t({
- " ",
- "<!-- prettier-ignore-start -->",
- " ",
- "> ",
- }),
- i(1),
- t({
- " ",
- " ",
- "<!-- prettier-ignore-end -->",
- }),
- })
-)
-
-table.insert(
- snippets,
- s({
- trig = "link",
- name = "Add this -> []()",
- }, {
- t("["),
- i(1),
- t("]("),
- i(2),
- t(")"),
- })
-)
-
-table.insert(
- snippets,
- s({
- trig = "linkt",
- name = 'Add this -> [](){:target="_blank"}',
- }, {
- t("["),
- i(1),
- t("]("),
- i(2),
- t('){:target="_blank"}'),
- })
-)
-
-table.insert(
- snippets,
- s({
- trig = "todo",
- name = "Add TODO: item",
- }, {
- t("<!-- TODO: "),
- i(1),
- t(" -->"),
- })
-)
-
--- Paste clipboard contents in link section, move cursor to ()
-table.insert(
- snippets,
- s({
- trig = "linkclip",
- name = "Paste clipboard as .md link",
- }, {
- t("["),
- i(1),
- t("]("),
- f(clipboard, {}),
- t(")"),
- })
-)
-
-ls.add_snippets("markdown", snippets)
diff --git a/ar/.config/TheSiahxyz/lua/thesiahxyz/snippets/neetcode1.lua b/ar/.config/TheSiahxyz/lua/thesiahxyz/snippets/neetcode1.lua
deleted file mode 100644
index 85da742..0000000
--- a/ar/.config/TheSiahxyz/lua/thesiahxyz/snippets/neetcode1.lua
+++ /dev/null
@@ -1,103 +0,0 @@
-local ls = require("luasnip")
-local s = ls.snippet
-local i = ls.insert_node
-local fmt = require("luasnip.extras.fmt").fmt
-local rep = require("luasnip.extras").rep
-local f = ls.function_node -- Import function_node for dynamic content
-
--- Function to get the filename without the path
-local function get_filename()
- local filepath = vim.api.nvim_buf_get_name(0)
- local filename = vim.fn.fnamemodify(filepath, ":t:r") -- Get filename without path and extension
- return filename:gsub("_", " ") -- Replace underscores with spaces
-end
-
-local neetcode_snippet = s(
- "neetcode",
- fmt(
- [[
-"""
-Question
-
-{1}
-"""
-
-
-from typing import Dict
-
-class Solution:
- """
- A class to solve {file_name} from {2}
- """
- def {3}(self, {4}) -> {5}:
- """
- {file_name} from the input {parameters_type} using a {func_name} approach.
-
- Args:
- {parameters_type}: {6}
-
- Returns:
- {return_type}: {7}
- """
- return {8}
-
- def print(self, examples: Dict[str, {parameters_type}]) -> None:
- for name, example in examples.items():
- result = self.{3}(example)
- print(f"{{name}}: {{result}}")
-
- def main(self):
- cases = {{
- "case1" : {9},
- "case2" : {10},
- "case3" : {11},
- }}
-
- self.print(cases)
-
-
-solution = Solution()
-solution.main()
-
-"""
-Solution
-
-url: {12}
-video: {13}
-
-1. {func_name}
-time: {14}
-space: {15}
-code:
-```python
-{16}
-```
-"""
-]],
- {
- i(1, '"Describe the question here"'),
- file_name = f(get_filename), -- Insert the filename dynamicall
- i(2, '"Describe the class here"'),
- i(3, '"Function name"'), -- Primary insert node for method name
- func_name = rep(3), -- Repeat the method name
- i(4, '"parameters"'),
- parameters_type = rep(4),
- i(5, '"return_type"'),
- return_type = rep(5),
- i(6, '"parameters_desc"'),
- i(7, '"return_type_desc"'),
- i(8, '"return"'),
- i(9, '"case1"'),
- i(10, '"case2"'),
- i(11, '"case3"'),
- i(12, '"url"'),
- i(13, '"video"'),
- i(14, '"time_complexity"'),
- i(15, '"space_complexity"'),
- i(16, '"code"'),
- }
- )
-)
-
--- Add the snippets for multiple filetypes
-ls.add_snippets("python", { neetcode_snippet })
diff --git a/ar/.config/TheSiahxyz/lua/thesiahxyz/snippets/neetcode2.lua b/ar/.config/TheSiahxyz/lua/thesiahxyz/snippets/neetcode2.lua
deleted file mode 100644
index 98e7258..0000000
--- a/ar/.config/TheSiahxyz/lua/thesiahxyz/snippets/neetcode2.lua
+++ /dev/null
@@ -1,104 +0,0 @@
-local ls = require("luasnip")
-local s = ls.snippet
-local i = ls.insert_node
-local fmt = require("luasnip.extras.fmt").fmt
-local rep = require("luasnip.extras").rep
-local f = ls.function_node -- Import function_node for dynamic content
-
--- Function to get the filename without the path
-local function get_filename()
- local filepath = vim.api.nvim_buf_get_name(0)
- local filename = vim.fn.fnamemodify(filepath, ":t:r") -- Get filename without path and extension
- return filename:gsub("_", " ") -- Replace underscores with spaces
-end
-
-local neetcode_snippet = s(
- "neetcode",
- fmt(
- [[
-"""
-Question
-
-{1}
-"""
-
-
-from typing import Dict
-
-class Solution:
- """
- A class to solve {file_name} from {2}
- """
- def {3}(self, {4}) -> {5}:
- """
- {file_name} from the input {parameters_type} using a {func_name} approach.
-
- Args:
- {parameters_type}: {6}
-
- Returns:
- {return_type}: {7}
- """
- return {8}
-
- def print(self, examples: Dict[str, {parameters_type}]) -> None:
- for name, (param1, param2) in examples.items():
- result = self.{3}(param1, param2)
- print(f"{{name}}: {{result}}")
-
- def main(self):
- cases = {{
- "case1" : ({9}),
- "case2" : ({10}),
- "case3" : ({11}),
- }}
-
- self.print(cases)
-
-
-
-solution = Solution()
-solution.main()
-
-"""
-Solution
-
-url: {12}
-video: {13}
-
-1. {func_name}
-time: {14}
-space: {15}
-code:
-```python
-{16}
-```
-"""
-]],
- {
- i(1, '"Describe the question here"'),
- file_name = f(get_filename), -- Insert the filename dynamicall
- i(2, '"Describe the class here"'),
- i(3, '"Function name"'), -- Primary insert node for method name
- func_name = rep(3), -- Repeat the method name
- i(4, '"parameters"'),
- parameters_type = rep(4),
- i(5, '"return_type"'),
- return_type = rep(5),
- i(6, '"parameters_desc"'),
- i(7, '"return_type_desc"'),
- i(8, '"return"'),
- i(9, '"case1"'),
- i(10, '"case2"'),
- i(11, '"case3"'),
- i(12, '"url"'),
- i(13, '"video"'),
- i(14, '"time_complexity"'),
- i(15, '"space_complexity"'),
- i(16, '"code"'),
- }
- )
-)
-
--- Add the snippets for multiple filetypes
-ls.add_snippets("python", { neetcode_snippet })
diff --git a/ar/.config/TheSiahxyz/lua/thesiahxyz/snippets/quarto.lua b/ar/.config/TheSiahxyz/lua/thesiahxyz/snippets/quarto.lua
deleted file mode 100644
index 74b9fb8..0000000
--- a/ar/.config/TheSiahxyz/lua/thesiahxyz/snippets/quarto.lua
+++ /dev/null
@@ -1,28 +0,0 @@
-local ls = require("luasnip")
-
-local s = ls.snippet
-local i = ls.insert_node
-local t = ls.text_node
--- local d = ls.dynamic_node
-local c = ls.choice_node
--- local f = ls.function_node
--- local r = ls.restore_node
-local fmt = require("luasnip.extras.fmt").fmta
--- local h = require("thesiahxyz.utils.snippet")
-
-local code_cell_snippet = s(
- "`",
- fmt(
- [[```<lang>
-<last>
-``]],
- {
- lang = c(1, { t("python"), t("") }),
- last = i(0), -- Place cursor here after expanding the snippet
- }
- )
-)
-
--- Add the snippets for multiple filetypes
-ls.add_snippets("markdown", { code_cell_snippet })
-ls.add_snippets("quarto", { code_cell_snippet })
diff --git a/ar/.config/TheSiahxyz/lua/thesiahxyz/snippets/whichkey.lua b/ar/.config/TheSiahxyz/lua/thesiahxyz/snippets/whichkey.lua
deleted file mode 100644
index fab5853..0000000
--- a/ar/.config/TheSiahxyz/lua/thesiahxyz/snippets/whichkey.lua
+++ /dev/null
@@ -1,18 +0,0 @@
-local ls = require("luasnip")
-
--- Using parse_snippet instead of fmt to avoid curly brace issues
-local whichkey_snippet = ls.parser.parse_snippet(
- "whichkey",
- [[
-init = function()
- local wk = require("which-key")
- wk.add({
- mode = { "n" },
- { "${1:Key}", group = "${2:Name}" },
- })
-end,
-]]
-)
-
--- Add the snippets for the Lua filetype
-ls.add_snippets("lua", { whichkey_snippet })