From f8fc4a1f14f08b9af8b35a37b349c2f171900006 Mon Sep 17 00:00:00 2001 From: Max Richter Date: Thu, 20 Apr 2023 15:28:34 +0200 Subject: [PATCH] @ --- configs/nvim/ftplugin/json.lua | 12 + configs/nvim/ftplugin/typescriptreact.lua | 38 + configs/nvim/lazy-lock.json | 51 +- configs/nvim/lua/max/core/plugins.lua | 138 -- configs/nvim/lua/max/plugins/autocomplete.lua | 3 + .../lua/max/plugins/autocomplete/snippets.lua | 38 +- configs/nvim/lua/max/plugins/autolist.lua | 5 + configs/nvim/lua/max/plugins/boole.lua | 14 + configs/nvim/lua/max/plugins/colorizer.lua | 5 + configs/nvim/lua/max/plugins/lsp.lua | 24 + configs/nvim/lua/max/plugins/lspsage.lua | 9 + configs/nvim/lua/max/plugins/oil.lua | 4 + configs/nvim/lua/max/plugins/rest.lua | 5 + configs/nvim/lua/max/plugins/sudoku.lua | 9 + .../nvim/lua/max/plugins/todo-comments.lua | 5 + configs/nvim/lua/max/plugins/trouble.lua | 6 + configs/zsh/.gitignore | 1 - configs/zsh/antigen.zsh | 2057 +++++++++++++++++ 18 files changed, 2262 insertions(+), 162 deletions(-) create mode 100644 configs/nvim/ftplugin/typescriptreact.lua create mode 100644 configs/nvim/lua/max/plugins/autolist.lua create mode 100644 configs/nvim/lua/max/plugins/boole.lua create mode 100644 configs/nvim/lua/max/plugins/colorizer.lua create mode 100644 configs/nvim/lua/max/plugins/lspsage.lua create mode 100644 configs/nvim/lua/max/plugins/oil.lua create mode 100644 configs/nvim/lua/max/plugins/rest.lua create mode 100644 configs/nvim/lua/max/plugins/sudoku.lua create mode 100644 configs/nvim/lua/max/plugins/todo-comments.lua create mode 100644 configs/nvim/lua/max/plugins/trouble.lua delete mode 100644 configs/zsh/.gitignore create mode 100644 configs/zsh/antigen.zsh diff --git a/configs/nvim/ftplugin/json.lua b/configs/nvim/ftplugin/json.lua index 7362634..9076fc0 100644 --- a/configs/nvim/ftplugin/json.lua +++ b/configs/nvim/ftplugin/json.lua @@ -1 +1,13 @@ vim.cmd [[autocmd BufRead,BufNewFile tsconfig.json set filetype=jsonc]] + +-- ftplugin/json.lua +vim.keymap.set('n', 'o', function() + local line = vim.api.nvim_get_current_line() + + local should_add_comma = string.find(line, '[^,{[]$') + if should_add_comma then + return 'A,' + else + return 'o' + end +end, { buffer = true, expr = true }) diff --git a/configs/nvim/ftplugin/typescriptreact.lua b/configs/nvim/ftplugin/typescriptreact.lua new file mode 100644 index 0000000..1520c4e --- /dev/null +++ b/configs/nvim/ftplugin/typescriptreact.lua @@ -0,0 +1,38 @@ +-- ftplugin/vue.lua +vim.keymap.set('i', '/', function() + local node = vim.treesitter.get_node() + if not node then + return '/' + end + + local first_sibling_node = node:prev_named_sibling() + if not first_sibling_node then + return '/' + end + + local parent_node = node:parent() + local is_tag_writing_in_progress = node:type() == 'text' and parent_node:type() == 'element' + + local is_start_tag = first_sibling_node:type() == 'start_tag' + + local start_tag_text = vim.treesitter.get_node_text(first_sibling_node, 0) + local tag_is_already_terminated = string.match(start_tag_text, '>$') + + if + is_tag_writing_in_progress + and is_start_tag + and not tag_is_already_terminated + then + local char_at_cursor = vim.fn.strcharpart( + vim.fn.strpart(vim.fn.getline '.', vim.fn.col '.' - 2), + 0, + 1 + ) + local already_have_space = char_at_cursor == ' ' + + -- We can also automatically add a space if there isn't one already + return already_have_space and '/>' or ' />' + end + + return '/' +end, { expr = true, buffer = true }) diff --git a/configs/nvim/lazy-lock.json b/configs/nvim/lazy-lock.json index b8a0faa..68f7ba0 100644 --- a/configs/nvim/lazy-lock.json +++ b/configs/nvim/lazy-lock.json @@ -1,9 +1,10 @@ { "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, - "LuaSnip": { "branch": "master", "commit": "a6355b12a3b7da0aef71f02560e17ff480182b97" }, - "alpha-nvim": { "branch": "main", "commit": "dafa11a6218c2296df044e00f88d9187222ba6b0" }, + "LuaSnip": { "branch": "master", "commit": "8d6c0a93dec34900577ba725e91c44b8d3ca1f45" }, + "alpha-nvim": { "branch": "main", "commit": "87c204040e3f5d4c1c95067b35905d8f8a2f2545" }, + "autolist.nvim": { "branch": "main", "commit": "0936e384b10315f65b8ef3bf1be938314d23a528" }, "barbar.nvim": { "branch": "master", "commit": "8edf23fe94a2486a8bc74cb64efb9211810f7e83" }, - "catppuccin": { "branch": "main", "commit": "fa9a4465672fa81c06b23634c0f04f6a5d622211" }, + "boole.nvim": { "branch": "main", "commit": "f4f9996f91159e54b8f1893b20e2e599c91bc1bd" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-emoji": { "branch": "main", "commit": "19075c36d5820253d32e2478b6aaf3734aeaafa0" }, "cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" }, @@ -11,51 +12,57 @@ "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, "copilot-cmp": { "branch": "master", "commit": "99467081478aabe4f1183a19a8ba585e511adc20" }, - "copilot.lua": { "branch": "master", "commit": "a4a37dda9e48986e5d2a90d6a3cbc88fca241dbb" }, + "copilot.lua": { "branch": "master", "commit": "decc8d43bcd73a288fa689690c20faf0485da217" }, "flit.nvim": { "branch": "main", "commit": "f60e4b3d49bb5a5e97cfffe66f2e671eb422078e" }, - "friendly-snippets": { "branch": "main", "commit": "8f26df063f0fdabc27845c7aed56db9102d385e8" }, - "git-conflict.nvim": { "branch": "main", "commit": "80bc8931d4ed8c8c4d289a08e1838fcf4741408d" }, + "friendly-snippets": { "branch": "main", "commit": "b1b78a6433268fc172adb5a843e165035e83861e" }, + "git-conflict.nvim": { "branch": "main", "commit": "f2ed4dc910a7dd23f1762fc57c1986cfd210283b" }, "gitsigns.nvim": { "branch": "main", "commit": "372d5cb485f2062ac74abc5b33054abac21d8b58" }, - "lazy.nvim": { "branch": "main", "commit": "57cce98dfdb2f2dd05a0567d89811e6d0505e13b" }, - "leap.nvim": { "branch": "main", "commit": "98a72ad93c629c49bd7127d342960cc1b159b620" }, + "lazy.nvim": { "branch": "main", "commit": "5c89dc52f42e5058a46b0912d7d9042f564e44e0" }, + "leap.nvim": { "branch": "main", "commit": "0eb3611593e135150e2f7880ec67568ccb51c17a" }, "lsp-format.nvim": { "branch": "master", "commit": "ca0df5c8544e51517209ea7b86ecc522c98d4f0a" }, "lspkind.nvim": { "branch": "master", "commit": "c68b3a003483cf382428a43035079f78474cd11e" }, + "lspsaga.nvim": { "branch": "main", "commit": "c483c9b43fa6cb47fb8c18a8ebd4ece45bbf07f4" }, "lualine-lsp-progress": { "branch": "master", "commit": "56842d097245a08d77912edf5f2a69ba29f275d7" }, "lualine.nvim": { "branch": "master", "commit": "84ffb80e452d95e2c46fa29a98ea11a240f7843e" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "b81c50c4baae7d80b1723b3fa86e814d7754d15b" }, - "mason.nvim": { "branch": "main", "commit": "7caf4f7143b4b2e17fe0e893bdd05c622c508207" }, - "mini.nvim": { "branch": "main", "commit": "10d3903189418af95d5852d7b93d4e22f6a1e46f" }, - "neo-tree.nvim": { "branch": "v2.x", "commit": "2b2f74828eeb02cf29d6b21aa32eedadadc94ca7" }, - "neotest": { "branch": "master", "commit": "3dbac1ebda49861956e3c53f37a9d14de6dffb9b" }, - "neotest-jest": { "branch": "main", "commit": "821bb227e31259307db30c88671a1c3724f78637" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "7034065099c1665143091c7282b3b1b8f0b23783" }, + "mason.nvim": { "branch": "main", "commit": "4b357eded58ef0993fb49a591ed70306c6b44e08" }, + "mini.nvim": { "branch": "main", "commit": "672d6d1e7c117e393b269f5af30856e923271203" }, + "neo-tree.nvim": { "branch": "v2.x", "commit": "7a6b0d43d70636edfec183fb49c02f725765da73" }, + "neotest": { "branch": "master", "commit": "8d279ac31542553461f5377db1596ae52e042d00" }, + "neotest-jest": { "branch": "main", "commit": "22b1050dda3ebd401780ec4b8e193cf52523a4da" }, "neotest-vitest": { "branch": "main", "commit": "d6577b191e16c174bffbec1eadfcd65c22fdcc0d" }, - "noice.nvim": { "branch": "main", "commit": "1da4edfba3e9278e98fc9723d7235d9ab3889744" }, + "noice.nvim": { "branch": "main", "commit": "7bd435a48a2d2b3f028c633126e3f669ae6b902f" }, "nui.nvim": { "branch": "main", "commit": "ecd9def93891b9260b15b5fcef542eaabf4145c9" }, "null-ls.nvim": { "branch": "main", "commit": "f8ffcd7cb8fb3325c711d459152ef132b5b65aed" }, "nvim-cmp": { "branch": "main", "commit": "777450fd0ae289463a14481673e26246b5e38bf2" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6" }, "nvim-dap": { "branch": "master", "commit": "debd7c2f80eaf20c5f5df25db8d8c1b9b18f4421" }, "nvim-dap-ui": { "branch": "master", "commit": "286f682f366fbc652b38dff893569374e9433dd3" }, "nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" }, - "nvim-lspconfig": { "branch": "master", "commit": "e52efca5d4f5536533d447ec0d97e4d525b37ace" }, - "nvim-notify": { "branch": "master", "commit": "50d037041ada0895aeba4c0215cde6d11b7729c4" }, + "nvim-lspconfig": { "branch": "master", "commit": "eddaef928c1e1dd79a96f5db45f2fd7f2efe7ea0" }, + "nvim-notify": { "branch": "master", "commit": "159c6cf1be25a933f35e97499314c9faab55c98f" }, "nvim-recorder": { "branch": "main", "commit": "0f6dec901a530c41095cff8def0c723877374cb4" }, "nvim-scrollbar": { "branch": "main", "commit": "f85b29805cf917f9b1d5ff0c9a52c5b1bdca5943" }, "nvim-toggleterm.lua": { "branch": "main", "commit": "1c5996ee3c30b54751093fe68d40676859e7778f" }, - "nvim-treesitter": { "branch": "master", "commit": "dad0864fa324d1df88242a978e9d7de383c5be68" }, + "nvim-treesitter": { "branch": "master", "commit": "b0338a056525e83d88aaa76e8cf396af07410bed" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "8673926519ea61069f9c1366d1ad1949316d250e" }, "nvim-ts-autotag": { "branch": "main", "commit": "cac97f3b47bcb927db6d1d784c0c323056506ef3" }, - "nvim-ts-context-commentstring": { "branch": "main", "commit": "729d83ecb990dc2b30272833c213cc6d49ed5214" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "0bf8fbc2ca8f8cdb6efbd0a9e32740d7a991e4c3" }, "nvim-web-devicons": { "branch": "master", "commit": "4ec26d67d419c12a4abaea02f1b6c57b40c08d7e" }, + "oil.nvim": { "branch": "master", "commit": "fb8b101d7cb4727d8719ab6ed141330eca997d3f" }, "persisted.nvim": { "branch": "main", "commit": "dbdd6af1847105f5cc7f7c51a648b32a78598eec" }, "plenary.nvim": { "branch": "master", "commit": "9ac3e9541bbabd9d73663d757e4fe48a675bb054" }, "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, - "sniprun": { "branch": "master", "commit": "52ecf6ad06304e46722118af2aaea5647b157ab8" }, + "rest.nvim": { "branch": "main", "commit": "df826bc0a76d5eb79b458db894d47a5538b454fe" }, + "sniprun": { "branch": "master", "commit": "7afcd7797e2d265732c718264f95e093bae9acfe" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "580b6c48651cabb63455e97d7e131ed557b8c7e2" }, "telescope.nvim": { "branch": "master", "commit": "6258d50b09f9ae087317e392efe7c05a7323492d" }, + "todo-comments.nvim": { "branch": "main", "commit": "8febc60a76feefd8203077ef78b6a262ea1a41f9" }, "translate.nvim": { "branch": "main", "commit": "7b2fd50c21ecfe536d572d62dcd3fa83acad3743" }, + "trouble.nvim": { "branch": "main", "commit": "d56bfc0c501ced4002a57cb60433362fb2ce9c4d" }, "undotree": { "branch": "master", "commit": "485f01efde4e22cb1ce547b9e8c9238f36566f21" }, "vim-dadbod": { "branch": "master", "commit": "3f57c0cd41523423fd781422dfc833820095a3e8" }, "vim-dadbod-completion": { "branch": "master", "commit": "e71eb6140556c5ced80de6299a1fdfe22bd3c1b1" }, - "vim-dadbod-ui": { "branch": "master", "commit": "986324fa6372170ec47b28a5558ae7f7185e1d71" }, - "which-key.nvim": { "branch": "main", "commit": "4b73390eec680b4c061ea175eb32c0ff3412271d" } + "vim-dadbod-ui": { "branch": "master", "commit": "4c306bef457ebfdbe71c76b49672d48ef310ddd3" }, + "which-key.nvim": { "branch": "main", "commit": "94cb020ff33a1e0e22fac1c41663d2c439741f17" } } \ No newline at end of file diff --git a/configs/nvim/lua/max/core/plugins.lua b/configs/nvim/lua/max/core/plugins.lua index a672f00..afbf871 100644 --- a/configs/nvim/lua/max/core/plugins.lua +++ b/configs/nvim/lua/max/core/plugins.lua @@ -1,120 +1,3 @@ --- local plugins = { --- --- { --- dir = "~/Projects/sudoku.nvim", --- cmd = "Sudoku", --- config = function() --- require("sudoku").setup({ --- custom_highlights = { --- square = { fg = "red" } --- } --- }) --- vim.cmd("hi SudokuSquare guibg=red") --- end --- }, --- --- --- --- { --- "shortcuts/no-neck-pain.nvim", --- cmd = "NoNeckPain", --- config = true --- }, --- , --- { --- "stevearc/dressing.nvim", --- enabled = false, --- lazy = true, --- }, --- { --- "simrat39/symbols-outline.nvim", --- cmd = "SymbolsOutline", --- config = true, --- }, --- --------------------- --- -- Code Navigation -- --- --------------------- --- --------------- --- -- Lsp Setup -- --- --------------- --- { --- "glepnir/lspsaga.nvim", --- event = "BufRead", --- config = function() --- require("lspsaga").setup({ --- symbol_in_winbar = { --- enable = false, --- }, --- }) --- end, --- }, --- { --- "folke/trouble.nvim", --- cmd = "TroubleToggle", --- dependencies = "nvim-tree/nvim-web-devicons", --- config = function() --- require("trouble").setup({}) --- end, --- }, --- ------------------- --- -- Autocomplete -- --- ------------------- --- { --- "nat-418/boole.nvim", --- event = "InsertEnter", --- config = function() --- require("boole").setup({ --- mappings = { --- increment = '+', --- decrement = '-' --- }, --- additions = { --- { "const", "let", "var" }, --- { "absolute", "relative", "fixed", "sticky" } --- } --- }) --- end, --- }, --- { --- "gaoDean/autolist.nvim", --- event = "InsertEnter", --- config = true, --- }, --- ------------------------- --- -- Syntax Highlighting -- --- ------------------------- --- { --- "norcalli/nvim-colorizer.lua", --- config = true, --- event = "BufReadPost", --- }, --- { --- "folke/todo-comments.nvim", --- config = true, --- event = "VeryLazy", --- }, --- -------------------- --- -- IDE Type Stuff -- --- -------------------- --- { --- "rest-nvim/rest.nvim", --- lazy = false, --- dependencies = { "nvim-lua/plenary.nvim" }, --- config = function() --- require("rest-nvim").setup({}) --- end, --- }, --- { --- "jackMort/ChatGPT.nvim", --- cmd = "ChatGPT", --- config = true, --- dependencies = { --- "MunifTanjim/nui.nvim", --- }, --- }, --- --Dap Debugger -- Have not yet been able to set this up --- } - local opts = { defaults = { lazy = true }, install = { colorscheme = { require("max.plugins.theme").name } }, @@ -125,27 +8,6 @@ local opts = { performance = { rtp = { reset = true, - disabled_plugins = { - "gzip", - "zip", - "zipPlugin", - "fzf", - "tar", - "tarPlugin", - "getscript", - "getscriptPlugin", - "vimball", - "vimballPlugin", - "2html_plugin", - "matchit", - "matchparen", - "logiPat", - "rrhelper", - "netrw", - "netrwPlugin", - "netrwSettings", - "netrwFileHandlers", - }, }, } } diff --git a/configs/nvim/lua/max/plugins/autocomplete.lua b/configs/nvim/lua/max/plugins/autocomplete.lua index 7c2a376..0e478b9 100644 --- a/configs/nvim/lua/max/plugins/autocomplete.lua +++ b/configs/nvim/lua/max/plugins/autocomplete.lua @@ -15,6 +15,9 @@ return { }, config = function() local luasnip = require("luasnip") + luasnip.config.set_config { + enable_autosnippets = true, + } require("max.plugins.autocomplete.snippets") local lspkind = require("lspkind") diff --git a/configs/nvim/lua/max/plugins/autocomplete/snippets.lua b/configs/nvim/lua/max/plugins/autocomplete/snippets.lua index 05dc2c9..fc62c31 100644 --- a/configs/nvim/lua/max/plugins/autocomplete/snippets.lua +++ b/configs/nvim/lua/max/plugins/autocomplete/snippets.lua @@ -19,7 +19,7 @@ ls.config.set_config({ -- Update more often, :h events for more info. updateevents = "TextChanged,TextChangedI", ext_opts = { - [types.choiceNode] = { + [types.choiceNode] = { active = { virt_text = { { "choiceNode", "Comment" } }, }, @@ -51,6 +51,42 @@ local function simple_restore(args, _) return sn(nil, { i(1, args[1]) }) end + +ls.add_snippets('lua', { + s( + { + trig = 'if', + condition = function() + local ignored_nodes = { 'string', 'comment' } + + local pos = vim.api.nvim_win_get_cursor(0) + -- Use one column to the left of the cursor to avoid a "chunk" node + -- type. Not sure what it is, but it seems to be at the end of lines in + -- some cases. + local row, col = pos[1] - 1, pos[2] - 1 + + local node_type = vim.treesitter + .get_node({ + pos = { row, col }, + }) + :type() + + return not vim.tbl_contains(ignored_nodes, node_type) + end, + }, + fmt( + [[ +if {} then + {} +end + ]], + { i(1), i(2) } + ) + ), +}, { + type = 'autosnippets', +}) + ls.add_snippets("svelte", { s("slt", { t({ '