From 17e319a4455f3135ed3cc759dee8ba5034fde75b Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Thu, 15 Aug 2024 20:28:13 +0200 Subject: update vim config --- .config/nvim/lua/pm/plugins/nvim-cmp/load.lua | 20 ++++++ .config/nvim/lua/pm/plugins/nvim-cmp/setup.lua | 86 ++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 .config/nvim/lua/pm/plugins/nvim-cmp/load.lua create mode 100644 .config/nvim/lua/pm/plugins/nvim-cmp/setup.lua (limited to '.config/nvim/lua/pm/plugins/nvim-cmp') diff --git a/.config/nvim/lua/pm/plugins/nvim-cmp/load.lua b/.config/nvim/lua/pm/plugins/nvim-cmp/load.lua new file mode 100644 index 0000000..25509d5 --- /dev/null +++ b/.config/nvim/lua/pm/plugins/nvim-cmp/load.lua @@ -0,0 +1,20 @@ +return { + 'hrsh7th/nvim-cmp', + event = "InsertEnter", + dependencies = { + { + "L3MON4D3/LuaSnip", + dependencies = "rafamadriz/friendly-snippets", + opts = { history = true, updateevents = "TextChanged,TextChangedI" }, + config = function(_, opts) + require("luasnip").config.set_config(opts) + end, + }, + { + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-path", + }, + }, +} diff --git a/.config/nvim/lua/pm/plugins/nvim-cmp/setup.lua b/.config/nvim/lua/pm/plugins/nvim-cmp/setup.lua new file mode 100644 index 0000000..c1c9644 --- /dev/null +++ b/.config/nvim/lua/pm/plugins/nvim-cmp/setup.lua @@ -0,0 +1,86 @@ +local cmp = require("cmp") +require("luasnip.loaders.from_vscode").lazy_load() + +local function border(hl_name) + return { + { "╭", hl_name }, + { "─", hl_name }, + { "╮", hl_name }, + { "│", hl_name }, + { "╯", hl_name }, + { "─", hl_name }, + { "╰", hl_name }, + { "│", hl_name }, + } +end + +cmp.setup { + completion = { + completeopt = "menu,menuone", + }, + + window = { + completion = { + border = border "CmpBorder", + side_padding = 1, + winhighlight = "Normal:CmpPmenu,CursorLine:CmpSel,Search:None", + scrollbar = true, + }, + documentation = { + border = border "CmpDocBorder", + winhighlight = "Normal:CmpDoc", + }, + }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + + mapping = { + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.close(), + + [""] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }, + + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") + else + fallback() + end + end, { "i", "s" }), + + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-jump-prev", true, true, true), "") + else + fallback() + end + end, { "i", "s" }), + }, + sources = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "nvim_lua" }, + { name = "path" }, + }, +} + +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 = hl }) +end -- cgit v1.2.3-70-g09d2