vim.o.completeopt = "menuone,noselect" -- Avoid having a "Pattern not found" message vim.cmd("set shortmess+=c") local cmp = require'cmp' local snippy = require('snippy') cmp.setup({ window = { completion = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(), }, snippet = { expand = function(args) snippy.expand_snippet(args.body) end, }, mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.confirm({ select = true }), [''] = cmp.mapping.abort(), }), sources = cmp.config.sources({ { name = 'nvim_lsp' }, { name = 'async_path' }, { name = 'snippy' }, }, { { name = 'buffer' }, }) }) snippy.setup({ mappings = { is = { [''] = 'expand_or_advance', [''] = 'previous', }, }, }) require('lspsaga').setup({}) -- require'compe'.setup { -- enabled = true; -- autocomplete = true; -- debug = false; -- min_length = 1; -- preselect = 'always'; -- throttle_time = 80; -- source_timeout = 200; -- incomplete_delay = 400; -- max_abbr_width = 100; -- max_kind_width = 100; -- max_menu_width = 100; -- documentation = true; -- source = { -- path = true; -- buffer = false; -- calc = false; -- vsnip = false; -- Could be used if I want to start using snippets. -- nvim_lsp = true; -- nvim_lua = true; -- tags = true; -- snippets_nvim = true; -- treesitter = true; -- }; -- } -- vim.cmd([[ -- autocmd FileType ocaml call compe#setup({ -- \ 'preselect': 'disable' -- \ }, 0) -- ]]) -- local t = function(str) -- return vim.api.nvim_replace_termcodes(str, true, true, true) -- end -- _G.comp_jump_if_avail = function() -- if vim.fn.pumvisible() == 1 then -- return t "" -- end -- end -- _G.comp_jump_prev_if_avail = function() -- if vim.fn.pumvisible() == 1 then -- return t "" -- end -- end -- _G.tab_complete = function() -- if vim.fn.pumvisible() == 1 then -- return vim.fn['compe#confirm']('') -- else -- return t "" -- end -- end -- _G.enter_complete = function() -- if vim.bo.filetype == "ocaml" then -- return t "" -- elseif vim.fn.pumvisible() == 1 then -- return vim.fn['compe#confirm']('') -- else -- return t "" -- end -- end -- vim.api.nvim_set_keymap("i", "", "v:lua.comp_jump_if_avail()", {expr = true}) -- vim.api.nvim_set_keymap("s", "", "v:lua.comp_jump_if_avail()", {expr = true}) -- vim.api.nvim_set_keymap("i", "", "v:lua.comp_jump_prev_if_avail()", {expr = true}) -- vim.api.nvim_set_keymap("s", "", "v:lua.comp_jump_prev_if_avail()", {expr = true}) -- -- The next 4 funtcions don't work if compe doesn't automatically select the first option. -- -- meaning the preselect option has to be set to alwasy. -- vim.api.nvim_set_keymap("i", "", "v:lua.tab_complete()", {expr = true}) -- vim.api.nvim_set_keymap("s", "", "v:lua.tab_complete()", {expr = true}) -- vim.api.nvim_set_keymap("i", "", "v:lua.enter_complete()", {expr = true}) -- vim.api.nvim_set_keymap("s", "", "v:lua.enter_complete()", {expr = true})