diff --git a/lazy-lock.json b/lazy-lock.json index 17941bb..5e9609a 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,29 +1,28 @@ { - "LuaSnip": { "branch": "master", "commit": "642b0c595e11608b4c18219e93b88d7637af27bc" }, - "aerial.nvim": { "branch": "master", "commit": "645d108a5242ec7b378cbe643eb6d04d4223f034" }, + "aerial.nvim": { "branch": "master", "commit": "585db11015abccf673dc5bd6502714d5655554be" }, "blink.cmp": { "branch": "main", "commit": "78336bc89ee5365633bcf754d93df01678b5c08f" }, "blink.compat": { "branch": "main", "commit": "1454f14a8d855a578ceeba77c62538fa1459a67c" }, - "catppuccin": { "branch": "main", "commit": "426dbebe06b5c69fd846ceb17b42e12f890aedf1" }, + "catppuccin": { "branch": "main", "commit": "0303a7208dba448c459767486a38a6ec05c4216b" }, "cloak.nvim": { "branch": "main", "commit": "648aca6d33ec011dc3166e7af3b38820d01a71e4" }, - "conform.nvim": { "branch": "master", "commit": "dca1a190aa85f9065979ef35802fb77131911106" }, + "conform.nvim": { "branch": "master", "commit": "619363c30309d29ffa631e67c8183f2a72caa373" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, "elixir-tools.nvim": { "branch": "main", "commit": "b51b48edc668924a6b2f6610f9a0aff34741d20e" }, "emoji.nvim": { "branch": "main", "commit": "a79e45d35853bb6446638f4d74c6f778ddebd8e3" }, - "fidget.nvim": { "branch": "main", "commit": "889e2e96edef4e144965571d46f7a77bcc4d0ddf" }, + "fidget.nvim": { "branch": "main", "commit": "82404b196e73a00b1727a91903beef5ddc319d22" }, "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, "gitlab.nvim": { "branch": "main", "commit": "f01ccbdaef7e8460af72c75be65f5f359928a0b4" }, "gitsigns.nvim": { "branch": "main", "commit": "dd3f588bacbeb041be6facf1742e42097f62165d" }, "go.nvim": { "branch": "master", "commit": "5c741a26f5df77c95d42d8f48e7008aea10e5f4f" }, - "guihua.lua": { "branch": "master", "commit": "7c364432c2f9153ed068f4eab1989edd9f3fd302" }, + "guihua.lua": { "branch": "master", "commit": "f8e06bd8a26dee3377d63c2adf1e57cdb58ac474" }, "harpoon": { "branch": "harpoon2", "commit": "87b1a3506211538f460786c23f98ec63ad9af4e5" }, - "kulala.nvim": { "branch": "main", "commit": "6656c9d332735ca6a27725e0fb45a1715c4372d9" }, + "kulala.nvim": { "branch": "main", "commit": "e43f4d85c9cd57b0638cd557a1cf141fb5ef670b" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, - "lsp_signature.nvim": { "branch": "master", "commit": "f40bcf203812beaf26766ec0bc169a7f429fd730" }, + "lsp_signature.nvim": { "branch": "master", "commit": "b7ace9ddb1640ce266012a45a672dfdaedfa5ec6" }, "lspkind.nvim": { "branch": "master", "commit": "c7274c48137396526b59d86232eabcdc7fed8a32" }, - "lualine.nvim": { "branch": "master", "commit": "131a558e13f9f28b15cd235557150ccb23f89286" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "1423254f58a3407a5afd5ade0ccd901f3eecc6ba" }, - "mason.nvim": { "branch": "main", "commit": "cb8445f8ce85d957416c106b780efd51c6298f89" }, - "mini.nvim": { "branch": "main", "commit": "48555f1615f08c6318150aacb52bf7d61a5af798" }, + "lualine.nvim": { "branch": "master", "commit": "221ce6b2d999187044529f49da6554a92f740a96" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "0a695750d747db1e7e70bcf0267ef8951c95fc83" }, + "mason.nvim": { "branch": "main", "commit": "16ba83bfc8a25f52bb545134f5bee082b195c460" }, + "mini.nvim": { "branch": "main", "commit": "232ceeb14f7f7e849056309b85cb2fed712db46f" }, "neoscroll.nvim": { "branch": "master", "commit": "c8d29979cb0cb3a2437a8e0ae683fd82f340d3b8" }, "neotest": { "branch": "master", "commit": "ad991822b7076b1d940b33a9d6d0d30416d5df81" }, "neotest-elixir": { "branch": "master", "commit": "a242aebeaa6997c1c149138ff77f6cacbe33b6fc" }, @@ -33,46 +32,48 @@ "neotest-rust": { "branch": "main", "commit": "2c9941d4a358839918fac21d20fc8fef0e1ad05f" }, "neovim-tips": { "branch": "master", "commit": "1339a0da1ff59fab8cfc07661ef92aa8c7d07f79" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, - "nvim-autopairs": { "branch": "master", "commit": "59bce2eef357189c3305e25bc6dd2d138c1683f5" }, - "nvim-colorizer.lua": { "branch": "master", "commit": "5cfe7fffbd01e17b3c1e14af85d5febdef88bd8c" }, + "nvim-autopairs": { "branch": "master", "commit": "7b9923abad60b903ece7c52940e1321d39eccc79" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "664c0b7cea1de71f8b65dfe951b7996fc3e6ccde" }, "nvim-coverage": { "branch": "main", "commit": "a939e425e363319d952a6c35fb3f38b34041ded2" }, - "nvim-dap": { "branch": "master", "commit": "45a69eba683a2c448dd9ecfc4de89511f0646b5f" }, + "nvim-dap": { "branch": "master", "commit": "531771530d4f82ad2d21e436e3cc052d68d7aebb" }, + "nvim-dap-go": { "branch": "main", "commit": "b4421153ead5d726603b02743ea40cf26a51ed5f" }, "nvim-dap-python": { "branch": "master", "commit": "1808458eba2b18f178f990e01376941a42c7f93b" }, "nvim-dap-ui": { "branch": "master", "commit": "1a66cabaa4a4da0be107d5eda6d57242f0fe7e49" }, "nvim-devdocs": { "branch": "master", "commit": "668e25f06da43c7b5e95c2419c9864076bb3bd9c" }, "nvim-jqx": { "branch": "master", "commit": "07393e80fa8097e82f9038fec05e948fe8a60fd1" }, - "nvim-lint": { "branch": "master", "commit": "eab58b48eb11d7745c11c505e0f3057165902461" }, - "nvim-lspconfig": { "branch": "master", "commit": "cd576dd72d31ddffcbfa6d064c0dd697ca218758" }, + "nvim-lint": { "branch": "master", "commit": "d48f3a76189d03b2239f6df1b2f7e3fa8353743b" }, + "nvim-lspconfig": { "branch": "master", "commit": "9573948c38bfabeec353ae7dd7d3ffec4c506a6b" }, "nvim-man": { "branch": "master", "commit": "7fe6b3b78c71c9ef834c49e3dcbd955f7ed5c6cb" }, "nvim-navic": { "branch": "master", "commit": "f5eba192f39b453675d115351808bd51276d9de5" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, + "nvim-scissors": { "branch": "main", "commit": "9cc1ba06afa8b23b0d30cadc02c40940df1d701e" }, "nvim-silicon": { "branch": "main", "commit": "7f66bda8f60c97a5bf4b37e5b8acb0e829ae3c32" }, "nvim-spectre": { "branch": "master", "commit": "72f56f7585903cd7bf92c665351aa585e150af0f" }, "nvim-surround": { "branch": "main", "commit": "1098d7b3c34adcfa7feb3289ee434529abd4afd1" }, "nvim-treesitter": { "branch": "main", "commit": "4916d6592ede8c07973490d9322f187e07dfefac" }, "nvim-treesitter-textobjects": { "branch": "main", "commit": "851e865342e5a4cb1ae23d31caf6e991e1c99f1e" }, "nvim-ufo": { "branch": "main", "commit": "ab3eb124062422d276fae49e0dd63b3ad1062cfc" }, - "nvim-web-devicons": { "branch": "master", "commit": "4fc505ac7bd7692824a142e96e5f529c133862f8" }, + "nvim-web-devicons": { "branch": "master", "commit": "dfbfaa967a6f7ec50789bead7ef87e336c1fa63c" }, "obsidian.nvim": { "branch": "main", "commit": "ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b" }, - "octo.nvim": { "branch": "master", "commit": "bbd903ce905c301ac516d64c33b2511a05f6b59b" }, - "overseer.nvim": { "branch": "master", "commit": "f818eefff81f4b12fb7cf236f1b6c16768a2fcbc" }, + "octo.nvim": { "branch": "master", "commit": "b495047f0b9d35de3d8c6b84fad9de296d353b41" }, + "overseer.nvim": { "branch": "master", "commit": "a93d9f6d6defdac4bcd6d2c8ba988650e42e0a0e" }, "package-info.nvim": { "branch": "master", "commit": "9725099fb118bab8360e560c1219bff60763b7e1" }, "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, "pr-description.nvim": { "branch": "main", "commit": "76fbca834059448a88cb682e4bc064f49cb9f7a3" }, "profile.nvim": { "branch": "master", "commit": "30433d7513f0d14665c1cfcea501c90f8a63e003" }, "promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" }, - "refactoring.nvim": { "branch": "master", "commit": "29bada48407a9e00d670207d00bbdc0c46c5dc58" }, - "render-markdown.nvim": { "branch": "main", "commit": "629eb9533ec989d9d5c6cab8f3ad5372422c24e0" }, - "smart-splits.nvim": { "branch": "master", "commit": "80be31a3d2e37d32bd37794da72a4f69fce7a85f" }, + "refactoring.nvim": { "branch": "master", "commit": "624c01e8175901484eac74512baf35e9dfe269b8" }, + "render-markdown.nvim": { "branch": "main", "commit": "5adf0895310c1904e5abfaad40a2baad7fe44a07" }, + "smart-splits.nvim": { "branch": "master", "commit": "1865e6826b1cd90098f198acb0f5b744a7b40c22" }, "smartcolumn.nvim": { "branch": "main", "commit": "b9cdbdf42f7ac5a659204cd5926017c7ff724a19" }, - "snacks.nvim": { "branch": "main", "commit": "ad9ede6a9cddf16cedbd31b8932d6dcdee9b716e" }, + "snacks.nvim": { "branch": "main", "commit": "882c996cf28183f4d63640de0b4c02ec886d01f2" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "b25b749b9db64d375d782094e2b9dce53ad53a40" }, "telescope-terraform.nvim": { "branch": "main", "commit": "072c97023797ca1a874668aaa6ae0b74425335df" }, "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, "trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" }, "undotree": { "branch": "master", "commit": "6fa6b57cda8459e1e4b2ca34df702f55242f4e4d" }, - "venv-selector.nvim": { "branch": "main", "commit": "bcb2f58533c59b01565285eba49693f00bc460f5" }, + "venv-selector.nvim": { "branch": "main", "commit": "cc4bb3975de8835291f9bb45889e96c6b2795fc4" }, "vim-dadbod": { "branch": "master", "commit": "6d1d41da4873a445c5605f2005ad2c68c99d8770" }, "vim-dadbod-completion": { "branch": "master", "commit": "a8dac0b3cf6132c80dc9b18bef36d4cf7a9e1fe6" }, "vim-dadbod-ui": { "branch": "master", "commit": "07e92e22114cc5b1ba4938d99897d85b58e20475" }, diff --git a/lua/plugins/go-nvim.lua b/lua/plugins/go-nvim.lua index 4c92f33..45bce8e 100644 --- a/lua/plugins/go-nvim.lua +++ b/lua/plugins/go-nvim.lua @@ -42,7 +42,7 @@ return { test_runner = "go", verbose_tests = true, run_in_floaterm = false, - luasnip = true, + luasnip = false, iferr_vertical_shift = 4, }) diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index 62c68ac..678ac67 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -50,7 +50,27 @@ return { }, }) - vim.lsp.enable("lua_ls") + -- Terraform language server + vim.lsp.config("terraformls", { + filetypes = { "terraform", "terraform-vars", "tf" }, + root_markers = { ".terraform", ".git" }, + }) + + -- Pyright owns Python type checking + vim.lsp.config("pyright", { + settings = { + python = { + analysis = { + typeCheckingMode = "basic", + autoSearchPaths = true, + useLibraryCodeForTypes = true, + diagnosticMode = "openFilesOnly", + }, + }, + }, + }) + + vim.lsp.enable({ "lua_ls", "pyright", "gopls", "terraformls" }) -- Diagnostic configuration vim.diagnostic.config({ diff --git a/lua/plugins/luasnip.lua b/lua/plugins/luasnip.lua deleted file mode 100644 index b227f3c..0000000 --- a/lua/plugins/luasnip.lua +++ /dev/null @@ -1,178 +0,0 @@ -return { - "L3MON4D3/LuaSnip", - version = "v2.*", - build = "make install_jsregexp", - dependencies = { - "rafamadriz/friendly-snippets", - }, - config = function() - local luasnip = require("luasnip") - - luasnip.setup({ - history = true, - delete_check_events = "TextChanged", - region_check_events = "CursorMoved", - enable_autosnippets = true, - store_selection_keys = "", - ft_func = function() - return vim.split(vim.bo.filetype, ".", { plain = true }) - end, - }) - - require("luasnip.loaders.from_vscode").lazy_load() - require("luasnip.loaders.from_vscode").lazy_load({ paths = vim.fn.stdpath("config") .. "/snippets" }) - - require("luasnip.loaders.from_lua").load({ paths = vim.fn.stdpath("config") .. "/lua/snippets" }) - local s = luasnip.snippet - local t = luasnip.text_node - local i = luasnip.insert_node - local extras = require("luasnip.extras") - local rep = extras.rep - local fmt = require("luasnip.extras.fmt").fmt - - luasnip.add_snippets("python", { - s( - "def", - fmt( - [[ - def {}({}): - """{}""" - {} - ]], - { i(1, "function_name"), i(2), i(3, "Description"), i(0) } - ) - ), - - s( - "class", - fmt( - [[ - class {}({}): - """{}""" - - def __init__(self{}): - {} - ]], - { i(1, "ClassName"), i(2, "object"), i(3, "Description"), i(4), i(0) } - ) - ), - - s( - "ifmain", - t({ - 'if __name__ == "__main__":', - " main()", - }) - ), - }) - - luasnip.add_snippets("go", { - s( - "func", - fmt( - [[ - func {}({}) {} {{ - {} - }} - ]], - { i(1, "functionName"), i(2), i(3, "returnType"), i(0) } - ) - ), - - s( - "struct", - fmt( - [[ - type {} struct {{ - {} - }} - ]], - { i(1, "StructName"), i(0) } - ) - ), - - s( - "iferr", - t({ - "if err != nil {", - "\treturn err", - "}", - }) - ), - }) - - luasnip.add_snippets("terraform", { - s( - "resource", - fmt( - [[ - resource "{}" "{}" {{ - {} - }} - ]], - { i(1, "resource_type"), i(2, "name"), i(0) } - ) - ), - - s( - "variable", - fmt( - [[ - variable "{}" {{ - description = "{}" - type = {} - default = {} - }} - ]], - { i(1, "var_name"), i(2, "description"), i(3, "string"), i(0) } - ) - ), - - s( - "output", - fmt( - [[ - output "{}" {{ - description = "{}" - value = {} - }} - ]], - { i(1, "output_name"), i(2, "description"), i(0) } - ) - ), - - s( - "module", - fmt( - [[ - module "{}" {{ - source = "{}" - - # Required variables: - {} - - # Optional variables: - {} - }} - ]], - { i(1, "module_name"), i(2, "./modules/example"), i(3, "# Add required vars"), i(0) } - ) - ), - }) - - vim.keymap.set({ "i" }, "", function() - luasnip.expand() - end, { silent = true }) - vim.keymap.set({ "i", "s" }, "", function() - luasnip.jump(1) - end, { silent = true }) - vim.keymap.set({ "i", "s" }, "", function() - luasnip.jump(-1) - end, { silent = true }) - vim.keymap.set({ "i", "s" }, "", function() - if luasnip.choice_active() then - luasnip.change_choice(1) - end - end, { silent = true }) - end, -} diff --git a/lua/plugins/mason-lspconfig.lua b/lua/plugins/mason-lspconfig.lua index 8100d7e..dbf55af 100644 --- a/lua/plugins/mason-lspconfig.lua +++ b/lua/plugins/mason-lspconfig.lua @@ -4,6 +4,8 @@ return { ensure_installed = { "lua_ls", "pyright", + "gopls", + "terraformls", }, }, } diff --git a/lua/plugins/neovim-tips.lua b/lua/plugins/neovim-tips.lua deleted file mode 100644 index 65e5d66..0000000 --- a/lua/plugins/neovim-tips.lua +++ /dev/null @@ -1,20 +0,0 @@ -return { - "saxon1964/neovim-tips", - version = "*", - dependencies = { - "MunifTanjim/nui.nvim", - "MeanderingProgrammer/render-markdown.nvim", - }, - opts = { - daily_tip = 1, - }, - init = function() - local map = vim.keymap.set - map("n", "nto", ":NeovimTips", { desc = "Neovim tips", noremap = true, silent = true }) - map("n", "nte", ":NeovimTipsEdit", { desc = "Edit your Neovim tips", noremap = true, silent = true }) - map("n", "nta", ":NeovimTipsAdd", { desc = "Add your Neovim tip", noremap = true, silent = true }) - map("n", "nth", ":help neovim-tips", { desc = "Neovim tips help", noremap = true, silent = true }) - map("n", "ntr", ":NeovimTipsRandom", { desc = "Show random tip", noremap = true, silent = true }) - map("n", "ntp", ":NeovimTipsPdf", { desc = "Open Neovim tips PDF", noremap = true, silent = true }) - end, -} diff --git a/lua/plugins/nvim-dap-go.lua b/lua/plugins/nvim-dap-go.lua new file mode 100644 index 0000000..9769375 --- /dev/null +++ b/lua/plugins/nvim-dap-go.lua @@ -0,0 +1,25 @@ +return { + { + "leoluz/nvim-dap-go", + ft = "go", + dependencies = { + "mfussenegger/nvim-dap", + "rcarriga/nvim-dap-ui", + }, + config = function() + require("dap-go").setup({ + delve = { + -- Increase timeout for slow CI/large repos + initialize_timeout_sec = 20, + }, + }) + + vim.keymap.set("n", "dgt", function() + require("dap-go").debug_test() + end, { desc = "Debug Go test" }) + vim.keymap.set("n", "dgl", function() + require("dap-go").debug_last_test() + end, { desc = "Debug last Go test" }) + end, + }, +} diff --git a/lua/plugins/nvim-lint.lua b/lua/plugins/nvim-lint.lua index 5ee083c..420fc80 100644 --- a/lua/plugins/nvim-lint.lua +++ b/lua/plugins/nvim-lint.lua @@ -5,7 +5,7 @@ return { event = { "BufReadPost", "BufNewFile" }, config = function() require("lint").linters_by_ft = { - python = { "ruff", "mypy" }, + python = { "ruff" }, javascript = { "eslint" }, typescript = { "eslint" }, go = { "golangcilint", "staticcheck" }, diff --git a/lua/plugins/nvim-ufo.lua b/lua/plugins/nvim-ufo.lua index d712072..3cc2b1f 100644 --- a/lua/plugins/nvim-ufo.lua +++ b/lua/plugins/nvim-ufo.lua @@ -1,12 +1,21 @@ return { "kevinhwang91/nvim-ufo", dependencies = "kevinhwang91/promise-async", - config = function() + event = { "BufReadPost", "BufNewFile" }, + keys = { + { "zR", desc = "Open all folds" }, + { "zM", desc = "Close all folds" }, + { "zr", desc = "Open folds except kinds" }, + { "zm", desc = "Close folds with" }, + }, + init = function() + -- Fold options must be set before ufo loads so folds work on first buffer vim.o.foldcolumn = "1" vim.o.foldlevel = 99 vim.o.foldlevelstart = 99 vim.o.foldenable = true - + end, + config = function() require("ufo").setup({ provider_selector = function(bufnr, filetype, buftype) return { "treesitter", "indent" } diff --git a/lua/plugins/octo.lua b/lua/plugins/octo.lua index abaa940..2b379fa 100644 --- a/lua/plugins/octo.lua +++ b/lua/plugins/octo.lua @@ -41,7 +41,7 @@ return { }, file_panel = { size = 10, - use_icons = true, + icons = true, }, mappings_disable_default = false, mappings = { diff --git a/lua/plugins/render-markdown.lua b/lua/plugins/render-markdown.lua index ba76261..d5d68d9 100644 --- a/lua/plugins/render-markdown.lua +++ b/lua/plugins/render-markdown.lua @@ -5,7 +5,7 @@ return { "echasnovski/mini.nvim", -- for icons }, enabled = true, - ft = { "markdown", "norg", "rmd", "org" }, + ft = { "markdown" }, opts = { heading = { enabled = true, diff --git a/lua/plugins/scissors.lua b/lua/plugins/scissors.lua new file mode 100644 index 0000000..39b7c71 --- /dev/null +++ b/lua/plugins/scissors.lua @@ -0,0 +1,40 @@ +return { + "chrisgrieser/nvim-scissors", + dependencies = { "nvim-telescope/telescope.nvim" }, + cmd = { "ScissorsAddNewSnippet", "ScissorsEditSnippet" }, + keys = { + { + "csa", + function() + require("scissors").addNewSnippet() + end, + mode = { "n", "x" }, + desc = "Add new snippet", + }, + { + "cse", + function() + require("scissors").editSnippet() + end, + desc = "Edit snippet", + }, + }, + opts = { + snippetDir = vim.fn.stdpath("config") .. "/snippets", + editSnippetPopup = { + height = 0.4, + width = 0.6, + border = "rounded", + keymaps = { + cancel = "q", + saveChanges = "", + goBackToSearch = "", + deleteSnippet = "", + duplicateSnippet = "", + openInFile = "", + insertNextToken = "", + jumpBetweenBodyAndPrefix = "", + }, + }, + }, +} diff --git a/lua/plugins/which-key.lua b/lua/plugins/which-key.lua index 0a74b7a..a7b5e86 100644 --- a/lua/plugins/which-key.lua +++ b/lua/plugins/which-key.lua @@ -17,6 +17,7 @@ return { { "c", group = "Code/LSP" }, { "cA", group = "CodeCompanion" }, { "co", group = "Coverage" }, + { "cs", group = "Snippets" }, { "d", group = "Debug" }, { "dp", group = "Debug Python" }, { "D", group = "Database" }, diff --git a/neovim_tips/user_tips.md b/neovim_tips/user_tips.md deleted file mode 100644 index c37fe96..0000000 --- a/neovim_tips/user_tips.md +++ /dev/null @@ -1 +0,0 @@ -# Your personal Neovim tips diff --git a/snippets/go.json b/snippets/go.json new file mode 100644 index 0000000..d74abfb --- /dev/null +++ b/snippets/go.json @@ -0,0 +1,29 @@ +{ + "function": { + "prefix": "func", + "body": [ + "func ${1:functionName}(${2}) ${3:returnType} {", + "\t${0}", + "}" + ], + "description": "Function declaration" + }, + "struct": { + "prefix": "struct", + "body": [ + "type ${1:StructName} struct {", + "\t${0}", + "}" + ], + "description": "Struct declaration" + }, + "if err != nil": { + "prefix": "iferr", + "body": [ + "if err != nil {", + "\treturn err", + "}" + ], + "description": "Standard error check" + } +} diff --git a/snippets/package.json b/snippets/package.json new file mode 100644 index 0000000..ae2a774 --- /dev/null +++ b/snippets/package.json @@ -0,0 +1,34 @@ +{ + "contributes": { + "snippets": [ + { + "language": "python", + "path": "./python.json" + }, + { + "language": "go", + "path": "./go.json" + }, + { + "language": [ + "terraform", + "terraform-vars", + "opentofu", + "opentofu-vars" + ], + "path": "./terraform.json" + }, + { + "language": [ + "tf" + ], + "path": "./tf.json" + } + ] + }, + "engines": { + "vscode": "^1.11.0" + }, + "name": "personal-snippets", + "version": "1.0.0" +} \ No newline at end of file diff --git a/snippets/python.json b/snippets/python.json new file mode 100644 index 0000000..749e950 --- /dev/null +++ b/snippets/python.json @@ -0,0 +1,30 @@ +{ + "function definition": { + "prefix": "def", + "body": [ + "def ${1:function_name}(${2}):", + " \"\"\"${3:Description}\"\"\"", + " ${0}" + ], + "description": "Function with docstring" + }, + "class definition": { + "prefix": "class", + "body": [ + "class ${1:ClassName}(${2:object}):", + " \"\"\"${3:Description}\"\"\"", + "", + " def __init__(self${4}):", + " ${0}" + ], + "description": "Class with __init__ and docstring" + }, + "if main": { + "prefix": "ifmain", + "body": [ + "if __name__ == \"__main__\":", + " main()" + ], + "description": "if __name__ == \"__main__\" guard" + } +} diff --git a/snippets/terraform.json b/snippets/terraform.json new file mode 100644 index 0000000..1a346e8 --- /dev/null +++ b/snippets/terraform.json @@ -0,0 +1,122 @@ +{ + "resource block": { + "prefix": "resource", + "body": [ + "resource \"${1:resource_type}\" \"${2:name}\" {", + " ${0}", + "}" + ], + "description": "Terraform/OpenTofu resource block" + }, + "variable block": { + "prefix": "variable", + "body": [ + "variable \"${1:var_name}\" {", + " description = \"${2:description}\"", + " type = ${3|string,number,list(string),map(string),set(string),any|}", + " default = ${4}", + "", + " validation {", + " condition = ${5:true}", + " error_message = \"${6:Invalid value.}\"", + " }", + "}" + ], + "description": "Variable block with validation (remove manually for bool)" + }, + "variable block (bool)": { + "prefix": "variableb", + "body": [ + "variable \"${1:var_name}\" {", + " description = \"${2:description}\"", + " type = bool", + " default = ${3:false}", + "}" + ], + "description": "Bool variable block (no validation)" + }, + "output block": { + "prefix": "output", + "body": [ + "output \"${1:output_name}\" {", + " description = \"${2:description}\"", + " value = ${0}", + "}" + ], + "description": "Terraform/OpenTofu output block" + }, + "module block": { + "prefix": "module", + "body": [ + "module \"${1:module_name}\" {", + " source = \"${2:./modules/example}\"", + "", + " # Required variables:", + " ${3:# Add required vars}", + "", + " # Optional variables:", + " ${0}", + "}" + ], + "description": "Terraform/OpenTofu module block" + }, + "data source": { + "prefix": "data", + "body": [ + "data \"${1:source_type}\" \"${2:name}\" {", + " ${0}", + "}" + ], + "description": "Terraform/OpenTofu data source block" + }, + "locals": { + "prefix": "locals", + "body": [ + "locals {", + " ${1:name} = ${0}", + "}" + ], + "description": "Terraform/OpenTofu locals block" + }, + "lifecycle": { + "prefix": "lifecycle", + "body": [ + "lifecycle {", + " ${1|prevent_destroy,create_before_destroy,ignore_changes|} = ${0:true}", + "}" + ], + "description": "Terraform/OpenTofu lifecycle meta-argument" + }, + "dynamic block": { + "prefix": "dynamic", + "body": [ + "dynamic \"${1:block_name}\" {", + " for_each = ${2:var.items}", + " content {", + " ${0}", + " }", + "}" + ], + "description": "Terraform/OpenTofu dynamic block" + }, + "moved block": { + "prefix": "moved", + "body": [ + "moved {", + " from = ${1:old.address}", + " to = ${2:new.address}", + "}" + ], + "description": "Refactor resource address without destroy/recreate" + }, + "import block": { + "prefix": "import", + "body": [ + "import {", + " to = ${1:resource.address}", + " id = \"${2:id}\"", + "}" + ], + "description": "Declarative import (Terraform 1.5+ / OpenTofu)" + } +} diff --git a/snippets/tf.json b/snippets/tf.json new file mode 100644 index 0000000..4d9ebc2 --- /dev/null +++ b/snippets/tf.json @@ -0,0 +1,11 @@ +{ + "variable": { + "body": [ + "variable {", + " name = \"\"", + " value = \"\"", + "}" + ], + "prefix": "variable" + } +} \ No newline at end of file