add: config for disable cmp doc

This commit is contained in:
asep.komarudin 2024-06-02 19:31:26 +07:00
parent 72ff763f68
commit 4bbbf4bc75
3 changed files with 118 additions and 114 deletions

View file

@ -38,9 +38,9 @@
"nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" },
"nvim-scrollview": { "branch": "main", "commit": "c29c5f69d37040a1fac88cbea7f5e6f06f0aff4d" }, "nvim-scrollview": { "branch": "main", "commit": "c29c5f69d37040a1fac88cbea7f5e6f06f0aff4d" },
"nvim-tree.lua": { "branch": "master", "commit": "2bc725a3ebc23f0172fb0ab4d1134b81bcc13812" }, "nvim-tree.lua": { "branch": "master", "commit": "2bc725a3ebc23f0172fb0ab4d1134b81bcc13812" },
"nvim-treesitter": { "branch": "master", "commit": "979beffc1a86e7ba19bd6535c0370d8e1aaaad3c" }, "nvim-treesitter": { "branch": "master", "commit": "a80fe081b4c5890980561e0de2458f64aaffbfc7" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "fd41b7ccc5490a3a99c734d1ee418b68d06c48a9" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "fd41b7ccc5490a3a99c734d1ee418b68d06c48a9" },
"nvim-ts-autotag": { "branch": "main", "commit": "bcf3146864262ef2d3c877beba3e222b5c73780d" }, "nvim-ts-autotag": { "branch": "main", "commit": "6eb4120a1aadef07ac312f1c4bc6456712220007" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" },
"nvim-ufo": { "branch": "main", "commit": "a5390706f510d39951dd581f6d2a972741b3fa26" }, "nvim-ufo": { "branch": "main", "commit": "a5390706f510d39951dd581f6d2a972741b3fa26" },
"nvim-web-devicons": { "branch": "master", "commit": "5b9067899ee6a2538891573500e8fd6ff008440f" }, "nvim-web-devicons": { "branch": "master", "commit": "5b9067899ee6a2538891573500e8fd6ff008440f" },

View file

@ -118,3 +118,5 @@ vim.g.pcode_codeium = true
vim.g.pcode_nvimufo = true vim.g.pcode_nvimufo = true
vim.g.pcode_indentscope = true vim.g.pcode_indentscope = true
vim.g.pvode_minianimate = true vim.g.pvode_minianimate = true
vim.g.pcode_disable_cmpdoc = false

View file

@ -3,116 +3,118 @@ local cmpcalc = vim.g.pcode_cmpcalc or false
local cmptag = vim.g.pcode_cmptag or false local cmptag = vim.g.pcode_cmptag or false
local lspghost_text = vim.g.pcode_lspghost_text or false local lspghost_text = vim.g.pcode_lspghost_text or false
local icons = require("user.icons").ui local icons = require("user.icons").ui
return { local cmp_documentation = {
{ "hrsh7th/cmp-nvim-lsp", event = "InsertEnter", lazy = true }, border = icons.Border,
{ "hrsh7th/cmp-buffer", event = "InsertEnter", lazy = true }, winhighlight = "Normal:bg,FloatBorder:BorderBG,CursorLine:PmenuSel,Search:None",
{ "hrsh7th/cmp-path", event = "InsertEnter", lazy = true }, scrollbar = true,
{ "saadparwaiz1/cmp_luasnip", event = "InsertEnter", lazy = true }, }
{ "hrsh7th/cmp-nvim-lua", event = "InsertEnter", lazy = true },
{ "lukas-reineke/cmp-rg", lazy = true, enabled = cmprg }, -- experimental return {
{ "hrsh7th/cmp-calc", lazy = true, enabled = cmpcalc }, -- experimental { "hrsh7th/cmp-nvim-lsp", event = "InsertEnter", lazy = true },
{ "quangnguyen30192/cmp-nvim-tags", lazy = true, enabled = cmptag }, -- experimental { "hrsh7th/cmp-buffer", event = "InsertEnter", lazy = true },
{ { "hrsh7th/cmp-path", event = "InsertEnter", lazy = true },
"hrsh7th/nvim-cmp", { "saadparwaiz1/cmp_luasnip", event = "InsertEnter", lazy = true },
lazy = true, { "hrsh7th/cmp-nvim-lua", event = "InsertEnter", lazy = true },
version = false, -- last release is way too old { "lukas-reineke/cmp-rg", lazy = true, enabled = cmprg }, -- experimental
event = "InsertEnter", { "hrsh7th/cmp-calc", lazy = true, enabled = cmpcalc }, -- experimental
opts = function() { "quangnguyen30192/cmp-nvim-tags", lazy = true, enabled = cmptag }, -- experimental
local cmp = require("cmp") {
local luasnip = require("luasnip") "hrsh7th/nvim-cmp",
lazy = true,
local check_backspace = function() version = false, -- last release is way too old
local col = vim.fn.col(".") - 1 event = "InsertEnter",
return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") opts = function()
end local cmp = require "cmp"
local luasnip = require "luasnip"
return {
completion = { local check_backspace = function()
completeopt = "menu,menuone,noinsert", local col = vim.fn.col "." - 1
}, return col == 0 or vim.fn.getline("."):sub(col, col):match "%s"
snippet = { end
expand = function(args)
require("luasnip").lsp_expand(args.body) return {
end, completion = {
}, completeopt = "menu,menuone,noinsert",
mapping = cmp.mapping.preset.insert({ },
["<C-b>"] = cmp.mapping.scroll_docs(-4), snippet = {
["<C-f>"] = cmp.mapping.scroll_docs(4), expand = function(args)
["<C-Space>"] = cmp.mapping.complete(), require("luasnip").lsp_expand(args.body)
["<C-e>"] = cmp.mapping.abort(), end,
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. },
["<Tab>"] = cmp.mapping(function(fallback) mapping = cmp.mapping.preset.insert {
if cmp.visible() then ["<C-b>"] = cmp.mapping.scroll_docs(-4),
cmp.select_next_item() ["<C-f>"] = cmp.mapping.scroll_docs(4),
elseif luasnip.expandable() then ["<C-Space>"] = cmp.mapping.complete(),
luasnip.expand() ["<C-e>"] = cmp.mapping.abort(),
elseif luasnip.expand_or_jumpable() then ["<CR>"] = cmp.mapping.confirm { select = true }, -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
luasnip.expand_or_jump() ["<Tab>"] = cmp.mapping(function(fallback)
elseif check_backspace() then if cmp.visible() then
fallback() cmp.select_next_item()
else elseif luasnip.expandable() then
fallback() luasnip.expand()
end elseif luasnip.expand_or_jumpable() then
end, { luasnip.expand_or_jump()
"i", elseif check_backspace() then
"s", fallback()
}), else
["<S-Tab>"] = cmp.mapping(function(fallback) fallback()
if cmp.visible() then end
cmp.select_prev_item() end, {
elseif luasnip.jumpable(-1) then "i",
luasnip.jump(-1) "s",
else }),
fallback() ["<S-Tab>"] = cmp.mapping(function(fallback)
end if cmp.visible() then
end, { cmp.select_prev_item()
"i", elseif luasnip.jumpable(-1) then
"s", luasnip.jump(-1)
}), else
}), fallback()
sources = cmp.config.sources({ end
{ name = "nvim_lsp" }, end, {
{ name = "luasnip" }, "i",
{ name = "buffer" }, "s",
{ name = "path" }, }),
{ name = "nvim_lua" }, },
{ name = "rg" }, -- experimental sources = cmp.config.sources {
{ name = "calc" }, -- experimental { name = "nvim_lsp" },
{ name = "tags" }, --experimental { name = "luasnip" },
}), { name = "buffer" },
formatting = { { name = "path" },
fields = { "kind", "abbr", "menu" }, { name = "nvim_lua" },
format = function(entry, vim_item) { name = "rg" }, -- experimental
vim_item.kind = string.format("%s", require("user.icons")["kind"][vim_item.kind]) { name = "calc" }, -- experimental
vim_item.menu = ({ { name = "tags" }, --experimental
nvim_lsp = "(LSP)", },
luasnip = "(Snippet)", formatting = {
buffer = "(Buffer)", fields = { "kind", "abbr", "menu" },
path = "(Path)", format = function(entry, vim_item)
})[entry.source.name] vim_item.kind = string.format("%s", require("user.icons")["kind"][vim_item.kind])
return vim_item vim_item.menu = ({
end, nvim_lsp = "(LSP)",
}, luasnip = "(Snippet)",
window = { buffer = "(Buffer)",
-- completion = cmp.config.window.bordered(), path = "(Path)",
-- documentation = cmp.config.window.bordered(), })[entry.source.name]
-- remove border window from cmp return vim_item
completion = { end,
border = icons.Border, },
winhighlight = "Normal:bg,FloatBorder:BorderBG,CursorLine:PmenuSel,Search:None", window = {
scrollbar = true, -- completion = cmp.config.window.bordered(),
}, -- documentation = cmp.config.window.bordered(),
documentation = { -- remove border window from cmp
border = icons.Border, completion = {
winhighlight = "Normal:bg,FloatBorder:BorderBG,CursorLine:PmenuSel,Search:None", border = icons.Border,
scrollbar = true, winhighlight = "Normal:bg,FloatBorder:BorderBG,CursorLine:PmenuSel,Search:None",
}, scrollbar = true,
}, },
experimental = { documentation = vim.g.pcode_disable_cmpdoc and cmp.config.disable or cmp_documentation,
ghost_text = lspghost_text, },
native_menu = false, experimental = {
}, ghost_text = lspghost_text,
} native_menu = false,
end, },
}, }
end,
},
} }