diff --git a/.config/nvim/lua/kamu/plugins/completions.lua b/.config/nvim/lua/kamu/plugins/completions.lua index 42d06c7..c5e7107 100644 --- a/.config/nvim/lua/kamu/plugins/completions.lua +++ b/.config/nvim/lua/kamu/plugins/completions.lua @@ -1,16 +1,3 @@ --- local function check_backspace() --- local col = vim.fn.col(".") - 1 --- if col == 0 or vim.fn.getline("."):sub(col, col):match("%s") then --- return true --- else --- return false --- end --- end --- --- local function T(str) --- return vim.api.nvim_replace_termcodes(str, true, true, true) --- end - return { { 'saghen/blink.cmp', @@ -31,7 +18,7 @@ return { opts = { keymap = { preset = 'super-tab' }, appearance = { - use_nvim_cmp_as_default = false, + use_nvim_cmp_as_default = true, nerd_font_variant = 'mono', }, completion = { @@ -41,6 +28,7 @@ return { }, }, menu = { + border = "single", draw = { treesitter = { "lsp" }, }, @@ -48,11 +36,18 @@ return { documentation = { auto_show = true, auto_show_delay_ms = 200, + window = { + border = "single", + }, }, + ghost_text = { + enabled = true + } }, signature = { enabled = true }, sources = { default = { 'lsp', 'path', 'luasnip', 'buffer' }, + -- TODO: add cmp-emoji as another cmp source -- needs https://github.com/Saghen/blink.compat per_filetype = { tex = { 'lsp', 'path', 'luasnip', 'buffer' }, lua = { 'lsp', 'path', 'luasnip', 'buffer', 'lazydev' }, @@ -108,145 +103,3 @@ return { end, }, } - --- return { --- { --- 'hrsh7th/nvim-cmp', --- dependencies = { --- 'hrsh7th/cmp-nvim-lsp', --- 'hrsh7th/cmp-buffer', --- 'hrsh7th/cmp-path', --- 'hrsh7th/cmp-cmdline', --- 'onsails/lspkind.nvim', --- { 'L3MON4D3/LuaSnip', build = "make install_jsregexp" }, --- 'saadparwaiz1/cmp_luasnip', --- 'rafamadriz/friendly-snippets', --- }, --- lazy = false, --- priority = 100, --- config = function() --- vim.opt.completeopt = { "menu", "menuone" } --- --- --- local lspkind = require('lspkind') --- local cmp = require('cmp') --- local ls = require("luasnip") --- ls.setup({ --- history = true, --- }) --- --- ls.filetype_extend("latex", { "tex" }) --- --- -- require("luasnip.loaders.from_vscode").lazy_load() --- require("luasnip.loaders.from_lua").load({ --- -- paths = vim.api.nvim_get_runtime_file("lua/kamu/snippets/", true)[1] --- paths = "~/.config/nvim/lua/kamu/snippets/", --- }) --- -- require("luasnip.loaders").edit_snippet_files() --- --- -- vim.keymap.set({ "i", "s" }, "", function() --- -- if ls.expand_or_jumpable() then --- -- ls.expand_or_jump() --- -- else --- -- return "" --- -- end --- -- end, { expr = true, silent = true }) --- -- --- -- vim.keymap.set({ "i", "s" }, "", function() --- -- if ls.jumpable(-1) then --- -- ls.jump(-1) --- -- else --- -- print("can't go further back") --- -- end --- -- end, { silent = true }) --- --- cmp.setup({ --- formatting = { --- format = lspkind.cmp_format({ --- mode = 'symbol_text', --- }), --- }, --- ellipsis_char = '...', --- show_labelDetails = true, --- snippet = { --- expand = function(args) --- -- vim.snippet.expand(args.body) --- require('luasnip').lsp_expand(args.body) --- end, --- }, --- maxwidth = { --- menu = 50, --- abbr = 50, --- }, --- 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.abort(), --- -- [''] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. --- [''] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. --- [''] = cmp.mapping(function(fallback) --- if vim.fn.pumvisible() == 1 then --- vim.fn.feedkeys(T(''), 'n') --- elseif ls.expand_or_jumpable() then --- ls.expand_or_jump() --- elseif not check_backspace() then --- cmp.mapping.complete()(core, fallback) --- else --- vim.cmd(':>') --- vim.cmd(':startinsert') --- end --- end, { "i", "s" }), --- [''] = cmp.mapping(function(fallback) --- if vim.fn.pumvisible() == 1 then --- vim.fn.feedkeys(T(''), 'n') --- elseif ls.jumpable(-1) then --- ls.jump(-1) --- else --- vim.cmd(':<') --- vim.cmd(':startinsert') --- end --- end, { "i", "s" }), --- }), --- sources = cmp.config.sources({ --- { name = 'nvim_lsp' }, --- { name = 'luasnip' }, --- { name = 'path' }, --- { name = 'buffer' }, --- }), --- }) --- --- -- Set configuration for specific filetype. --- -- cmp.setup.filetype('gitcommit', { --- -- sources = cmp.config.sources({ --- -- { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). --- -- }, { --- -- { name = 'buffer' }, --- -- }) --- -- }) --- --- -- -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). --- -- cmp.setup.cmdline({ '/', '?' }, { --- -- mapping = cmp.mapping.preset.cmdline(), --- -- sources = { --- -- { name = 'buffer' } --- -- } --- -- }) --- -- --- --- -- -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). --- -- cmp.setup.cmdline(':', { --- -- mapping = cmp.mapping.preset.cmdline(), --- -- sources = cmp.config.sources({ --- -- { name = 'path' } --- -- }, { --- -- { name = 'cmdline' } --- -- }) --- -- }) --- end --- }, --- }