From 92ab0206c2ec23253ee0919a7f5e722a3042fef9 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Wed, 27 Aug 2025 20:34:11 -0700 Subject: [PATCH] Add Comment.nvim plugin with shortcuts --- .config/nvim/lua/plugins/completions.lua | 96 +++++++++++++----------- 1 file changed, 54 insertions(+), 42 deletions(-) diff --git a/.config/nvim/lua/plugins/completions.lua b/.config/nvim/lua/plugins/completions.lua index a22bb3a..9710229 100644 --- a/.config/nvim/lua/plugins/completions.lua +++ b/.config/nvim/lua/plugins/completions.lua @@ -1,45 +1,57 @@ return { - { - "L3MON4D3/LuaSnip", - -- dependencies = { - -- "saadparwaiz1/cmp_luasnip", -- Snippets source for nvim-cmp - -- "rafamadriz/friendly-snippets", -- Collection of snippets - -- }, - }, - { - "hrsh7th/nvim-cmp", - config = function() - -- require("luasnip.loaders.from_vscode").lazy_load() -- Load snippets from friendly-snippets - local cmp = require("cmp") + { + "L3MON4D3/LuaSnip", + -- dependencies = { + -- "saadparwaiz1/cmp_luasnip", -- Snippets source for nvim-cmp + -- "rafamadriz/friendly-snippets", -- Collection of snippets + -- }, + }, + { + "hrsh7th/nvim-cmp", + config = function() + -- require("luasnip.loaders.from_vscode").lazy_load() -- Load snippets from friendly-snippets + local cmp = require("cmp") - cmp.setup({ - snippet = { - -- REQUIRED - you must specify a snippet engine - expand = function(args) - require("luasnip").lsp_expand(args.body) -- For `luasnip` users. - end, - }, - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.abort(), - [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - }), - sources = cmp.config.sources({ - { name = "nvim_lsp" }, -- Show suggestions from LSP - { name = "luasnip" }, -- For luasnip users. - }, { - { name = "buffer" }, - }), - }) - end, - }, - { - "hrsh7th/cmp-nvim-lsp", - }, + cmp.setup({ + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + require("luasnip").lsp_expand(args.body) -- For `luasnip` users. + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, -- Show suggestions from LSP + { name = "luasnip" }, -- For luasnip users. + }, { + { name = "buffer" }, + }), + }) + end, + }, + { + "hrsh7th/cmp-nvim-lsp", + }, + { + "numToStr/Comment.nvim", + config = function() + -- Configure Comment Shortcuts + local comment = require("Comment.api") + vim.keymap.set("i", "", function() + comment.toggle.linewise.current() + end, { noremap = true, silent = true }) + vim.keymap.set("n", "", '(comment_toggle_linewise_current)') + vim.keymap.set("x", "", '(comment_toggle_linewise_visual)') + end, + }, }