From 6c0e06ff11ab54c654a1fe76e37ca1e7a1676ebb Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sat, 18 Jan 2025 23:25:36 -0600 Subject: [PATCH] feat: add keymap for yanking to system clipboard --- lua/plugins/completions.lua | 125 ++++++++++++++++++------------------ lua/plugins/debugging.lua | 6 +- lua/plugins/lsp.lua | 4 ++ lua/plugins/treesitter.lua | 8 ++- lua/vim-options.lua | 4 +- 5 files changed, 78 insertions(+), 69 deletions(-) diff --git a/lua/plugins/completions.lua b/lua/plugins/completions.lua index 4902546..9643d10 100644 --- a/lua/plugins/completions.lua +++ b/lua/plugins/completions.lua @@ -1,66 +1,67 @@ return { - { - "hrsh7th/cmp-nvim-lsp", - }, - { - "L3MON4D3/LuaSnip", - dependencies = { - "saadparwaiz1/cmp_luasnip", - "rafamadriz/friendly-snippets", - }, - }, - { - "hrsh7th/nvim-cmp", - config = function() - local luasnip = require("luasnip") - local cmp = require("cmp") + { + "hrsh7th/cmp-nvim-lsp", + }, + { + "L3MON4D3/LuaSnip", + dependencies = { + "saadparwaiz1/cmp_luasnip", + "rafamadriz/friendly-snippets", + }, + }, + { + "hrsh7th/nvim-cmp", + config = function() + local luasnip = require("luasnip") + local cmp = require("cmp") - require("luasnip.loaders.from_vscode").lazy_load() + require("luasnip.loaders.from_vscode").lazy_load() - cmp.setup({ - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - 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.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }), - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "luasnip" }, - }, { - { name = "buffer" }, - }), - }) - end, - }, + cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.close(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, {}), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, {}), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + }, { + { name = "buffer" }, + }), + }) + end, + }, } diff --git a/lua/plugins/debugging.lua b/lua/plugins/debugging.lua index 87d4db9..46a412a 100644 --- a/lua/plugins/debugging.lua +++ b/lua/plugins/debugging.lua @@ -61,7 +61,7 @@ return { name = "launch - netcoredbg", request = "launch", program = function() - return vim.fn.input("Path to dll", vim.fn.getcwd() .. "/bin/Debug/", "file") + return vim.fn.input("Path to dll: ", vim.fn.getcwd(), "file") end, }, } @@ -79,7 +79,7 @@ return { dapui.close() end - vim.keymap.set("n", "dt", dap.toggle_breakpoint, {}) - vim.keymap.set("n", "dc", dap.continue, {}) + vim.keymap.set("n", "dt", dap.toggle_breakpoint, { desc = "Toggle breakpoint" }) + vim.keymap.set("n", "dc", dap.continue, { desc = "Continue" }) end, } diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 0c5c7d0..7a50349 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -73,6 +73,10 @@ return { capabilities = capabilities, }) + lspconfig.lemminx.setup({ + capabilities = capabilities, + }) + vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("UserLspConfig", {}), callback = function(ev) diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index bb71b02..b2b4e00 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -7,8 +7,10 @@ return { config.setup({ auto_install = true, indent = { enabled = true }, - highlight = { enabled = true }, + highlight = { + enabled = true, + additional_vim_regex_highlighting = true, + }, }) - - end, + end, } diff --git a/lua/vim-options.lua b/lua/vim-options.lua index 87d0fee..28f71fc 100644 --- a/lua/vim-options.lua +++ b/lua/vim-options.lua @@ -2,7 +2,6 @@ vim.cmd("set expandtab") vim.cmd("set tabstop=2") vim.cmd("set softtabstop=2") vim.cmd("set shiftwidth=2") --- vim.cmd("set shellslash") vim.cmd("set number") vim.cmd("set shell=pwsh") vim.cmd("let &shellcmdflag = '-NoLogo'") @@ -10,3 +9,6 @@ vim.cmd("let &shellcmdflag = '-NoLogo'") vim.g.mapleader = " " vim.g.maplocalleader = "\\" vim.opt.wrap = false + +vim.keymap.set("n", "y", '"+y', { desc = "Yank to system clipboard" }) +vim.keymap.set("v", "y", '"+y', { desc = "Yank to system clipboard" })