diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2024-05-14 17:00:51 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2024-05-14 17:00:51 +0200 |
| commit | 346854ff3ea83202de7437f01f1c1c336f4c3edf (patch) | |
| tree | 16f439c4e5194b9f3e08e5124e1184daf68f24af /.config/nvim/lua/cmp-config.lua | |
| parent | 201e36c823925ccb6d0b608b2ce985ec32b2e276 (diff) | |
add whole neovim config
Diffstat (limited to '.config/nvim/lua/cmp-config.lua')
| -rw-r--r-- | .config/nvim/lua/cmp-config.lua | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/.config/nvim/lua/cmp-config.lua b/.config/nvim/lua/cmp-config.lua new file mode 100644 index 0000000..2bb6047 --- /dev/null +++ b/.config/nvim/lua/cmp-config.lua @@ -0,0 +1,90 @@ +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 + +--if cmp_style ~= "atom" and cmp_style ~= "atom_colored" then +-- options.window.completion.border = border "CmpBorder" +-- 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 = { + ["<C-p>"] = cmp.mapping.select_prev_item(), + ["<C-n>"] = cmp.mapping.select_next_item(), + ["<C-d>"] = cmp.mapping.scroll_docs(-4), + ["<C-f>"] = cmp.mapping.scroll_docs(4), + ["<C-Space>"] = cmp.mapping.complete(), + ["<C-e>"] = cmp.mapping.close(), + + ["<CR>"] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }, + + ["<Tab>"] = 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("<Plug>luasnip-expand-or-jump", true, true, true), "") + else + fallback() + end + end, { "i", "s" }), + + ["<S-Tab>"] = 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("<Plug>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 |