diff --git a/.config/nvim/snippets/languages/lua.json b/.config/nvim/snippets/languages/lua.json new file mode 100644 index 00000000..f7e8a981 --- /dev/null +++ b/.config/nvim/snippets/languages/lua.json @@ -0,0 +1,50 @@ +{ + "@class (LuaDoc)": { + "body": [ + "---@class (exact) ${1:class_name}", + "---@field ${2:field_name} string", + "---@field ${3:field_name} string" + ], + "description": "https://github.com/LuaLS/lua-language-server/wiki/Annotations#class", + "prefix": "@class (LuaDoc)" + }, + "@type (LuaDoc)": { + "body": "---@type ${1:string}", + "prefix": "@type (LuaDoc)" + }, + "export module": { + "body": [ + "local M = {}", + "--------------------------------------------------------------------------------", + "", + "$0--------------------------------------------------------------------------------", + "return M" + ], + "prefix": "export module" + }, + "find all in string": { + "body": [ + "local ${1:matches} = {}", + "for match in ${2:str}:gmatch(${3:pattern}) do", + "\ttable.insert(${1:matches}, match)", + "end" + ], + "prefix": "find all in string" + }, + "home": { + "body": "os.getenv(\"HOME\")", + "prefix": "home" + }, + "ignore (stylua)": { + "body": "-- stylua: ignore", + "prefix": "ignore (stylua)" + }, + "ignore start/end (stylua)": { + "body": ["-- stylua: ignore start", "-- stylua: ignore end"], + "prefix": "ignore start/end (stylua)" + }, + "import module": { + "body": "local ${1:name} = require(\"${2:module}.${1:name}\")", + "prefix": "import module" + } +} diff --git a/.config/nvim/snippets/languages/markdown.json b/.config/nvim/snippets/languages/markdown.json index a8d9040e..22e282d4 100644 --- a/.config/nvim/snippets/languages/markdown.json +++ b/.config/nvim/snippets/languages/markdown.json @@ -3,5 +3,35 @@ "body": "\"${2:alt", "description": "HTML syntax for images used to display images with reduced size", "prefix": "image" + }, + "details & summary": { + "body": ["
", "${1:Text}", "$0", "
"], + "description": "https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details", + "prefix": ["toggle / fold", "details & summary"] + }, + "caution (callout)": { + "body": ["> [!CAUTION]", "> $0"], + "description": "https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts", + "prefix": "caution (callout)" + }, + "important (callout)": { + "body": ["> [!IMPORTANT]", "> $0"], + "description": "https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts", + "prefix": "important (callout)" + }, + "note (callout)": { + "body": ["> [!NOTE]", "> $0"], + "description": "https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts", + "prefix": ["info (callout)", "note (callout)"] + }, + "tip (callout)": { + "body": ["> [!TIP]", "> $0"], + "description": "https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts", + "prefix": "tip (callout)" + }, + "warning (callout)": { + "body": ["> [!WARNING]", "> $0"], + "description": "https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts", + "prefix": "warning (callout)" } } diff --git a/.config/nvim/snippets/languages/python/python.json b/.config/nvim/snippets/languages/python/python.json new file mode 100644 index 00000000..01932eee --- /dev/null +++ b/.config/nvim/snippets/languages/python/python.json @@ -0,0 +1,19 @@ +{ + "list comprehension": { + "body": "list(${1:value} for ${2:value} in ${3:iterable})$0", + "description": "List comprehension for creating a list based on existing lists.", + "prefix": "list comprehension" + }, + "replace (regex)": { + "body": "re.sub(r\"${1:regex}\", r\"${2:replace}\", ${3:str})$0", + "prefix": "replace (regex)" + }, + "ternary": { + "body": "${1:value1} if ${2:condition} else ${3:value2}", + "prefix": "ternary" + }, + "while": { + "body": "while ${1:condition}:\n\t${2:pass}$0", + "prefix": "while" + } +} diff --git a/.config/nvim/snippets/package.json b/.config/nvim/snippets/package.json index f6a37ddb..1db66e6b 100644 --- a/.config/nvim/snippets/package.json +++ b/.config/nvim/snippets/package.json @@ -30,6 +30,14 @@ "stylus" ], "path": "./languages/css.json" + }, + { + "language": "python", + "path": "./languages/python/python.json" + }, + { + "language": "lua", + "path": "./languages/lua.json" } ] }