Add Comment.nvim plugin with <c-/> shortcuts

This commit is contained in:
Daniel McKnight 2025-08-27 20:34:11 -07:00
parent 44063ad379
commit 92ab0206c2

View file

@ -1,45 +1,57 @@
return { return {
{ {
"L3MON4D3/LuaSnip", "L3MON4D3/LuaSnip",
-- dependencies = { -- dependencies = {
-- "saadparwaiz1/cmp_luasnip", -- Snippets source for nvim-cmp -- "saadparwaiz1/cmp_luasnip", -- Snippets source for nvim-cmp
-- "rafamadriz/friendly-snippets", -- Collection of snippets -- "rafamadriz/friendly-snippets", -- Collection of snippets
-- }, -- },
}, },
{ {
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
config = function() config = function()
-- require("luasnip.loaders.from_vscode").lazy_load() -- Load snippets from friendly-snippets -- require("luasnip.loaders.from_vscode").lazy_load() -- Load snippets from friendly-snippets
local cmp = require("cmp") local cmp = require("cmp")
cmp.setup({ cmp.setup({
snippet = { snippet = {
-- REQUIRED - you must specify a snippet engine -- REQUIRED - you must specify a snippet engine
expand = function(args) expand = function(args)
require("luasnip").lsp_expand(args.body) -- For `luasnip` users. require("luasnip").lsp_expand(args.body) -- For `luasnip` users.
end, end,
}, },
window = { window = {
completion = cmp.config.window.bordered(), completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(),
}, },
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
["<C-PageUp>"] = cmp.mapping.scroll_docs(-4), ["<C-PageUp>"] = cmp.mapping.scroll_docs(-4),
["<C-PageDown>"] = cmp.mapping.scroll_docs(4), ["<C-PageDown>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(), ["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(), ["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. ["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}), }),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = "nvim_lsp" }, -- Show suggestions from LSP { name = "nvim_lsp" }, -- Show suggestions from LSP
{ name = "luasnip" }, -- For luasnip users. { name = "luasnip" }, -- For luasnip users.
}, { }, {
{ name = "buffer" }, { name = "buffer" },
}), }),
}) })
end, end,
}, },
{ {
"hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-nvim-lsp",
}, },
{
"numToStr/Comment.nvim",
config = function()
-- Configure Comment Shortcuts
local comment = require("Comment.api")
vim.keymap.set("i", "<C-_>", function()
comment.toggle.linewise.current()
end, { noremap = true, silent = true })
vim.keymap.set("n", "<C-_>", '<Plug>(comment_toggle_linewise_current)')
vim.keymap.set("x", "<C-_>", '<Plug>(comment_toggle_linewise_visual)')
end,
},
} }