From 3e4977e02de2ef0e065e94b6777dcd861499de1f Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Wed, 29 Jun 2022 08:41:32 +0200 Subject: [PATCH] refactor: clean up code --- home-manager/neovim/nvim-cmp.lua | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/home-manager/neovim/nvim-cmp.lua b/home-manager/neovim/nvim-cmp.lua index b08ec32..e5ea9d1 100644 --- a/home-manager/neovim/nvim-cmp.lua +++ b/home-manager/neovim/nvim-cmp.lua @@ -5,7 +5,7 @@ local has_words_before = function() col, col):match("%s") == nil end -local cmp = require('cmp') +local cmp = require("cmp") local luasnip = require("luasnip") cmp.setup({ @@ -14,7 +14,7 @@ cmp.setup({ luasnip.lsp_expand(args.body) end }, - sources = require("cmp").config.sources({ + sources = cmp.config.sources({ { name = "nvim_lsp" }, { name = "luasnip" }, { name = "path" }, @@ -23,11 +23,11 @@ cmp.setup({ { name = "calc" }, }), 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. + [""] = 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. [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() @@ -53,10 +53,16 @@ cmp.setup({ }) -- `/` cmdline setup. -cmp.setup.cmdline('/', { sources = { { name = 'buffer' } } }) +cmp.setup.cmdline("/", { + sources = cmp.config.sources( + { { name = "buffer" } } + ) +}) -- `:` cmdline setup. -cmp.setup.cmdline(':', { - sources = cmp.config - .sources({ { name = 'path' } }, { { name = 'cmdline' } }) +cmp.setup.cmdline(":", { + sources = cmp.config.sources( + { { name = "path" } }, + { { name = "cmdline" } } + ) })