From a4647b1cae82d534f3a99b3e4dd8b8c82db4733e Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Tue, 5 Nov 2024 14:07:43 +0545 Subject: [PATCH] updates --- dotfyle.json | 2944 +---------------- lua/core/autocmd.lua | 42 + lua/core/keys.lua | 70 +- lua/lock.json | 58 +- lua/mason-lock.json | 42 +- lua/plugins/autopairs.lua | 55 + lua/plugins/coding.lua | 51 +- lua/plugins/configs/lsp.lua | 205 -- lua/plugins/configs/whichkey.lua | 2 +- lua/plugins/conform.lua | 146 + lua/plugins/{dap.lua => debug.lua} | 59 +- lua/plugins/editor.lua | 9 +- lua/plugins/extra.lua | 54 + lua/plugins/formater.lua | 106 - lua/plugins/lint.lua | 68 +- lua/plugins/lsp.lua | 374 ++- lua/plugins/mini.lua | 180 +- lua/plugins/treesitter.lua | 62 +- lua/plugins/ui.lua | 1 + selene.toml | 4 + snippets/c.json | 360 ++ snippets/cpp.json | 219 ++ snippets/css.json | 651 ++++ snippets/frameworks/django/filetemplates.json | 35 + snippets/frameworks/django/forms.json | 168 + snippets/frameworks/django/imports.json | 43 + snippets/frameworks/django/models.json | 183 + snippets/frameworks/django/views.json | 243 ++ snippets/frameworks/ejs.json | 87 + snippets/frameworks/flutter.json | 498 +++ snippets/frameworks/jekyll.json | 526 +++ snippets/frameworks/rails.json | 294 ++ snippets/frameworks/twig.json | 536 +++ snippets/frameworks/vue/html.json | 397 +++ snippets/frameworks/vue/javascript.json | 1075 ++++++ snippets/frameworks/vue/pug.json | 352 ++ snippets/frameworks/vue/vue.json | 33 + snippets/gitcommit.json | 96 + snippets/global.json | 44 + snippets/go.json | 286 ++ snippets/html.json | 850 +++++ snippets/java.json | 161 + snippets/javascript.json | 349 -- snippets/javascript/javascript.json | 693 ++++ snippets/javascript/react-native-ts.json | 445 +++ snippets/javascript/react-native.json | 476 +++ snippets/javascript/react-ts.json | 385 +++ snippets/javascript/react.json | 394 +++ snippets/javascript/typescript.json | 282 ++ snippets/javascriptreact.json | 734 ---- snippets/lua.json | 182 +- snippets/make.json | 45 + snippets/markdown.json | 688 ++-- snippets/package.json | 235 +- snippets/python.json | 326 -- snippets/python/base.json | 163 + snippets/python/comprehension.json | 47 + snippets/python/debug.json | 34 + snippets/python/python.json | 122 + snippets/python/unittest.json | 54 + snippets/shell.json | 93 + templates/LICENSE/Apache2.0 | 201 ++ templates/LICENSE/GNUGPLv3 | 674 ++++ templates/LICENSE/MIT | 21 + templates/LICENSE/Unlicensed | 24 + templates/go/main.go | 3 + templates/html/index.html | 11 + templates/python/main.py | 9 + templates/vue/component.vue | 14 + 69 files changed, 12974 insertions(+), 5399 deletions(-) create mode 100644 lua/plugins/autopairs.lua delete mode 100644 lua/plugins/configs/lsp.lua create mode 100644 lua/plugins/conform.lua rename lua/plugins/{dap.lua => debug.lua} (67%) delete mode 100644 lua/plugins/formater.lua create mode 100644 selene.toml create mode 100644 snippets/c.json create mode 100644 snippets/cpp.json create mode 100644 snippets/css.json create mode 100644 snippets/frameworks/django/filetemplates.json create mode 100644 snippets/frameworks/django/forms.json create mode 100644 snippets/frameworks/django/imports.json create mode 100644 snippets/frameworks/django/models.json create mode 100644 snippets/frameworks/django/views.json create mode 100644 snippets/frameworks/ejs.json create mode 100644 snippets/frameworks/flutter.json create mode 100644 snippets/frameworks/jekyll.json create mode 100644 snippets/frameworks/rails.json create mode 100644 snippets/frameworks/twig.json create mode 100644 snippets/frameworks/vue/html.json create mode 100644 snippets/frameworks/vue/javascript.json create mode 100644 snippets/frameworks/vue/pug.json create mode 100644 snippets/frameworks/vue/vue.json create mode 100644 snippets/gitcommit.json create mode 100644 snippets/global.json create mode 100644 snippets/go.json create mode 100644 snippets/html.json create mode 100644 snippets/java.json delete mode 100644 snippets/javascript.json create mode 100644 snippets/javascript/javascript.json create mode 100644 snippets/javascript/react-native-ts.json create mode 100644 snippets/javascript/react-native.json create mode 100644 snippets/javascript/react-ts.json create mode 100644 snippets/javascript/react.json create mode 100644 snippets/javascript/typescript.json delete mode 100644 snippets/javascriptreact.json create mode 100644 snippets/make.json delete mode 100644 snippets/python.json create mode 100644 snippets/python/base.json create mode 100644 snippets/python/comprehension.json create mode 100644 snippets/python/debug.json create mode 100644 snippets/python/python.json create mode 100644 snippets/python/unittest.json create mode 100644 snippets/shell.json create mode 100644 templates/LICENSE/Apache2.0 create mode 100644 templates/LICENSE/GNUGPLv3 create mode 100644 templates/LICENSE/MIT create mode 100644 templates/LICENSE/Unlicensed create mode 100644 templates/go/main.go create mode 100644 templates/html/index.html create mode 100644 templates/python/main.py create mode 100644 templates/vue/component.vue diff --git a/dotfyle.json b/dotfyle.json index e97800b..80a7ac8 100644 --- a/dotfyle.json +++ b/dotfyle.json @@ -1,2959 +1,59 @@ { "distribution": "custom", "masonTools": [ - "basedpyright", - "basedpyright-langserver", "bash-language-server", + "beautysh", "black", - "clang-format", "clangd", "codespell", "cspell", + "djlint", "emmet-ls", "eslint_d", "isort", "jdtls", "lua-language-server", "markdownlint", - "mypy", "phpcs", "prettier", + "prettierd", "pylint", "pyright", "pyright-langserver", "ruff", - "shfmt", + "rust-analyzer", + "selene", "stylua", "tailwindcss-language-server", + "taplo", "trivy", "typescript-language-server", "vscode-css-language-server", - "vscode-json-language-server" - ], - "keymaps": [ - { - "desc": "Next Buffer", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "bnext" - }, - { - "desc": "Escape and clear hlsearch", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "noh" - }, - { - "desc": "Copy Git URL", - "noremap": true, - "lhs": "yg", - "mode": "v", - "rhs": "lua require\"gitlinker\".get_buf_range_url(\"v\")" - }, - { - "desc": "Extract Variable", - "noremap": true, - "lhs": "rv", - "mode": "v", - "rhs": "lua require('refactoring').refactor('Extract Variable')" - }, - { - "desc": "Refactor Commands", - "noremap": true, - "lhs": "rr", - "mode": "v", - "rhs": "lua require('telescope').extensions.refactoring.refactors()" - }, - { - "desc": "Inline Variable", - "noremap": true, - "lhs": "ri", - "mode": "v", - "rhs": "lua require('refactoring').refactor('Inline Variable')" - }, - { - "desc": "Extract To File", - "noremap": true, - "lhs": "rf", - "mode": "v", - "rhs": "lua require('refactoring').refactor('Extract Function To File')" - }, - { - "desc": "Extract Function", - "noremap": true, - "lhs": "re", - "mode": "v", - "rhs": "lua require('refactoring').refactor('Extract Function')" - }, - { - "desc": "Current Word", - "noremap": true, - "lhs": "jw", - "mode": "v", - "rhs": "lua require(\"flash\").jump({ pattern = vim.fn.expand(\"cword>\")})" - }, - { - "desc": "Remote Treesitter", - "noremap": true, - "lhs": "jt", - "mode": "v", - "rhs": "lua require('flash').treesitter_search()" - }, - { - "desc": "Search", - "noremap": true, - "lhs": "js", - "mode": "v", - "rhs": "lua require('flash').jump()" - }, - { - "desc": "Previous Jump", - "noremap": true, - "lhs": "jp", - "mode": "v", - "rhs": "lua require('flash').jump({continue = true})" - }, - { - "desc": "Search Forward", - "noremap": true, - "lhs": "jn", - "mode": "v", - "rhs": "lua require('flash').jump({search = { forward = true, wrap = false, multi_window = false },})" - }, - { - "desc": "Treesitter", - "noremap": true, - "lhs": "jk", - "mode": "v", - "rhs": "lua require('flash').treesitter()" - }, - { - "desc": "Remote", - "noremap": true, - "lhs": "jj", - "mode": "v", - "rhs": "lua require('flash').remote()" - }, - { - "desc": "Diagnostics", - "noremap": true, - "lhs": "jd", - "mode": "v", - "rhs": "FlashDiagnostics" - }, - { - "desc": "Search Backward", - "noremap": true, - "lhs": "jN", - "mode": "v", - "rhs": "lua require('flash').jump({search = { forward = false, wrap = false, multi_window = false },})" - }, - { - "desc": "Delete Comment Style", - "noremap": true, - "lhs": "Cd", - "mode": "v", - "rhs": "CBd" - }, - { - "desc": "Catalog", - "noremap": true, - "lhs": "Cc", - "mode": "v", - "rhs": "CBcatalog" - }, - { - "desc": "Marked", - "noremap": true, - "lhs": "Cm", - "mode": "v", - "rhs": "CBllbox14" - }, - { - "desc": "Line", - "noremap": true, - "lhs": "Cl", - "mode": "v", - "rhs": "CBline" - }, - { - "desc": "Tiled line", - "noremap": true, - "lhs": "Ct", - "mode": "v", - "rhs": "CBllline" - }, - { - "desc": "Comment Box", - "noremap": true, - "lhs": "Cb", - "mode": "v", - "rhs": "CBccbox" - }, - { - "desc": "Run Code", - "noremap": true, - "lhs": "cx", - "mode": "v", - "rhs": "','>SnipRun" - }, - { - "desc": "Unique", - "noremap": true, - "lhs": "cu", - "mode": "v", - "rhs": ":!uniq" - }, - { - "desc": "Sort Asc", - "noremap": true, - "lhs": "cs", - "mode": "v", - "rhs": ":sort" - }, - { - "desc": "Sort Case Insensitive", - "noremap": true, - "lhs": "ci", - "mode": "v", - "rhs": ":sort i" - }, - { - "desc": "Sort Desc", - "noremap": true, - "lhs": "cS", - "mode": "v", - "rhs": ":sort!" - }, - { - "desc": "Copy Git URL", - "noremap": true, - "lhs": "yg", - "mode": "n", - "rhs": "lua require\"gitlinker\".get_buf_range_url()" - }, - { - "desc": "File Name", - "noremap": true, - "lhs": "yf", - "mode": "n", - "rhs": "CopyFileName" - }, - { - "desc": "Copy Whole File", - "noremap": true, - "lhs": "ya", - "mode": "n", - "rhs": "%y+" - }, - { - "desc": "Absolute Path", - "noremap": true, - "lhs": "yP", - "mode": "n", - "rhs": "CopyAbsolutePath" - }, - { - "desc": "Relative Path", - "noremap": true, - "lhs": "yp", - "mode": "n", - "rhs": "CopyRelativePath" - }, - { - "desc": "Quickfix List (Trouble)", - "noremap": true, - "lhs": "xQ", - "mode": "n", - "rhs": "Trouble qflist toggle" - }, - { - "desc": "Location List (Trouble)", - "noremap": true, - "lhs": "xL", - "mode": "n", - "rhs": "Trouble loclist toggle" - }, - { - "desc": "LSP references/definitions/... (Trouble)", - "noremap": true, - "lhs": "xS", - "mode": "n", - "rhs": "Trouble lsp toggle" - }, - { - "desc": "Symbols (Trouble)", - "noremap": true, - "lhs": "xs", - "mode": "n", - "rhs": "Trouble symbols toggle" - }, - { - "desc": "Buffer Diagnostics (Trouble)", - "noremap": true, - "lhs": "xX", - "mode": "n", - "rhs": "Trouble diagnostics toggle filter.buf=0" - }, - { - "desc": "Diagnostics (Trouble)", - "noremap": true, - "lhs": "xx", - "mode": "n", - "rhs": "Trouble diagnostics toggle" - }, - { - "desc": " Save and Quit", - "noremap": true, - "lhs": "x", - "mode": "n", - "rhs": "x" - }, - { - "desc": "ZenMode", - "noremap": true, - "lhs": "wz", - "mode": "n", - "rhs": "ZenMode" - }, - { - "desc": "Write and Quit", - "noremap": true, - "lhs": "ww", - "mode": "n", - "rhs": "w" - }, - { - "desc": "Twilight", - "noremap": true, - "lhs": "wt", - "mode": "n", - "rhs": "Twilight" - }, - { - "desc": "Suggestions", - "noremap": true, - "lhs": "ws", - "mode": "n", - "rhs": "Telescope spell_suggest" - }, - { - "desc": "Write and Quit", - "noremap": true, - "lhs": "wq", - "mode": "n", - "rhs": "wq" - }, - { - "desc": "Prev Misspell", - "noremap": true, - "lhs": "wk", - "mode": "n", - "rhs": "[s" - }, - { - "desc": "Next Misspell", - "noremap": true, - "lhs": "wj", - "mode": "n", - "rhs": "]s" - }, - { - "desc": "Force Write", - "noremap": true, - "lhs": "wf", - "mode": "n", - "rhs": "lua require'utils'.sudo_write()" - }, - { - "desc": "Suda Write", - "noremap": true, - "lhs": "wF", - "mode": "n", - "rhs": ":SudaWrite" - }, - { - "desc": "Spellcheck", - "noremap": true, - "lhs": "wc", - "mode": "n", - "rhs": "set spell!" - }, - { - "desc": "Quote", - "noremap": true, - "lhs": "vq", - "mode": "n", - "rhs": "viq" - }, - { - "desc": "Paragraph", - "noremap": true, - "lhs": "vp", - "mode": "n", - "rhs": "vip" - }, - { - "desc": "Bracket", - "noremap": true, - "lhs": "vb", - "mode": "n", - "rhs": "vib" - }, - { - "desc": "Around Quote", - "noremap": true, - "lhs": "vQ", - "mode": "n", - "rhs": "vaq" - }, - { - "desc": "Around Para", - "noremap": true, - "lhs": "vP", - "mode": "n", - "rhs": "vap" - }, - { - "desc": "Around Bracket", - "noremap": true, - "lhs": "vB", - "mode": "n", - "rhs": "vab" - }, - { - "desc": "Toggle Output Panel", - "noremap": true, - "lhs": "uO", - "mode": "n", - "rhs": "lua require(\"neotest\").output_panel.toggle" - }, - { - "desc": "Stop", - "noremap": true, - "lhs": "us", - "mode": "n", - "rhs": "lua require(\"neotest\").run.stop()" - }, - { - "desc": "Run Nearest Test", - "noremap": true, - "lhs": "ur", - "mode": "n", - "rhs": "lua require(\"neotest\").run.run()" - }, - { - "desc": "Toggle Summary", - "noremap": true, - "lhs": "uS", - "mode": "n", - "rhs": "lua require(\"neotest\").summary.toggle" - }, - { - "desc": "Show Output", - "noremap": true, - "lhs": "uo", - "mode": "n", - "rhs": "lua require(\"neotest\").output.open({ enter = true, auto_close = true })" - }, - { - "desc": "Run Test File", - "noremap": true, - "lhs": "uf", - "mode": "n", - "rhs": "lua require(\"neotest\").run.run(vim.fn.expand(\"%\"))" - }, - { - "desc": "Run Current Test", - "noremap": true, - "lhs": "uc", - "mode": "n", - "rhs": "lua require(\"neotest\").run.run()" - }, - { - "desc": "Vertical Terminal", - "noremap": true, - "lhs": "tv", - "mode": "n", - "rhs": "Vterm" - }, - { - "desc": "Horizontal Terminal", - "noremap": true, - "lhs": "th", - "mode": "n", - "rhs": "Sterm" - }, - { - "desc": "Toggle Terminal", - "noremap": true, - "lhs": "t2", - "mode": "n", - "rhs": "2ToggleTerm" - }, - { - "desc": "Toggle Terminal", - "noremap": true, - "lhs": "t1", - "mode": "n", - "rhs": "1ToggleTerm" - }, - { - "desc": "Vertical Split", - "noremap": true, - "lhs": "ss", - "mode": "n", - "rhs": "vsplit" - }, - { - "desc": "Close Split", - "noremap": true, - "lhs": "sq", - "mode": "n", - "rhs": "c" - }, - { - "desc": "Previous Pane", - "noremap": true, - "lhs": "sp", - "mode": "n", - "rhs": "NavigatorPrevious" - }, - { - "desc": "Move Right", - "noremap": true, - "lhs": "sl", - "mode": "n", - "rhs": "l" - }, - { - "desc": "Move Up", - "noremap": true, - "lhs": "sk", - "mode": "n", - "rhs": "k" - }, - { - "desc": "Move Down", - "noremap": true, - "lhs": "sj", - "mode": "n", - "rhs": "j" - }, - { - "desc": "Move Left", - "noremap": true, - "lhs": "sh", - "mode": "n", - "rhs": "h" - }, - { - "desc": "First Tab", - "noremap": true, - "lhs": "sf", - "mode": "n", - "rhs": "tabfirst" - }, - { - "desc": "Close Tab", - "noremap": true, - "lhs": "sc", - "mode": "n", - "rhs": "tabclose" - }, - { - "desc": "Horizontal Split", - "noremap": true, - "lhs": "sa", - "mode": "n", - "rhs": "split" - }, - { - "desc": "Previous Window", - "noremap": true, - "lhs": "s`", - "mode": "n", - "rhs": "p" - }, - { - "desc": "Decrease window height", - "noremap": true, - "lhs": "s_", - "mode": "n", - "rhs": "resize -10" - }, - { - "desc": "Split Right", - "noremap": true, - "lhs": "s\\", - "mode": "n", - "rhs": "v" - }, - { - "desc": "Increase window width", - "noremap": true, - "lhs": "sL", - "mode": "n", - "rhs": "vertical resize +10" - }, - { - "desc": "Increase window height", - "noremap": true, - "lhs": "sK", - "mode": "n", - "rhs": "resize +5" - }, - { - "desc": "Decrease window height", - "noremap": true, - "lhs": "sJ", - "mode": "n", - "rhs": "resize -5" - }, - { - "desc": "Decrease window width", - "noremap": true, - "lhs": "sH", - "mode": "n", - "rhs": "vertical resize -10" - }, - { - "desc": "Increase window width", - "noremap": true, - "lhs": "s=", - "mode": "n", - "rhs": "vertical resize +20" - }, - { - "desc": "Split Below", - "noremap": true, - "lhs": "s/", - "mode": "n", - "rhs": "s" - }, - { - "desc": "Decrease window width", - "noremap": true, - "lhs": "s-", - "mode": "n", - "rhs": "vertical resize -20" - }, - { - "desc": "Increase window height", - "noremap": true, - "lhs": "s+", - "mode": "n", - "rhs": "resize +10" - }, - { - "desc": "Replace Word", - "noremap": true, - "lhs": "rw", - "mode": "n", - "rhs": "lua require('spectre').open_visual({select_word=true})" - }, - { - "desc": "Extract Variable", - "noremap": true, - "lhs": "rv", - "mode": "n", - "rhs": "lua require('refactoring').refactor('Extract Variable')" - }, - { - "desc": "Replace Word", - "noremap": true, - "lhs": "rs", - "mode": "n", - "rhs": ":%s/\\\\>//gI" - }, - { - "desc": "Smart Rename", - "noremap": true, - "lhs": "rr", - "mode": "n", - "rhs": "" - }, - { - "desc": "Swap Previous", - "noremap": true, - "lhs": "rp", - "mode": "n", - "rhs": "" - }, - { - "desc": "Swap Next", - "noremap": true, - "lhs": "rn", - "mode": "n", - "rhs": "" - }, - { - "desc": "List Definition", - "noremap": true, - "lhs": "rl", - "mode": "n", - "rhs": "" - }, - { - "desc": "Previous Usage", - "noremap": true, - "lhs": "rk", - "mode": "n", - "rhs": "" - }, - { - "desc": "Next Usage", - "noremap": true, - "lhs": "rj", - "mode": "n", - "rhs": "" - }, - { - "desc": "Inline Variable", - "noremap": true, - "lhs": "ri", - "mode": "n", - "rhs": "lua require('refactoring').refactor('Inline Variable')" - }, - { - "desc": "List Definition Head", - "noremap": true, - "lhs": "rh", - "mode": "n", - "rhs": "" - }, - { - "desc": "Extract To File", - "noremap": true, - "lhs": "rf", - "mode": "n", - "rhs": "lua require('refactoring').refactor('Extract Block To File')" - }, - { - "desc": "Extract Block", - "noremap": true, - "lhs": "re", - "mode": "n", - "rhs": "lua require('refactoring').refactor('Extract Block')" - }, - { - "desc": "Go To Definition", - "noremap": true, - "lhs": "rd", - "mode": "n", - "rhs": "" - }, - { - "desc": "Replace Buffer", - "noremap": true, - "lhs": "rb", - "mode": "n", - "rhs": "lua require('spectre').open_file_search()" - }, - { - "desc": "Replace", - "noremap": true, - "lhs": "rS", - "mode": "n", - "rhs": "lua require('spectre').open()" - }, - { - "desc": "Refactor Commands", - "noremap": true, - "lhs": "rR", - "mode": "n", - "rhs": "lua require('telescope').extensions.refactoring.refactors()" - }, - { - "desc": "Code Runner", - "noremap": true, - "lhs": "rc", - "mode": "n", - "rhs": "" - }, - { - "desc": "Write and Quit", - "noremap": true, - "lhs": "qw", - "mode": "n", - "rhs": "wq" - }, - { - "desc": "Close Split", - "noremap": true, - "lhs": "qs", - "mode": "n", - "rhs": "c" - }, - { - "desc": "Quit", - "noremap": true, - "lhs": "qq", - "mode": "n", - "rhs": "q" - }, - { - "desc": "Close Others", - "noremap": true, - "lhs": "qo", - "mode": "n", - "rhs": ":%bdelete|b#|bdelete#" - }, - { - "desc": "Force Quit", - "noremap": true, - "lhs": "qf", - "mode": "n", - "rhs": "qall!" - }, - { - "desc": "Delete Buffer", - "noremap": true, - "lhs": "qd", - "mode": "n", - "rhs": "bdelete" - }, - { - "desc": "Close Buffer", - "noremap": true, - "lhs": "qc", - "mode": "n", - "rhs": "bw" - }, - { - "desc": "Quit All", - "noremap": true, - "lhs": "qa", - "mode": "n", - "rhs": "qall" - }, - { - "desc": "Save ASCII code snapshot into clipboard", - "noremap": true, - "lhs": "pi", - "mode": "x", - "rhs": "CodeSnapASCII" - }, - { - "desc": "Save selected code snapshot in ~/Pictures", - "noremap": true, - "lhs": "ps", - "mode": "x", - "rhs": "CodeSnapSave" - }, - { - "desc": "Save selected code snapshot into clipboard", - "noremap": true, - "lhs": "py", - "mode": "x", - "rhs": "CodeSnap" - }, - { - "desc": "All Options", - "noremap": true, - "lhs": "oo", - "mode": "n", - "rhs": "Telescope vim_options" - }, - { - "desc": "Relative Numbers", - "noremap": true, - "lhs": "on", - "mode": "n", - "rhs": "set relativenumber!" - }, - { - "desc": "Highlight Colors", - "noremap": true, - "lhs": "oh", - "mode": "n", - "rhs": "Telescope highlights" - }, - { - "desc": "Colorscheme", - "noremap": true, - "lhs": "oc", - "mode": "n", - "rhs": "Telescope colorscheme" - }, - { - "desc": "Don't Save Current Session", - "noremap": true, - "lhs": "md", - "mode": "n", - "rhs": "" - }, - { - "desc": "Restore Last Session", - "noremap": true, - "lhs": "ml", - "mode": "n", - "rhs": "" - }, - { - "desc": "Restore Session", - "noremap": true, - "lhs": "ms", - "mode": "n", - "rhs": "" - }, - { - "desc": "Peek Type Definition", - "noremap": true, - "lhs": "lt", - "mode": "n", - "rhs": "Lspsaga peek_type_definition" - }, - { - "desc": "Document Symbols", - "noremap": true, - "lhs": "ls", - "mode": "n", - "rhs": "Telescope lsp_document_symbols theme=get_ivy" - }, - { - "desc": "Rename", - "noremap": true, - "lhs": "lr", - "mode": "n", - "rhs": "Lspsaga rename" - }, - { - "desc": "Stop LSP", - "noremap": true, - "lhs": "lq", - "mode": "n", - "rhs": "LspStop" - }, - { - "desc": "Incoming Calls", - "noremap": true, - "lhs": "lp", - "mode": "n", - "rhs": "Telescope lsp_incoming_calls" - }, - { - "desc": "Outline", - "noremap": true, - "lhs": "lo", - "mode": "n", - "rhs": "Lspsaga outline" - }, - { - "desc": "File Diagnostics", - "noremap": true, - "lhs": "ll", - "mode": "n", - "rhs": "Telescope diagnostics layout_strategy=vertical" - }, - { - "desc": "Prev Diagnostic", - "noremap": true, - "lhs": "lk", - "mode": "n", - "rhs": "Lspsaga diagnostic_jump_prev" - }, - { - "desc": "Next Diagnostic", - "noremap": true, - "lhs": "lj", - "mode": "n", - "rhs": "Lspsaga diagnostic_jump_next" - }, - { - "desc": "LSP Info", - "noremap": true, - "lhs": "li", - "mode": "n", - "rhs": "LspInfo" - }, - { - "desc": "Hover", - "noremap": true, - "lhs": "lh", - "mode": "n", - "rhs": "Lspsaga hover_doc" - }, - { - "desc": "Goto Definition", - "noremap": true, - "lhs": "lg", - "mode": "n", - "rhs": "Lspsaga goto_definition" - }, - { - "desc": "Finder", - "noremap": true, - "lhs": "lf", - "mode": "n", - "rhs": "Lspsaga finder" - }, - { - "desc": "Peek Definition", - "noremap": true, - "lhs": "ld", - "mode": "n", - "rhs": "Lspsaga peek_definition" - }, - { - "desc": "Code Action", - "noremap": true, - "lhs": "la", - "mode": "n", - "rhs": "Lspsaga code_action" - }, - { - "desc": "Goto Type Definition", - "noremap": true, - "lhs": "lT", - "mode": "n", - "rhs": "Lspsaga goto_type_definition" - }, - { - "desc": "Workspace Symbols", - "noremap": true, - "lhs": "lS", - "mode": "n", - "rhs": "Telescope lsp_dynamic_workspace_symbols" - }, - { - "desc": "Replace", - "noremap": true, - "lhs": "lR", - "mode": "n", - "rhs": "Lspsaga project_replace" - }, - { - "desc": "Restart LSP", - "noremap": true, - "lhs": "lQ", - "mode": "n", - "rhs": "LspRestart" - }, - { - "desc": "Outgoing Calls", - "noremap": true, - "lhs": "lP", - "mode": "n", - "rhs": "Telescope lsp_outgoing_calls" - }, - { - "desc": "Workspace Diagnostics", - "noremap": true, - "lhs": "lL", - "mode": "n", - "rhs": "Lspsaga show_workspace_diagnostics" - }, - { - "desc": "References", - "noremap": true, - "lhs": "lF", - "mode": "n", - "rhs": "Telescope lsp_references layout_strategy=vertical" - }, - { - "desc": "Toggle keys", - "noremap": true, - "lhs": "kt", - "mode": "n", - "rhs": "Screenkey" - }, - { - "desc": "Current Word", - "noremap": true, - "lhs": "jw", - "mode": "n", - "rhs": "lua require(\"flash\").jump({ pattern = vim.fn.expand(\"cword>\")})" - }, - { - "desc": "Remote Treesitter", - "noremap": true, - "lhs": "jt", - "mode": "n", - "rhs": "lua require('flash').treesitter_search()" - }, - { - "desc": "Search", - "noremap": true, - "lhs": "js", - "mode": "n", - "rhs": "lua require('flash').jump()" - }, - { - "desc": "Previous Jump", - "noremap": true, - "lhs": "jp", - "mode": "n", - "rhs": "lua require('flash').jump({continue = true})" - }, - { - "desc": "Search Forward", - "noremap": true, - "lhs": "jn", - "mode": "n", - "rhs": "lua require('flash').jump({search = { forward = true, wrap = false, multi_window = false },})" - }, - { - "desc": "Forward", - "noremap": true, - "lhs": "jl", - "mode": "n", - "rhs": "" - }, - { - "desc": "Treesitter", - "noremap": true, - "lhs": "jk", - "mode": "n", - "rhs": "lua require('flash').treesitter()" - }, - { - "desc": "Remote", - "noremap": true, - "lhs": "jj", - "mode": "n", - "rhs": "lua require('flash').remote()" - }, - { - "desc": "Backward", - "noremap": true, - "lhs": "jh", - "mode": "n", - "rhs": "" - }, - { - "desc": "Jumplist", - "noremap": true, - "lhs": "jf", - "mode": "n", - "rhs": "Telescope jumplist" - }, - { - "desc": "Diagnostics", - "noremap": true, - "lhs": "jd", - "mode": "n", - "rhs": "FlashDiagnostics" - }, - { - "desc": "Word", - "noremap": true, - "lhs": "jc", - "mode": "n", - "rhs": "*" - }, - { - "desc": "Search Backward", - "noremap": true, - "lhs": "jN", - "mode": "n", - "rhs": "lua require('flash').jump({search = { forward = false, wrap = false, multi_window = false },})" - }, - { - "desc": "Time", - "noremap": true, - "lhs": "it", - "mode": "n", - "rhs": "put =strftime('## %r')" - }, - { - "desc": "Registers", - "noremap": true, - "lhs": "ir", - "mode": "n", - "rhs": "Telescope registers" - }, - { - "desc": "Relative Path", - "noremap": true, - "lhs": "ip", - "mode": "n", - "rhs": "put %" - }, - { - "desc": "Nerd Glyphs", - "noremap": true, - "lhs": "in", - "mode": "n", - "rhs": "Nerdy" - }, - { - "desc": "File Name", - "noremap": true, - "lhs": "if", - "mode": "n", - "rhs": "put =expand('%:t')" - }, - { - "desc": "Emojis", - "noremap": true, - "lhs": "ie", - "mode": "n", - "rhs": "Telescope symbols" - }, - { - "desc": "Date", - "noremap": true, - "lhs": "id", - "mode": "n", - "rhs": "put =strftime('## %a, %d %b, %Y, %r')" - }, - { - "desc": "Absolute Path", - "noremap": true, - "lhs": "iP", - "mode": "n", - "rhs": "put %:p" - }, - { - "desc": "Man Pages", - "noremap": true, - "lhs": "hm", - "mode": "n", - "rhs": "Telescope man_pages" - }, - { - "desc": "Hover Doc", - "noremap": true, - "lhs": "hk", - "mode": "n", - "rhs": "Lspsaga hover_doc" - }, - { - "desc": "Inspect Position", - "noremap": true, - "lhs": "hi", - "mode": "n", - "rhs": "vim.show_pos" - }, - { - "desc": "Help Pages", - "noremap": true, - "lhs": "hh", - "mode": "n", - "rhs": "Telescope help_tags" - }, - { - "desc": "Fuzzy Find in File", - "noremap": true, - "lhs": "fs", - "mode": "n", - "rhs": "Telescope current_buffer_fuzzy_find" - }, - { - "desc": "Quickfix", - "noremap": true, - "lhs": "fq", - "mode": "n", - "rhs": "Telescope quickfix" - }, - { - "desc": "Undo History", - "noremap": true, - "lhs": "fu", - "mode": "n", - "rhs": "Telescope undo" - }, - { - "desc": "Diagnostics", - "noremap": true, - "lhs": "fd", - "mode": "n", - "rhs": "Telescope diagnostics" - }, - { - "desc": "Search History", - "noremap": true, - "lhs": "ks", - "mode": "n", - "rhs": "Telescope search_history" - }, - { - "desc": "Command History", - "noremap": true, - "lhs": "kh", - "mode": "n", - "rhs": "Telescope command_history" - }, - { - "desc": "Commands", - "noremap": true, - "lhs": "kc", - "mode": "n", - "rhs": "Telescope commands" - }, - { - "desc": "Keymaps", - "noremap": true, - "lhs": "kk", - "mode": "n", - "rhs": "Telescope keymaps" - }, - { - "desc": "Grep String", - "noremap": true, - "lhs": "fG", - "mode": "n", - "rhs": "Telescope grep_string" - }, - { - "desc": "Find Highlight Groups", - "noremap": true, - "lhs": "fH", - "mode": "n", - "rhs": "Telescope highlights" - }, - { - "desc": "Marks", - "noremap": true, - "lhs": "fm", - "mode": "n", - "rhs": "Telescope marks" - }, - { - "desc": "Old Recent Files", - "noremap": true, - "lhs": "fo", - "mode": "n", - "rhs": "Telescope oldfiles" - }, - { - "desc": "Find Help", - "noremap": true, - "lhs": "fh", - "mode": "n", - "rhs": "Telescope help_tags" - }, - { - "desc": "Buffers", - "noremap": true, - "lhs": "fb", - "mode": "n", - "rhs": "Telescope buffers" - }, - { - "desc": "Live Grep", - "noremap": true, - "lhs": "fg", - "mode": "n", - "rhs": "Telescope live_grep" - }, - { - "desc": "Find Files (CWD)", - "noremap": true, - "lhs": "ff", - "mode": "n", - "rhs": "Telescope find_files" - }, - { - "desc": "New File", - "noremap": true, - "lhs": "en", - "mode": "n", - "rhs": "new" - }, - { - "desc": "Readme", - "noremap": true, - "lhs": "em", - "mode": "n", - "rhs": "e README.md" - }, - { - "desc": "File Browser", - "noremap": true, - "lhs": "ef", - "mode": "n", - "rhs": "Telescope file_browser" - }, - { - "desc": "Left File Explorer", - "noremap": true, - "lhs": "eE", - "mode": "n", - "rhs": ":Neotree toggle left" - }, - { - "desc": "Float File Explorer", - "noremap": true, - "lhs": "ee", - "mode": "n", - "rhs": ":Neotree toggle float" - }, - { - "desc": "Config Dir", - "noremap": true, - "lhs": "ed", - "mode": "n", - "rhs": "lua require(\"telescope.builtin\").find_files({cwd = vim.fn.stdpath(\"config\")})" - }, - { - "desc": "Config", - "noremap": true, - "lhs": "ec", - "mode": "n", - "rhs": "e $MYVIMRC" - }, - { - "desc": "Alternate File", - "noremap": true, - "lhs": "ea", - "mode": "n", - "rhs": "b#" - }, - { - "desc": "DB Last query", - "noremap": true, - "lhs": "dl", - "mode": "n", - "rhs": "DBUILastQueryInfo" - }, - { - "desc": "DB Rename buffer", - "noremap": true, - "lhs": "dr", - "mode": "n", - "rhs": "DBUIRenameBuffer" - }, - { - "desc": "DB Find buffer", - "noremap": true, - "lhs": "db", - "mode": "n", - "rhs": "DBUIFindBuffer" - }, - { - "desc": "Toggle DB UI", - "noremap": true, - "lhs": "du", - "mode": "n", - "rhs": "DBUIToggle" - }, - { - "desc": "Delete Comment Style", - "noremap": true, - "lhs": "Cd", - "mode": "n", - "rhs": "CBd" - }, - { - "desc": "Catalog", - "noremap": true, - "lhs": "Cc", - "mode": "n", - "rhs": "CBcatalog" - }, - { - "desc": "Marked", - "noremap": true, - "lhs": "Cm", - "mode": "n", - "rhs": "CBllbox14" - }, - { - "desc": "Line", - "noremap": true, - "lhs": "Cl", - "mode": "n", - "rhs": "CBline" - }, - { - "desc": "Tiled line", - "noremap": true, - "lhs": "Ct", - "mode": "n", - "rhs": "CBllline" - }, - { - "desc": "Comment Box", - "noremap": true, - "lhs": "Cb", - "mode": "n", - "rhs": "CBccbox" - }, - { - "desc": "Reload Module", - "noremap": true, - "lhs": "cr", - "mode": "n", - "rhs": "Telescope reloader" - }, - { - "desc": "Pick Color", - "noremap": true, - "lhs": "cp", - "mode": "n", - "rhs": "CccPick" - }, - { - "desc": "Dashboard", - "noremap": true, - "lhs": "co", - "mode": "n", - "rhs": "Dashboard" - }, - { - "desc": "Notifications", - "noremap": true, - "lhs": "cn", - "mode": "n", - "rhs": "Telescope notify" - }, - { - "desc": "Markdown Preview", - "noremap": true, - "lhs": "cm", - "mode": "n", - "rhs": "MarkdownPreviewToggle" - }, - { - "desc": "Clean Empty Lines", - "noremap": true, - "lhs": "cl", - "mode": "n", - "rhs": ":g/^\\s*$/d" - }, - { - "desc": "Hardtime", - "noremap": true, - "lhs": "ch", - "mode": "n", - "rhs": "Hardtime toggle" - }, - { - "desc": "Root Directory", - "noremap": true, - "lhs": "cd", - "mode": "n", - "rhs": "RootDir" - }, - { - "desc": "Highlight Colors", - "noremap": true, - "lhs": "cc", - "mode": "n", - "rhs": "CccHighlighterToggle" - }, - { - "desc": "Reload Configs", - "noremap": true, - "lhs": "cR", - "mode": "n", - "rhs": "ReloadConfig" - }, - { - "desc": "Convert Color", - "noremap": true, - "lhs": "cP", - "mode": "n", - "rhs": "CccConvert" - }, - { - "desc": "Fix Tabs", - "noremap": true, - "lhs": "cF", - "mode": "n", - "rhs": "retab" - }, - { - "desc": "Toggle Alternate", - "noremap": true, - "lhs": "a", - "mode": "n", - "rhs": "Alternate" - }, - { - "desc": "Exit", - "noremap": true, - "lhs": "bx", - "mode": "n", - "rhs": "DapTerminate" - }, - { - "desc": "Debugger", - "noremap": true, - "lhs": "bt", - "mode": "n", - "rhs": "DapUIToggle" - }, - { - "desc": "Repl", - "noremap": true, - "lhs": "br", - "mode": "n", - "rhs": "DapToggleRepl" - }, - { - "desc": "Over", - "noremap": true, - "lhs": "bo", - "mode": "n", - "rhs": "DapStepOver" - }, - { - "desc": "Last", - "noremap": true, - "lhs": "bl", - "mode": "n", - "rhs": "lua require'dap'.run_last()" - }, - { - "desc": "Into", - "noremap": true, - "lhs": "bi", - "mode": "n", - "rhs": "DapStepInto" - }, - { - "desc": "Continue", - "noremap": true, - "lhs": "bc", - "mode": "n", - "rhs": "DapContinue" - }, - { - "desc": "Breakpoint", - "noremap": true, - "lhs": "bb", - "mode": "n", - "rhs": "DapToggleBreakpoint" - }, - { - "desc": "Restart Frame", - "noremap": true, - "lhs": "bR", - "mode": "n", - "rhs": "DapRestartFrame" - }, - { - "desc": "Out", - "noremap": true, - "lhs": "bO", - "mode": "n", - "rhs": "DapStepOut" - }, - { - "desc": "Dismiss All Notifications", - "noremap": true, - "lhs": "mn", - "mode": "n", - "rhs": "" - }, - { - "desc": "", - "noremap": true, - "lhs": "mt", - "mode": "n", - "rhs": "lua require(\"onedark\").toggle()" - }, - { - "desc": "", - "noremap": false, - "lhs": "/", - "mode": "v", - "rhs": "gcc" - }, - { - "desc": "", - "noremap": false, - "lhs": "/", - "mode": "n", - "rhs": "gcc" - }, - { - "desc": "", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "" - }, - { - "desc": ":help v_#-default", - "noremap": true, - "lhs": "#", - "mode": "x", - "rhs": "" - }, - { - "desc": "", - "noremap": false, - "lhs": "%", - "mode": "x", - "rhs": "(MatchitVisualForward)" - }, - { - "desc": "", - "noremap": false, - "lhs": "%", - "mode": "n", - "rhs": "(MatchitNormalForward)" - }, - { - "desc": ":help &-default", - "noremap": true, - "lhs": "&", - "mode": "n", - "rhs": ":&&" - }, - { - "desc": ":help v_star-default", - "noremap": true, - "lhs": "*", - "mode": "x", - "rhs": "" - }, - { "desc": "", "noremap": true, "lhs": "-", "mode": "x", "rhs": "" }, - { - "desc": "", - "noremap": true, - "lhs": "-", - "mode": "n", - "rhs": "" - }, - { - "desc": "Highlight and snapshot selected code into clipboard", - "noremap": true, - "lhs": "h", - "mode": "x", - "rhs": "CodeSnapHighlight" - }, - { "desc": "", "noremap": true, "lhs": "<", "mode": "v", "rhs": "gv" }, - { "desc": "", "noremap": true, "lhs": "=", "mode": "x", "rhs": "" }, - { "desc": "", "noremap": true, "lhs": "=", "mode": "n", "rhs": "" }, - { "desc": "", "noremap": true, "lhs": ">", "mode": "v", "rhs": ">gv" }, - { - "desc": ":help v_@-default", - "noremap": true, - "lhs": "@", - "mode": "x", - "rhs": "mode() ==# 'V' ? ':normal! @'.getcharstr().'' : '@'" - }, - { - "desc": "Previous Buffer", - "noremap": true, - "lhs": "H", - "mode": "n", - "rhs": "bprevious" - }, - { - "desc": "", - "noremap": true, - "lhs": "J", - "mode": "x", - "rhs": ":move '>+1gv-gv" - }, - { "desc": "", "noremap": true, "lhs": "J", "mode": "n", "rhs": "mzJ`z" }, - { - "desc": "LSP Hover", - "noremap": true, - "lhs": "K", - "mode": "n", - "rhs": "Lspsaga hover_doc" - }, - { - "desc": "", - "noremap": true, - "lhs": "K", - "mode": "x", - "rhs": ":move '-2gv-gv" - }, - { - "desc": "Next Buffer", - "noremap": true, - "lhs": "L", - "mode": "n", - "rhs": "bnext" - }, - { - "desc": "Prev search result", - "noremap": true, - "lhs": "N", - "mode": "x", - "rhs": "'nN'[v:searchforward]" - }, - { - "desc": "Prev search result", - "noremap": true, - "lhs": "N", - "mode": "n", - "rhs": "'nN'[v:searchforward]" - }, - { - "desc": "Put yanked text before cursor", - "noremap": true, - "lhs": "P", - "mode": "x", - "rhs": "(YankyPutBefore)" - }, - { - "desc": "Put yanked text before cursor", - "noremap": true, - "lhs": "P", - "mode": "n", - "rhs": "(YankyPutBefore)" - }, - { - "desc": "Force Quit!", - "noremap": true, - "lhs": "Q", - "mode": "n", - "rhs": "qall!" - }, - { - "desc": ":help v_Q-default", - "noremap": true, - "lhs": "Q", - "mode": "x", - "rhs": "mode() ==# 'V' ? ':normal! @=reg_recorded()' : 'Q'" - }, - { - "desc": "Flash Treesitter", - "noremap": true, - "lhs": "S", - "mode": "x", - "rhs": "" - }, - { - "desc": "Flash Treesitter", - "noremap": true, - "lhs": "S", - "mode": "n", - "rhs": "" - }, - { - "desc": "Redo", - "noremap": true, - "lhs": "U", - "mode": "n", - "rhs": "redo" - }, - { - "desc": ":help Y-default", - "noremap": true, - "lhs": "Y", - "mode": "n", - "rhs": "y$" - }, - { - "desc": "Git Hunk", - "noremap": true, - "lhs": "[g", - "mode": "n", - "rhs": "Gitsigns prev_hunk" - }, - { "desc": "Edit", "noremap": true, "lhs": "[e", "mode": "n", "rhs": "g;" }, - { - "desc": "Undo backward", - "noremap": true, - "lhs": "[u", - "mode": "n", - "rhs": "lua MiniBracketed.undo('backward')" - }, - { - "desc": "Undo first", - "noremap": true, - "lhs": "[U", - "mode": "n", - "rhs": "lua MiniBracketed.undo('first')" - }, - { - "desc": "Treesitter backward", - "noremap": true, - "lhs": "[n", - "mode": "x", - "rhs": "lua MiniBracketed.treesitter('backward')" - }, - { - "desc": "Treesitter backward", - "noremap": true, - "lhs": "[n", - "mode": "n", - "rhs": "lua MiniBracketed.treesitter('backward')" - }, - { - "desc": "Treesitter first", - "noremap": true, - "lhs": "[N", - "mode": "x", - "rhs": "lua MiniBracketed.treesitter('first')" - }, - { - "desc": "Treesitter first", - "noremap": true, - "lhs": "[N", - "mode": "n", - "rhs": "lua MiniBracketed.treesitter('first')" - }, - { - "desc": "Location backward", - "noremap": true, - "lhs": "[l", - "mode": "n", - "rhs": "lua MiniBracketed.location('backward')" - }, - { - "desc": "Location first", - "noremap": true, - "lhs": "[L", - "mode": "n", - "rhs": "lua MiniBracketed.location('first')" - }, - { - "desc": "Oldfile backward", - "noremap": true, - "lhs": "[o", - "mode": "n", - "rhs": "lua MiniBracketed.oldfile('backward')" - }, - { - "desc": "Oldfile first", - "noremap": true, - "lhs": "[O", - "mode": "n", - "rhs": "lua MiniBracketed.oldfile('first')" - }, - { - "desc": "Jump", - "noremap": true, - "lhs": "[j", - "mode": "n", - "rhs": "" - }, - { - "desc": "Jump first", - "noremap": true, - "lhs": "[J", - "mode": "n", - "rhs": "lua MiniBracketed.jump('first')" - }, - { - "desc": "Indent backward", - "noremap": true, - "lhs": "[i", - "mode": "x", - "rhs": "lua MiniBracketed.indent('backward')" - }, - { - "desc": "Indent backward", - "noremap": true, - "lhs": "[i", - "mode": "n", - "rhs": "lua MiniBracketed.indent('backward')" - }, - { - "desc": "Indent first", - "noremap": true, - "lhs": "[I", - "mode": "x", - "rhs": "lua MiniBracketed.indent('first')" - }, - { - "desc": "Indent first", - "noremap": true, - "lhs": "[I", - "mode": "n", - "rhs": "lua MiniBracketed.indent('first')" - }, - { - "desc": "Diagnostic backward", - "noremap": true, - "lhs": "[d", - "mode": "x", - "rhs": "lua MiniBracketed.diagnostic('backward')" - }, - { - "desc": "Diagnostic first", - "noremap": true, - "lhs": "[D", - "mode": "x", - "rhs": "lua MiniBracketed.diagnostic('first')" - }, - { - "desc": "Diagnostic first", - "noremap": true, - "lhs": "[D", - "mode": "n", - "rhs": "lua MiniBracketed.diagnostic('first')" - }, - { - "desc": "Conflict backward", - "noremap": true, - "lhs": "[x", - "mode": "x", - "rhs": "lua MiniBracketed.conflict('backward')" - }, - { - "desc": "Conflict backward", - "noremap": true, - "lhs": "[x", - "mode": "n", - "rhs": "lua MiniBracketed.conflict('backward')" - }, - { - "desc": "Conflict first", - "noremap": true, - "lhs": "[X", - "mode": "x", - "rhs": "lua MiniBracketed.conflict('first')" - }, - { - "desc": "Conflict first", - "noremap": true, - "lhs": "[X", - "mode": "n", - "rhs": "lua MiniBracketed.conflict('first')" - }, - { - "desc": "Comment backward", - "noremap": true, - "lhs": "[c", - "mode": "x", - "rhs": "lua MiniBracketed.comment('backward')" - }, - { - "desc": "Comment backward", - "noremap": true, - "lhs": "[c", - "mode": "n", - "rhs": "lua MiniBracketed.comment('backward')" - }, - { - "desc": "Comment first", - "noremap": true, - "lhs": "[C", - "mode": "x", - "rhs": "lua MiniBracketed.comment('first')" - }, - { - "desc": "Comment first", - "noremap": true, - "lhs": "[C", - "mode": "n", - "rhs": "lua MiniBracketed.comment('first')" - }, - { - "desc": "Buffer", - "noremap": true, - "lhs": "[b", - "mode": "n", - "rhs": "bprevious" - }, - { - "desc": "First Buffer", - "noremap": true, - "lhs": "[B", - "mode": "n", - "rhs": "bfirst" - }, - { - "desc": "", - "noremap": false, - "lhs": "[%", - "mode": "x", - "rhs": "(MatchitVisualMultiBackward)" - }, - { - "desc": "", - "noremap": false, - "lhs": "[%", - "mode": "n", - "rhs": "(MatchitNormalMultiBackward)" - }, - { - "desc": "Diagnostic", - "noremap": true, - "lhs": "[d", - "mode": "n", - "rhs": "Lspsaga diagnostic_jump_prev" - }, - { - "desc": "Git Hunk", - "noremap": true, - "lhs": "]g", - "mode": "n", - "rhs": "Gitsigns next_hunk" - }, - { "desc": "Edit", "noremap": true, "lhs": "]e", "mode": "n", "rhs": "g," }, - { - "desc": "Undo forward", - "noremap": true, - "lhs": "]u", - "mode": "n", - "rhs": "lua MiniBracketed.undo('forward')" - }, - { - "desc": "Undo last", - "noremap": true, - "lhs": "]U", - "mode": "n", - "rhs": "lua MiniBracketed.undo('last')" - }, - { - "desc": "Treesitter forward", - "noremap": true, - "lhs": "]n", - "mode": "x", - "rhs": "lua MiniBracketed.treesitter('forward')" - }, - { - "desc": "Treesitter forward", - "noremap": true, - "lhs": "]n", - "mode": "n", - "rhs": "lua MiniBracketed.treesitter('forward')" - }, - { - "desc": "Treesitter last", - "noremap": true, - "lhs": "]N", - "mode": "x", - "rhs": "lua MiniBracketed.treesitter('last')" - }, - { - "desc": "Treesitter last", - "noremap": true, - "lhs": "]N", - "mode": "n", - "rhs": "lua MiniBracketed.treesitter('last')" - }, - { - "desc": "Location forward", - "noremap": true, - "lhs": "]l", - "mode": "n", - "rhs": "lua MiniBracketed.location('forward')" - }, - { - "desc": "Location last", - "noremap": true, - "lhs": "]L", - "mode": "n", - "rhs": "lua MiniBracketed.location('last')" - }, - { - "desc": "Oldfile forward", - "noremap": true, - "lhs": "]o", - "mode": "n", - "rhs": "lua MiniBracketed.oldfile('forward')" - }, - { - "desc": "Oldfile last", - "noremap": true, - "lhs": "]O", - "mode": "n", - "rhs": "lua MiniBracketed.oldfile('last')" - }, - { - "desc": "Jump", - "noremap": true, - "lhs": "]j", - "mode": "n", - "rhs": "" - }, - { - "desc": "Jump last", - "noremap": true, - "lhs": "]J", - "mode": "n", - "rhs": "lua MiniBracketed.jump('last')" - }, - { - "desc": "Indent forward", - "noremap": true, - "lhs": "]i", - "mode": "x", - "rhs": "lua MiniBracketed.indent('forward')" - }, - { - "desc": "Indent forward", - "noremap": true, - "lhs": "]i", - "mode": "n", - "rhs": "lua MiniBracketed.indent('forward')" - }, - { - "desc": "Indent last", - "noremap": true, - "lhs": "]I", - "mode": "x", - "rhs": "lua MiniBracketed.indent('last')" - }, - { - "desc": "Indent last", - "noremap": true, - "lhs": "]I", - "mode": "n", - "rhs": "lua MiniBracketed.indent('last')" - }, - { - "desc": "Diagnostic forward", - "noremap": true, - "lhs": "]d", - "mode": "x", - "rhs": "lua MiniBracketed.diagnostic('forward')" - }, - { - "desc": "Diagnostic last", - "noremap": true, - "lhs": "]D", - "mode": "x", - "rhs": "lua MiniBracketed.diagnostic('last')" - }, - { - "desc": "Diagnostic last", - "noremap": true, - "lhs": "]D", - "mode": "n", - "rhs": "lua MiniBracketed.diagnostic('last')" - }, - { - "desc": "Conflict forward", - "noremap": true, - "lhs": "]x", - "mode": "x", - "rhs": "lua MiniBracketed.conflict('forward')" - }, - { - "desc": "Conflict forward", - "noremap": true, - "lhs": "]x", - "mode": "n", - "rhs": "lua MiniBracketed.conflict('forward')" - }, - { - "desc": "Conflict last", - "noremap": true, - "lhs": "]X", - "mode": "x", - "rhs": "lua MiniBracketed.conflict('last')" - }, - { - "desc": "Conflict last", - "noremap": true, - "lhs": "]X", - "mode": "n", - "rhs": "lua MiniBracketed.conflict('last')" - }, - { - "desc": "Comment forward", - "noremap": true, - "lhs": "]c", - "mode": "x", - "rhs": "lua MiniBracketed.comment('forward')" - }, - { - "desc": "Comment forward", - "noremap": true, - "lhs": "]c", - "mode": "n", - "rhs": "lua MiniBracketed.comment('forward')" - }, - { - "desc": "Comment last", - "noremap": true, - "lhs": "]C", - "mode": "x", - "rhs": "lua MiniBracketed.comment('last')" - }, - { - "desc": "Comment last", - "noremap": true, - "lhs": "]C", - "mode": "n", - "rhs": "lua MiniBracketed.comment('last')" - }, - { - "desc": "Buffer", - "noremap": true, - "lhs": "]b", - "mode": "n", - "rhs": "bnext" - }, - { - "desc": "Buffer", - "noremap": true, - "lhs": "]B", - "mode": "n", - "rhs": "blast" - }, - { - "desc": "", - "noremap": false, - "lhs": "]%", - "mode": "x", - "rhs": "(MatchitVisualMultiForward)" - }, - { - "desc": "", - "noremap": false, - "lhs": "]%", - "mode": "n", - "rhs": "(MatchitNormalMultiForward)" - }, - { - "desc": "Diagnostic", - "noremap": true, - "lhs": "]d", - "mode": "n", - "rhs": "Lspsaga diagnostic_jump_next" - }, - { - "desc": "Around last textobject", - "noremap": false, - "lhs": "al", - "mode": "x", - "rhs": "" - }, - { - "desc": "Around next textobject", - "noremap": false, - "lhs": "an", - "mode": "x", - "rhs": "" - }, - { - "desc": "Around textobject", - "noremap": false, - "lhs": "a", - "mode": "x", - "rhs": "" - }, - { - "desc": "", - "noremap": false, - "lhs": "a%", - "mode": "x", - "rhs": "(MatchitVisualTextObject)" - }, - { - "desc": "Change without replacing clipboard", - "noremap": true, - "lhs": "c", - "mode": "n", - "rhs": "\"_c" - }, - { - "desc": "Delete without replacing clipboard", - "noremap": true, - "lhs": "d", - "mode": "n", - "rhs": "\"_d" - }, - { - "desc": "Put yanked text before selection", - "noremap": true, - "lhs": "gP", - "mode": "x", - "rhs": "(YankyGPutBefore)" - }, - { - "desc": "Put yanked text before selection", - "noremap": true, - "lhs": "gP", - "mode": "n", - "rhs": "(YankyGPutBefore)" - }, - { - "desc": "Put yanked text after selection", - "noremap": true, - "lhs": "gp", - "mode": "x", - "rhs": "(YankyGPutAfter)" - }, - { - "desc": "Put yanked text after selection", - "noremap": true, - "lhs": "gp", - "mode": "n", - "rhs": "(YankyGPutAfter)" - }, - { - "desc": "Highlight next surrounding", - "noremap": true, - "lhs": "gshn", - "mode": "n", - "rhs": "" - }, - { - "desc": "Find next left surrounding", - "noremap": true, - "lhs": "gsFn", - "mode": "n", - "rhs": "" - }, - { - "desc": "Find next right surrounding", - "noremap": true, - "lhs": "gsfn", - "mode": "n", - "rhs": "" - }, - { - "desc": "Replace next surrounding", - "noremap": true, - "lhs": "gsrn", - "mode": "n", - "rhs": "" - }, - { - "desc": "Delete next surrounding", - "noremap": true, - "lhs": "gsdn", - "mode": "n", - "rhs": "" - }, - { - "desc": "Highlight previous surrounding", - "noremap": true, - "lhs": "gshl", - "mode": "n", - "rhs": "" - }, - { - "desc": "Find previous left surrounding", - "noremap": true, - "lhs": "gsFl", - "mode": "n", - "rhs": "" - }, - { - "desc": "Find previous right surrounding", - "noremap": true, - "lhs": "gsfl", - "mode": "n", - "rhs": "" - }, - { - "desc": "Replace previous surrounding", - "noremap": true, - "lhs": "gsrl", - "mode": "n", - "rhs": "" - }, - { - "desc": "Delete previous surrounding", - "noremap": true, - "lhs": "gsdl", - "mode": "n", - "rhs": "" - }, - { - "desc": "Add surrounding to selection", - "noremap": true, - "lhs": "gsa", - "mode": "x", - "rhs": ":lua MiniSurround.add('visual')" - }, - { - "desc": "Update `MiniSurround.config.n_lines`", - "noremap": true, - "lhs": "gsn", - "mode": "n", - "rhs": "" - }, - { - "desc": "Highlight surrounding", - "noremap": true, - "lhs": "gsh", - "mode": "n", - "rhs": "" - }, - { - "desc": "Find left surrounding", - "noremap": true, - "lhs": "gsF", - "mode": "n", - "rhs": "" - }, - { - "desc": "Find right surrounding", - "noremap": true, - "lhs": "gsf", - "mode": "n", - "rhs": "" - }, - { - "desc": "Replace surrounding", - "noremap": true, - "lhs": "gsr", - "mode": "n", - "rhs": "" - }, - { - "desc": "Delete surrounding", - "noremap": true, - "lhs": "gsd", - "mode": "n", - "rhs": "" - }, - { - "desc": "Add surrounding", - "noremap": true, - "lhs": "gsa", - "mode": "n", - "rhs": "" - }, - { - "desc": "Move to right \"around\"", - "noremap": false, - "lhs": "g]", - "mode": "x", - "rhs": "" - }, - { - "desc": "Move to right \"around\"", - "noremap": false, - "lhs": "g]", - "mode": "n", - "rhs": "" - }, - { - "desc": "Move to left \"around\"", - "noremap": false, - "lhs": "g[", - "mode": "x", - "rhs": "" - }, - { - "desc": "Move to left \"around\"", - "noremap": false, - "lhs": "g[", - "mode": "n", - "rhs": "" - }, - { - "desc": "", - "noremap": false, - "lhs": "g%", - "mode": "x", - "rhs": "(MatchitVisualBackward)" - }, - { - "desc": "", - "noremap": false, - "lhs": "g%", - "mode": "n", - "rhs": "(MatchitNormalBackward)" - }, - { - "desc": "Beginning of line", - "noremap": true, - "lhs": "gh", - "mode": "x", - "rhs": "^" - }, - { - "desc": "Beginning of line", - "noremap": true, - "lhs": "gh", - "mode": "n", - "rhs": "^" - }, - { - "desc": "End of line", - "noremap": true, - "lhs": "gl", - "mode": "x", - "rhs": "$" - }, - { - "desc": "End of line", - "noremap": true, - "lhs": "gl", - "mode": "n", - "rhs": "$" - }, - { - "desc": "Comment line", - "noremap": true, - "lhs": "gcc", - "mode": "n", - "rhs": "" - }, - { - "desc": "Comment selection", - "noremap": true, - "lhs": "gc", - "mode": "x", - "rhs": "" - }, - { - "desc": "Comment", - "noremap": true, - "lhs": "gc", - "mode": "n", - "rhs": "" - }, - { - "desc": "Opens filepath or URI under cursor with the system handler (file explorer, web browser, …)", - "noremap": true, - "lhs": "gx", - "mode": "x", - "rhs": "" - }, - { - "desc": "Opens filepath or URI under cursor with the system handler (file explorer, web browser, …)", - "noremap": true, - "lhs": "gx", - "mode": "n", - "rhs": "" - }, - { - "desc": "Inside last textobject", - "noremap": false, - "lhs": "il", - "mode": "x", - "rhs": "" - }, - { - "desc": "Inside next textobject", - "noremap": false, - "lhs": "in", - "mode": "x", - "rhs": "" - }, - { - "desc": "Inside textobject", - "noremap": false, - "lhs": "i", - "mode": "x", - "rhs": "" - }, - { - "desc": "", - "noremap": true, - "lhs": "j", - "mode": "n", - "rhs": "v:count == 0 ? 'gj' : 'j'" - }, - { - "desc": "", - "noremap": true, - "lhs": "k", - "mode": "n", - "rhs": "v:count == 0 ? 'gk' : 'k'" - }, - { - "desc": "Next search result", - "noremap": true, - "lhs": "n", - "mode": "x", - "rhs": "'Nn'[v:searchforward]" - }, - { - "desc": "Next search result", - "noremap": true, - "lhs": "n", - "mode": "n", - "rhs": "'Nn'[v:searchforward]" - }, - { - "desc": "Put yanked text after cursor", - "noremap": true, - "lhs": "p", - "mode": "x", - "rhs": "(YankyPutAfter)" - }, - { - "desc": "Put yanked text after cursor", - "noremap": true, - "lhs": "p", - "mode": "n", - "rhs": "(YankyPutAfter)" - }, - { - "desc": "Flash", - "noremap": true, - "lhs": "s", - "mode": "n", - "rhs": "" - }, - { - "desc": "Flash", - "noremap": true, - "lhs": "s", - "mode": "x", - "rhs": "" - }, - { - "desc": "", - "noremap": true, - "lhs": "u", - "mode": "n", - "rhs": "ulua MiniBracketed.register_undo_state()" - }, - { - "desc": "Cut without replacing clipboard", - "noremap": true, - "lhs": "x", - "mode": "n", - "rhs": "\"_x" - }, - { "desc": "", "noremap": true, "lhs": "x", "mode": "x", "rhs": "\"_x" }, - { - "desc": "Yank text", - "noremap": true, - "lhs": "y", - "mode": "x", - "rhs": "(YankyYank)" - }, - { - "desc": "Yank text", - "noremap": true, - "lhs": "y", - "mode": "n", - "rhs": "(YankyYank)" - }, - { - "desc": "Multi Edit Next", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": ":call vm#commands#ctrln(v:count1)" - }, - { - "desc": "Add Cursor Down", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": ":call vm#commands#add_cursor_up(0, v:count1)" - }, - { - "desc": "Add Cursor Down", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": ":call vm#commands#add_cursor_down(0, v:count1)" - }, - { - "desc": "Add Cursor Up", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": ":call vm#commands#add_cursor_up(0, v:count1)" - }, - { - "desc": "Add Cursor Down", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": ":call vm#commands#add_cursor_down(0, v:count1)" - }, - { - "desc": "", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "(YankyCycleBackward)" - }, - { - "desc": "", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "(YankyCycleForward)" - }, - { - "desc": "Previous Buffer", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "bprevious" - }, - { - "desc": "Previous Pane", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "p" - }, - { - "desc": "Move Up", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "k" - }, - { - "desc": "Move Down", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "j" - }, - { - "desc": "Move Left", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "h" - }, - { - "desc": "Lazygit", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "Fterm lazygit" - }, - { - "desc": "Find Files", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "Telescope find_files" - }, - { - "desc": "Increase window height", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "resize +10which_key.add(no_leader_mappings)" - }, - { - "desc": "Increase window width", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "vertical resize +10" - }, - { - "desc": "Decrease window width", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "vertical resize -10" - }, - { - "desc": "Decrease window height", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "resize -10" - }, - { - "desc": "Move line up", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "lua MiniMove.move_line('up')" - }, - { - "desc": "Move line down", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "lua MiniMove.move_line('down')" - }, - { - "desc": "Move line right", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "lua MiniMove.move_line('right')" - }, - { - "desc": "Move line left", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "lua MiniMove.move_line('left')" - }, - { - "desc": "Move up", - "noremap": true, - "lhs": "", - "mode": "x", - "rhs": "lua MiniMove.move_selection('up')" - }, - { - "desc": "Move down", - "noremap": true, - "lhs": "", - "mode": "x", - "rhs": "lua MiniMove.move_selection('down')" - }, - { - "desc": "Move right", - "noremap": true, - "lhs": "", - "mode": "x", - "rhs": "lua MiniMove.move_selection('right')" - }, - { - "desc": "Move left", - "noremap": true, - "lhs": "", - "mode": "x", - "rhs": "lua MiniMove.move_selection('left')" - }, - { - "desc": "", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "lua MiniBracketed.register_undo_state()" - }, - { - "desc": "", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "zz" - }, - { - "desc": "", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "zz" - }, - { "desc": "", "noremap": true, "lhs": "", "mode": "n", "rhs": "ggVG" }, - { - "desc": "Show diagnostics under the cursor", - "noremap": false, - "lhs": "", - "mode": "n", - "rhs": "d" - }, - { - "desc": "Show diagnostics under the cursor", - "noremap": true, - "lhs": "d", - "mode": "n", - "rhs": "" - }, - { - "desc": "Move Right", - "noremap": true, - "lhs": "", - "mode": "n", - "rhs": "l" - } + "vscode-html-language-server", + "yaml-language-server" ], "plugins": [ "2kabhishek/nerdy.nvim", "2kabhishek/termim.nvim", + "Bilal2453/luvit-meta", "Exafunction/codeium.vim", "HiPhish/rainbow-delimiters.nvim", "L3MON4D3/LuaSnip", "LudoPinelli/comment-box.nvim", "LunarVim/bigfile.nvim", "MunifTanjim/nui.nvim", - "NStefan002/screenkey.nvim", "ThePrimeagen/refactoring.nvim", "akinsho/toggleterm.nvim", "altermo/ultimate-autopair.nvim", - "antosha417/nvim-lsp-file-operations", "creativenull/dotfyle-metadata.nvim", + "cvigilv/esqueleto.nvim", "debugloop/telescope-undo.nvim", "echasnovski/mini.files", "echasnovski/mini.icons", "echasnovski/mini.nvim", - "folke/flash.nvim", + "epwalsh/pomo.nvim", "folke/lazy.nvim", + "folke/lazydev.nvim", "folke/noice.nvim", "folke/persistence.nvim", "folke/trouble.nvim", @@ -2961,6 +61,7 @@ "folke/which-key.nvim", "folke/zen-mode.nvim", "gbprod/yanky.nvim", + "ggandor/leap.nvim", "hrsh7th/cmp-buffer", "hrsh7th/cmp-cmdline", "hrsh7th/cmp-nvim-lsp", @@ -2969,13 +70,18 @@ "hrsh7th/cmp-path", "hrsh7th/nvim-cmp", "iamcco/markdown-preview.nvim", + "j-hui/fidget.nvim", + "kawre/leetcode.nvim", "kristijanhusak/vim-dadbod-completion", "kristijanhusak/vim-dadbod-ui", + "lambdalisue/suda.vim", + "linux-cultist/venv-selector.nvim", "lukas-reineke/indent-blankline.nvim", "m-demare/hlargs.nvim", "m4xshen/hardtime.nvim", "max397574/better-escape.nvim", "mfussenegger/nvim-dap", + "mfussenegger/nvim-dap-python", "mfussenegger/nvim-lint", "mg979/vim-visual-multi", "michaelb/sniprun", @@ -2986,6 +92,7 @@ "navarasu/onedark.nvim", "neovim/nvim-lspconfig", "numToStr/Navigator.nvim", + "nvchad/showkeys", "nvim-lua/plenary.nvim", "nvim-lualine/lualine.nvim", "nvim-neo-tree/neo-tree.nvim", @@ -3029,37 +136,40 @@ "treesitterParsers": [ "bash", "c", - "cpp", "css", + "diff", + "gitcommit", "html", "java", "javascript", "json", "liquid", "lua", + "luadoc", "markdown", "markdown_inline", "python", "scss", - "toml", "tsx", "typescript", "vim", "vimdoc" ], "lspServers": [ - "basedpyright", "bashls", "clangd", "cssls", "emmet_ls", + "html", "jdtls", - "jsonls", "lua_ls", "pyright", "ruff", + "rust_analyzer", "tailwindcss", - "tsserver" + "taplo", + "ts_ls", + "yamlls" ], "leaderKey": "" } diff --git a/lua/core/autocmd.lua b/lua/core/autocmd.lua index a605616..9db6ea3 100644 --- a/lua/core/autocmd.lua +++ b/lua/core/autocmd.lua @@ -135,6 +135,48 @@ vim.api.nvim_create_autocmd('FileType', { end, }) +vim.api.nvim_create_autocmd('BufReadPost', { + callback = function() + if vim.fn.line('\'"') > 1 and vim.fn.line('\'"') <= vim.fn.line('$') then + vim.cmd('normal! g`"') + end + end, + group = augroup('General'), + desc = 'Go To The Last Cursor Position', +}) + +vim.api.nvim_create_autocmd('FileType', { + pattern = { 'c', 'cpp', 'py', 'java', 'cs' }, + callback = function() + vim.bo.shiftwidth = 4 + end, + group = augroup('General'), + desc = 'Set shiftwidth to 4 in these filetypes', +}) + +-- Toggle between relative/absolute line numbers +local numbertoggle = augroup('numbertoggle') +vim.api.nvim_create_autocmd({ 'BufEnter', 'FocusGained', 'InsertLeave', 'CmdlineLeave', 'WinEnter' }, { + pattern = '*', + group = numbertoggle, + callback = function() + if vim.o.nu and vim.api.nvim_get_mode().mode ~= 'i' then + vim.opt.relativenumber = true + end + end, +}) + +vim.api.nvim_create_autocmd({ 'BufLeave', 'FocusLost', 'InsertEnter', 'CmdlineEnter', 'WinLeave' }, { + pattern = '*', + group = numbertoggle, + callback = function() + if vim.o.nu then + vim.opt.relativenumber = false + vim.cmd.redraw() + end + end, +}) + -- ╭─────────────────────────────────────────────────────────╮ -- │ VIM-VISUAL-MULTI │ -- ╰─────────────────────────────────────────────────────────╯ diff --git a/lua/core/keys.lua b/lua/core/keys.lua index 5147217..afa7a0f 100644 --- a/lua/core/keys.lua +++ b/lua/core/keys.lua @@ -15,7 +15,23 @@ vim.g.maplocalleader = ' ' -- visual_block_mode = "x", term_mode = "t", command_mode = "c", -- Comment -map({ 'n', 'v' }, '/', 'gcc', { remap = true }) +map({ 'n', 'v' }, '/', 'gcc', { desc = 'Comment toggle', remap = true }) +map({ 'v', 'x' }, '/', 'gc', { desc = 'Comment toggle', remap = true }) + +-- save file +map({ 'x', 'i', 'n', 's' }, '', 'w', { desc = 'Save File' }) + +-- Shortcut for surrounding a word (inner) with a ' +map('n', 'S', '') -- Don't keep S mapping +map('n', 'Sq', "Siw'", { desc = "Wrap word with '", remap = true }) +map('n', 'Sp', 'SiW(', { desc = 'Wrap word with ()', remap = true }) +map('n', 'Sb', 'Saw}', { desc = 'Wrap word with {}', remap = true }) + +-- Remove all text +map('n', 'r', '%d+', { desc = 'General | Remove All Text', silent = true }) + +-- Able to use semicolon in normal mode +map('n', ';', ':', { desc = '; Command mode' }) -- Select all map('n', '', 'ggG') @@ -84,3 +100,55 @@ map('n', 'd', '"_d', { desc = 'Delete without replacing clipboad' }) map('n', 'x', '"_x', { desc = 'Cut without replacing clipboad' }) map('n', 'c', '"_c', { desc = 'Change without replacing clipboad' }) map('v', 'p', '"_dP', { desc = 'Paste without replacing clipboard' }) + +map('n', 'oz', function() + ---@diagnostic disable-next-line: undefined-field + if vim.opt.foldcolumn:get() == '0' then + vim.opt.foldcolumn = '1' + else + vim.opt.foldcolumn = '0' + end +end, { desc = 'Toggle foldcolumn' }) + +map('n', 'op', function() + vim.g.minipairs_disable = not vim.g.minipairs_disable and true or false +end, { desc = 'Toggle mini.pairs' }) + +-- -- Indent backward +-- vim.keymap.set("n", "<", "<<", { desc = "General | Indent backward", silent = true }) +-- +-- -- Indent forward +-- vim.keymap.set("n", ">", ">>", { desc = "General | Indent forward", silent = true }) +-- +-- -- Move the line up +-- vim.keymap.set("n", "", "m .+1==", { desc = "General | Move the line up", silent = true }) +-- +-- -- Move the line down +-- vim.keymap.set("n", "", "m .-2==", { desc = "General | Move the line down", silent = true }) +-- +-- -- Move the line up (Insert Mode) +-- vim.keymap.set("i", "", ":m .+1==gi", { desc = "General | Move the line up", silent = true }) +-- +-- -- Move the line down (Insert Mode) +-- vim.keymap.set("i", "", ":m .-2==gi", { desc = "General | Move the line down", silent = true }) +-- +-- -- Better Down (Visual Mode) +-- vim.keymap.set("v", "j", "v:count == 0 ? 'gj' : 'j'", { desc = "General | Better Down", expr = true, silent = true }) +-- +-- -- Better Up (Visual Mode) +-- vim.keymap.set("v", "k", "v:count == 0 ? 'gk' : 'k'", { desc = "General | Better Up", expr = true, silent = true }) +-- +-- -- Better Paste (Visual Mode) +-- vim.keymap.set("v", "p", '"_dP', { desc = "General | Better Paste", silent = true }) +-- +-- -- Indent backward (Visual Mode) +-- vim.keymap.set("v", "<", "", ">gv", { desc = "General | Indent forward", silent = true }) +-- +-- -- Move the selected text up (Visual Mode) +-- vim.keymap.set("v", "", "m '>+1gv=gv", { desc = "General | Move the selected text up", silent = true }) +-- +-- -- Move the selected text down (Visual Mode) +-- vim.keymap.set("v", "", "m '<-2gv=gv", { desc = "General | Move the selected text down", silent = true }) diff --git a/lua/lock.json b/lua/lock.json index 55a3aa3..7c2e8e3 100644 --- a/lua/lock.json +++ b/lua/lock.json @@ -1,7 +1,7 @@ { - "LuaSnip": { "branch": "master", "commit": "787dee55ca364cc9119787165418fe93b74c1842" }, + "LuaSnip": { "branch": "master", "commit": "4bf40748f6fe939bdcb69325918535b1c5edea51" }, "Navigator.nvim": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" }, - "better-escape.nvim": { "branch": "master", "commit": "bb197e51a91a635deb88630813c3bfc284413697" }, + "better-escape.nvim": { "branch": "master", "commit": "199dcc2643dec5d8dbdab4ec672cf405224dcb3b" }, "bigfile.nvim": { "branch": "main", "commit": "33eb067e3d7029ac77e081cfe7c45361887a311a" }, "ccc.nvim": { "branch": "main", "commit": "7c639042583c7bdc7ce2e37e5a0e0aa6d0659c6a" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, @@ -10,35 +10,40 @@ "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "031e6ba70b0ad5eee49fd2120ff7a2e325b17fa7" }, "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, "codeium.vim": { "branch": "main", "commit": "8c01979323b2b480c8bf160d3ff85bd1668baa49" }, "codesnap.nvim": { "branch": "main", "commit": "6400480aa6cc366cbd931146c429aaa64680dab9" }, "comment-box.nvim": { "branch": "main", "commit": "06bb771690bc9df0763d14769b779062d8f12bc5" }, - "conform.nvim": { "branch": "master", "commit": "5fbea7d7043bae2499d643c97b407f6da44abff4" }, - "dashboard-nvim": { "branch": "master", "commit": "d2c5a4d1341f5ca1ed2ecb4ecfcff2bc8ea18b14" }, + "conform.nvim": { "branch": "master", "commit": "d28ccf945374edd9f1c34a82f6c22261dbd8ab98" }, + "dashboard-nvim": { "branch": "master", "commit": "ae309606940d26d8c9df8b048a6e136b6bbec478" }, "dotfyle-metadata.nvim": { "branch": "main", "commit": "342ef8f3f98f3ccc451c9cf2be74e95149ced05d" }, - "dressing.nvim": { "branch": "master", "commit": "1b7921eecc65af1baf8ac1dc06f0794934cbcfb2" }, + "dressing.nvim": { "branch": "master", "commit": "6ef1ca479d37d4ff66f13eed44d08912caff483a" }, + "esqueleto.nvim": { "branch": "main", "commit": "0f79ccafc931f706d175549c1339848eb8fa8470" }, + "fidget.nvim": { "branch": "main", "commit": "e2a175c2abe2d4f65357da1c98c59a5cfb2b543f" }, "flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" }, "flatten.nvim": { "branch": "main", "commit": "e420e531d2ab24aebcf7b3c9fca28e6c5c34964d" }, "friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" }, "hardtime.nvim": { "branch": "main", "commit": "027d6f991927a71bd510a7673ae5bb404ca2a1c7" }, "hlargs.nvim": { "branch": "main", "commit": "53ec5d8ca6ed012de5545ba83ea1eb3d636b09fb" }, "inc-rename.nvim": { "branch": "main", "commit": "8ba77017ca468f3029bf88ef409c2d20476ea66b" }, - "indent-blankline.nvim": { "branch": "master", "commit": "e7a4442e055ec953311e77791546238d1eaae507" }, - "lazy.nvim": { "branch": "main", "commit": "cf8ecc2c5e4332760431a33534240b0cbc6680ab" }, + "indent-blankline.nvim": { "branch": "master", "commit": "04e44b09ee3ff189c69ab082edac1ef7ae2e256c" }, + "lazy.nvim": { "branch": "main", "commit": "b1134ab82ee4279e31f7ddf7e34b2a99eb9b7bc9" }, + "lazydev.nvim": { "branch": "main", "commit": "d5800897d9180cea800023f2429bce0a94ed6064" }, "leap.nvim": { "branch": "main", "commit": "c6bfb191f1161fbabace1f36f578a20ac6c7642c" }, - "lspkind.nvim": { "branch": "master", "commit": "59c3f419af48a2ffb2320cea85e44e5a95f71664" }, + "leetcode.nvim": { "branch": "master", "commit": "6a2e54ff13027fb3ce46b61a0e721eccc020ec80" }, + "lspkind.nvim": { "branch": "master", "commit": "a700f1436d4a938b1a1a93c9962dc796afbaef4d" }, "lspsaga.nvim": { "branch": "main", "commit": "d027f8b9c7c55e26cf4030c8657a2fc8222ed762" }, - "lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" }, + "lualine.nvim": { "branch": "master", "commit": "640260d7c2d98779cab89b1e7088ab14ea354a02" }, + "luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, "mason-conform.nvim": { "branch": "main", "commit": "abce2be529f3b4b336c56d0ba6336a9144e0fee6" }, "mason-lock.nvim": { "branch": "main", "commit": "86614f76c3442fba1c5c8d79aa1efcb3ad69de1c" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "7446f47b3dfb7df801f31a6f6783c2ad119a6935" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" }, "mason-nvim-lint": { "branch": "main", "commit": "b579a00ee39dcd590b1023028dc8fb3d203a67b0" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "mini.files": { "branch": "main", "commit": "6abe854f1410fc6aec69897a78b1db994c32d9c6" }, "mini.icons": { "branch": "main", "commit": "a2742459f0ee32806c2438ca06b4d8b331f3f4d4" }, - "mini.nvim": { "branch": "main", "commit": "77533e69cc4fadb7f4c25f23255ae0890a058818" }, + "mini.nvim": { "branch": "main", "commit": "c8bc67a35e627908da644c5f8cd26b3f987f2627" }, "modes.nvim": { "branch": "main", "commit": "3188692abf02a8838ec75e59d68c2ce3e4323f5c" }, "neo-tree.nvim": { "branch": "main", "commit": "a77af2e764c5ed4038d27d1c463fa49cd4794e07" }, "neotest": { "branch": "master", "commit": "6d3d22cdad49999ef774ebe1bc250a4994038964" }, @@ -46,30 +51,30 @@ "neotest-python": { "branch": "master", "commit": "a2861ab3c9a0bf75a56b11835c2bfc8270f5be7e" }, "neotest-rspec": { "branch": "main", "commit": "53fc108a06ae43d7f873d42ee5189c2301e33623" }, "nerdy.nvim": { "branch": "main", "commit": "b467d6609b78d6a5f1e12cbc08fcc1ac87af20f5" }, - "noice.nvim": { "branch": "main", "commit": "df448c649ef6bc5a6a633a44f2ad0ed8d4442499" }, + "noice.nvim": { "branch": "main", "commit": "5a78b42bec5e775f2db03bf93f6d1e0f3636306c" }, "nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" }, "numb.nvim": { "branch": "master", "commit": "3f7d4a74bd456e747a1278ea1672b26116e0824d" }, - "nvim-cmp": { "branch": "main", "commit": "29fb4854573355792df9e156cb779f0d31308796" }, + "nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" }, "nvim-dap": { "branch": "master", "commit": "7ff6936010b7222fea2caea0f67ed77f1b7c60dd" }, + "nvim-dap-python": { "branch": "master", "commit": "3e3dd98d4d83715c9e0e429b4a5da7bd706e6ceb" }, "nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" }, - "nvim-lint": { "branch": "master", "commit": "16b21a7d04d06661f92f273a0744fd81fb19e09e" }, - "nvim-lsp-file-operations": { "branch": "master", "commit": "92a673de7ecaa157dd230d0128def10beb56d103" }, - "nvim-lspconfig": { "branch": "master", "commit": "edd9591199d1c78c0cb20514231f7f936f9412a2" }, + "nvim-lint": { "branch": "master", "commit": "36da8dd0ddc4f88e0beae234c20e75397326f143" }, + "nvim-lspconfig": { "branch": "master", "commit": "bc6ada4b0892b7f10852c0b8ca7209fd39a6d754" }, "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, "nvim-notify": { "branch": "master", "commit": "fbef5d32be8466dd76544a257d3f3dce20082a07" }, - "nvim-spectre": { "branch": "master", "commit": "ba7fb777edff6c1fbbeffd343e113af64c04e90a" }, - "nvim-treesitter": { "branch": "master", "commit": "377039daa260b71f304c881d1b21d643c501a261" }, - "nvim-treesitter-context": { "branch": "master", "commit": "e7fdb4cdf0942cd6e63dd822110a93c0ec777fe5" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "0d79d169fcd45a8da464727ac893044728f121d4" }, + "nvim-spectre": { "branch": "master", "commit": "08be31c104df3b4b049607694ebb2b6ced4f928b" }, + "nvim-treesitter": { "branch": "master", "commit": "509d38fee865eefd38eacf17c8920b68cf67b0fd" }, + "nvim-treesitter-context": { "branch": "master", "commit": "a2a334900d3643de585ac5c6140b03403454124f" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "3e450cd85243da99dc23ebbf14f9c70e9a0c26a4" }, "nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" }, - "nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" }, "odoo-snippets": { "branch": "main", "commit": "5e6b7191e3ea60bba00df6cdbc031291b194768d" }, "onedark.nvim": { "branch": "master", "commit": "fae34f7c635797f4bf62fb00e7d0516efa8abe37" }, "persistence.nvim": { "branch": "main", "commit": "f6aad7dde7fcf54148ccfc5f622c6d5badd0cc3d" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, - "rainbow-delimiters.nvim": { "branch": "master", "commit": "d227e6c9879bb50af35cd733461198666981d482" }, - "refactoring.nvim": { "branch": "master", "commit": "c406fc5fb4d7ba5fce7b668637075fad6e75e9f8" }, - "screenkey.nvim": { "branch": "main", "commit": "0589de3c857721e150ea694cfe66d6d0e8aecacb" }, + "pomo.nvim": { "branch": "main", "commit": "aa8decc421d89be0f10b1fc6a602cdd269f350ff" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "e0f9b3efe150724af2d2ed59997d5ece373840e3" }, + "refactoring.nvim": { "branch": "master", "commit": "53ed6854e0bba64d467c58e87084dcf8b1c22d36" }, + "showkeys": { "branch": "main", "commit": "82965404a3d1b740d5efa24c09c0daccf7571f24" }, "sniprun": { "branch": "master", "commit": "67ac2d84d03f3b857d59571ff5fefb6080dffa2d" }, "suda.vim": { "branch": "master", "commit": "b97fab52f9cdeabe2bbb5eb98d82356899f30829" }, "telescope-file-browser.nvim": { "branch": "master", "commit": "626998e5c1b71c130d8bc6cf7abb6709b98287bb" }, @@ -77,12 +82,13 @@ "telescope-symbols.nvim": { "branch": "master", "commit": "a6d0127a53d39b9fc2af75bd169d288166118aec" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope-undo.nvim": { "branch": "main", "commit": "51be9ae7c42fc27c0b05505e3a0162e0f05fbb6a" }, - "telescope.nvim": { "branch": "master", "commit": "df534c3042572fb958586facd02841e10186707c" }, + "telescope.nvim": { "branch": "master", "commit": "85922dde3767e01d42a08e750a773effbffaea3e" }, "termim.nvim": { "branch": "main", "commit": "58344167abb97bcef9bf720a762ea653a94e9daa" }, "toggleterm.nvim": { "branch": "main", "commit": "48be57eaba817f038d61bbf64d2c597f578c0827" }, "trouble.nvim": { "branch": "main", "commit": "2f3b537f2207ce32f4459f9d56746ee013b5e01b" }, "twilight.nvim": { "branch": "main", "commit": "1584c0b0a979b71fd86b18d302ba84e9aba85b1b" }, "ultimate-autopair.nvim": { "branch": "v0.6", "commit": "9e3209190c22953566ae4e6436ad2b4ff4dabb95" }, + "venv-selector.nvim": { "branch": "regexp", "commit": "e82594274bf7b54387f9a2abe65f74909ac66e97" }, "vim-alternate": { "branch": "master", "commit": "b3b7d5e9982f228a4d62fbbe2f2fe3e3ae92768c" }, "vim-dadbod": { "branch": "master", "commit": "fe5a55e92b2dded7c404006147ef97fb073d8b1b" }, "vim-dadbod-completion": { "branch": "master", "commit": "880f7e9f2959e567c718d52550f9fae1aa07aa81" }, diff --git a/lua/mason-lock.json b/lua/mason-lock.json index 41bf136..43ca87b 100644 --- a/lua/mason-lock.json +++ b/lua/mason-lock.json @@ -1,25 +1,31 @@ { - "basedpyright": "1.17.0", - "bash-language-server": "5.4.0", - "black": "24.8.0", - "clang-format": "18.1.8", - "clangd": "18.1.3", + "bash-language-server": "5.4.2", + "beautysh": "6.2.1", + "black": "24.10.0", + "clangd": "19.1.0", "codespell": "2.3.0", - "cspell": "8.14.2", + "cspell": "8.15.7", + "css-lsp": "4.10.0", + "djlint": "1.35.4", "emmet-ls": "0.4.2", - "eslint_d": "14.0.3", + "eslint_d": "14.2.2", + "html-lsp": "4.10.0", "isort": "5.13.2", - "jdtls": "v1.38.0", - "lua-language-server": "3.10.5", - "markdownlint": "0.41.0", - "mypy": "1.11.2", - "phpcs": "3.10.2", + "jdtls": "v1.41.0", + "lua-language-server": "3.12.0", + "markdownlint": "0.42.0", + "phpcs": "3.10.3", "prettier": "3.3.3", - "pylint": "3.2.6", - "ruff": "0.6.2", - "shfmt": "v3.9.0", + "prettierd": "0.25.3", + "pylint": "3.3.1", + "pyright": "1.1.387", + "ruff": "0.7.2", + "rust-analyzer": "2024-11-04", + "selene": "0.27.1", "stylua": "v0.20.0", - "tailwindcss-language-server": "0.0.23", - "trivy": "v0.54.1", - "typescript-language-server": "4.3.3" + "tailwindcss-language-server": "0.0.26", + "taplo": "0.9.3", + "trivy": "v0.57.0", + "typescript-language-server": "4.3.3", + "yaml-language-server": "1.15.0" } \ No newline at end of file diff --git a/lua/plugins/autopairs.lua b/lua/plugins/autopairs.lua new file mode 100644 index 0000000..20e499a --- /dev/null +++ b/lua/plugins/autopairs.lua @@ -0,0 +1,55 @@ +-- autopairs +-- https://github.com/windwp/nvim-autopairs + +return { + 'windwp/nvim-autopairs', + event = 'InsertEnter', + enabled = false, + -- Optional dependency + dependencies = { 'hrsh7th/nvim-cmp' }, + config = function() + local npairs = require('nvim-autopairs') + + npairs.setup({ + -- The string you provided appears to be a pattern or sequence of characters enclosed within [=[[ and ]]=]. + -- This syntax is used in Lua to create long string literals that can span multiple lines. + -- Here's what the pattern [=[[%w%%%'%[%"%.%%$]]=]` represents: + -- + -- %w matches any alphanumeric character (letters and digits) and underscore. + -- %% matches a literal percent sign %. + -- %' matches a literal single quote '. + -- %[ matches a literal opening square bracket [. + -- %" matches a literal double quote ". + -- %. matches a literal period or dot .. + -- %`` matches a literal backtick `` ``. + -- %$ matches a literal dollar sign $. + -- + -- So, this pattern would match any string that contains alphanumeric characters, underscores, percent signs, + -- single quotes, square brackets, double quotes, periods, backticks, and dollar signs. + -- ignored_next_char = [=[[%w%%%'%[%"%.%`%$]]=] + + -- Add { and ( to the list so it won't add the pair when we're adding a function around + -- existing text + ignored_next_char = [=[[%w%%%'%[%"%.%`%$%{%(]]=], + fast_wrap = {}, + check_ts = true, + ts_config = { + lua = { 'string' }, -- it will not add a pair on that treesitter node + javascript = { 'template_string' }, + java = false, -- don't check treesitter on java + }, + }) + -- If you want to automatically add `(` after selecting a function or method + local cmp_autopairs = require('nvim-autopairs.completion.cmp') + local cmp = require('cmp') + cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) + + local Rule = require('nvim-autopairs.rule') + local cond = require('nvim-autopairs.conds') + + vim.notify(vim.inspect(npairs.get_rules('"'))) + + npairs.remove_rule('`') + npairs.add_rule(Rule('`', '`'):with_pair(cond.not_before_regex('[%w%p]'))) + end, +} diff --git a/lua/plugins/coding.lua b/lua/plugins/coding.lua index c713eae..dd20248 100644 --- a/lua/plugins/coding.lua +++ b/lua/plugins/coding.lua @@ -1,7 +1,5 @@ --Coding related - return { - { 'max397574/better-escape.nvim', event = 'InsertEnter', @@ -27,7 +25,6 @@ return { vim.g.VM_maps = { ['Find Under'] = '', } - vim.g.VM_maps['I BS'] = '' vim.g.VM_maps['I CtrlC'] = '' vim.g.VM_maps['I CtrlN'] = '' @@ -46,7 +43,6 @@ return { terminal_width = 45, notification_timeout = 5, }, - inline_messages = 0, borders = 'single', }) @@ -108,37 +104,29 @@ return { vim.g.codeium_manual = false vim.fn['codeium#Complete']() end) - vim.g.codeium_filetypes = { TelescopePrompt = false, DressingInput = false, ['neo-tree-popup'] = false, ['dap-repl'] = false, } - local opts = { expr = true, silent = true } vim.g.codeium_disable_bindings = 1 - vim.keymap.set('i', '', function() return vim.fn['codeium#Accept']() end, opts) - -- vim.keymap.set('n', 'ch', function() -- return vim.fn['codeium#Chat']() -- end, { desc = 'Chat with IA (Codeium)' }) - vim.keymap.set('i', '', function() return vim.fn['codeium#CycleCompletions'](1) end, opts) - vim.keymap.set('i', '', function() return vim.fn['codeium#CycleCompletions'](-1) end, opts) - vim.keymap.set('i', '', function() return vim.fn['codeium#Clear']() end, opts) - vim.keymap.set('n', 'cI', 'CodeiumToggle', { desc = 'Toggle IA (Codeium)' }) end, }, @@ -147,6 +135,18 @@ return { lazy = true, ft = { 'cpp', 'h', 'hpp', 'c' }, }, + { + 'linux-cultist/venv-selector.nvim', + branch = 'regexp', + cmd = { 'VenvSelect', 'VenvSelectCached' }, + init = function() + vim.keymap.set('n', 'cv', 'VenvSelect', { desc = 'Venv Selector | Select Python venv' }) + end, + opts = {}, + config = function(_, opts) + require('venv-selector').setup(opts) + end, + }, { 'nacro90/numb.nvim', event = 'CmdlineEnter', @@ -161,27 +161,14 @@ return { end, }, { - 'NStefan002/screenkey.nvim', - cmd = 'Screenkey', - version = '*', - config = function() - require('screenkey').setup({ - win_opts = { - relative = 'editor', - anchor = 'SE', - width = 40, - height = 1, - border = 'single', - }, - compress_after = 3, - clear_after = 3, - disable = { - filetypes = {}, -- for example: "toggleterm" - buftypes = {}, -- for example: "terminal" - }, - }) - end, + 'nvchad/showkeys', + cmd = 'ShowkeysToggle', + opts = { + timeout = 1, + maxkeys = 8, + }, }, + -- { 'rachartier/tiny-inline-diagnostic.nvim', event = 'BufReadPost', opts = {} }, { 'gbprod/yanky.nvim', event = 'BufReadPost', diff --git a/lua/plugins/configs/lsp.lua b/lua/plugins/configs/lsp.lua deleted file mode 100644 index 75f15e3..0000000 --- a/lua/plugins/configs/lsp.lua +++ /dev/null @@ -1,205 +0,0 @@ --- Define nvim-lspconfig LSP servers here -local lsp_servers = { - -- 'basedpyright', - 'pyright', - 'pylsp', - 'lua_ls', - 'ts_ls', - 'tailwindcss', - 'emmet_ls', - 'bashls', - 'jdtls', - 'clangd', - 'html', - 'cssls', -} - -local lspconfig = require('lspconfig') - --- import cmp-nvim-lsp plugin -local cmp_nvim_lsp = require('cmp_nvim_lsp') - --- import mason_lspconfig plugin -local mason_lspconfig = require('mason-lspconfig') - --- local keymap = vim.keymap -- for conciseness - --- vim.api.nvim_create_autocmd('LspAttach', { --- group = vim.api.nvim_create_augroup('UserLspConfig', {}), --- callback = function(ev) --- -- Buffer local mappings. --- -- See `:help vim.lsp.*` for documentation on any of the below functions --- local opts = { buffer = ev.buf, silent = true } --- --- -- set keybinds --- opts.desc = 'Show LSP references' --- keymap.set('n', 'lR', 'Telescope lsp_references', opts) -- show definition, references --- --- opts.desc = 'Go to declaration' --- keymap.set('n', 'lD', vim.lsp.buf.declaration, opts) -- go to declaration --- --- opts.desc = 'Inlay hint' --- keymap.set( --- 'n', --- 'lh', --- 'lua vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())', --- opts --- ) --- --- opts.desc = 'Show LSP definitions' --- keymap.set('n', 'ld', 'Telescope lsp_definitions', opts) -- show lsp definitions --- --- opts.desc = 'Show LSP implementations' --- keymap.set('n', 'li', 'Telescope lsp_implementations', opts) -- show lsp implementations --- --- opts.desc = 'Show LSP type definitions' --- keymap.set('n', 'lt', 'Telescope lsp_type_definitions', opts) -- show lsp type definitions --- --- opts.desc = 'See available code actions' --- keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection --- --- opts.desc = 'Smart rename' --- keymap.set('n', 'mR', vim.lsp.buf.rename, opts) -- smart rename --- --- opts.desc = 'Show buffer diagnostics' --- keymap.set('n', 'lD', 'Telescope diagnostics bufnr=0', opts) -- show diagnostics for file --- --- opts.desc = 'Show line diagnostics' --- keymap.set('n', 'ld', vim.diagnostic.open_float, opts) -- show diagnostics for line --- --- opts.desc = 'Show documentation for what is under cursor' --- keymap.set('n', 'K', vim.lsp.buf.hover, opts) -- show documentation for what is under cursor --- --- opts.desc = 'Restart LSP' --- keymap.set('n', 'ls', ':LspRestart', opts) -- mapping to restart lsp if necessary --- end, --- }) - --- used to enable autocompletion (assign to every lsp server config) -local capabilities = cmp_nvim_lsp.default_capabilities() - --- Change the Diagnostic symbols in the sign column (gutter) -local signs = { Error = ' ', Warn = ' ', Hint = '󰠠 ', Info = ' ' } -for type, icon in pairs(signs) do - local hl = 'DiagnosticSign' .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' }) -end - --- Set Mason LSPs Here -mason_lspconfig.setup({ - ensure_installed = lsp_servers, - automatic_installation = true, - handlers = { - -- default handler for installed servers - function(server_name) - lspconfig[server_name].setup({ - capabilities = capabilities, - }) - end, - ['lua_ls'] = function() - -- configure lua server (with special settings) - lspconfig['lua_ls'].setup({ - capabilities = capabilities, - settings = { - Lua = { - -- make the language server recognize "vim" global - diagnostics = { - globals = { 'vim' }, - }, - completion = { - callSnippet = 'Replace', - }, - workspace = { - library = { - [vim.fn.expand('$VIMRUNTIME/lua')] = true, - [vim.fn.stdpath('config') .. '/lua'] = true, - }, - }, - }, - }, - }) - end, - ['pyright'] = function() - -- configure pyright server (with special settings) - lspconfig['pyright'].setup({ - capabilities = capabilities, - settings = { - python = { - hint = { enable = true }, - analysis = { - ignore = { '*' }, - autoImportCompletions = false, - }, - }, - -- pyright = { - -- -- Using Ruff's import organizer - -- disableOrganizeImports = true, - -- }, - }, - handlers = { - ['textDocument/publishDiagnostics'] = function() end, - }, - }) - end, - -- ['pylsp'] = function() - -- lspconfig['pylsp'].setup({ - -- capabilities = capabilities, - -- settings = { - -- pylsp = { - -- plugins = { - -- autopep8 = { - -- enabled = true, - -- }, - -- pycodestyle = { - -- enabled = true, - -- ignore = { 'E501', 'E231', 'W503' }, - -- maxLineLength = 79, - -- }, - -- pylint = { - -- enabled = true, - -- executable = 'pylint', - -- args = { - -- '--enable=W0611,W0614', - -- }, - -- }, - -- }, - -- }, - -- }, - -- }) - -- end, - ['emmet_ls'] = function() - -- configure emmet language server - lspconfig['emmet_ls'].setup({ - capabilities = capabilities, - filetypes = { - 'html', - 'javascript', - 'typescript', - 'javascriptreact', - 'typescriptreact', - 'css', - 'less', - }, - }) - end, - ['cssls'] = function() - lspconfig.cssls.setup({ - capabilities = capabilities, - settings = { - css = { - validate = true, - lint = { - unknownAtRules = 'ignore', - }, - }, - scss = { - validate = true, - lint = { - unknownAtRules = 'ignore', - }, - }, - }, - }) - end, - }, -}) diff --git a/lua/plugins/configs/whichkey.lua b/lua/plugins/configs/whichkey.lua index e277db2..2d57190 100644 --- a/lua/plugins/configs/whichkey.lua +++ b/lua/plugins/configs/whichkey.lua @@ -59,9 +59,9 @@ local n_mappings = { { 'cR', 'ReloadConfig', desc = 'Reload Configs' }, { 'cc', 'CccHighlighterToggle', desc = 'Highlight Colors' }, { 'cd', 'RootDir', desc = 'Root Directory' }, + { 'ce', ':g/^\\s*$/d', desc = 'Clean Empty Lines' }, { 'cf', group = 'Formate File' }, { 'ch', 'Hardtime toggle', desc = 'Hardtime' }, - { 'cl', ':g/^\\s*$/d', desc = 'Clean Empty Lines' }, { 'cm', 'MarkdownPreviewToggle', desc = 'Markdown Preview' }, { 'cn', 'Telescope notify', desc = 'Notifications' }, { 'co', 'Dashboard', desc = 'Dashboard' }, diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua new file mode 100644 index 0000000..d6f5842 --- /dev/null +++ b/lua/plugins/conform.lua @@ -0,0 +1,146 @@ +-- Define conform.nvim formatting servers here +local formatting_servers = { + 'prettier', + 'isort', + 'uncrustify', + 'black', + 'stylua', + 'shfmt', + 'php-cs-fixer', + 'google-java-formatter', + 'codespell', + 'autoflake', + 'djlint', +} + +return { + 'stevearc/conform.nvim', + dependencies = { 'zapling/mason-conform.nvim' }, + event = { 'BufReadPre', 'BufNewFile' }, + cmd = { 'ConformInfo' }, + keys = { + { + 'cfF', + function() + require('conform').format({ async = true, lsp_format = 'fallback' }) + end, + mode = '', + desc = 'Format Buffer', + }, + { + 'cff', + function() + if vim.b.disable_autoformat then + vim.cmd('FormatEnable!') + vim.notify('Formatting enabled') + else + vim.cmd('FormatDisable!') + vim.notify('Formatting disabled') + end + end, + mode = '', + desc = 'Toggle Format on save', + }, + }, + config = function() + local conform = require('conform') + require('mason-conform').setup({ + ensure_installed = formatting_servers, + automatic_installation = true, + }) + conform.setup({ + notify_on_error = true, + formatters_by_ft = { + cpp = { 'uncrustify' }, + c = { 'uncrustify' }, + -- Conform can also run multiple formatters sequentially + -- You can use a sub-list to tell conform to run *until* a formatter is found. + javascript = { 'eslint_d', 'prettierd', 'prettier', stop_after_first = true }, + typescript = { 'eslint_d', 'prettierd', 'prettier', stop_after_first = true }, + javascriptreact = { 'eslint_d', 'prettierd', 'prettier', stop_after_first = true }, + typescriptreact = { 'eslint_d', 'prettierd', 'prettier', stop_after_first = true }, + css = { 'prettierd', 'prettier', stop_after_first = true }, + html = { 'prettierd', 'prettier', stop_after_first = true }, + json = { 'prettierd', 'prettier', stop_after_first = true }, + yaml = { 'prettierd', 'prettier', stop_after_first = true }, + markdown = { 'prettierd', 'prettier', stop_after_first = true }, + lua = { 'stylua' }, + python = { 'isort', 'black' }, + php = { 'php-cs-fixer' }, + htmldjango = { 'djlint' }, + java = { 'google-java-formatter' }, + graphql = { 'prettierd', 'prettier', stop_after_first = true }, + liquid = { 'prettierd', 'prettier', stop_after_first = true }, + bash = { 'beautysh' }, + sh = { 'beautysh' }, + -- yaml = {'yamlfix'}, + ['*'] = { 'codespell' }, + ['_'] = { 'trim_whitespace' }, + }, + formatters = { + prettier = { + javascript = { + args = { '--single-quote' }, + }, + }, + eslint_d = { + require_cwd = true, + }, + yamlfix = { + env = { + YAMLFIX_SEQUENCE_STYLE = 'block_style', + YAMLFIX_preserve_quotes = 'true', + }, + }, + }, + -- support a global format disable + format_on_save = function(bufnr) + -- Disable with a global or buffer-local variable + if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then + return + end + -- Disable "format_on_save lsp_fallback" for languages that don't + -- have a well standardized coding style. You can add additional + -- languages here or re-enable it for the disabled ones. + local disable_filetypes = { + c = true, + cpp = true, + liquid = true, + } + local lsp_format_opt + if disable_filetypes[vim.bo[bufnr].filetype] then + lsp_format_opt = 'never' + else + lsp_format_opt = 'fallback' + end + return { + timeout_ms = 2000, + lsp_format = lsp_format_opt, + } + end, + }) + + -- From: https://github.com/stevearc/conform.nvim/blob/master/doc/recipes.md#command-to-toggle-format-on-save + vim.api.nvim_create_user_command('FormatDisable', function(args) + if args.bang then + -- FormatDisable! will disable formatting just for this buffer + vim.b.disable_autoformat = true + else + vim.g.disable_autoformat = true + end + end, { + desc = 'Disable autoformat-on-save', + bang = true, + }) + vim.api.nvim_create_user_command('FormatEnable', function(args) + if args.bang then + vim.b.disable_autoformat = false + else + vim.g.disable_autoformat = false + end + end, { + desc = 'Re-enable autoformat-on-save', + bang = true, + }) + end, +} diff --git a/lua/plugins/dap.lua b/lua/plugins/debug.lua similarity index 67% rename from lua/plugins/dap.lua rename to lua/plugins/debug.lua index c300e29..5345fd9 100644 --- a/lua/plugins/dap.lua +++ b/lua/plugins/debug.lua @@ -2,7 +2,10 @@ return { { 'mfussenegger/nvim-dap', dependencies = { + -- Creates a beautiful debugger UI 'rcarriga/nvim-dap-ui', + -- Required dependency for nvim-dap-ui + 'nvim-neotest/nvim-nio', }, cmd = { 'DapUIToggle', 'DapToggleRepl', 'DapToggleBreakpoint' }, config = function() @@ -94,27 +97,51 @@ return { end, }, } + -- local dap_utils = require 'user.plugins.configs.dap.utils' + local BASH_DEBUG_ADAPTER_BIN = vim.fn.stdpath('data') + .. '/mason/packages/bash-debug-adapter/bash-debug-adapter' + local BASHDB_DIR = vim.fn.stdpath('data') .. '/mason/packages/bash-debug-adapter/extension/bashdb_dir' - -- dap.adapters.ruby = { - -- type = 'executable', - -- command = 'bundle', - -- args = { 'exec', 'readapt', 'stdio' }, - -- } - - -- dap.configurations.ruby = { - -- { - -- type = 'ruby', - -- request = 'launch', - -- name = 'Rails', - -- program = 'bundle', - -- programArgs = { 'exec', 'rails', 's' }, - -- useBundler = true, - -- }, - -- } + dap.adapters.sh = { + type = 'executable', + command = BASH_DEBUG_ADAPTER_BIN, + } + dap.configurations.sh = { + { + name = 'Launch Bash debugger', + type = 'sh', + request = 'launch', + program = '${file}', + cwd = '${fileDirname}', + pathBashdb = BASHDB_DIR .. '/bashdb', + pathBashdbLib = BASHDB_DIR, + pathBash = 'bash', + pathCat = 'cat', + pathMkfifo = 'mkfifo', + pathPkill = 'pkill', + env = {}, + args = {}, + -- showDebugOutput = true, + -- trace = true, + }, + } vim.api.nvim_create_user_command('DapUIToggle', function() require('dapui').toggle() end, {}) end, }, + { + 'mfussenegger/nvim-dap-python', + ft = 'python', + dependencies = { + 'mfussenegger/nvim-dap', + 'rcarriga/nvim-dap-ui', + 'nvim-neotest/nvim-nio', + }, + config = function(_, _) + local path = '~/.local/share/nvim/mason/packages/debugpy/venv/bin/python' + require('dap-python').setup(path) + end, + }, } diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua index fc016ec..22ee424 100644 --- a/lua/plugins/editor.lua +++ b/lua/plugins/editor.lua @@ -30,6 +30,7 @@ return { }, { 'folke/flash.nvim', + enabled = false, keys = { { 's', @@ -71,7 +72,13 @@ return { lazy = true, dependencies = { { 'nvim-tree/nvim-web-devicons' }, - { 'nvim-telescope/telescope-fzf-native.nvim', build = 'zig' }, + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'make', + cond = function() + return vim.fn.executable('make') == 1 + end, + }, { 'nvim-telescope/telescope-ui-select.nvim' }, { 'nvim-telescope/telescope-symbols.nvim' }, { 'nvim-telescope/telescope-file-browser.nvim' }, diff --git a/lua/plugins/extra.lua b/lua/plugins/extra.lua index b3040cc..bc239c7 100644 --- a/lua/plugins/extra.lua +++ b/lua/plugins/extra.lua @@ -6,6 +6,60 @@ return { require('leap').add_default_mappings() end, }, + { + 'cvigilv/esqueleto.nvim', + event = 'VeryLazy', + opts = { + directories = { + vim.fn.stdpath('config') .. '/templates', + }, + patterns = { + -- File + 'README', + 'LICENSE', + -- Filetype + 'sh', + 'markdown', + 'python', + 'lua', + 'html', + 'vue', + }, + }, + }, + { + 'kawre/leetcode.nvim', + cmd = 'Leet', + build = ':TSUpdate html', + dependencies = { + 'nvim-telescope/telescope.nvim', + 'nvim-lua/plenary.nvim', -- required by telescope + 'MunifTanjim/nui.nvim', + + -- optional + 'nvim-treesitter/nvim-treesitter', + 'rcarriga/nvim-notify', + 'nvim-tree/nvim-web-devicons', + }, + opts = {}, + }, + { + 'epwalsh/pomo.nvim', + cmd = { 'TimerStart', 'TimerStop', 'TimerRepeat' }, + dependencies = { + 'rcarriga/nvim-notify', + }, + opts = { + notifiers = { + { + name = 'Default', + opts = { + sticky = false, + }, + }, + }, + }, + }, { 'ThePrimeagen/refactoring.nvim', config = function() diff --git a/lua/plugins/formater.lua b/lua/plugins/formater.lua deleted file mode 100644 index 699c547..0000000 --- a/lua/plugins/formater.lua +++ /dev/null @@ -1,106 +0,0 @@ --- Define conform.nvim formatting servers here -local formatting_servers = { - 'prettier', - 'isort', - 'clang-format', - 'black', - 'stylua', - 'shfmt', - 'php-cs-fixer', - 'google-java-formatter', - 'codespell', - 'autoflake', - 'djlint', -} - -return { - 'stevearc/conform.nvim', - dependencies = { 'zapling/mason-conform.nvim' }, - event = { 'BufReadPre', 'BufNewFile' }, - cmd = { 'ConformInfo' }, - config = function() - local conform = require('conform') - require('mason-conform').setup({ - ensure_installed = formatting_servers, - automatic_installation = true, - }) - conform.setup({ - formatters_by_ft = { - cpp = { 'clang-format' }, - c = { 'clang-format' }, - javascript = { 'prettier' }, - typescript = { 'prettier' }, - javascriptreact = { 'prettier' }, - typescriptreact = { 'prettier' }, - css = { 'prettier' }, - html = { 'prettier' }, - json = { 'prettier' }, - yaml = { 'prettier' }, - markdown = { 'prettier', 'markdownlint' }, - lua = { 'stylua' }, - python = { 'isort', 'black' }, - php = { 'php-cs-fixer' }, - htmldjango = { 'djlint' }, - java = { 'google-java-formatter' }, - graphql = { 'prettier' }, - liquid = { 'prettier' }, - bash = { 'shfmt' }, - sh = { 'shfmt' }, - ['*'] = { 'codespell' }, - ['_'] = { 'trim_whitespace' }, - }, - formatters = { - prettier = { - javascript = { - args = { '--single-quote' }, - }, - }, - isort = { - python = { - args = { '--profile', 'black' }, - }, - }, - black = { - python = { - args = { '--fast', '--line-length', '80' }, - }, - }, - }, - format_on_save = function(bufnr) - -- Disable with a global or buffer-local variable - if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then - return - end - return { - lsp_fallback = true, - async = false, - timeout_ms = 2500, - } - end, - }) - - vim.keymap.set({ 'n', 'v' }, 'cff', function() - conform.format({ - lsp_fallback = true, - async = true, - timeout_ms = 2500, - }) - end, { desc = 'Format file or range (in visual mode)' }) - - vim.keymap.set({ 'n' }, 'cfb', function() - vim.b.disable_autoformat = not vim.b.disable_autoformat - vim.notify( - 'Buffer auto-format on-save: ' .. (vim.b.disable_autoformat and 'OFF' or 'ON'), - vim.log.levels.INFO - ) - end, { desc = 'Toggle auto-format on-save for buffer.' }) - - vim.keymap.set({ 'n' }, 'cft', function() - vim.g.disable_autoformat = not vim.g.disable_autoformat - vim.notify( - 'Global auto-format on-save: ' .. (vim.g.disable_autoformat and 'OFF' or 'ON'), - vim.log.levels.INFO - ) - end, { desc = 'Toggle auto-format on-save globally.' }) - end, -} diff --git a/lua/plugins/lint.lua b/lua/plugins/lint.lua index 4cfd8a6..9b1f46e 100644 --- a/lua/plugins/lint.lua +++ b/lua/plugins/lint.lua @@ -2,12 +2,13 @@ local linting_servers = { 'eslint_d', 'cspell', - 'ruff', - 'mypy', + -- 'ruff', + -- 'mypy', 'trivy', 'phpcs', 'markdownlint', 'pylint', + -- 'shellcheck', } return { @@ -25,27 +26,80 @@ return { }) lint.linters_by_ft = { - -- lua = { 'selene' }, + lua = { 'selene' }, javascript = { 'eslint_d' }, typescript = { 'eslint_d' }, javascriptreact = { 'eslint_d' }, typescriptreact = { 'eslint_d' }, - python = { 'ruff', 'mypy' }, + python = { 'pylint' }, markdown = { 'markdownlint' }, java = { 'trivy' }, php = { 'phpcs' }, + -- bash = { 'shellcheck' }, } + -- Run pylint in the venv + -- https://gist.github.com/Norbiox/652befc91ca0f90014aec34eccee27b2 + lint.linters.pylint.cmd = 'python' + lint.linters.pylint.args = { + '-m', + 'pylint', + '-f', + 'json', + '--from-stdin', + function() + return vim.api.nvim_buf_get_name(0) + end, + } + -- To allow other plugins to add linters to require('lint').linters_by_ft, + -- instead set linters_by_ft like this: + -- lint.linters_by_ft = lint.linters_by_ft or {} + -- lint.linters_by_ft['markdown'] = { 'markdownlint' } + -- + -- However, note that this will enable a set of default linters, + -- which will cause errors unless these tools are available: + -- { + -- clojure = { "clj-kondo" }, + -- dockerfile = { "hadolint" }, + -- inko = { "inko" }, + -- janet = { "janet" }, + -- json = { "jsonlint" }, + -- markdown = { "vale" }, + -- rst = { "vale" }, + -- ruby = { "ruby" }, + -- terraform = { "tflint" }, + -- text = { "vale" } + -- } + -- + -- You can disable the default linters by setting their filetypes to nil: + -- lint.linters_by_ft['clojure'] = nil + -- lint.linters_by_ft['dockerfile'] = nil + -- lint.linters_by_ft['inko'] = nil + -- lint.linters_by_ft['janet'] = nil + -- lint.linters_by_ft['json'] = nil + -- lint.linters_by_ft['markdown'] = nil + -- lint.linters_by_ft['rst'] = nil + -- lint.linters_by_ft['ruby'] = nil + -- lint.linters_by_ft['terraform'] = nil + -- lint.linters_by_ft['text'] = nil + local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true }) vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { group = lint_augroup, callback = function() - lint.try_lint() + if not vim.g.disable_linting then + if not vim.b.disable_linting then + lint.try_lint() + end + end end, }) + vim.keymap.set('n', 'cl', function() + vim.b.disable_linting = not (vim.b.disable_linting == true) + end, { desc = 'Toggle linting for file' }) vim.keymap.set('n', 'cL', function() - lint.try_lint() - end, { desc = 'Trigger linting for current file' }) + vim.g.disable_linting = not (vim.g.disable_linting == true) + end, { desc = 'Toggle linting for all files' }) end, } diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 40dc7c7..1aa8309 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,19 +1,7 @@ return { - { - 'neovim/nvim-lspconfig', - event = { 'BufReadPost', 'BufNewFile', 'BufWritePre' }, - dependencies = { - 'hrsh7th/cmp-nvim-lsp', - { 'antosha417/nvim-lsp-file-operations', config = true }, - 'williamboman/mason-lspconfig.nvim', - }, - config = function() - require('plugins.configs.lsp') - end, - }, { 'williamboman/mason.nvim', - cmd = { 'Mason', 'MasonInstall', 'MasonInstallAll', 'MasonUpdate' }, + cmd = { 'Mason', 'MasonInstall', 'MasonUninstall', 'MasonInstallAll', 'MasonUpdate' }, config = function() -- import mason local mason = require('mason') @@ -30,4 +18,364 @@ return { }) end, }, + { + -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins + -- used for completion, annotations and signatures of Neovim apis + 'folke/lazydev.nvim', + ft = 'lua', + opts = { + library = { + -- Load luvit types when the `vim.uv` word is found + { path = 'luvit-meta/library', words = { 'vim%.uv' } }, + }, + }, + }, + { 'Bilal2453/luvit-meta', lazy = true }, + { + -- Main LSP Configuration + 'neovim/nvim-lspconfig', + event = { 'BufReadPre', 'BufNewFile' }, + dependencies = { + -- Automatically install LSPs and related tools to stdpath for Neovim + 'williamboman/mason.nvim', + 'williamboman/mason-lspconfig.nvim', + + -- Useful status updates for LSP. + -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` + { 'j-hui/fidget.nvim', opts = {} }, + + -- Allows extra capabilities provided by nvim-cmp + 'hrsh7th/cmp-nvim-lsp', + }, + config = function() + -- Brief aside: **What is LSP?** + -- + -- LSP is an initialism you've probably heard, but might not understand what it is. + -- + -- LSP stands for Language Server Protocol. It's a protocol that helps editors + -- and language tooling communicate in a standardized fashion. + -- + -- In general, you have a "server" which is some tool built to understand a particular + -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers + -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone + -- processes that communicate with some "client" - in this case, Neovim! + -- + -- LSP provides Neovim with features like: + -- - Go to definition + -- - Find references + -- - Autocompletion + -- - Symbol Search + -- - and more! + -- + -- Thus, Language Servers are external tools that must be installed separately from + -- Neovim. This is where `mason` and related plugins come into play. + -- + -- If you're wondering about lsp vs treesitter, you can check out the wonderfully + -- and elegantly composed help section, `:help lsp-vs-treesitter` + + -- This function gets run when an LSP attaches to a particular buffer. + -- That is to say, every time a new file is opened that is associated with + -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this + -- function will be executed to configure the current buffer + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), + callback = function(event) + -- NOTE: Remember that Lua is a real programming language, and as such it is possible + -- to define small helper and utility functions so you don't have to repeat yourself. + -- + -- In this case, we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + local map = function(keys, func, desc, mode) + mode = mode or 'n' + vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) + end + + -- Jump to the definition of the word under your cursor. + -- This is where a variable was first declared, or where a function is defined, etc. + -- To jump back, press . + map('gd', function() + require('telescope.builtin').lsp_definitions() + end, 'Goto definition') + + -- Find references for the word under your cursor. + map('gr', function() + require('telescope.builtin').lsp_references() + end, 'Goto references') + + -- Jump to the implementation of the word under your cursor. + -- Useful when your language has ways of declaring types without an actual implementation. + map('gI', function() + require('telescope.builtin').lsp_implementations() + end, 'Goto implementation') + + -- Jump to the type of the word under your cursor. + -- Useful when you're not sure what type a variable is and you want to see + -- the definition of its *type*, not where it was *defined*. + map('cD', function() + require('telescope.builtin').lsp_type_definitions() + end, 'Code Type definition') + + -- Fuzzy find all the symbols in your current document. + -- Symbols are things like variables, functions, types, etc. + map('ss', function() + require('telescope.builtin').lsp_document_symbols() + end, 'Document symbols') + + -- Fuzzy find all the symbols in your current workspace. + -- Similar to document symbols, except searches over your entire project. + map('sS', function() + require('telescope.builtin').lsp_dynamic_workspace_symbols() + end, 'Workspace symbols') + + -- Rename the variable under your cursor. + -- Most Language Servers support renaming across files, etc. + map('cR', vim.lsp.buf.rename, 'Code: rename') + + -- Execute a code action, usually your cursor needs to be on top of an error + -- or a suggestion from your LSP for this to activate. + -- map('ca', vim.lsp.buf.code_action, 'Code action') + map('ca', vim.lsp.buf.code_action, 'Code action', { 'n', 'x' }) + -- map('ca', function() require('tiny-code-action').code_action() end, 'Code action', { 'n', 'x' }) + + map('vR', 'LspRestart', 'Restart LSP') + + -- Opens a popup that displays documentation about the word under your cursor + -- See `:help K` for why this keymap. + map('K', vim.lsp.buf.hover, 'Hover Documentation') + + -- WARN: This is not Goto Definition, this is Goto Declaration. + -- For example, in C this would take you to the header. + map('gD', vim.lsp.buf.declaration, 'Goto declaration') + + -- The following two autocommands are used to highlight references of the + -- word under your cursor when your cursor rests there for a little while. + -- See `:help CursorHold` for information about when this is executed + -- + -- When you move your cursor, the highlights will be cleared (the second autocommand). + local client = vim.lsp.get_client_by_id(event.data.client_id) + if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then + local highlight_augroup = + vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) + vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.document_highlight, + }) + + vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.clear_references, + }) + + vim.api.nvim_create_autocmd('LspDetach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), + callback = function(event2) + vim.lsp.buf.clear_references() + vim.api.nvim_clear_autocmds({ group = 'kickstart-lsp-highlight', buffer = event2.buf }) + end, + }) + end + + -- The following code creates a keymap to toggle inlay hints in your + -- code, if the language server you are using supports them + -- + -- This may be unwanted, since they displace some of your code + if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then + map('vH', function() + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf })) + end, 'Toggle inlay hints') + vim.lsp.inlay_hint.enable() + end + end, + }) + + -- LSP servers and clients are able to communicate to each other what features they support. + -- By default, Neovim doesn't support everything that is in the LSP specification. + -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. + -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers. + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) + + -- Change the Diagnostic symbols in the sign column (gutter) + -- local signs = { Error = '󰅚 ', Warn = '󰀪 ', Info = ' ', Hint = '󰌶 ' } + local signs = { Error = ' ', Warn = ' ', Info = ' ', Hint = '' } + for type, icon in pairs(signs) do + local hl = 'DiagnosticSign' .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' }) + end + + -- Change border of documentation hover window, See https://github.com/neovim/neovim/pull/13998. + vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { + border = 'rounded', + }) + + -- Enable the following language servers + -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. + -- + -- Add any additional override configuration in the following tables. Available keys are: + -- - cmd (table): Override the default command used to start the server + -- - filetypes (table): Override the default list of associated filetypes for the server + -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. + -- - settings (table): Override the default settings passed when initializing the server. + -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ + + local servers = { + -- clangd = {}, + -- gopls = {}, + -- pyright = {}, + -- rust_analyzer = {}, + -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs + -- + -- Some languages (like typescript) have entire language plugins that can be useful: + -- https://github.com/pmizio/typescript-tools.nvim + -- + -- But for many setups, the LSP (`tsserver`) will work just fine + -- tsserver = {}, + -- + + lua_ls = { + -- cmd = {...}, + -- filetypes = { ...}, + -- capabilities = {}, + settings = { + Lua = { + workspace = { + checkThirdParty = false, + }, + completion = { + callSnippet = 'Replace', + }, + codeLens = { + enable = true, + }, + doc = { + privateName = { '^_' }, + }, + hint = { + enable = true, + setType = false, + paramType = true, + paramName = 'Disable', + semicolon = 'Disable', + arrayIndex = 'Disable', + }, + -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings + -- diagnostics = { disable = { 'missing-fields' } }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { + 'vim', + 'it', + 'describe', + 'before_each', + 'after_each', + }, + }, + }, + }, + }, + + -- Bash + bashls = { + filetypes = { 'sh', 'bash' }, + }, + + -- HTML / CSS + html = {}, + cssls = {}, + tailwindcss = {}, + + -- Javascript/Typescript + ts_ls = {}, + + -- Java + jdtls = {}, + + -- Python + pyright = {}, + ruff = {}, + + -- C/C++ + clangd = {}, + + -- Ruby for Shopify + -- ruby_lsp = { + -- init_options = { + -- formatter = 'standard', + -- linters = { 'standard' }, + -- }, + -- }, + + rust_analyzer = { + cargo = { + allFeatures = true, + loadOutDirsFromCheck = true, + buildScripts = { + enable = true, + }, + }, + -- Add clippy lints for Rust. + checkOnSave = true, + procMacro = { + enable = true, + ignored = { + ['async-trait'] = { 'async_trait' }, + ['napi-derive'] = { 'napi' }, + ['async-recursion'] = { 'async_recursion' }, + }, + }, + }, + + -- TOML + taplo = {}, + + -- Shopify + -- theme_check = {}, + + -- Typo is too noisy for me without a simple way to override + -- typos_lsp = {}, + + -- YAML + yamlls = {}, + } + + -- Ensure the servers and tools above are installed + -- To check the current status of installed tools and/or manually install + -- other tools, you can run + -- :Mason + -- + -- You can press `g?` for help in this menu. + + -- You can add other tools here that you want Mason to install + -- for you, so that they are available from within Neovim. + local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { + 'pyright', -- Used to format Lua code + }) + + if not vim.g.no_mason_autoinstall then + require('mason-lspconfig').setup({ ensure_installed = ensure_installed }) + end + + require('mason-lspconfig').setup({ + handlers = { + function(server_name) + -- https://github.com/neovim/nvim-lspconfig/pull/3232#issuecomment-2331025714 + -- if server_name == 'tsserver' then server_name = 'ts_ls' end + + local server = servers[server_name] or {} + -- This handles overriding only values explicitly passed + -- by the server configuration above. Useful when disabling + -- certain features of an LSP (for example, turning off formatting for tsserver) + server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) + require('lspconfig')[server_name].setup(server) + end, + }, + }) + + -- Border for LSPInfo + require('lspconfig.ui.windows').default_options.border = 'single' + end, + }, } diff --git a/lua/plugins/mini.lua b/lua/plugins/mini.lua index 1e162c6..497a0df 100644 --- a/lua/plugins/mini.lua +++ b/lua/plugins/mini.lua @@ -1,82 +1,104 @@ return { - { - "echasnovski/mini.nvim", - event = { "BufReadPost", "BufAdd", "BufNewFile" }, - version = false, - config = function() - require("mini.comment").setup({}) - require("mini.ai").setup({}) - require("mini.cursorword").setup() - require("mini.bracketed").setup({ - file = { suffix = "" }, - window = { suffix = "" }, - quickfix = { suffix = "" }, - yank = { suffix = "" }, - treesitter = { suffix = "n" }, - }) - require("mini.surround").setup({ - mappings = { - add = "gsa", -- Add surrounding in Normal and Visual modes - delete = "gsd", -- Delete surrounding - replace = "gsr", -- Replace surrounding - find = "gsf", -- Find surrounding (to the right) - find_left = "gsF", -- Find surrounding (to the left) - highlight = "gsh", -- Highlight surrounding - update_n_lines = "gsn", -- Update `n_lines` - }, - keys = { - { "gz", "", desc = "+surround" }, - }, - }) - require("mini.pairs").setup({ - -- odes = { command = true }, - -- mappings = { - -- ['<'] = { action = 'open', pair = '<>', neigh_pattern = '[^\\].' }, - -- ['>'] = { action = 'close', pair = '<>', neigh_pattern = '[^\\].' }, - -- }, - }) - require("mini.move").setup({ - keys = { - { "", mode = { "n", "v" } }, - { "", mode = { "n", "v" } }, - { "", mode = { "n", "v" } }, - { "", mode = { "n", "v" } }, - }, + { + 'echasnovski/mini.nvim', + event = 'VeryLazy', + -- event = { "BufReadPost", "BufAdd", "BufNewFile" }, + version = false, + config = function() + require('mini.comment').setup({}) + require('mini.ai').setup({}) + require('mini.cursorword').setup() + require('mini.bracketed').setup({ + file = { suffix = '' }, + window = { suffix = '' }, + quickfix = { suffix = '' }, + yank = { suffix = '' }, + treesitter = { suffix = 'n' }, + }) + local ai = require('mini.ai') + ai.setup({ + n_lines = 500, + custom_textobjects = { + s = ai.gen_spec.treesitter({ -- code block + a = { '@block.outer', '@conditional.outer', '@loop.outer' }, + i = { '@block.inner', '@conditional.inner', '@loop.inner' }, + }), + f = ai.gen_spec.treesitter({ a = '@function.outer', i = '@function.inner' }), -- function + i = require('mini.extra').gen_ai_spec.indent(), + g = require('mini.extra').gen_ai_spec.buffer(), + }, + }) + require('mini.surround').setup({ + mappings = { + add = 'gsa', -- Add surrounding in Normal and Visual modes + delete = 'gsd', -- Delete surrounding + replace = 'gsr', -- Replace surrounding + find = 'gsf', -- Find surrounding (to the right) + find_left = 'gsF', -- Find surrounding (to the left) + highlight = 'gsh', -- Highlight surrounding + update_n_lines = 'gsn', -- Update `n_lines` + }, + keys = { + { 'gz', '', desc = '+surround' }, + }, + }) + require('mini.pairs').setup({ + -- odes = { command = true }, + -- mappings = { + -- ['<'] = { action = 'open', pair = '<>', neigh_pattern = '[^\\].' }, + -- ['>'] = { action = 'close', pair = '<>', neigh_pattern = '[^\\].' }, + -- }, + mappings = { + ['('] = { action = 'open', pair = '()', neigh_pattern = '[^\\][%s)}%]]' }, + ['['] = { action = 'open', pair = '[]', neigh_pattern = '[^\\][%s)}%]]' }, + ['{'] = { action = 'open', pair = '{}', neigh_pattern = '[^\\][%s)}%]]' }, + ['`'] = { neigh_pattern = '[^%a%d\\%-`][%s)}%]]' }, + ['"'] = { neigh_pattern = '[^%a%d\\%-"][%s)}%]]' }, + ["'"] = { neigh_pattern = "[^%a%d\\%-'][%s)}%]]" }, + }, + }) + require('mini.move').setup({ + keys = { + { '', mode = { 'n', 'v' } }, + { '', mode = { 'n', 'v' } }, + { '', mode = { 'n', 'v' } }, + { '', mode = { 'n', 'v' } }, + }, - mappings = { - left = "", - line_left = "", - right = "", - line_right = "", - down = "", - line_down = "", - up = "", - line_up = "", - }, - }) - end, - }, - { - "echasnovski/mini.files", - version = false, - keys = { - { "-", "lua require('mini.files').open(vim.api.nvim_buf_get_name(0))", { silent = true } }, - }, - }, - { - "echasnovski/mini.icons", - opts = {}, - lazy = true, - specs = { - { "nvim-tree/nvim-web-devicons", enabled = false, optional = true }, - }, - init = function() - package.preload["nvim-web-devicons"] = function() - -- needed since it will be false when loading and mini will fail - package.loaded["nvim-web-devicons"] = {} - require("mini.icons").mock_nvim_web_devicons() - return package.loaded["nvim-web-devicons"] - end - end, - }, + mappings = { + left = '', + line_left = '', + right = '', + line_right = '', + down = '', + line_down = '', + up = '', + line_up = '', + }, + }) + end, + }, + { + 'echasnovski/mini.files', + version = false, + keys = { + { '-', "lua require('mini.files').open(vim.api.nvim_buf_get_name(0))", { silent = true } }, + }, + }, + { + 'echasnovski/mini.icons', + opts = {}, + lazy = true, + specs = { + { 'nvim-tree/nvim-web-devicons', enabled = false, optional = true }, + }, + init = function() + package.preload['nvim-web-devicons'] = function() + -- needed since it will be false when loading and mini will fail + package.loaded['nvim-web-devicons'] = {} + require('mini.icons').mock_nvim_web_devicons() + return package.loaded['nvim-web-devicons'] + end + end, + }, } diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index e5613b8..8b6ab50 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -3,20 +3,18 @@ return { { 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', - event = 'FileType', + event = 'VeryLazy', cmd = { 'TSInstall', 'TSBufEnable', 'TSBufDisable', 'TSModuleInfo' }, dependencies = { 'nvim-treesitter/nvim-treesitter-textobjects', - { 'windwp/nvim-ts-autotag', event = { 'BufReadPost', 'BufNewFile', 'BufWritePre' } }, + { 'windwp/nvim-ts-autotag', ft = { 'html', 'xml', 'tsx' }, opts = {} }, }, config = function() require('nvim-ts-autotag').setup() require('nvim-treesitter.configs').setup({ - highlight = { - enable = true, - }, indent = { enable = true, + disable = { 'ruby' }, }, ensure_installed = { 'vim', @@ -25,21 +23,58 @@ return { 'markdown_inline', 'bash', 'c', - 'cpp', 'java', 'javascript', 'typescript', 'tsx', 'json', - 'toml', 'html', 'css', 'scss', 'lua', + 'luadoc', + 'diff', + 'gitcommit', 'python', 'liquid', }, auto_install = true, + highlight = { + enable = true, + disable = function(_, buf) + local line_count = vim.api.nvim_buf_line_count(buf) + local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + + -- vim.notify('stats: ' .. vim.inspect(stats)) + + -- if file is at least 10k and the average bytes per line is > 250, then disable treesitter + if ok and stats and (stats.size > (10 * 1024)) and (stats.size / line_count) > 250 then + vim.notify( + 'Disabling treesitter, bytes: ' + .. stats.size + .. ', lines: ' + .. line_count + .. ', bytes / lines: ' + .. math.floor(stats.size / line_count) + ) + return true + end + return false + end, + -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. + -- If you are experiencing weird indenting issues, add the language to + -- the list of additional_vim_regex_highlighting and disabled languages for indent. + additional_vim_regex_highlighting = { 'ruby' }, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + scope_incremental = false, + node_decremental = '', + }, + }, playground = { enable = true, disable = {}, @@ -55,6 +90,19 @@ return { ['ic'] = { query = '@class.inner', desc = 'Select inner part of a class region' }, }, }, + move = { + enable = true, + -- don't include classes to not conflict with conflicts in a diff + -- (LazyVim has some clever code but i don't think we need it right now) + -- goto_next_start = { [']f'] = '@function.outer', [']c'] = '@class.outer', [']a'] = '@parameter.inner' }, + -- goto_next_end = { [']F'] = '@function.outer', [']C'] = '@class.outer', [']A'] = '@parameter.inner' }, + -- goto_previous_start = { ['[f'] = '@function.outer', ['[c'] = '@class.outer', ['[a'] = '@parameter.inner' }, + -- goto_previous_end = { ['[F'] = '@function.outer', ['[C'] = '@class.outer', ['[A'] = '@parameter.inner' }, + goto_next_start = { [']f'] = '@function.outer', [']a'] = '@parameter.inner' }, + goto_next_end = { [']F'] = '@function.outer', [']A'] = '@parameter.inner' }, + goto_previous_start = { ['[f'] = '@function.outer', ['[a'] = '@parameter.inner' }, + goto_previous_end = { ['[F'] = '@function.outer', ['[A'] = '@parameter.inner' }, + }, swap = { enable = true, swap_next = { diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua index 74b6ca5..c231f3c 100644 --- a/lua/plugins/ui.lua +++ b/lua/plugins/ui.lua @@ -144,6 +144,7 @@ return { }) end, }, + {}, { 'nvim-lualine/lualine.nvim', event = { 'BufReadPost', 'BufNewFile' }, diff --git a/selene.toml b/selene.toml new file mode 100644 index 0000000..eac3e9b --- /dev/null +++ b/selene.toml @@ -0,0 +1,4 @@ +std = "vim" + +[lints] +mixed_table = "allow" diff --git a/snippets/c.json b/snippets/c.json new file mode 100644 index 0000000..96cbe4e --- /dev/null +++ b/snippets/c.json @@ -0,0 +1,360 @@ +{ + "for": { + "prefix": "for", + "body": [ + "for (${1:size_t} ${2:i} = ${3:0}; $2 < ${4:length}; $2++) {", + "\t$0", + "}" + ], + "description": "Code snippet for 'for' loop" + }, + "_FOREACH": { + "prefix": "_FOREACH", + "body": [ + "#define foreach(item, array) \\", + "\tfor(int keep = 1, \\", + "\tcount = 0,\\", + "\tsize = sizeof (array) / sizeof *(array); \\", + "\tkeep && count != size; \\", + "\tkeep = !keep, count++) \\", + "\tfor(item = (array) + count; keep; keep = !keep)" + ], + "description": "foreach loop C" + }, + "*": { + "prefix": "*", + "body": ["/* $0 */"], + "description": "Block comment" + }, + "glfw330win": { + "prefix": "glfw330win", + "body": [ + "if (!glfwInit()) {", + "log_warn(\"GLFW failed\");", + "glfwTerminate();", + "return 1;", + "}", + "glfwWindowHint(GLFW_SAMPLES, 4);", + "glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);", + "glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);", + "glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);" + ], + "description": "Glfw window hint for opengl v3.3" + }, + "gl_vertex_arr": { + "prefix": "gl_vertex_arr", + "body": [ + "glGenVertexArrays(${1:size}, &$2);", + "glBindVertexArray($2);" + ], + "description": "GL generate vertex array" + }, + "gl_vertex_buffer": { + "prefix": "gl_vertex_buffer", + "body": [ + "glGenBuffers(${1:1}, &$2);", + "glBindBuffer(${3:buffer_type}, $2);", + "glBufferData($3, sizeof($4), $4, $5)" + ], + "description": "gl generate buffer" + }, + "DBG": { + "prefix": "DBG", + "body": ["#define WHERE fprintf(stderr,\"[LOG]%s:%d\\n\",__FILE__,__LINE__);"], + "description": "Debug code line" + }, + "forr": { + "prefix": "forr", + "body": [ + "for (${1:size_t} ${2:i} = ${3:length} - 1; $2 >= ${4:0}; $2--) {", + "\t$0", + "}" + ], + "description": "Code snippet for reverse 'for' loop" + }, + "mod": { + "prefix": "_MOD", + "body": ["#define MOD(N,M)\t((N)%(M) < 0 ? (N)%(M) + (M) : (N)%(M))\n"], + "description": "mod of N,M" + }, + "between": { + "prefix": "_BETWEEN", + "body": ["#define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b))\n"], + "description": "x is between a, b" + }, + "length" : { + "prefix": "_LENGTH", + "body": ["#define LENGTH(x) sizeof(x)/sizeof(x[0])\n"], + "description": "Array size macro" + }, + "max" : { + "prefix": "_MAX", + "body": ["#define MAX(x,y) (x) > (y) ? (x) : (y)","$0"], + "description": "Get max element" + }, + "min" : { + "prefix": "_MIN", + "body": ["#define MIN(x,y) (x) < (y) ? (x) : (y)","$0"], + "description": "Get min element" + }, + "getbit": { + "prefix": "_GETBIT", + "body": ["#define GETBIT(x,i) (x&(1<"], + "description": "Code snippet for #include < >" + }, + "#def": { + "prefix": "def", + "body": ["#define $0"], + "description": "Code snippet for #define \" \"" + }, + "Main function template": { + "prefix": "main", + "body": [ + "int main (int argc, char *argv[])", + "{", + "\t$0", + "\treturn 0;", + "}" + ], + "description": "A standard main function for a C program" + }, + "Standard Starter Template": { + "prefix": "sst", + "body": [ + "#include ", + "", + "int main ()", + "{", + "\t$0", + "\treturn 0;", + "}" + ], + "description": "A standard starter template for a C program" + }, + "Stdlib Variant Starter Template": { + "prefix": "libsst", + "body": [ + "#include ", + "#include ", + "", + "int main (int argc, char *argv[])", + "{", + "\t$0", + "\treturn 0;", + "}" + ], + "description": "A standard starter template for a C program with stdlib included" + }, + "Create linked list": { + "prefix": "clist", + "body": [ + "typedef struct _node * Link;", + "typedef struct _node node;", + "struct _node {", + "\tint value;", + "\tLink next;", + "};" + ], + "description": "Creates a linked list template" + }, + "Scan integer": { + "prefix": "sci", + "body": ["scanf(\"%d\", &$1);"], + "description": "Scan int" + }, + "Scan 2 integer": { + "prefix": "sci2", + "body": ["scanf(\"%d %d\", &$1, &$2);"], + "description": "Scan 2 int" + }, + "Scan unsigned integer": { + "prefix": "scui", + "body": ["scanf(\"%d\", &$1);"], + "description": "Scan unsigned int" + }, + "Scan float": { + "prefix": "scf", + "body": ["scanf(\"%f\", &$1);"], + "description": "Scan float" + }, + "Scan 2 float": { + "prefix": "scf2", + "body": ["scanf(\"%f %f\", &$1, &$2);"], + "description": "Scan 2 float" + }, + "Scan long": { + "prefix": "scl", + "body": ["scanf(\"%ld\", &$1);"], + "description": "Scan long" + }, + "Scan 2 long": { + "prefix": "scl2", + "body": ["scanf(\"%ld %ld\", &$1, &$2);"], + "description": "Scan 2 long" + }, + "Scan unsigned long": { + "prefix": "scul", + "body": ["scanf(\"%lu\", &$1);"], + "description": "Scan unsigned long" + }, + "Scan unsigned long long": { + "prefix": "scull", + "body": ["scanf(\"%llu\", &$1);"], + "description": "Scan unsigned long long" + }, + "Print variable of type float (2 decimal places)": { + "prefix": "pflo", + "body": ["printf(\"$1 :>> %.2f\\n\", $1);"], + "description": "Calls printf() to log value of variable of type float rounded to 2 decimal places" + }, + "Print variable of type integer": { + "prefix": "pint", + "body": ["printf(\"$1 : %d\\n\", $1);"], + "description": "Calls printf() to log value of variable of type signed integer" + }, + "Print variable of type char": { + "prefix": "pcha", + "body": ["printf(\"$1 : %c\\n\", $1);"], + "description": "Calls printf() to log value of variable of type char" + }, + "Print variable of type pointer": { + "prefix": "ppoint", + "body": ["printf(\"$1 : %p\\n\", (void *) $1);"], + "description": "Calls printf() to log value of variable of type pointer" + }, + "Print variable of type size_t": { + "prefix": "psiz", + "body": ["printf(\"$1 : %zu\\n\", $1);"], + "description": "Calls printf() to log value of variable of type size_t" + }, + "printf": { + "prefix": "printf", + "body": ["printf(\"$1\\n\"$0);"], + "description": "Generic printf() snippet" + }, + "sprintf": { + "prefix": "sprintf", + "body": ["sprintf($1, \"$2\\n\"$0);"], + "description": "Generic sprintf() snippet" + }, + "fprintf": { + "prefix": "fprintf", + "body": ["fprintf(${1:stderr}, \"$2\\n\"$0);"], + "description": "Generic fprintf() snippet" + }, + "scanf": { + "prefix": "scanf", + "body": ["scanf(\"$1\"$0);"], + "description": "Generic scanf() snippet" + }, + "sscanf": { + "prefix": "sscanf", + "body": ["sscanf($1, \"$2\"$0);"], + "description": "Generic sscanf() snippet" + }, + "fscanf": { + "prefix": "fscanf", + "body": ["fscanf($1, \"$2\"$0);"], + "description": "Generic fscanf() snippet" + }, + "Allocate memory using malloc": { + "prefix": "mal", + "body": [ + "${1:int} *${2:v} = malloc(${3:1} * sizeof($1));", + "", + "if (!$2) {", + "\tfprintf(stderr, \"Memory allocation failed!\\n\");", + "\t$4;", + "}", + "$0", + "free($2);" + ], + "description": "Allocates memory to a pointer variable using malloc(), then deallocates using free()." + }, + "Allocate memory using calloc": { + "prefix": "cal", + "body": [ + "${1:int} *${2:v} = calloc(${3:1}, sizeof($1));", + "", + "if (!$2) {", + "\tfprintf(stderr, \"Memory allocation failed!\\n\");", + "\t$4;", + "}", + "$0", + "free($2);" + ], + "description": "Allocates memory to a pointer variable using calloc(), then deallocates using free()." + }, + "X11 default incs": { + "prefix": "_X11", + "body": ["#include \n#include \n#include \n#include \n"], + "description": "X11 default library headers" + }, + "Primitive macros": { + "prefix": "_PRIMITIVE", + "body": [ + "#define i16 short", + "#define ui16 unsigned short", + "#define i32 int", + "#define ui32 unsigned int", + "#define i64 long long", + "#define ui64 unsigned long long" + ], + "description": "Primitive macros for int type" + } +} diff --git a/snippets/cpp.json b/snippets/cpp.json new file mode 100644 index 0000000..c949464 --- /dev/null +++ b/snippets/cpp.json @@ -0,0 +1,219 @@ +{ + "for": { + "prefix": "for", + "body": [ + "for (${1:size_t} ${2:i} = ${3:0}; $2 < ${4:length}; $2++) {", + "\t$0", + "}" + ], + "description": "Code snippet for 'for' loop" + }, + "*": { + "prefix": "*", + "body": ["/* $0 */"], + "description": "Block comment" + }, + "forr": { + "prefix": "forr", + "body": [ + "for (${1:size_t} ${2:i} = ${3:length} - 1; $2 >= ${4:0}; $2--) {", + "\t$0", + "}" + ], + "description": "Code snippet for reverse 'for' loop" + }, + "mod": { + "prefix": "MOD", + "body": ["#define MOD(N,M)\t((N)%(M) < 0 ? (N)%(M) + (M) : (N)%(M))"], + "description": "mod of N,M" + }, + "between": { + "prefix": "between", + "body": ["#define BETWEEN(x, a, b)\t((a) <= (x) && (x) <= (b))"], + "description": "x is between a, b" + }, + "sze" : { + "prefix": "sze", + "body": ["#define SIZE(x) sizeof(x)/sizeof(x[0])","$0"], + "description": "Array size macro" + }, + "do": { + "prefix": "do", + "body": ["do", "{", "\t$1", "} while($2);"], + "description": "Code snippet for do...while loop" + }, + "while": { + "prefix": "while", + "body": ["while ($1) {", "\t$2", "}"], + "description": "" + }, + "foreach": { + "prefix": "foreach", + "body": ["for (${1:auto} ${2:var} : ${3:collection_to_loop}) {", "\t$0", "}"], + "description": "Code snippet for range-based for loop (c++11) statement" + }, + "enum": { + "prefix": "enum", + "body": ["enum ${1:MyEnum} {", "\t$0", "};"], + "description": "Code snippet for enum" + }, + "enum class": { + "prefix": "enum class", + "body": ["enum class ${1:MyClass} {$0};"], + "description": "Code snippet for enum class (c++11)" + }, + "class": { + "prefix": "class", + "body": [ + "class ${1:MyClass}", + "{", + "public:", + "\t$1();", + "\t$1($1 &&) = default;", + "\t$1(const $1 &) = default;", + "\t$1 &operator=($1 &&) = default;", + "\t$1 &operator=(const $1 &) = default;", + "\t~$1();", + "", + "private:", + "\t$2", + "};", + "", + "$1::$1()", + "{", + "}", + "", + "$1::~$1()", + "{", + "}" + ], + "description": "Code snippet for class" + }, + "classi": { + "prefix": "classi", + "body": [ + "class ${1:MyClass}", + "{", + "public:", + "\t$1() = default;", + "\t$1($1 &&) = default;", + "\t$1(const $1 &) = default;", + "\t$1 &operator=($1 &&) = default;", + "\t$1 &operator=(const $1 &) = default;", + "\t~$1() = default;", + "", + "private:", + "\t$2", + "};" + ], + "description": "Code snippet for class with inline constructor/destructor" + }, + "interface": { + "prefix": "interface", + "body": ["__interface I${1:Interface}", "{", "\t$0", "};"], + "description": "Code snippet for interface (Visual C++)" + }, + "namespace": { + "prefix": "namespace", + "body": ["namespace ${1:MyNamespace}", "{", "\t$0", "}"] + }, + "#ifdef": { + "prefix": "#ifdef", + "body": ["#ifdef ${1:DEBUG}", "$0", "#endif // ${DEBUG}"], + "description": "Code snippet for #ifdef" + }, + "#ifndef": { + "prefix": "#ifndef", + "body": ["#ifndef ${1:DEBUG}", "$0", "#endif // !$1"], + "description": "Code snippet for #ifndef" + }, + "#if": { + "prefix": "#if", + "body": ["#if ${1:0}", "$0", "#endif // $1"], + "description": "Code snippet for #if" + }, + "struct": { + "prefix": "struct", + "body": ["struct ${1:MyStruct}", "{", "\t$0", "};"], + "description": "Code snippet for struct" + }, + "switch": { + "prefix": "switch", + "body": ["switch (${1:switch_on}) {", "\tdefault:", "\t\t$0", "\t\tbreak;", "}"], + "description": "Code snippet for switch statement" + }, + "try": { + "prefix": "try", + "body": [ + "try {", + "\t", + "}", + "catch (const std::exception&)", + "{", + "\t$1", + "}" + ], + "description": "Code snippet for try catch" + }, + "union": { + "prefix": "union", + "body": ["union ${1:MyUnion}", "{", "\t$0", "};"], + "description": "Code snippet for union" + }, + "printf": { + "prefix": "printf", + "body": ["printf(\"$1\\n\"$0);"], + "description": "Generic printf() snippet" + }, + "sprintf": { + "prefix": "sprintf", + "body": ["sprintf($1, \"$2\\n\"$0);"], + "description": "Generic sprintf() snippet" + }, + "fprintf": { + "prefix": "fprintf", + "body": ["fprintf(${1:stderr}, \"$2\\n\"$0);"], + "description": "Generic fprintf() snippet" + }, + "scanf": { + "prefix": "scanf", + "body": ["scanf(\"$1\"$0);"], + "description": "Generic scanf() snippet" + }, + "sscanf": { + "prefix": "sscanf", + "body": ["sscanf($1, \"$2\"$0);"], + "description": "Generic sscanf() snippet" + }, + "fscanf": { + "prefix": "fscanf", + "body": ["fscanf($1, \"$2\"$0);"], + "description": "Generic fscanf() snippet" + }, + "#inc": { + "prefix": "#inc", + "body": ["#include \"$0\""], + "description": "Code snippet for #include \" \"" + }, + "#inc<": { + "prefix": "#inc<", + "body": ["#include <$0>"], + "description": "Code snippet for #include < >" + }, + "#def": { + "prefix": "def", + "body": ["#define $0"], + "description": "Code snippet for #define \" \"" + }, + "Main function template": { + "prefix": "main", + "body": [ + "int main (int argc, char *argv[])", + "{", + "\t$0", + "\treturn 0;", + "}" + ], + "description": "A standard main function for a C++ program" + } +} diff --git a/snippets/css.json b/snippets/css.json new file mode 100644 index 0000000..294af23 --- /dev/null +++ b/snippets/css.json @@ -0,0 +1,651 @@ +{ + "align-items": { + "prefix": "ai", + "body": "align-items: ${1|flex-start,flex-end,center,baseline,stretch,start,end,self-start,self-end|};", + "description": "initial value: stretch" + }, + "align-items: baseline": { + "prefix": "aib", + "body": "align-items: baseline;" + }, + "align-items: center": { + "prefix": "aic", + "body": "align-items: center;" + }, + "align-items: flex-start": { + "prefix": "aifs", + "body": "align-items: flex-start;" + }, + "align-items: flex-end": { + "prefix": "aife", + "body": "align-items: flex-end;" + }, + "align-items: stretch": { + "prefix": "ais", + "body": "align-items: stretch;" + }, + "align-self": { + "prefix": "as", + "body": "align-items: ${1|flex-start,flex-end,center,baseline,stretch,auto|};", + "description": "initial value: auto" + }, + "animation": { + "prefix": "ani", + "body": "animation: ${1:name} ${2:1s} ${3|linear,ease-in-out,ease,ease-in,ease-out,step-start,step-end,steps,cubic-bezier|};", + "description": "animation: name duration timing-function delay direction count fill-mode play-state" + }, + "animation-delay": { + "prefix": "anide", + "body": "animation-delay: ${0:1s};" + }, + "animation-direction": { + "prefix": "anidi", + "body": "animation-direction: ${1|alternate,alternate-reverse,reverse,normal|};", + "description": "initial value: normal" + }, + "animation-duratuion": { + "prefix": "anidu", + "body": "animation-duration: ${0:1s};" + }, + "animation-fill-mode": { + "prefix": "anifm", + "body": "animation-fill-mode: ${1|forwards,backwards,both,none|};", + "description": "initial value: none" + }, + "animation-iteration-count": { + "prefix": "aniic", + "body": "animation-iteration-count: ${0:infinite};", + "description": "initial value: 1" + }, + "animation-name": { + "prefix": "anin", + "body": "animation-name: ${0:name};" + }, + "animation-play-state": { + "prefix": "anips", + "body": "animation-play-state: ${1|paused,running|};", + "description": "initial value: running" + }, + "animation-timing-function": { + "prefix": "anitf", + "body": "animation-timing-function: ${1|linear,ease,ease-in-out,ease-in,ease-out,step-start,step-end,steps,cubic-bezier|};", + "description": "initial value: ease" + }, + "background": { + "prefix": "bg", + "body": "background: ${0:#fff};", + "description": "background: image position/size repeat attachment box box" + }, + "background-attachment": { + "prefix": "bga", + "body": "background-attachment: ${1|fixed,scroll,local|};", + "description": "initial value: scroll" + }, + "background-color": { + "prefix": "bgc", + "body": "background-color: ${0:#fff};" + }, + "background-clip": { + "prefix": "bgcl", + "body": "background-clip: ${1|border-box,padding-box,content-box,text|};", + "description": "initial value: border-box" + }, + "background-image": { + "prefix": "bgi", + "body": "background-image: url('${0:background.jpg}');" + }, + "background-origin": { + "prefix": "bgo", + "body": "background-origin: ${1|border-box,padding-box,content-box|};", + "description": "initial value: padding-box" + }, + "background-position": { + "prefix": "bgp", + "body": "background-position: ${1:left} ${2:top};" + }, + "background-repeat": { + "prefix": "bgr", + "body": "background-repeat: ${1|no-repeat,repeat-x,repeat-y,repeat,space,round|};", + "description": "initial value: repeat" + }, + "background-repeat: repeat": { + "prefix": "bgrr", + "body": "background-repeat: repeat;" + }, + "background-repeat: repeat-x": { + "prefix": "bgrx", + "body": "background-repeat: repeat-x;" + }, + "background-repeat: repeat-y": { + "prefix": "bgry", + "body": "background-repeat: repeat-y;" + }, + "background-repeat: no-repeat": { + "prefix": "bgrn", + "body": "background-repeat: no-repeat;" + }, + "background-size": { + "prefix": "bgs", + "body": "background-size: ${0:cover};" + }, + "border": { + "prefix": "bor", + "body": "border: ${1:1px} ${2|solid,dashed,dotted,double,groove,ridge,inset,outset,none,hidden|} ${0:#000};" + }, + "border: none": { + "prefix": "born", + "body": "border: none;" + }, + "border-color": { + "prefix": "borc", + "body": "border-color: ${0:#000};" + }, + "border-style": { + "prefix": "bors", + "body": "border-style: ${1|solid,dashed,dotted,double,groove,ridge,inset,outset,none,hidden|};" + }, + "border-width": { + "prefix": "borw", + "body": "border-width: ${0:1px};" + }, + "border-bottom": { + "prefix": "borb", + "body": "border-bottom: ${1:1px} ${2|solid,dashed,dotted,double,groove,ridge,inset,outset,none,hidden|} ${0:#000};" + }, + "border-left": { + "prefix": "borl", + "body": "border-left: ${1:1px} ${2|solid,dashed,dotted,double,groove,ridge,inset,outset,none,hidden|} ${0:#000};" + }, + "border-right": { + "prefix": "borr", + "body": "border-right: ${1:1px} ${2|solid,dashed,dotted,double,groove,ridge,inset,outset,none,hidden|} ${0:#000};" + }, + "border-top": { + "prefix": "bort", + "body": "border-top: ${1:1px} ${2|solid,dashed,dotted,double,groove,ridge,inset,outset,none,hidden|} ${0:#000};" + }, + "border-radius": { + "prefix": "br", + "body": "border-radius: ${0:2px};" + }, + "bottom": { + "prefix": "bot", + "body": "bottom: ${0:0};" + }, + "box-shadow": { + "prefix": "bos", + "body": "box-shadow: ${1:1px} ${2:1px} ${3:1px} ${4:1px} ${0:rgba(0, 0, 0, .5)};", + "description": "box-shadow: x-offset y-offset blur spread color" + }, + "box-sizing": { + "prefix": "boz", + "body": "box-sizing: ${1|border-box,content-box|};", + "description": "initial value: content-box" + }, + "clear": { + "prefix": "clr", + "body": "clear: ${1|both,left,right,none|};" + }, + "color": { + "prefix": "col", + "body": "color: ${0:#000};" + }, + "content": { + "prefix": "con", + "body": "content: '$0';" + }, + "cursor": { + "prefix": "cur", + "body": "cursor: ${1|auto,default,alias,cell,copy,crosshair,context-menu,help,grab,grabbing,move,none,no-drop,not-allowed,pointer,progress,e-resize,all-scroll,text,wait,vertical-text,zoom-in,zoom-out|};", + "description": "initial value: auto" + }, + "cursor: pointer": { + "prefix": "curp", + "body": "cursor: pointer;" + }, + "cursor: default": { + "prefix": "curd", + "body": "cursor: default;" + }, + "display": { + "prefix": "dis", + "body": "display: ${1|none,block,inline,inline-block,flex,inline-flex,list-item,table,inline-table,table-caption,table-cell,table-row,table-row-group,table-column|};" + }, + "display: block": { + "prefix": "disb", + "body": "display: block;" + }, + "display: inline-block": { + "prefix": "disi", + "body": "display: inline-block;" + }, + "display: none": { + "prefix": "disn", + "body": "display: none;" + }, + "display: flex": { + "prefix": "disf", + "body": "display: flex;" + }, + "flex": { + "prefix": "flex", + "body": "flex: ${1:1} ${2:1} ${3:auto};", + "description": "flex: grow shrink basis" + }, + "flex (alt)": { + "prefix": "fle", + "body": "flex: ${1:1} ${2:1} ${3:auto};" + }, + "flex-direction": { + "prefix": "fld", + "body": "flex-direction: ${1|row,row-reverse,column,column-reverse|};", + "description": "initial value: row" + }, + "flex-direction: row": { + "prefix": "fldr", + "body": "flex-direction: row;" + }, + "flex-direction: column": { + "prefix": "fldc", + "body": "flex-direction: column;" + }, + "flex-flow": { + "prefix": "flf", + "body": "flex-flow: ${1|row,row-reverse,column,column-reverse|} ${2|wrap,wrap-reverse,nowrap|};" + }, + "flex-wrap": { + "prefix": "flw", + "body": "flex-wrap: ${1|wrap,wrap-reverse,nowrap|};", + "description": "initial value: nowrap" + }, + "float": { + "prefix": "fl", + "body": "float: ${1|left,right,none|};" + }, + "float: left": { + "prefix": "fll", + "body": "float: left;" + }, + "float: right": { + "prefix": "flr", + "body": "float: right;" + }, + "float: none": { + "prefix": "fln", + "body": "float: none;" + }, + "font-family": { + "prefix": "ff", + "body": "font-family: ${0:arial};" + }, + "font-size": { + "prefix": "fz", + "body": "font-size: ${0:12px};" + }, + "font-style": { + "prefix": "fst", + "body": "font-style: ${1|italic,oblique,normal|};" + }, + "font-style: italic": { + "prefix": "fsti", + "body": "font-style: italic;" + }, + "font-style: normal": { + "prefix": "fstn", + "body": "font-style: normal;" + }, + "font-style: oblique": { + "prefix": "fsto", + "body": "font-style: oblique;" + }, + "font-weight": { + "prefix": "fw", + "body": "font-weight: ${0:bold};" + }, + "font-weight: bold": { + "prefix": "fwb", + "body": "font-weight: bold;" + }, + "font-weight: light": { + "prefix": "fwl", + "body": "font-weight: light;" + }, + "font-weight: normal": { + "prefix": "fwn", + "body": "font-weight: normal;" + }, + "font": { + "prefix": "ft", + "body": "font: ${0:12px/1.5};", + "description": "font: [weight style variant stretch] size/line-height family" + }, + "height": { + "prefix": "hei", + "body": "height: ${0:1px};" + }, + "justify-content": { + "prefix": "jc", + "body": "justify-content: ${1|flex-start,flex-end,center,space-between,space-around|};", + "description": "initial value: flex-start" + }, + "justify-content: flex-start": { + "prefix": "jcfs", + "body": "justify-content: flex-start;" + }, + "justify-content: flex-end": { + "prefix": "jcfe", + "body": "justify-content: flex-end;" + }, + "justify-content: center": { + "prefix": "jcc", + "body": "justify-content: center;" + }, + "justify-content: space-around": { + "prefix": "jcsa", + "body": "justify-content: space-around;" + }, + "justify-content: space-between": { + "prefix": "jcsb", + "body": "justify-content: space-between;" + }, + "list-style": { + "prefix": "lis", + "body": "list-style: ${1|disc,circle,square,decimal,lower-roman,upper-roman,lower-alpha,upper-alpha,none,armenian,cjk-ideographic,georgian,lower-greek,hebrew,hiragana,hiragana-iroha,katakana,katakana-iroha,lower-latin,upper-latin|} ${2|outside,inside|};", + "description": "list-style: type position image" + }, + "list-style-position": { + "prefix": "lisp", + "body": "${1|outside,inside|}", + "description": "initial value: outside" + }, + "list-style-type": { + "prefix": "list", + "body": "list-style-type: ${1|disc,circle,square,decimal,lower-roman,upper-roman,lower-alpha,upper-alpha,none,armenian,cjk-ideographic,georgian,lower-greek,hebrew,hiragana,hiragana-iroha,katakana,katakana-iroha,lower-latin,upper-latin|};", + "description": "initial value: disc" + }, + "list-style-type: circle": { + "prefix": "listc", + "body": "list-style-type: circle;" + }, + "list-style-type: disc": { + "prefix": "listd", + "body": "list-style-type: disc;" + }, + "list-style-type: none": { + "prefix": "listn", + "body": "list-style-type: none;" + }, + "list-style-type: square": { + "prefix": "lists", + "body": "list-style-type: square;" + }, + "list-style-type: lower-roman": { + "prefix": "listlr", + "body": "list-style-type: lower-roman;" + }, + "list-style-type: upper-roman": { + "prefix": "listur", + "body": "list-style-type: upper-roman;" + }, + "left": { + "prefix": "lef", + "body": "left: ${0:0};" + }, + "line-height": { + "prefix": "lh", + "body": "line-height: ${0:1.5};" + }, + "letter-spacing": { + "prefix": "ls", + "body": "letter-spacing: ${0:2px};" + }, + "letter-spacing: normal": { + "prefix": "lsn", + "body": "letter-spacing: normal;" + }, + "margin": { + "prefix": "mar", + "body": "margin: ${0:0};" + }, + "margin-bottom": { + "prefix": "marb", + "body": "margin-bottom: ${0:0};" + }, + "margin-left": { + "prefix": "marl", + "body": "margin-left: ${0:0};" + }, + "margin-right": { + "prefix": "marr", + "body": "margin-right: ${0:0};" + }, + "margin-top": { + "prefix": "mart", + "body": "margin-top: ${0:0};" + }, + "margin: 0 auto": { + "prefix": "mara", + "body": "margin: 0 auto;" + }, + "min-height": { + "prefix": "mih", + "body": "min-height: ${0:1px};" + }, + "min-width": { + "prefix": "miw", + "body": "min-width: ${0:1px};" + }, + "max-height": { + "prefix": "mah", + "body": "max-height: ${0:1px};" + }, + "max-width": { + "prefix": "maw", + "body": "max-width: ${0:1px};" + }, + "opacity": { + "prefix": "opa", + "body": "opacity: ${0:0};" + }, + "overflow": { + "prefix": "ov", + "body": "overflow: ${1|visible,hidden,scroll,auto,clip|};" + }, + "overflow: auto": { + "prefix": "ova", + "body": "overflow: auto;" + }, + "overflow: hidden": { + "prefix": "ovh", + "body": "overflow: hidden;" + }, + "overflow: scroll": { + "prefix": "ovs", + "body": "overflow: scroll;" + }, + "overflow: visible": { + "prefix": "ovv", + "body": "overflow: visible;" + }, + "padding": { + "prefix": "pad", + "body": "padding: ${0:0};" + }, + "padding-bottom": { + "prefix": "padb", + "body": "padding-bottom: ${0:0};" + }, + "padding-left": { + "prefix": "padl", + "body": "padding-left: ${0:0};" + }, + "padding-right": { + "prefix": "padr", + "body": "padding-right: ${0:0};" + }, + "padding-top": { + "prefix": "padt", + "body": "padding-top: ${0:0};" + }, + "position": { + "prefix": "pos", + "body": "position: ${1|relative,absolute,fixed,sticky,static|};" + }, + "position absolute": { + "prefix": "posa", + "body": "position: absolute;" + }, + "position fixed": { + "prefix": "posf", + "body": "position: fixed;" + }, + "position relative": { + "prefix": "posr", + "body": "position: relative;" + }, + "position sticky": { + "prefix": "poss", + "body": "position: sticky;" + }, + "right": { + "prefix": "rig", + "body": "right: ${0:0};" + }, + "text-align": { + "prefix": "ta", + "body": "text-align: ${1|center,left,right,justify,start,end|};" + }, + "text-align: center": { + "prefix": "tac", + "body": "text-align: center;" + }, + "text-align: left": { + "prefix": "tal", + "body": "text-align: left;" + }, + "text-align: right": { + "prefix": "tar", + "body": "text-align: right;" + }, + "text-decoration": { + "prefix": "td", + "body": "text-decoration: ${1|none,underline,overline,line-through|};" + }, + "text-decoration: underline": { + "prefix": "tdu", + "body": "text-decoration: underline;" + }, + "text-decoration: none": { + "prefix": "tdn", + "body": "text-decoration: none;" + }, + "text-decoration: line-through": { + "prefix": "tdl", + "body": "text-decoration: line-through;" + }, + "text-indent": { + "prefix": "ti", + "body": "text-indent: ${0:2em};" + }, + "text-shadow": { + "prefix": "ts", + "body": "text-shadow: ${1:1px} ${2:1px} ${3:1px} ${4:1px} ${0:rgba(0, 0, 0, .5)};", + "description": "text-shadow: x-offset y-offset blur spread color" + }, + "text-transform": { + "prefix": "tt", + "body": "text-transform: ${1|capitalize,uppercase,lowercase,full-width,none|};" + }, + "top": { + "prefix": "top", + "body": "top: ${0:0};" + }, + "vertical-align": { + "prefix": "va", + "body": "vertical-align: ${1|baseline,middle,top,bottom,sub,super,text-top,text-bottom|};" + }, + "vertical-align: bottom": { + "prefix": "vab", + "body": "vertical-align: bottom;" + }, + "vertical-align: middle": { + "prefix": "vam", + "body": "vertical-align: middle;" + }, + "vertical-align: top": { + "prefix": "vat", + "body": "vertical-align: top;" + }, + "visibility": { + "prefix": "vis", + "body": "visibility: ${1|visible,hidden,collapse|};" + }, + "visibility: visible": { + "prefix": "visv", + "body": "visibility: visible;" + }, + "visibility: hidden": { + "prefix": "vish", + "body": "visibility: hidden;" + }, + "word-break": { + "prefix": "wb", + "body": "word-break: ${1|break-all,keep-all,break-word,normal|};" + }, + "width": { + "prefix": "wid", + "body": "width: ${0:0};" + }, + "width: auto": { + "prefix": "wida", + "body": "width: auto;" + }, + "white-space": { + "prefix": "ws", + "body": "white-space: ${1|nowrap,pre,pre-wrap,pre-line,normal|};" + }, + "white-space: nowrap": { + "prefix": "wsn", + "body": "white-space: nowrap;" + }, + "white-space: pre": { + "prefix": "wsp", + "body": "white-space: pre;" + }, + "word-wrap": { + "prefix": "ww", + "body": "word-wrap: ${1|break-word,break-spaces,normal|};" + }, + "z-index": { + "prefix": "zi", + "body": "z-index: ${0:-1};" + }, + "@import": { + "prefix": "imp", + "body": "@import '${0:filename}';" + }, + "@mixin": { + "prefix": "mix", + "body": "@mixin ${1:name} {\n $0\n}" + }, + "@include": { + "prefix": "inc", + "body": "@include ${0:mixin};" + }, + "@keyframes": { + "prefix": "key", + "body": "@keyframes ${1:name} {\n $0\n}" + }, + "@media": { + "prefix": "med", + "body": "@media screen and (${1:max-width: 300px}) {\n $0\n}" + }, + "!important": { + "prefix": "!", + "body": "!important" + }, + "!important (alt)": { + "prefix": "i", + "body": "!important" + } +} diff --git a/snippets/frameworks/django/filetemplates.json b/snippets/frameworks/django/filetemplates.json new file mode 100644 index 0000000..c6561f3 --- /dev/null +++ b/snippets/frameworks/django/filetemplates.json @@ -0,0 +1,35 @@ +{ + "Django URLFile Template":{ + "prefix": "fturl", + "body": [ + "from django.urls import path", + "from . import views as v", + "\n\napp_name = ${1:AppName}", + "urlpatterns = [", + "\t# TODO: Define $1 URLs here", + "\t${0}", + "]" + ], + "description": "Django File-Template Sinppet For ``URL`` File" + }, + "Django FormFile Template":{ + "prefix": "ftform", + "body": [ + "from django import forms", + "from ${1:.models} import ${2}", + "\n\n# TODO: Create your forms here", + "${0}" + ], + "description": "Django File-Template Sinppet For ``Form`` File" + }, + "Django CustomTagsFile Template":{ + "prefix": "ftcutomtags", + "body": [ + "from django import template", + "\nregister = template.Library()", + "\n# TODO: Create your custom tags here", + "${0}" + ], + "description": "Django File-Template Sinppet For ``CustomTags`` File" + } +} diff --git a/snippets/frameworks/django/forms.json b/snippets/frameworks/django/forms.json new file mode 100644 index 0000000..5b2c319 --- /dev/null +++ b/snippets/frameworks/django/forms.json @@ -0,0 +1,168 @@ +{ + "Django Simple Form ":{ + "prefix": "sform", + "body": [ + "class ${1:Name}Form(forms.Form):", + "\t# Define $1Form fields here", + "\t${0}" + ], + "description": "Django Simple Form" + }, + "Django Model Form ":{ + "prefix": "modelform", + "body": [ + "class ${1:ModelName}Form(forms.ModelForm):", + "\tclass Meta:", + "\t\tmodel = ${2:$1}", + "\t\tfields = (${3:\"__all__\"})", + "\t\t${0}" + ], + "description": "Django Model Form" + }, + "Forms BooleanField":{ + "prefix": "fbool", + "body": "${1:FIELDNAME} = forms.BooleanField(${2})", + "description": "Django forms ``BooleanField``" + }, + "Forms CharField":{ + "prefix": "fchar", + "body": "${1:FIELDNAME} = forms.CharField(${2})", + "description": "Django forms ``CharField``" + }, + "Forms ComboField":{ + "prefix": "fcombo", + "body": "${1:FIELDNAME} = forms.ComboField(${2})", + "description": "Django forms ``ComboField``" + }, + "Forms DateField":{ + "prefix": "fdate", + "body": "${1:FIELDNAME} = forms.DateField(${2})", + "description": "Django forms ``DateField``" + }, + "Forms DateTime":{ + "prefix": "fdatetime", + "body": "${1:FIELDNAME} = forms.DateTime(${2})", + "description": "Django forms ``DateTime``" + }, + "Forms DecimalField":{ + "prefix": "fdecimal", + "body": "${1:FIELDNAME} = forms.DecimalField(${2})", + "description": "Django forms ``DecimalField``" + }, + "Forms DurationField":{ + "prefix": "fduration", + "body": "${1:FIELDNAME} = forms.DurationField(${2})", + "description": "Django forms ``DurationField``" + }, + "Forms EmailField":{ + "prefix": "femail", + "body": "${1:FIELDNAME} = forms.EmailField(${2})", + "description": "Django forms ``EmailField``" + }, + "Forms FileField":{ + "prefix": "ffile", + "body": "${1:FIELDNAME} = forms.FileField(${2})", + "description": "Django forms ``FileField``" + }, + "Forms FilePathField":{ + "prefix": "ffilepath", + "body": "${1:FIELDNAME} = forms.FilePathField(${2})", + "description": "Django forms ``FilePathField``" + }, + "Forms FloatField":{ + "prefix": "ffloat", + "body": "${1:FIELDNAME} = forms.FloatField(${2})", + "description": "Django forms ``FloatField``" + }, + "Forms GenericIPAddressField":{ + "prefix": "fgip", + "body": "${1:FIELDNAME} = forms.GenericIPAddressField(${2})", + "description": "Django forms ``GenericIPAddressField``" + }, + "Forms GenericIPAddressField":{ + "prefix": "fgip", + "body": "${1:FIELDNAME} = forms.GenericIPAddressField(${2})", + "description": "Django forms ``GenericIPAddressField``" + }, + "Forms ImageField":{ + "prefix": "fimg", + "body": "${1:FIELDNAME} = forms.ImageField(${2})", + "description": "Django forms ``ImageField``" + }, + "Forms IntegerField":{ + "prefix": "fint", + "body": "${1:FIELDNAME} = forms.IntegerField(${2})", + "description": "Django forms ``IntegerField``" + }, + "Forms IPAddressField":{ + "prefix": "fip", + "body": "${1:FIELDNAME} = forms.IPAddressField(${2})", + "description": "Django forms ``IPAddressField``" + }, + "Forms ModelChoiceField":{ + "prefix": "fmochoice", + "body": "${1:FIELDNAME} = forms.ModelChoiceField(${2})", + "description": "Django forms ``ModelChoiceField``" + }, + "Forms ModelMultipleChoiceField":{ + "prefix": "fmomuchoice", + "body": "${1:FIELDNAME} = forms.ModelMultipleChoiceField(${2})", + "description": "Django forms ``ModelMultipleChoiceField``" + }, + "Forms MultipleChoiceField":{ + "prefix": "fmuchoice", + "body": "${1:FIELDNAME} = forms.MultipleChoiceField(${2})", + "description": "Django forms ``MultipleChoiceField``" + }, + "Forms MultipleValueField":{ + "prefix": "fmuvalue", + "body": "${1:FIELDNAME} = forms.MultipleValueField(${2})", + "description": "Django forms ``MultipleValueField``" + }, + "Forms NullBooleanField":{ + "prefix": "fnullbool", + "body": "${1:FIELDNAME} = forms.NullBooleanField(${2})", + "description": "Django forms ``NullBooleanField``" + }, + "Forms RegexField":{ + "prefix": "fregex", + "body": "${1:FIELDNAME} = forms.RegexField(${2})", + "description": "Django forms ``RegexField``" + }, + "Forms SlugField":{ + "prefix": "fslug", + "body": "${1:FIELDNAME} = forms.SlugField(${2})", + "description": "Django forms ``SlugField``" + }, + "Forms SplitDateTime":{ + "prefix": "fsdatetime", + "body": "${1:FIELDNAME} = forms.SplitDateTime(${2})", + "description": "Django forms ``SplitDateTime`` Field" + }, + "Forms TimeField":{ + "prefix": "ftime", + "body": "${1:FIELDNAME} = forms.TimeField(${2})", + "description": "Django forms ``TimeField``" + }, + "Forms TypedChoiceField":{ + "prefix": "ftchoice", + "body": "${1:FIELDNAME} = forms.TypedChoiceField(${2})", + "description": "Django forms ``TypedChoiceField``" + }, + "Forms TypedMultipleChoiceField":{ + "prefix": "ftmuchoice", + "body": "${1:FIELDNAME} = forms.TypedMultipleChoiceField(${2})", + "description": "Django forms ``TypedMultipleChoiceField``" + }, + "Forms URLField":{ + "prefix": "fulr", + "body": "${1:FIELDNAME} = forms.URLField(${2})", + "description": "Django forms ``URLField``" + }, + "Forms UUIDField":{ + "prefix": "fuuid", + "body": "${1:FIELDNAME} = forms.UUIDField(${2})", + "description": "Django forms ``UUIDField``" + } + +} diff --git a/snippets/frameworks/django/imports.json b/snippets/frameworks/django/imports.json new file mode 100644 index 0000000..d099fb9 --- /dev/null +++ b/snippets/frameworks/django/imports.json @@ -0,0 +1,43 @@ +{ + "Import forms":{ + "prefix": "di-forms", + "body": "from django import forms", + "description": "Import Django ``forms``" + }, + "Import models":{ + "prefix": "di-model", + "body": "from django import models", + "description": "Import Django ``models``" + }, + "Import get_user_model":{ + "prefix": "di-getusermodel", + "body": "from django.contrib.auth import get_user_model", + "description": "Import Django ``get_user_model``" + }, + "Import generic views":{ + "prefix": "di-generic", + "body": "from django.views import generic", + "description": "Import Django ``generic``" + }, + "Import JsonResponse":{ + "prefix": "di-jsonresponse", + "body": "from django.http import JsonResponse", + "description": "Import Django ``JsonResponse``" + }, + "Import reverse":{ + "prefix": "di-reverse", + "body": "from django.urls import reverse", + "description": "Import Django ``reverse``" + }, + "Import reverse_lazy":{ + "prefix": "di-reverse_lazy", + "body": "from django.urls import revers_lazy", + "description": "Import Django ``revers_lazy``" + }, + + "Import messages":{ + "prefix": "di-messages", + "body": "from django.contrib import messages", + "description": "Import Django ``messages``" + } +} diff --git a/snippets/frameworks/django/models.json b/snippets/frameworks/django/models.json new file mode 100644 index 0000000..c0b656c --- /dev/null +++ b/snippets/frameworks/django/models.json @@ -0,0 +1,183 @@ +{ + "Django Simple Model": { + "prefix": "smodel", + "body": [ + "class ${1:ModelName}(models.Model):", + "\t# Define $1 fields here", + "\t${2}", + "\n\tclass Meta:", + "\t\tordering = [\"${3:-pk}\"]", + "\t\tverbose_name = \"${4:$1}\"", + "\t\tverbose_name_plural = \"${5:$1s}\"", + "\n\tdef __str__(self):", + "\t\treturn ${6:super().__str__()}", + "\n\t# Define $1 properties here", + "\t${0}" + ], + "description": "Django Simple Model with properties and attributes" + }, + "Django Full Model": { + "prefix": "model", + "body": [ + "class ${1:ModelName}(models.Model):", + "\t# Define $1 fields here", + "\t${2}", + "\n\tclass Meta:", + "\t\tordering = [\"${3:-pk}\"]", + "\t\tverbose_name = \"${4:$1}\"", + "\t\tverbose_name_plural = \"${5:$1s}\"", + "\n\tdef __str__(self):", + "\t\treturn ${6:super().__str__()}", + "\n\tdef save(self, *args, **kwargs):", + "\t\treturn ${7:super().save(*args, **kwargs)}", + "\n\tdef get_absolute_url(self):", + "\t\treturn reverse('${8:view_or_url_name}', kwargs={${9:'pk'}: ${10: self.pk}})", + "\n\t# Define $1 properties here", + "\t${0}" + ], + "description": "Django Full Model with properties and attributes" + }, + + "Models AutoField":{ + "prefix": "mauto", + "body": "${1:FIELDNAME} = models.AutoField(${2})", + "description": "Django model ``AutoField``" + }, + "Models BigIntegerField":{ + "prefix": "mbigint", + "body": "${1:FIELDNAME} = models.AutoField(${2})", + "description": "Django model ``AutoField``" + }, + "Models BinaryField":{ + "prefix": "mbinary", + "body": "${1:FIELDNAME} = models.BinaryField(${2})", + "description": "Django model ``BinaryField``" + }, + "Models Boolean":{ + "prefix": "mbool", + "body": "${1:FIELDNAME} = models.BooleanField(default=${2:False})", + "description": "Django model ``BooleanField``" + }, + "Models CharField":{ + "prefix": "mchar", + "body": "${1:FieldName} = models.CharField(max_length=${2:32})", + "description": "Django model ``CharField``" + }, + "Models CommaSeparatedIntegerField":{ + "prefix": "mcomma", + "body": "${1:FIELDNAME} = models.CommaSeparatedIntegerField(max_length=${2})", + "description": "Django model ``CommaSeparatedIntegerField``" + }, + "Models DateField":{ + "prefix": "mdate", + "body": "${1:FIELDNAME} = models.DateField(auto_now_add=${2:True}, auto_now=${3:False}})", + "description": "Django model ``DateField``" + }, + "Models DateTimeField":{ + "prefix": "mdatetime", + "body": "${1:FIELDNAME} = models.DateTimeField(auto_now_add=${2:True}, auto_now=${3:False})", + "description": "Django model ``DateTimeField``" + }, + "Models DecimalField":{ + "prefix": "mdecimal", + "body": "${1:FIELDNAME} = models.DecimalField(max_digits=${2}, decimal_places=${3})", + "description": "Django model ``DecimalField``" + }, + "Models EmailField":{ + "prefix": "memail", + "body": "${1:FIELDNAME} = models.EmailField(${2})", + "description": "Django model ``EmailField``" + }, + "Models FileField":{ + "prefix": "mfile", + "body": "${1:FIELDNAME} = models.FileField(upload_to=${2:path/for/upload})", + "description": "Django model ``FileField``" + }, + "Models FilePathField":{ + "prefix": "mfilepath", + "body": "${1:FIELDNAME} = models.FilePathField(path=${2:\"/abs/path/to/dir\"}${3:, max_length=100}${4:, match=\"*.ext\"}${4:, recursive=True})", + "description": "Django model ``FilePathField``" + }, + "Models FloatField":{ + "prefix": "mfloat", + "body": "${1:FIELDNAME} = models.FloatField(${2})", + "description": "Django model ``FloatField``" + }, + "Models ImageField":{ + "prefix": "mimg", + "body": "${1:FIELDNAME} = models.ImageField(upload_to=${2:path/for/upload}${3:, height_field=height, width_field=width}${4:, max_length=100})", + "description": "Django model ``ImageField``" + }, + "Models IntegerField":{ + "prefix": "mint", + "body": "${1:FIELDNAME} = models.IntegerField(${2})", + "description": "Django model ``IntegerField``" + }, + "Models IPAddressField":{ + "prefix": "mip", + "body": "${1:FIELDNAME} = models.IPAddressField(${2})", + "description": "Django model ``IPAddressField``" + }, + "Models NullBooleanField":{ + "prefix": "mnullboolean", + "body": "${1:FIELDNAME} = models.NullBooleanField(${2})", + "description": "Django model ``NullBooleanField``" + }, + "Models PositiveIntegerField":{ + "prefix": "mposint", + "body": "${1:FIELDNAME} = models.PositiveIntegerField(${2})", + "description": "Django model ``PositiveIntegerField``" + }, + "Models PositiveSmallIntegerField":{ + "prefix": "mpossmallint", + "body": "${1:FIELDNAME} = models.PositiveSmallIntegerField(${2})", + "description": "Django model ``PositiveSmallIntegerField``" + }, + "Models SlugField":{ + "prefix": "mslug", + "body": "${1:FIELDNAME} = models.SlugField(${2})", + "description": "Django model ``SlugField``" + }, + "Models SmallIntegerField":{ + "prefix": "msmallint", + "body": "${1:FIELDNAME} = models.SmallIntegerField(${2})", + "description": "Django model ``SmallIntegerField``" + }, + "Models TextField":{ + "prefix": "mtext", + "body": "${1:FIELDNAME} = models.TextField(${2})", + "description": "Django model ``TextField``" + }, + "Models TimeField":{ + "prefix": "mtime", + "body": "${1:FIELDNAME} = models.TimeField(auto_now_add=${2:True}, auto_now=${3:False})", + "description": "Django model ``TimeField``" + }, + "Models URLField":{ + "prefix": "murl", + "body": "${1:FIELDNAME} = models.URLField(verify_exists=${2:False})", + "description": "Django model ``URLField``" + }, + "Models XMLField":{ + "prefix": "mxml", + "body": "${1:FIELDNAME} = models.XMLField(schema_path=${2:None})", + "description": "Django model ``XMLField``" + }, + + "Models ForeignKey":{ + "prefix": "fk", + "body": "${1:FIELDNAME} = models.ForeignKey(${2:OtherModel}, on_delete=models.${3:CASCADE}, related_name=\"${4:RelatedName}\" ${0:, limit_choices_to=})", + "description": "Django model ``ForeignKey``" + }, + "Models ManyToManyField":{ + "prefix": "m2m", + "body": "${1:FIELDNAME} = models.ManyToManyField(${2:OtherModel}, related_name=\"${3:RelatedName}\" ${0:, limit_choices_to=})", + "description": "Django model ``ManyToManyField``" + }, + "Models OneToOneField":{ + "prefix": "o2o", + "body": "${1:FIELDNAME} = models.OneToOneField(${2:OtherModel}, related_name=\"${4:RelatedName}\"${0:, to_field=''})", + "description": "Django model ``OneToOneField``" + } +} + diff --git a/snippets/frameworks/django/views.json b/snippets/frameworks/django/views.json new file mode 100644 index 0000000..4faa917 --- /dev/null +++ b/snippets/frameworks/django/views.json @@ -0,0 +1,243 @@ +{ + "Django CreateView":{ + "prefix": "createview", + "body": [ + "class ${1:ModelName}CreateView(generic.CreateView):", + "\tmodel = ${2:$1}", + "\ttemplate_name = \"${3:$1/$1_form.html}\"", + "\tform_class = ${4:forms.$1Form}", + "\tsuccess_url = \"${5:.}\"" + ], + "description": "Django CBV ``CreateView``" + }, + "Django UpdateView":{ + "prefix": "updateview", + "body": [ + "class ${1:ModelName}UpdateView(generic.UpdateView):", + "\tmodel = ${2:$1}", + "\ttemplate_name = \"${3:$1/$1_form.html}\"", + "\tform_class = ${4:forms.$1Form}", + "\tsuccess_url = \"${5:.}\"", + "\n\tdef get_object(self):", + "\t\treturn $1.objects.get(pk=${6:self.kwargs.get(\"pk\")})" + ], + "description": "Django CBV ``UpdateView``" + }, + "Django DeleteView":{ + "prefix": "deleteview", + "body": [ + "class ${1:ModelName}DeleteView(generic.DeleteView):", + "\tmodel = ${2:$1}", + "\n\tdef get_success_url(self):", + "\t\treturn reverse(\"${3:$1:list}\")", + "\n\tdef get(self, request, *args, **kwargs):", + "\t\treturn post(request, *args, **kwargs)" + ], + "description": "Django CBV ``DeleteView``" + }, + "Django DetailView":{ + "prefix": "detailview", + "body": [ + "class ${1:ModelName}DetailView(generic.DetailView):", + "\tmodel = ${2:$1}", + "\ttemplate_name = \"${3:$1/$1_detail.html}\"", + "\n\tdef get_object(self):", + "\t\treturn $1.objects.get(pk=${4:self.kwargs.get(\"pk\")})", + "\n\tdef get_queryset(self):", + "\t\treturn $1.objects.filter(${5})" + ], + "description": "Django CBV ``DetailView``" + }, + "Django ListView":{ + "prefix": "listview", + "body": [ + "class ${1:ModelName}ListView(generic.ListView):", + "\tmodel = ${2:$1}", + "\ttemplate_name = \"${3:$1/$1_list.html}\"", + "\n\tdef get_queryset(self):", + "\t\treturn $1.objects.filter(${4})" + ], + "description": "Django CBV ``ListView``" + }, + "Django TemplateView":{ + "prefix": "templateview", + "body": [ + "class ${1:ModelName}TemplateView(generic.TemplateView):", + "\ttemplate_name = \"${2:$1/$1_list.html}\"", + "\n${3}" + ], + "description": "Django CBV ``TemplateView``" + }, + "Django FormView":{ + "prefix": "formview", + "body": [ + "class ${1:ModelName}FormView(generic.FormView):", + "\tform_class = ${2:forms.$1Form}", + "\ttemplate_name = \"${3}\"" + ], + "description": "Django CBV ``FormView``" + }, + "Django AdminView":{ + "prefix": "adminview", + "body": [ + "@admin.register($1)", + "class ${1:ModelName}Admin(admin.ModelAdmin):", + "\tlist_display = ${2:\"pk\",}", + "\tsearch_fields = ${3:\"pk\",}", + "\tlist_filter = ${4:\"FilterFields\",}" + ], + "description": "Django AdminView for ``admin.py``" + }, + "Django AdminTabularInline":{ + "prefix": "tabularinline", + "body": [ + "class ${1:ModelName}Inline(admin.TabularInline):", + "\tmodel = ${2:$1}", + "\tmin_num = ${4:0}", + "\tmax_num = ${4:8}", + "\textra = ${5:1}" + ], + "description": "Django TabularInline for ``admin.py``" + }, + "Django AdminStackedInline":{ + "prefix": "stackedinline", + "body": [ + "class ${1:ModelName}Inline(admin.StackedInline):", + "\tmodel = ${2:$1}", + "\tmin_num = ${4:0}", + "\tmax_num = ${4:8}", + "\textra = ${5:1}" + ], + "description": "Django StackedInline for ``admin.py``" + }, + + "Django Views get_context_data":{ + "prefix": "getcontextdata", + "body": [ + "def get_context_data(self, *args, **kwargs):", + "\tcontext = super().get_context_data(*args, **kwargs)", + "\treturn context" + ], + "description": "Django Views ``get_context_data`` method" + }, + "Django Views get_success_url":{ + "prefix": "getsuccessurl", + "body": [ + "def get_success_url(self):", + "\treturn reverse(\"${1:ViewName}\", kwargs={${2:\"pk\": self.get_object().pk}})" + ], + "description": "Django Views ``get_success_url`` method" + }, + "Django Views get_queryset":{ + "prefix": "getqueryset", + "body": [ + "def get_queryset(self):", + "\treturn ${1:ModelName}.objects.filter(${2})" + ], + "description": "Django Views ``get_queryset`` method" + }, + "Django Views get_object":{ + "prefix": "getobject", + "body": [ + "def get_object(self):", + "\treturn ${1:ModelName}.objects.get(${2})" + ], + "description": "Django Views ``get_object`` method" + }, + "Django Views form_valid":{ + "prefix": "formvalid", + "body": [ + "def form_valid(self, form):", + "\treturn super().form_valid(form)" + ], + "description": "Django Views ``form_valid`` method" + }, + "Django Views form_invalid":{ + "prefix": "forminvalid", + "body": [ + "def form_invalid(self, form):", + "\treturn super().form_invalid(form)" + ], + "description": "Django Views ``form_invalid`` method" + }, + "Django Views get_form_kwargs":{ + "prefix": "getformkwargs", + "body": [ + "def get_form_kwargs(self, form):", + "\tkwargs = super().get_form_kwargs()", + "\treturn kwargs" + ], + "description": "Django Views ``get_form_kwargs`` method" + }, + "Django Views dispatch":{ + "prefix": "dispatch", + "body": [ + "def dispatch(self, request, *args, **kwargs):", + "\treturn super().dispatch(request, *args, **kwargs)" + ], + "description": "Django Views ``dispatch`` method" + }, + "Django Views get_initial":{ + "prefix": "getinitial", + "body": [ + "def get_initial(self):", + "\tinit = super().get_initial()", + "\treturn init" + ], + "description": "Django Views ``get_initial`` method" + }, + "Django Views post":{ + "prefix": "post", + "body": [ + "def post(self, request, *args, **kwargs):", + "\treturn super().post(request, *args, **kwargs)" + ], + "description": "Django Views ``post`` method" + }, + "Django Views get":{ + "prefix": "get", + "body": [ + "def get(self, request, *args, **kwargs):", + "\treturn super().get(request, *args, **kwargs)" + ], + "description": "Django Views ``post`` method" + }, + + + "Django Forms field_clean":{ + "prefix": "cleanf", + "body": [ + "def clean_${1:FieldName}(self):", + "\t$1 = self.cleaned_data[\"$1\"]", + "\t${0}", + "\treturn $1" + ], + "description": "Django Views ``field_clean`` method" + }, + "Django Forms clean":{ + "prefix": "cleanff", + "body": [ + "def clean(self):", + "\tcleaned_data = super().clean()", + "\t${0}" + ], + "description": "Django Views ``clean`` method" + }, + + + "Django FBV Path":{ + "prefix": "fpath", + "body": "path(\"${1:Path}\", v.${2:View}, name=${0:PathName})", + "description": "Django Path For ``Function Based Views``" + }, + "Django CBV Path":{ + "prefix": "cpath", + "body": "path(\"${1:Path}\", v.${2:View}.as_viewJ(), name=${0:PathName})", + "description": "Django Path For ``Class Based Views``" + }, + "Django Path as Include":{ + "prefix": "ipath", + "body": "path(\"${1:Path}\", include(\"${2}.urls\", namespace=${0:Name})", + "description": "Django Path as ``Include``" + } +} diff --git a/snippets/frameworks/ejs.json b/snippets/frameworks/ejs.json new file mode 100644 index 0000000..477ecf5 --- /dev/null +++ b/snippets/frameworks/ejs.json @@ -0,0 +1,87 @@ +{ + "EJS No Output": { + "prefix": "ejs", + "body": [ + "<% $1 %> $2" + ], + "description": "EJS No Output" + }, + "EJS Output Value": { + "prefix": "ejsout", + "body": [ + "<%= $1 %> $2" + ], + "description": "EJS outputs no value" + }, + "EJS Output Escaped": { + "prefix": "ejsesc", + "body": [ + "<%- $1 %> $2" + ], + "description": "EJS outputs value" + }, + "EJS Comment": { + "prefix": "ejscom", + "body": [ + "<%# $1 %> $2" + ], + "description": "EJS comment tag with no output" + }, + "EJS Literal": { + "prefix": "ejslit", + "body": [ + "<%% $1 %> $2" + ], + "description": "EJS outputs a literal '<%'" + }, + "EJS Include": { + "prefix": "ejsinc", + "body": [ + "<% include $1 %> $2" + ], + "description": "EJS include statement" + }, + "EJS For Loop": { + "prefix": "ejsfor", + "body": [ + "<% for( let ${1:index} = 0; ${1:index} < ${2:array}.length; ${1:index}++ ) { %>", + "$3", + "<% } %>" + ], + "description": "EJS For Loop" + }, + "EJS ForEach": { + "prefix": "ejseach", + "body": [ + "<% ${1:array}.forEach(${2:element} => { %>", + " $3", + "<% }) %>" + ], + "description": "EJS ForEach Loop" + }, + "EJS If Statement": { + "prefix": "ejsif", + "body": [ + "<% if (${1:condition}) { %>", + " $2", + "<% } %>" + ], + "description": "EJS if statement" + }, + "EJS Else Statement": { + "prefix": "ejselse", + "body": [ + "<% } else { %>", + " $1" + ], + "description": "EJS if statement" + }, + "EJS Else If Statement": { + "prefix": "ejselif", + "body": [ + "<% } else if ({$1:condition}) { %>", + " $2" + ], + "description": "EJS if statement" + } +} diff --git a/snippets/frameworks/flutter.json b/snippets/frameworks/flutter.json new file mode 100644 index 0000000..594eeba --- /dev/null +++ b/snippets/frameworks/flutter.json @@ -0,0 +1,498 @@ +{ + "Stateless Widget": { + "prefix": "statelessW", + "body": [ + "class ${1:name} extends StatelessWidget {", + " const ${1:name}({Key? key}) : super(key: key);\n", + " @override", + " Widget build(BuildContext context) {", + " return Container(", + " child: ${2:null},", + " );", + " }", + "}" + ], + "description": "Create a Stateless widget" + }, + "Stateful Widget": { + "prefix": "statefulW", + "body": [ + "class ${1:name} extends StatefulWidget {", + " ${1:name}({Key? key}) : super(key: key);\n", + " @override", + " _${1:WidgetName}State createState() => _${1:WidgetName}State();", + "}\n", + "class _${1:index}State extends State<${1:index}> {", + " @override", + " Widget build(BuildContext context) {", + " return Container(", + " child: ${2:null},", + " );", + " }", + "}" + ], + "description": "Create a Stateful widget" + }, + "Build Method": { + "prefix": "build", + "body": [ + "@override", + "Widget build(BuildContext context) {", + " return ${0:};", + "}" + ], + "description": "Describes the part of the user interface represented by this widget." + }, + "Custom Painter ": { + "prefix": "customPainter", + "body": [ + "class ${0:name}Painter extends CustomPainter {", + "", + " @override", + " void paint(Canvas canvas, Size size) {", + " }", + "", + " @override", + " bool shouldRepaint(${0:name}Painter oldDelegate) => false;", + "", + " @override", + " bool shouldRebuildSemantics(${0:name}Painter oldDelegate) => false;", + "}" + ], + "description": "Used for creating custom paint" + }, + "Custom Clipper ": { + "prefix": "customClipper", + "body": [ + "class ${0:name}Clipper extends CustomClipper {", + "", + " @override", + " Path getClip(Size size) {", + " }", + "", + " @override", + " bool shouldReclip(CustomClipper oldClipper) => false;", + "}" + ], + "description": "Used for creating custom shapes" + }, + "InitState ": { + "prefix": "initS", + "body": [ + "@override", + "void initState() { ", + " super.initState();", + " ${0:}", + "}" + ], + "description": "Called when this object is inserted into the tree. The framework will call this method exactly once for each State object it creates." + }, + "Dispose": { + "prefix": "dis", + "body": [ + "@override", + "void dispose() { ", + " ${0:}", + " super.dispose();", + "}" + ], + "description": "Called when this object is removed from the tree permanently. The framework calls this method when this State object will never build again." + }, + "Reassemble": { + "prefix": "reassemble", + "body": [ + "@override", + "void reassemble(){", + " super.reassemble();", + " ${0:}", + "}" + ], + "description": "Called whenever the application is reassembled during debugging, for example during hot reload." + }, + "didChangeDependencies": { + "prefix": "didChangeD", + "body": [ + "@override", + "void didChangeDependencies() {", + " super.didChangeDependencies();", + " ${0:}", + "}" + ], + "description": "Called when a dependency of this State object changes" + }, + "didUpdateWidget": { + "prefix": "didUpdateW", + "body": [ + "@override", + "void didUpdateWidget (${1:Type} ${2:oldWidget}) {", + " super.didUpdateWidget(${2:oldWidget});", + " ${0:}", + "}" + ], + "description": "Called whenever the widget configuration changes." + }, + "ListView.Builder": { + "prefix": "listViewB", + "body": [ + "ListView.builder(", + " itemCount: ${1:1},", + " itemBuilder: (BuildContext context, int index) {", + " return ${2:};", + " },", + ")," + ], + "description": "Creates a scrollable, linear array of widgets that are created on demand.Providing a non-null `itemCount` improves the ability of the [ListView] to estimate the maximum scroll extent." + }, + "ListView.Separated": { + "prefix": "listViewS", + "body": [ + "ListView.separated(", + " itemCount: ${1:1},", + " separatorBuilder: (BuildContext context, int index) {", + " return ${2:};", + " },", + " itemBuilder: (BuildContext context, int index) {", + " return ${3:};", + " },", + ")," + ], + "description": "Creates a fixed-length scrollable linear array of list 'items' separated by list item 'separators'." + }, + "GridView.Builder": { + "prefix": "gridViewB", + "body": [ + "GridView.builder(", + " gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(", + " crossAxisCount: ${1:2},", + " ),", + " itemCount: ${2:2},", + " itemBuilder: (BuildContext context, int index) {", + " return ${3:};", + " },", + ")," + ], + "description": "Creates a scrollable, 2D array of widgets that are created on demand. Providing a non-null `itemCount` improves the ability of the [GridView] to estimate the maximum scroll extent." + }, + "GridView.Count": { + "prefix": "gridViewC", + "body": [ + "GridView.count(", + " crossAxisSpacing: ${1:1},", + " mainAxisSpacing: ${2:2},", + " crossAxisCount: ${3:2},", + " children: [", + " ${4:}", + " ],", + ")," + ], + "description": "Creates a scrollable, 2D array of widgets with a fixed number of tiles in the cross axis." + }, + "GridView.Extent": { + "prefix": "gridViewE", + "body": [ + "GridView.extent(", + " maxCrossAxisExtent: ${1:2},", + " children: [", + " ${2:}", + " ],", + ")," + ], + "description": "Creates a scrollable, 2D array of widgets with tiles that each have a maximum cross-axis extent." + }, + "Custom Scroll View": { + "prefix": "customScrollV", + "body": [ + "CustomScrollView(", + " slivers: [", + " ${0:}", + " ],", + ")," + ], + "description": "Creates a `ScrollView` that creates custom scroll effects using slivers. If the `primary` argument is true, the `controller` must be null." + }, + "Stream Builder": { + "prefix": "streamBldr", + "body": [ + "StreamBuilder(", + " stream: ${1:stream},", + " initialData: ${2:initialData},", + " builder: (BuildContext context, AsyncSnapshot snapshot) {", + " return Container(", + " child: ${3:child},", + " );", + " },", + ")," + ], + "description": "Creates a new `StreamBuilder` that builds itself based on the latest snapshot of interaction with the specified `stream`" + }, + "Animated Builder": { + "prefix": "animatedBldr", + "body": [ + "AnimatedBuilder(", + " animation: ${1:animation},", + " child: ${2:child},", + " builder: (BuildContext context, Widget child) {", + " return ${3:};", + " },", + ")," + ], + "description": "Creates an Animated Builder. The widget specified to `child` is passed to the `builder` " + }, + "Stateful Builder": { + "prefix": "statefulBldr", + "body": [ + "StatefulBuilder(", + " builder: (BuildContext context, setState) {", + " return ${0:};", + " },", + ")," + ], + "description": "Creates a widget that both has state and delegates its build to a callback. Useful for rebuilding specific sections of the widget tree." + }, + "Orientation Builder": { + "prefix": "orientationBldr", + "body": [ + "OrientationBuilder(", + " builder: (BuildContext context, Orientation orientation) {", + " return Container(", + " child: ${3:child},", + " );", + " },", + ")," + ], + "description": "Creates a builder which allows for the orientation of the device to be specified and referenced" + }, + "Layout Builder": { + "prefix": "layoutBldr", + "body": [ + "LayoutBuilder(", + " builder: (BuildContext context, BoxConstraints constraints) {", + " return ${0:};", + " },", + ")," + ], + "description": "Similar to the Builder widget except that the framework calls the builder function at layout time and provides the parent widget's constraints." + }, + "Single Child ScrollView": { + "prefix": "singleChildSV", + "body": [ + "SingleChildScrollView(", + " controller: ${1:controller,}", + " child: Column(", + " ${0:}", + " ),", + ")," + ], + "description": "Creates a scroll view with a single child" + }, + "Future Builder": { + "prefix": "futureBldr", + "body": [ + "FutureBuilder(", + " future: ${1:Future},", + " initialData: ${2:InitialData},", + " builder: (BuildContext context, AsyncSnapshot snapshot) {", + " return ${3:};", + " },", + ")," + ], + "description": "Creates a Future Builder. This builds itself based on the latest snapshot of interaction with a Future." + }, + "No Such Method": { + "prefix": "nosm", + "body": [ + "@override", + "dynamic noSuchMethod(Invocation invocation) {", + " ${1:}", + "}" + ], + "description": "This method is invoked when a non-existent method or property is accessed." + }, + "Inherited Widget": { + "prefix": "inheritedW", + "body": [ + "class ${1:Name} extends InheritedWidget {", + " ${1:Name}({Key? key, required this.child}) : super(key: key, child: child);", + "", + " final Widget child;", + "", + " static ${1:Name}? of(BuildContext context) {", + " return context.dependOnInheritedWidgetOfExactType<${1:Name}>();", + " }", + "", + " @override", + " bool updateShouldNotify(${1:Name} oldWidget) {", + " return ${2:true};", + " }", + "}" + ], + "description": "Class used to propagate information down the widget tree" + }, + "Mounted": { + "prefix": "mounted", + "body": [ + "@override", + "bool get mounted {", + " ${0:}", + "}" + ], + "description": "Whether this State object is currently in a tree." + }, + "Sink": { + "prefix": "snk", + "body": [ + "Sink<${1:type}> get ${2:name} => _${2:name}Controller.sink;", + "final _${2:name}Controller = StreamController<${1:type}>();" + ], + "description": "A Sink is the input of a stream." + }, + "Stream": { + "prefix": "strm", + "body": [ + "Stream<${1:type}> get ${2:name} => _${2:name}Controller.stream;", + "final _${2:name}Controller = StreamController<${1:type}>();" + ], + "description": "A source of asynchronous data events. A stream can be of any data type " + }, + "Subject": { + "prefix": "subj", + "body": [ + "Stream<${1:type}> get ${2:name} => _${2:name}Subject.stream;", + "final _${2:name}Subject = BehaviorSubject<${1:type}>();" + ], + "description": "A BehaviorSubject is also a broadcast StreamController which returns an Observable rather than a Stream." + }, + "toString": { + "prefix": "toStr", + "body": [ + "@override", + "String toString() {", + "return ${1:toString};", + " }" + ], + "description": "Returns a string representation of this object." + }, + "debugPrint": { + "prefix": "debugP", + "body": [ + "debugPrint(${1:statement});" + ], + "description": "Prints a message to the console, which you can access using the flutter tool's `logs` command (flutter logs)." + }, + "Material Package": { + "prefix": "importM", + "body": "import 'package:flutter/material.dart';", + "description": "Import flutter material package" + }, + "Cupertino Package": { + "prefix": "importC", + "body": "import 'package:flutter/cupertino.dart';", + "description": "Import Flutter Cupertino package" + }, + "flutter_test Package": { + "prefix": "importFT", + "body": "import 'package:flutter_test/flutter_test.dart';", + "description": "Import flutter_test package" + }, + "Material App": { + "prefix": "mateapp", + "description": "Create a MaterialApp", + "body": [ + "import 'package:flutter/material.dart';", + " ", + "void main() => runApp(MyApp());", + " ", + "class MyApp extends StatelessWidget {", + " @override", + " Widget build(BuildContext context) {", + " return MaterialApp(", + " title: 'Material App',", + " home: Scaffold(", + " appBar: AppBar(", + " title: Text('Material App Bar'),", + " ),", + " body: Center(", + " child: Container(", + " child: Text('Hello World'),", + " ),", + " ),", + " ),", + " );", + " }", + "}" + ] + }, + "Cupertino App": { + "prefix": "cupeapp", + "description": "Create a CupertinoApp", + "body": [ + "import 'package:flutter/cupertino.dart';", + " ", + "void main() => runApp(MyApp());", + " ", + "class MyApp extends StatelessWidget {", + " @override", + " Widget build(BuildContext context) {", + " return CupertinoApp(", + " title: 'Cupertino App',", + " home: CupertinoPageScaffold(", + " navigationBar: CupertinoNavigationBar(", + " middle: Text('Cupertino App Bar'),", + " ),", + " child: Center(", + " child: Container(", + " child: Text('Hello World'),", + " ),", + " ),", + " ),", + " );", + " }", + "}" + ] + }, + "Tween Animation Builder": { + "prefix": "tweenAnimationBuilder", + "body": [ + "TweenAnimationBuilder(", + " duration: ${1:const Duration(),}", + " tween: ${2:Tween(),}", + " builder: (BuildContext context, ${3:dynamic} value, Widget? child) {", + " return ${4:Container();}", + " },", + " ), " + ], + "description": "Widget builder that animates a property of a Widget to a target value whenever the target value changes." + }, + "Value Listenable Builder": { + "prefix": "valueListenableBuilder", + "body": [ + "ValueListenableBuilder(", + " valueListenable: ${1: null},", + " builder: (BuildContext context, ${2:dynamic} value, Widget? child) {", + " return ${3: Container();}", + " },", + " )," + ], + "description": "Given a ValueListenable and a builder which builds widgets from concrete values of T, this class will automatically register itself as a listener of the ValueListenable and call the builder with updated values when the value changes." + }, + "Test": { + "prefix": "f-test", + "body": [ + "test(", + " \"${1:test description}\",", + " () {},", + ");" + ], + "description": "Create a test function" + }, + "Test Widgets": { + "prefix": "widgetTest", + "body": [ + "testWidgets(", + " \"${1:test description}\",", + " (WidgetTester tester) async {},", + ");" + ], + "description": "Create a testWidgets function" + } +} \ No newline at end of file diff --git a/snippets/frameworks/jekyll.json b/snippets/frameworks/jekyll.json new file mode 100644 index 0000000..9a11714 --- /dev/null +++ b/snippets/frameworks/jekyll.json @@ -0,0 +1,526 @@ +{ + "Show": { + "prefix": "show", + "description": "Output markup: {{ }}", + "body": "{{ $1 }}" + }, + + "Execute": { + "prefix": "execute", + "description": "Tag markup: {%- -%}", + "body": "{%- $1 -%}" + }, + + "Tag assign": { + "prefix": "assign", + "description": "Variable tag: assign", + "body": [ + "{%- assign ${variable} = ${value} -%}" + ] + }, + + "Tag break": { + "prefix": "break", + "description": "Iteration tag: break", + "body": [ + "{%- break -%}" + ] + }, + + "Tag capture": { + "prefix": "capture", + "description": "Variable tag: capture", + "body": [ + "{%- capture ${variable} -%}${code:}{%- endcapture -%}" + ] + }, + + "Tag case": { + "prefix": "case", + "description": "Control flow tag: case", + "body": [ + "{%- case ${variable} -%}", + "\t{%- when ${condition} -%}", + "\t\t${code1:}", + "\t{%- else -%}", + "\t\t${code2:}", + "{%- endcase -%}" + ] + }, + + "Tag comment": { + "prefix": "comment", + "description": "Control flow tag: case", + "body": [ + "{%- comment -%}${description:}{%- endcomment -%}" + ] + }, + + "Tag context variable": { + "prefix": "convar", + "description": "Context Variable", + "body": [ + "{{ ${variable:} }}" + ] + }, + + "Tag continue": { + "prefix": "continue", + "description": "Iteration tag: continue", + "body": [ + "{%- continue -%}" + ] + }, + + "Tag cycle": { + "prefix": "cycle", + "description": "Iteration tag: cycle", + "body": [ + "{%- cycle '${0:odd}', '${1:even}' -%}" + ] + }, + + "Tag collection directory": { + "prefix": "cdirp", + "description": "The full path to the collection's source direcotry", + "body": [ + "{{ site.${my_collection}.directory }}" + ] + }, + + "Tag collection relative path": { + "prefix": "crelp", + "description": "The path to the document's source file realtive to the site source", + "body": [ + "{{ site.collections.${my_collection}.relative_path }}" + ] + }, + + "Tag decrement": { + "prefix": "decrement", + "description": "Variable tag: decrement", + "body": [ + "{%- decrement ${variable} -%}" + ] + }, + + "Tag for": { + "prefix": "for", + "description": "Iteration tag: for", + "body": [ + "{%- for ${item} in ${collection} -%}", + "\t${code:}", + "{%- endfor -%}" + ] + }, + + "Tag increment": { + "prefix": "increment", + "description": "Variable tag: increment", + "body": [ + "{%- increment ${variable} -%}" + ] + }, + + "Tag if": { + "prefix": "if", + "description": "Control flow tag: if", + "body": [ + "{%- if ${condition} -%}", + "\t${code:}", + "{%- endif -%}" + ] + }, + + "Tag else": { + "prefix": "else", + "description": "Control flow tag: else", + "body": [ + "{%- else -%}" + ] + }, + + "Tag elsif": { + "prefix": "elsif", + "description": "Control flow tag: elsif", + "body": [ + "{%- elsif ${condition} -%}" + ] + }, + + "Tag if else": { + "prefix": "ifelse", + "description": "Control flow tag: if else", + "body": [ + "{%- if ${condition} -%}", + "\t${code1:}", + "{%- else -%}", + "\t${code2:}", + "{%- endif -%}" + ] + }, + + "Tag gist": { + "prefix": "gist", + "description": "Add a gist code block", + "body": [ + "{%- gist ${gist:user/gist-id} -%}" + ] + }, + + "Tag highlight": { + "prefix": "highlight", + "description": "Syntax tag: highlight", + "body": [ + "{%- highlight ${lang:javascript} -%}", + "\t\t${code:}", + "{%- endhighlight -%}" + ] + }, + + "Tag include": { + "prefix": "include", + "description": "Tag: include", + "body": [ + "{%- include ${snippet} -%}" + ] + }, + + "Site Vairable Date": { + "prefix": "date", + "description": "Tag: site.date", + "body": [ + "{{ site.date | date: '${format: %b %d, %Y}' }}" + ] + }, + + "Tag include relative": { + "prefix": "increl", + "description": "Tag: include relative", + "body": [ + "{%- include_relative '${file:}' -%}" + ] + }, + + "Tag Post URL": { + "prefix": "posturl", + "description": "Tag: post_url", + "body": [ + "{%- post_url ${url:} -%}" + ] + }, + + "Tag unless": { + "prefix": "unless", + "description": "Control flow tag: unless", + "body": [ + "{%- unless ${condition} -%}", + "\t${code:}", + "{%- endunless -%}" + ] + }, + + "Tag when": { + "prefix": "when", + "description": "Control flow tag: when", + "body": [ + "{%- when ${condition} -%}", + "${code:}" + ] + }, + + "Tag Option limit": { + "prefix": "limit", + "description": "For loops option", + "body": [ + "limit: ${limit:5}" + ] + }, + + "Tag Option offset": { + "prefix": "offset", + "description": "For loops option", + "body": [ + "offset: ${offset:0}" + ] + }, + + "Tag Option reversed": { + "prefix": "reversed", + "description": "For loops option", + "body": [ + "reversed" + ] + }, + + "Tag raw": { + "prefix": "raw", + "description": "Tag: raw", + "body": [ + "{%- raw -%}${code:}{%- endraw -%}" + ] + }, + + "Tag paginate next or previous page": { + "prefix": "paginate", + "description": "Tag: paginate next or previous page", + "body": [ + "{{ paginator.${next:previous}_page }}" + ] + }, + + "Filter jsonify": { + "prefix": "json", + "description": "Array filter: jsonify", + "body": "| jsonify }}'" + }, + + "Filter join": { + "prefix": "join", + "description": "Array filter: join", + "body": "| join: '${seperator:, }}'" + }, + + "Filter first": { + "prefix": "first", + "description": "Array filter: first", + "body": "| first" + }, + + "Filter last": { + "prefix": "last", + "description": "Array filter: last", + "body": "| last" + }, + + "Filter map": { + "prefix": "map", + "description": "Array filter: map", + "body": "| map: '${key}'" + }, + + "Filter size": { + "prefix": "size", + "description": "Array filter: size", + "body": "| size" + }, + + "Filter sort": { + "prefix": "sort", + "description": "Array filter: sort", + "body": "| sort" + }, + + "Filter uniq": { + "prefix": "uniq", + "description": "Array filter: uniq", + "body": "| uniq" + }, + + "Filter ceil": { + "prefix": "ceil", + "description": "Math filter: ceil", + "body": "| ceil" + }, + + "Filter divided by": { + "prefix": "divided_by", + "description": "Math filter: divided by", + "body": "| divided_by: ${divided_by:2}" + }, + + "Filter floor": { + "prefix": "floor", + "description": "Math filter: floor", + "body": "| floor" + }, + + "Filter minus": { + "prefix": "minus", + "description": "Math filter: minus", + "body": "| minus: ${minus:1}" + }, + + "Filter modulo": { + "prefix": "modulo", + "description": "Math filter: modulo", + "body": "| modulo: ${modulo:2}" + }, + + "Filter plus": { + "prefix": "plus", + "description": "Math filter: plus", + "body": "| plus: ${plus:1}" + }, + + "Filter round": { + "prefix": "round", + "description": "Math filter: round", + "body": "| round: ${round:0}" + }, + + "Filter times": { + "prefix": "times", + "description": "Math filter: times", + "body": "| times: ${times:1}" + }, + + "Filter append": { + "prefix": "append", + "description": "String filter: append", + "body": "| append: '${string}' }}" + }, + + "Filter capitalize": { + "prefix": "capitalize", + "description": "String filter: capitalize", + "body": "| capitalize }}" + }, + + "Filter downcase": { + "prefix": "downcase", + "description": "String filter: downcase", + "body": "| downcase }}" + }, + + "Filter escape": { + "prefix": "escape", + "description": "String filter: escape", + "body": "| escape }}" + }, + + "Filter markdownify": { + "prefix": "markdown", + "description": "String filter: markdownify", + "body": "| markdownify }}" + }, + + "Filter prepend": { + "prefix": "prepend", + "description": "String filter: prepend", + "body": "| prepend: '${string}' }}" + }, + + "Filter remove": { + "prefix": "remove", + "description": "String filter: remove", + "body": "| remove: '${string}' }}" + }, + + "Filter remove first": { + "prefix": "remove_first", + "description": "String filter: remove first", + "body": "| remove_first: '${string}' }}" + }, + + "Filter replace": { + "prefix": "replace", + "description": "String filter: replace", + "body": "| replace: '${target}', '${replace}' }}" + }, + + "Filter replace first": { + "prefix": "replace_first", + "description": "String filter: replace first", + "body": "| replace_first: '${target}', '${replace}' }}" + }, + + "Filter slice": { + "prefix": "slice", + "description": "String filter: slice", + "body": "| slice: ${from:0}, ${to:5} }}" + }, + + "Filter slice single character": { + "prefix": "slice_single", + "description": "String filter: slice with single parameter", + "body": "| slice: ${at} }}" + }, + + "Filter split": { + "prefix": "split", + "description": "String filter: split", + "body": "| split: '${splitter:,}' }}" + }, + + "Filter strip": { + "prefix": "strip", + "description": "String filter: strip", + "body": "| strip }}" + }, + + "Filter lstrip": { + "prefix": "lstrip", + "description": "String filter: lstrip", + "body": "| lstrip }}" + }, + + "Filter rstrip": { + "prefix": "rstrip", + "description": "String filter: rstrip", + "body": "| rstrip }}" + }, + + "Filter strip html": { + "prefix": "strip_html", + "description": "String filter: strip html", + "body": "| strip_html }}" + }, + + "Filter strip newlines": { + "prefix": "strip_newlines", + "description": "String filter: strip newlines", + "body": "| strip_newlines }}" + }, + + "Filter truncate": { + "prefix": "truncate", + "description": "String filter: truncate", + "body": "| truncate: ${length:20}, '${ellipsis:...}' }}" + }, + + "Filter truncatewords": { + "prefix": "truncatewords", + "description": "String filter: truncatewords", + "body": "| truncatewords: ${length:5}, '${ellipsis:...}' }}" + }, + + "Filter upcase": { + "prefix": "upcase", + "description": "String filter: upcase }}", + "body": "| upcase }}" + }, + + "Filter url encode": { + "prefix": "url_encode", + "description": "String filter: url encode", + "body": "| url_encode }}" + }, + + "Filter uri escape": { + "prefix": "uri_escape", + "description": "String filter: uri escape", + "body": "| uri_escape }}" + }, + + "Filter xml escape": { + "prefix": "xml_escape", + "description": "String filter: xml escape", + "body": "| xml_escape }}" + }, + + "Front Matter": { + "prefix": "fm", + "description": "Add front matter", + "body": [ + "---", + "layout: ${layout:default}", + "title: ${title}", + "categories: ${category}", + "permalink: ${path}", + "tags: ${tag}", + "excerpt: ${description}", + "---" + ] + } +} diff --git a/snippets/frameworks/rails.json b/snippets/frameworks/rails.json new file mode 100644 index 0000000..db095a9 --- /dev/null +++ b/snippets/frameworks/rails.json @@ -0,0 +1,294 @@ +{ + "Before action": { + "prefix": "ba", + "body": [ + "before_action :${0:method}" + ], + "description": "before_action" + }, + "Before validation": { + "prefix": "bv", + "body": [ + "before_validation :${0:method}" + ], + "description": "before_validation" + }, + "Before create": { + "prefix": "bc", + "body": [ + "before_create :${0:method}" + ], + "description": "before_create" + }, + "Before update": { + "prefix": "bu", + "body": [ + "before_update :${0:method}" + ], + "description": "before_update" + }, + "Before save": { + "prefix": "bs", + "body": [ + "before_save :${0:method}" + ], + "description": "before_save" + }, + "Before destroy": { + "prefix": "bd", + "body": [ + "before_destroy :${0:method}" + ], + "description": "before_destroy" + }, + "After create": { + "prefix": "ac", + "body": [ + "after_create :${0:method}" + ], + "description": "after_create" + }, + "After validation": { + "prefix": "av", + "body": [ + "after_validation :${0:method}" + ], + "description": "after_validation" + }, + " update": { + "prefix": "au", + "body": [ + "after_update :${0:method}" + ], + "description": "after_update" + }, + " save": { + "prefix": "as", + "body": [ + "after_save :${0:method}" + ], + "description": "after_create" + }, + " destroy": { + "prefix": "ad", + "body": [ + "after_destroy :${0:method}" + ], + "description": "after_destroy" + }, + "Belongs to": { + "prefix": "bt", + "body": [ + "belongs_to :${0:association}" + ], + "description": "belongs_to assocation" + }, + "Belongs to polymorphic": { + "prefix": "btp", + "body": [ + "belongs_to :${0:association}, polymorphic: true" + ], + "description": "belongs_to polymorphic assocation" + }, + "Create action": { + "prefix": "create", + "body": [ + "def create", + "\t@${1:model_class_name} = ${2:ModelClassName}.new($1_params)", + "\trespond_to do |format|", + "\t\tif @$1.save", + "\t\t\tformat.html { redirect_to @$1, notice: '$2 created' }", + "\t\telse", + "\t\t\tformat.html { render :new, status: :unprocessable_entity }", + "\t\tend", + "\tend", + "end" + ], + "description": "def create" + }, + "Destroy action": { + "prefix": "destroy", + "body": [ + "def destroy", + "\t@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])", + "\t@$1.destroy!", + "\tredirect_to $1s_path, notice: '$2 removed'", + "end" + ], + "description": "def destroy" + }, + "Edit action": { + "prefix": "edit", + "body": [ + "def edit", + "\t@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])", + "end" + ], + "description": "def edit" + }, + "Index action": { + "prefix": "index", + "body": [ + "def index", + "\t@${1:model_class_name} = ${2:ModelClassName}.all", + "end" + ], + "description": "def index" + }, + "New action": { + "prefix": "new", + "body": [ + "def new", + "\t@${1:model_class_name} = ${2:ModelClassName}.new", + "end" + ], + "description": "def new" + }, + "Show action": { + "prefix": "show", + "body": [ + "def show", + "\t@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])", + "end" + ], + "description": "def show" + }, + "Update action": { + "prefix": "update", + "body": [ + "def update", + "\t@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])", + "\trespond_to do |format|", + "\t\tif @$1.update($1_params)", + "\t\t\tformat.html { redirect_to @$1, notice: '$2 updated' }", + "\t\telse", + "\t\t\tformat.html { render :edit, status: :unprocessable_entity }", + "\t\tend", + "\tend", + "end" + ], + "description": "def update" + }, + "Model Params": { + "prefix": "params", + "body": [ + "def ${1:model_class_name}_params", + "\tparams.require(:$1).permit(${2:attributes})", + "end" + ], + "description": "def model_params" + }, + "Getting Params": { + "prefix": "pa", + "body": [ + "params[:${1:id}]" + ], + "description": "getting params using attribute" + }, + "Delegate to": { + "prefix": "dt", + "body": [ + "delegate: :${1:method}, to: :${0:object}" + ], + "description": "delegate to" + }, + "Delegate to with prefix": { + "prefix": "dtp", + "body": [ + "delegate: :${1:method}, to: :${2:object}, prefix: :${3:prefix}, allow_nil: ${0:allow_nil}" + ], + "description": "delegate to" + }, + "Scope": { + "prefix": "scope", + "body": [ + "scope :${1:name}, -> { where(${2:field}: ${0:value}) }" + ], + "description": "AR scope" + }, + "Validate presence": { + "prefix": "vp", + "body": [ + "validates :${1:attribute}, presence: true" + ], + "description": "validates presence" + }, + "Validate uniqueness": { + "prefix": "vu", + "body": [ + "validates :${1:attribute}, uniqueness: true" + ], + "description": "validates presence" + }, + "Migration add column": { + "prefix": "mac", + "body": [ + "add_column :${1:table_name}, :${2:column_name}, :${0:data_type}" + ], + "description": "Migration add column" + }, + "Migration add index": { + "prefix": "mai", + "body": [ + "add_index :${1:table_name}, :${0:column_name}" + ], + "description": "Migration add index" + }, + "Migration remove column": { + "prefix": "mrc", + "body": [ + "remove_column :${1:table_name}, :${0:column_name}" + ], + "description": "Migration remove column" + }, + "Migration rename column": { + "prefix": "mrnc", + "body": [ + "rename_column :${1:table_name}, :${2:old_column_name}, :${0:new_column_name}" + ], + "description": "Migration rename column" + }, + "Migration change column": { + "prefix": "mcc", + "body": [ + "change_column :${1:table_name}, :${2:old_column_name}, :${0:data_type}" + ], + "description": "Migration change column" + }, + "Has many dependent": { + "prefix": "hmd", + "body": [ + "has_many :${1:object}, dependent: :${0:destroy}" + ], + "description": "has_many dependent" + }, + "Has many": { + "prefix": "hm", + "body": [ + "has_many :${0:object}" + ], + "description": "has_many association" + }, + "Has many through": { + "prefix": "hmt", + "body": [ + "has_many :${1:object}, through: :${0:object}" + ], + "description": "has_many through association" + }, + "Has one": { + "prefix": "ho", + "body": [ + "has_one :${0:object}" + ], + "description": "has_one association" + }, + "Has one dependent": { + "prefix": "hod", + "body": [ + "has_one :${1:object}, dependent: :${0:destroy}" + ], + "description": "has_one dependent" + } +} + diff --git a/snippets/frameworks/twig.json b/snippets/frameworks/twig.json new file mode 100644 index 0000000..b9a7469 --- /dev/null +++ b/snippets/frameworks/twig.json @@ -0,0 +1,536 @@ +{ + "asset": { + "prefix": "asset", + "body": + "{% set asset = ${1:entry.assetFieldHandle}.one() %}\n\n{% if asset %}\n\t\"{{\n{% endif %}", + "description": "asset" + }, + "assets": { + "prefix": "assets", + "body": + "{% for image in craft.assets.\n\t.sourceId(\"${1:1}\")\n\t.kind(\"${2:image}\")\n\t.limit(${3:10})\n}).all() %}\n\t\"{{\n{% endfor %}\n$0", + "description": "craft.assets" + }, + "autoescape": { + "prefix": "autoescape", + "body": "{% autoescape \"${1:type}\" %}\n\t$0\n{% endautoescape %}", + "description": "autoescape" + }, + "blockb": { + "prefix": "blockb", + "body": "{% block ${1:name} %}\n\t$0\n{% endblock %}", + "description": "block (block)" + }, + "block": { + "prefix": "block", + "body": "{% block ${1:name} %}$0{% endblock %}", + "description": "block" + }, + "blockf": { + "prefix": "blockf", + "body": "{{ block(\"${1:name}\") }}$0", + "description": "blockf" + }, + "cache": { + "prefix": "cache", + "body": "{% cache %}\n\t$1\n{% endcache %}\n$0", + "description": "cache" + }, + "case": { + "prefix": "case", + "body": "{% case \"${1:value}\" %}\n\t$0", + "description": "case" + }, + "children": { + "prefix": "children", + "body": "{% children %}$0", + "description": "children" + }, + "ceil": { + "prefix": "ceil", + "body": "ceil($1)$0", + "description": "ceil" + }, + "assetso": { + "prefix": "assetso", + "body": + "{% set assets = craft.assets({\n\tsourceId: \"${1:1}\",\n\tkind: \"${2:image}\",\n\tlimit: ${3:10}\n}).all() %}\n\n{% for image in assets %}\n\t\"{{\n{% endfor %}\n$0", + "description": "craft.assets - object syntax" + }, + "categorieso": { + "prefix": "categorieso", + "body": + "{% set categories = craft.categories({\n\tgroup: \"${1:categoryGroupHandle}\",\n\tlimit: \"${2:11}\"\n}).all() %}\n\n
    \n\t{% nav category in categories %}\n\t\t
  • \n\t\t\t{{ category.title }}\n\t\t\t{% ifchildren %}\n\t\t\t\t
      \n\t\t\t\t\t{% children %}\n\t\t\t\t
    \n\t\t\t{% endifchildren %}\n\t\t
  • \n\t{% endnav %}\n
", + "description": "craft.categories - object syntax" + }, + "categories": { + "prefix": "categories", + "body": + "
    \n\t{% nav category in craft.categories\n\t\t.group(\"${1:categoryGroupHandle}\")\n\t\t.limit(${2:11})\n\t\t.all()\n\t%}\n\t\t
  • \n\t\t\t{{ category.title }}\n\t\t\t{% ifchildren %}\n\t\t\t\t
      \n\t\t\t\t\t{% children %}\n\t\t\t\t
    \n\t\t\t{% endifchildren %}\n\t\t
  • \n\t{% endnav %}\n
", + "description": "craft.categories" + }, + "entrieso": { + "prefix": "entrieso", + "body": + "{% set entries = craft.entries({\n\tsection: \"${1:sectionName}\",\n\tlimit: \"${2:10}\"\n}).all() %}\n\n{% for entry in entries %}\n\t{{ entry.title }}\n{% endfor %}\n$0", + "description": "craft.entries - object syntax" + }, + "entries": { + "prefix": "entries", + "body": + "{% for entry in craft.entries\n\t.section(\"${1:sectionName}\")\n\t.limit(${2:10})\n\t.all()\n%}\n\t{{ entry.title }}\n{% endfor %}\n$0", + "description": "craft.entries" + }, + "t": { + "prefix": "t", + "body": "{{ $1 | t }}$0", + "description": "translate with | t" + }, + "replace": { + "prefix": "replace", + "body": "{{ ${1:$TM_SELECTED_TEXT} | replace(\"search\", \"replace\") }}$0", + "description": "replace with | replace(\"search\", \"replace\")" + }, + "replacex": { + "prefix": "replacex", + "body": + "{{ ${1:$TM_SELECTED_TEXT} | replace(\"/(search)/i\", \"replace\") }}$0", + "description": "replace regex with | replace(\"/(search)/i\", \"replace\")" + }, + "split": { + "prefix": "split", + "body": "{{ ${1:$TM_SELECTED_TEXT} | split(\"\\n\") }}$0", + "description": "split on | split (\"\\n\")" + }, + "tagso": { + "prefix": "tagso", + "body": + "{% set tags = craft.tags({\n\tgroup: \"${1:tagGroupHandle}\"\n}).all() %}\n\n
    \n\t{% for tag in tags %}\n\t\t
  • {{ tag }}
  • \n\t{% endfor %}\n
\n$0", + "description": "craft.tags - object syntax" + }, + "tags": { + "prefix": "tags", + "body": + "
    \n\t{% for tag in craft.tags.group(\"${1:tagGroupHandle}\").all() %}\n\t\t
  • {{ tag }}
  • \n\t{% endfor %}\n
\n$0", + "description": "craft.tags" + }, + "userso": { + "prefix": "userso", + "body": + "{% set users = craft.users({\n\tgroup: \"${1:userGroupHandle}\"\n}).all() %}\n\n{% for user in users %}\n\t{{ user.firstName }} {{ user.lastName }}\n{% endfor %}\n$0", + "description": "craft.users - object syntax" + }, + "users": { + "prefix": "users", + "body": + "{% for user in craft.users.group(\"${1:userGroupHandle}\").all() %}\n\t{{ user.firstName }} {{ user.lastName }}\n{% endfor %}\n$0", + "description": "craft.users" + }, + "csrf": { + "prefix": "csrf", + "body": "{{ csrfInput() }}\n$0", + "description": "csrf" + }, + "dd": { + "prefix": "dd", + "body": "
\n\t{{ dump($1) }}\n
\n{% exit %}$0", + "description": "dump and die" + }, + "do": { + "prefix": "do", + "body": "{% do $1 %}$0", + "description": "do" + }, + "dojs": { + "prefix": "dojs", + "body": "{% do view.registerJsFile \"${1:url}\" %}$0", + "description": "do js" + }, + "docss": { + "prefix": "docss", + "body": "{% do view.registerCssFile \"${1:url}\" %}$0", + "description": "do css" + }, + "dump": { + "prefix": "dump", + "body": "
\n\t{{ dump($1) }}\n
", + "description": "dump" + }, + "else": { + "prefix": "else", + "body": "{% else %}\n\t$0", + "description": "else" + }, + "embed": { + "prefix": "embed", + "body": "{% embed \"${1:template}\" %}\n\t$0\n{% endembed %}", + "description": "embed" + }, + "endautoescape": { + "prefix": "endautoescape", + "body": "{% endautoescape %}$0", + "description": "endautoescape" + }, + "endblock": { + "prefix": "endblock", + "body": "{% endblock %}$0", + "description": "endblock" + }, + "endcache": { + "prefix": "endcache", + "body": "{% endcache %}$0", + "description": "endcache" + }, + "endembed": { + "prefix": "endembed", + "body": "{% endembed %}$0", + "description": "endembed" + }, + "endfilter": { + "prefix": "endfilter", + "body": "{% endfilter %}$0", + "description": "endfilter" + }, + "endfor": { + "prefix": "endfor", + "body": "{% endfor %}$0", + "description": "endfor" + }, + "endif": { + "prefix": "endif", + "body": "{% endif %}$0", + "description": "endif" + }, + "endifchildren": { + "prefix": "endifchildren", + "body": "{% endifchildren %}$0", + "description": "endifchildren" + }, + "endcss": { + "prefix": "endcss", + "body": "{% endcss %}$0", + "description": "endcss" + }, + "endjs": { + "prefix": "endjs", + "body": "{% endjs %}$0", + "description": "endjs" + }, + "endmacro": { + "prefix": "endmacro", + "body": "{% endmacro %}$0", + "description": "endmacro" + }, + "endnav": { + "prefix": "endnav", + "body": "{% endnav %}$0", + "description": "endnav" + }, + "endset": { + "prefix": "endset", + "body": "{% endset %}$0", + "description": "endset" + }, + "endspaceless": { + "prefix": "endspaceless", + "body": "{% endspaceless %}$0", + "description": "endspaceless" + }, + "endswitch": { + "prefix": "endswitch", + "body": "{% endswitch %}$0", + "description": "endswitch" + }, + "endtrans": { + "prefix": "endtrans", + "body": "{% endtrans %}$0", + "description": "endtrans" + }, + "endverbatim": { + "prefix": "endverbatim", + "body": "{% endverbatim %}$0", + "description": "endverbatim" + }, + "exit": { + "prefix": "exit", + "body": "{% exit ${1:404} %}", + "description": "exit" + }, + "extends": { + "prefix": "extends", + "body": "{% extends \"${1:template}\" %}$0", + "description": "extends" + }, + "filterb": { + "prefix": "filterb", + "body": "{% filter ${1:name} %}\n\t$0\n{% endfilter %}", + "description": "filter (block)" + }, + "filter": { + "prefix": "filter", + "body": "{% filter ${1:name} %}$0{% endfilter %}", + "description": "filter" + }, + "floor": { + "prefix": "floor", + "body": "floor($1)$0", + "description": "floor" + }, + "fore": { + "prefix": "fore", + "body": + "{% for ${1:item} in ${2:items} %}\n\t$3\n{% else %}\n\t$0\n{% endfor %}", + "description": "for ... else" + }, + "for": { + "prefix": "for", + "body": "{% for ${1:item} in ${2:items} %}\n\t$0\n{% endfor %}", + "description": "for" + }, + "from": { + "prefix": "from", + "body": "{% from \"${1:template}\" import \"${2:macro}\" %}$0", + "description": "from" + }, + "endbody": { + "prefix": "endbody", + "body": "{{ endBody() }}\n$0", + "description": "endBody" + }, + "head": { + "prefix": "head", + "body": "{{ head() }}\n$0", + "description": "head" + }, + "if": { + "prefix": "if", + "body": "{% if ${1:condition} %}$2{% endif %}\n$0", + "description": "if" + }, + "ifb": { + "prefix": "ifb", + "body": "{% if ${1:condition} %}\n\t$0\n{% endif %}", + "description": "if (block)" + }, + "ife": { + "prefix": "ife", + "body": "{% if ${1:condition} %}\n\t$2\n{% else %}\n\t$0\n{% endif %}", + "description": "if ... else" + }, + "if1": { + "prefix": "if", + "body": "{% if ${1:condition} %}$0{% endif %}", + "description": "if" + }, + "ifchildren": { + "prefix": "ifchildren", + "body": "{% ifchildren %}\n\t$1\n{% endifchildren %}\n$0", + "description": "ifchildren" + }, + "import": { + "prefix": "import", + "body": "{% import \"${1:template}\" as ${2:name} %}$0", + "description": "import" + }, + "importself": { + "prefix": "importself", + "body": "{% import _self as ${1:name} %}$0", + "description": "importself" + }, + "inckv": { + "prefix": "inckv", + "body": + "{% include \"${1:template}\" with {\n\t${2:key}: ${3:\"${4:value}\"}\n} %}\n$0", + "description": "include w/ key/value" + }, + "include": { + "prefix": "include", + "body": "{% include \"${1:template}\" %}$0", + "description": "include" + }, + "inc": { + "prefix": "inc", + "body": "{% include \"${1:template}\" %}$0", + "description": "inc" + }, + "incp": { + "prefix": "incp", + "body": "{% include \"${1:template}\"${2: with ${3:params} }%}$0", + "description": "include w/ params" + }, + "css1": { + "prefix": "css", + "body": "{% do view.registerCssFile(\"${1:/resources/css/global.css}\") %}\n$0", + "description": "registerCssFile" + }, + "js": { + "prefix": "js", + "body": "{% js %}\n\t$1\n{% endjs %}\n$0", + "description": "js" + }, + "js1": { + "prefix": "js", + "body": "{% do view.registerJsFile(\"${1:/resources/js/global.js}\") %}\n$0", + "description": "registerJsFile" + }, + "css": { + "prefix": "css", + "body": "{% css %}\n\t$1\n{% endcss %}\n$0", + "description": "css" + }, + "macro": { + "prefix": "macro", + "body": "{% macro ${1:name}(${2:params}) %}\n\t$0\n{% endmacro %}", + "description": "macro" + }, + "matrix": { + "prefix": "matrix", + "body": + "{% for block in ${1:entry.matrixFieldHandle}.all() %}\n\n\t{% if block.type == \"${2:blockHandle}\" %}\n\t\t{{ block.${3:fieldHandle} }}\n\t{% endif %}\n\n\t{% if block.type == \"${4:blockHandle}\" %}\n\t\t{{ block.${5:fieldHandle} }}\n\t{% endif %}\n\n{% endfor %}\n$0", + "description": "matrix" + }, + "matrixif": { + "prefix": "matrixif", + "body": + "{% for block in ${1:entry.matrixFieldHandle}.all() %}\n\n\t{% if block.type == \"${2:blockHandle}\" %}\n\t\t{{ block.${3:fieldHandle} }}\n\t{% endif %}\n\n\t{% if block.type == \"${4:blockHandle}\" %}\n\t\t{{ block.${5:fieldHandle} }}\n\t{% endif %}\n\n{% endfor %}\n$0", + "description": "matrixif" + }, + "matrixifelse": { + "prefix": "matrixifelse", + "body": + "{% for block in ${1:entry.matrixFieldHandle}.all() %}\n\n\t{% if block.type == \"${2:blockHandle}\" %}\n\n\t\t{{ block.${3:fieldHandle} }}\n\n\t{% elseif block.type == \"${4:blockHandle}\" %}\n\n\t\t$0\n\t\n\t{% endif %}\n\n{% endfor %}", + "description": "matrixifelse" + }, + "matrixswitch": { + "prefix": "matrixswitch", + "body": + "{% for block in ${1:entry.matrixFieldHandle}.all() %}\n\n\t{% switch block.type %}\n\n\t\t{% case \"${2:blockHandle}\" %}\n\n\t\t\t{{ block.${3:fieldHandle} }}\n\n\t\t{% case \"${4:blockHandle}\" %}\n\n\t\t\t$0\n\n\t{% endswitch %}\n\n{% endfor %}", + "description": "matrixswitch" + }, + "max": { + "prefix": "max", + "body": "max(${1:$2, $3})$0", + "description": "max" + }, + "min": { + "prefix": "min", + "body": "min(${1:$2, $3})$0", + "description": "min" + }, + "nav": { + "prefix": "nav", + "body": "{% nav ${1:item} in ${2:items} %}\n\t$3\n{% endnav %}\n$0", + "description": "nav" + }, + "paginate": { + "prefix": "paginate", + "body": + "{% paginate ${1:elements} as ${2:pageInfo}, ${3:pageEntries} %}\n\n{% for item in ${3:pageEntries} %}\n\t$0\n{% endfor %}\n\n{% if ${2:pageInfo}.prevUrl %}Previous Page{% endif %}\n{% if ${2:pageInfo}.nextUrl %}Next Page{% endif %}", + "description": "paginate simple" + }, + "paginate1": { + "prefix": "paginate", + "body": + "{# PAGINATION\n\t\t\nFor this pagination to work properly, we need to be sure to set\nthe paginateBase variable in the template we are including the \npagination in.\n\n{% set paginateBase = \"/blog/p\" %}\n#}\n\n{% if pageInfo.totalPages > 1 %}\n
    \n\t{% if pageInfo.currentPage != \"1\" %}\n\t\t
  • First Page
  • \n\t{% endif %}\n\n\t{% if pageInfo.prevUrl %}\n\t\t
  • Previous Page
  • \n\t{% endif %}\n\n\t{% for pageNumber in 1..pageInfo.totalPages %}\n\t\t
  • \n\t\t\t{{ pageNumber }}\n\t\t
  • \n\t{% endfor %}\n\n\t{% if pageInfo.nextUrl %}\n\t\t
  • Next Page
  • \n\t{% endif %}\n\n\t{% if pageInfo.currentPage != pageInfo.total %}\n\t\t
  • Last Page
  • \n\t{% endif %}\n
\n{% endif %}\n$0", + "description": "paginate advanced" + }, + "redirect": { + "prefix": "redirect", + "body": + "{% redirect \"${1:template/path or http://straightupcraft.com}\" %}\n$0", + "description": "redirect" + }, + "getparam": { + "prefix": "getparam", + "body": + "craft.app.request.getParam(${1:\"Query String or Post Variable Name\"})\n$0", + "description": "request getParam" + }, + "getbodyparam": { + "prefix": "getbodyparam", + "body": "craft.app.request.getBodyParam(${1:\"postVariableName\"})\n$0", + "description": "request getBodyParam" + }, + "getqueryparam": { + "prefix": "getqueryparam", + "body": "craft.app.request.getQueryParam(${1:\"queryStringName\"})\n$0", + "description": "request getQueryParam" + }, + "getsegment": { + "prefix": "getsegment", + "body": "craft.app.request.getSegment(${1:2})\n$0", + "description": "request getSegment" + }, + "requirelogin": { + "prefix": "requirelogin", + "body": "{% requireLogin %}\n$0", + "description": "requireLogin" + }, + "requirepermission": { + "prefix": "requirepermission", + "body": "{% requirePermission \"${1:spendTheNight}\" %}\n$0", + "description": "requirePermission" + }, + "round": { + "prefix": "round", + "body": "{{ $1 | round(1, 'floor') }}$0", + "description": "round" + }, + "setb": { + "prefix": "setb", + "body": "{% set ${1:var} %}\n\t$0\n{% endset %}", + "description": "set (block)" + }, + "set": { + "prefix": "set", + "body": "{% set ${1:var} = ${2:value} %}$0", + "description": "set" + }, + "shuffle": { + "prefix": "shuffle", + "body": "shuffle($1)$0", + "description": "shuffle" + }, + "random": { + "prefix": "random", + "body": "random($1)$0", + "description": "random" + }, + "spaceless": { + "prefix": "spaceless", + "body": "{% spaceless %}\n\t$0\n{% endspaceless %}", + "description": "spaceless" + }, + "switch": { + "prefix": "switch", + "body": + "{% switch ${1:variable} %}\n\n\t{% case \"${2:value1}\" %}\n\t\n\n\t{% case \"${3:value2}\" %}\n\t\n\n\t{% default %}\n\t\n\n{% endswitch %}\n$0", + "description": "switch" + }, + "trans": { + "prefix": "trans", + "body": "{% trans %}$0{% endtrans %}", + "description": "trans" + }, + "urla": { + "prefix": "urla", + "body": + "url(\"${1:path}\", ${2:{foo:\"1\", bar:\"2\"\\}}, ${3:\"http\"}, ${4:false})$0", + "description": "url w/ arguments" + }, + "url": { + "prefix": "url", + "body": "url(\"${1:path}\")$0", + "description": "url" + }, + "use": { + "prefix": "use", + "body": "{% use \"${1:template}\" %}$0", + "description": "use" + }, + "verbatim": { + "prefix": "verbatim", + "body": "{% verbatim %}\n\t$0\n{% endverbatim %}", + "description": "verbatim" + } +} diff --git a/snippets/frameworks/vue/html.json b/snippets/frameworks/vue/html.json new file mode 100644 index 0000000..9cb50ff --- /dev/null +++ b/snippets/frameworks/vue/html.json @@ -0,0 +1,397 @@ +{ + "template": { + "prefix": "template", + "body": [ + "" + ], + "description": "template element" + }, + "v-text": { + "prefix": "vText", + "body": [ + "v-text=\"${1:msg}\"" + ], + "description": "Expects: string. Updates the element’s textContent." + }, + "v-html": { + "prefix": "vHtml", + "body": [ + "v-html=\"${1:html}\"" + ], + "description": "Expects: string. Updates the element’s innerHTML." + }, + "v-show": { + "prefix": "vShow", + "body": [ + "v-show=\"${1:condition}\"" + ], + "description": "Expects: any" + }, + "v-if": { + "prefix": "vIf", + "body": [ + "v-if=\"${1:condition}\"" + ], + "description": "Expects: any" + }, + "v-else": { + "prefix": "vElse", + "body": [ + "v-else" + ], + "description": "Does not expect expression. previous sibling element must have v-if or v-else-if." + }, + "v-else-if": { + "prefix": "vElseIf", + "body": [ + "v-else-if=\"${1:condition}\"" + ], + "description": "Expects: any. previous sibling element must have v-if or v-else-if." + }, + "v-for-without-key": { + "prefix": "vForWithoutKey", + "body": [ + "v-for=\"${1:item} in ${2:items}\"" + ], + "description": "Expects: Array | Object | number | string" + }, + "v-for": { + "prefix": "vFor", + "body": [ + "v-for=\"(${1:item}, ${2:index}) in ${3:items}\" :key=\"${4:index}\"" + ], + "description": "Expects: Array | Object | number | string" + }, + "v-on": { + "prefix": "vOn", + "body": [ + "v-on:${1:event}=\"${2:handle}\"" + ], + "description": "Expects: Function | Inline Statement" + }, + "v-bind": { + "prefix": "vBind", + "body": [ + "v-bind$1=\"${2}\"" + ], + "description": "Expects: any (with argument) | Object (without argument)" + }, + "v-model": { + "prefix": "vModel", + "body": [ + "v-model=\"${1:something}\"" + ], + "description": "Expects: varies based on value of form inputs element or output of components" + }, + "v-slot": { + "prefix": "vSlot", + "body": [ + "v-slot$1=\"${2}\"" + ], + "description": "Expects: JavaScript expression that is valid in a function argument position (supports destructuring in supported environments). Optional - only needed if expecting props to be passed to the slot." + }, + "v-pre": { + "prefix": "vPre", + "body": [ + "v-pre" + ], + "description": "Does not expect expression" + }, + "v-cloak": { + "prefix": "vCloak", + "body": [ + "v-cloak" + ], + "description": "Does not expect expression" + }, + "v-once": { + "prefix": "vOnce", + "body": [ + "v-once" + ], + "description": "Does not expect expression" + }, + "key": { + "prefix": "key", + "body": [ + ":key=\"${1:key}\"" + ], + "description": "Expects: string. Children of the same common parent must have unique keys. Duplicate keys will cause render errors." + }, + "ref": { + "prefix": "ref", + "body": [ + "ref=\"${1:reference}\"$0" + ], + "description": "Expects: string. ref is used to register a reference to an element or a child component. The reference will be registered under the parent component’s $refs object. If used on a plain DOM element, the reference will be that element; if used on a child component, the reference will be component instance." + }, + "slotA": { + "prefix": "slotA", + "body": [ + "slot=\"$1\"$0" + ], + "description": "slot=''. Expects: string. Used on content inserted into child components to indicate which named slot the content belongs to." + }, + "slotE": { + "prefix": "slotE", + "body": [ + "$2$0" + ], + "description": ". Expects: string. Used on content inserted into child components to indicate which named slot the content belongs to." + }, + "slotScope": { + "prefix": "slotScope", + "body": [ + "slot-scope=\"$1\"$0" + ], + "description": "Used to denote an element or component as a scoped slot. The attribute’s value should be a valid JavaScript expression that can appear in the argument position of a function signature. This means in supported environments you can also use ES2015 destructuring in the expression. Serves as a replacement for scope in 2.5.0+." + }, + "scope": { + "prefix": "scope", + "body": [ + "scope=\"${1:this api replaced by slot-scope in 2.5.0+}\"$0" + ], + "description": "Used to denote a