Closed Qejun closed 1 year ago
Maybe the same as #624 ?
Maybe the same as #624 ?
I think you have a point,After I commented out the relevant code, the problem disappeared along with the Nerd fonts icon.
file in :nvim\lua\modules\configs\completion\cmp.lua
@Qejun https://github.com/ayamir/nvimdots/commit/d506a191287ef5e02de799e4340f5fc2889470a6 implemented a temporary workaround, you only need to pull the latest changes.
This is part of the v0.9 migration.
I pulled the new config file, but didn't upgrade nvim from 0.8 to 0.9, so my problem was not solved. I took the suggestion in https://github.com/ayamir/nvimdots/issues/624 and the solution in version 0.8 is as follows: file in \nvim\lua\modules\configs\completion\cmp.lua
return function()
local icons = {
kind = require("modules.utils.icons").get("kind"),
type = require("modules.utils.icons").get("type"),
cmp = require("modules.utils.icons").get("cmp"),
}
local t = function(str)
return vim.api.nvim_replace_termcodes(str, true, true, true)
end
local border = function(hl)
return {
{ "╭", hl },
{ "─", hl },
{ "╮", hl },
{ "│", hl },
{ "╯", hl },
{ "─", hl },
{ "╰", hl },
{ "│", hl },
}
end
---Handling situations where LuaSnip failed to perform any jumps
---@param r integer @Cursor position (row) before calling LuaSnip
---@param c integer @Cursor position (col) before calling LuaSnip
---@param fallback function @Fallback function inherited from cmp
local luasnip_fallback = vim.schedule_wrap(function(r, c, fallback)
local _r, _c = unpack(vim.api.nvim_win_get_cursor(0))
if _r == r and _c == c then
fallback()
end
end)
local cmp_window = require("cmp.utils.window")
cmp_window.info_ = cmp_window.info
cmp_window.info = function(self)
local info = self:info_()
info.scrollable = false
return info
end
local compare = require("cmp.config.compare")
compare.lsp_scores = function(entry1, entry2)
local diff
if entry1.completion_item.score and entry2.completion_item.score then
diff = (entry2.completion_item.score * entry2.score) - (entry1.completion_item.score * entry1.score)
else
diff = entry2.score - entry1.score
end
return (diff < 0)
end
local lspkind = require("lspkind")
local cmp = require("cmp")
local kind_icons = {
Class = "ﴯ",
-- Class = "",
-- Class = "",
Color = "",
-- Color = "",
Constant = "",
-- Constant = "",
Constructor = "",
-- Constructor = "",
-- Constructor = "",
Enum = "",
EnumMember = "",
Event = "",
Field = "ﰠ",
-- Field = "",
-- Field = "",
-- Field = "",
File = "",
-- File = "",
-- File = "",
Folder = "",
-- Folder = "",
Function = "",
Interface = "",
Keyword = "",
Method = "",
Module = "",
Operator = "",
Property = "",
-- Property = "ﰠ",
Reference = "",
-- Reference = "",
-- Reference = "",
Snippet = "",
-- Snippet = "",
Struct = "פּ",
-- Struct = "",
Text = "",
-- Text = "",
TypeParameter = "",
-- TypeParameter = "",
Unit = "",
Value = "",
Variable = "",
-- Variable = "",
-- Variable = "",
-- tree-sitter
String = "",
}
cmp.setup({
window = {
completion = {
border = border("Normal"),
max_width = 80,
max_height = 20,
},
documentation = {
border = border("CmpDocBorder"),
},
},
sorting = {
priority_weight = 2,
comparators = {
require("copilot_cmp.comparators").prioritize,
require("copilot_cmp.comparators").score,
-- require("cmp_tabnine.compare"),
compare.offset,
compare.exact,
compare.lsp_scores,
require("cmp-under-comparator").under,
compare.kind,
compare.sort_text,
compare.length,
compare.order,
},
},
--formatting = {
-- fields = { "kind", "abbr", "menu" },
-- format = function(entry, vim_item)
-- local kind = lspkind.cmp_format({
-- mode = "symbol_text",
-- maxwidth = 50,
-- symbol_map = vim.tbl_deep_extend("force", icons.kind, icons.type, icons.cmp),
-- })(entry, vim_item)
-- local strings = vim.split(kind.kind, "%s", { trimempty = true })
-- kind.kind = " " .. strings[1] .. " "
-- kind.menu = " (" .. strings[2] .. ")"
-- return kind
-- end,
--},
formatting = {
format = function(entry, vim_item)
local icon = kind_icons[vim_item.kind] or "default icon or text"
vim_item.kind = icon .. " " .. vim_item.kind
return vim_item
end,
},
-- You can set mappings if you want
mapping = cmp.mapping.preset.insert({
["<CR>"] = cmp.mapping.confirm({ select = true, behavior = cmp.ConfirmBehavior.Replace }),
["<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-w>"] = cmp.mapping.close(),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_locally_jumpable() then
local _r, _c = unpack(vim.api.nvim_win_get_cursor(0))
vim.fn.feedkeys(t("<Plug>luasnip-expand-or-jump"))
luasnip_fallback(_r, _c, fallback)
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(t("<Plug>luasnip-jump-prev"), "")
else
fallback()
end
end, { "i", "s" }),
}),
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
-- You should specify your *installed* sources.
sources = {
{ name = "nvim_lsp" },
{ name = "nvim_lua" },
{ name = "luasnip" },
{ name = "path" },
{ name = "treesitter" },
{ name = "spell" },
{ name = "tmux" },
{ name = "orgmode" },
{ name = "buffer" },
{ name = "latex_symbols" },
{ name = "copilot" },
-- { name = "codeium" },
-- { name = "cmp_tabnine" },
},
})
end
Version confirmation
Following prerequisites
Neovim version
NVIM v0.8.3 Build type: RelWithDebInfo LuaJIT 2.1.0-beta3 Compiled by runneradmin@fv-az171-224 Features: -acl +iconv +tui See ":help feature-compile" system vimrc file: "$VIM\sysinit.vim" fall-back for $VIM: "C:/Program Files (x86)/nvim/share/nvim"
Operating system/version
win10 22h2
Terminal name/version
PowerShell 7.3.3
$TERM environment variable
No response
Branch info
main (Default/Latest)
Fetch Preferences
SSH (use_ssh = true)
How to reproduce the issue
I get this error every time I try to type a letter Error executing vim.schedule lua callback: ...ppData\Local\nvim/lua/modules/configs/completion\cmp.lua:95: attempt to concatenate a nil value
stack traceback: ...ppData\Local\nvim/lua/modules/configs/completion\cmp.lua:95: in function 'format' ...ata/Local/nvim-data/site/lazy/nvim-cmp/lua/cmp/entry.lua:290: in function 'callback'
...cal/nvim-data/site/lazy/nvim-cmp/lua/cmp/utils/cache.lua:38: in function 'get_vim_item' ...ata/Local/nvim-data/site/lazy/nvim-cmp/lua/cmp/entry.lua:397: in function 'callback'
...cal/nvim-data/site/lazy/nvim-cmp/lua/cmp/utils/cache.lua:38: in function 'match' ...ta/Local/nvim-data/site/lazy/nvim-cmp/lua/cmp/source.lua:114: in function 'get_entries' ...ta/Local/nvim-data/site/lazy/nvim-cmp/lua/cmp/source.lua:352: in function 'cb' vim/_editor.lua:248: in function <vim/_editor.lua:247>
Expected behavior
what should i do to solve this problem?
Actual behavior
Additional information
This is what "checkhealth" outputs:
gitsigns: require("gitsigns.health").check()
lazy: require("lazy.health").check()
lazy.nvim
man: require("man.health").check()
mason: require("mason.health").check()
mason.nvim report
require("mason-registry.index")
is installed.github.com/mason-org/mason-registry version: 2023-04-08-roman-pond
is installed.UnZip 5.51 of 22 May 2004, by Info-ZIP. Maintained by C. Spieler. Send
go version go1.20.3 windows/amd64
cargo 1.68.2 (6feb7c9cf 2023-03-26)
luarocks 2.0.2
. Luarocks version must be >= 3.0.0.ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [x64-mingw-ucrt]
3.3.26
9.5.0
v18.15.0
Python 3.8.6
`
java version "9.0.1"
GNU Wget 1.21.3 built on mingw32.
curl 7.83.1 (Windows) libcurl/7.83.1 Schannel
bsdtar 3.5.2 - libarchive 3.5.2 zlib/1.2.5.f-ipp
7.3.3 Microsoft Windows 10.0.19045 Win32NT
Python 3.8.6
`
7-Zip 9.10 beta Copyright (c) 1999-2009 Igor Pavlov 2009-12-22
null-ls: require("null-ls.health").check()
nvim: health#nvim#check
Configuration
Performance
Remote Plugins
nvim-treesitter: require("nvim-treesitter.health").check()
Installation
tree-sitter
found 0.20.7 (b268e412ad4848380166af153300464e5a1cf83f) (parser generator, only needed for :TSInstallFromGrammar)node
found v18.15.0 (only needed for :TSInstallFromGrammar)git
executable found.cc
executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" } Version: cc (Rev4, Built by MSYS2 project) 12.2.0OS Info:
{ machine = "x86_64", release = "10.0.19045", sysname = "Windows_NT", version = "Windows 10 Pro" }
Parser/Features H L F I J
yaml ✓ ✓ ✓ ✓ ✓
Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections +) multiple parsers found, only one will be used x) errors found in the query, try to run :TSUpdate {lang}
provider: health#provider#check
Clipboard (optional)
Python 3 provider (optional)
import neovim
. Using the first available executable for diagnostics.Python virtualenv
Ruby provider (optional)
neovim-ruby-host
not found.gem install neovim
to ensure the neovim RubyGem is installed.gem environment
to ensure the gem bin directory is in $PATH.let g:loaded_ruby_provider = 0
to your init.vimNode.js provider (optional)
Perl provider (optional)
vim.lsp: require("vim.lsp.health").check()
vim.treesitter: require("vim.treesitter.health").check()
which_key: health#which_key#check
WhichKey: checking conflicting keymaps
<Cmd>HopChar1<CR>
<Plug>(comment_toggle_linewise)
<Plug>(comment_toggle_blockwise)
<Cmd>HopChar1<CR>
<cmd>lua require("which-key").show(" ", {mode = "n", auto = true})<cr>
<cmd>lua require("which-key").show(" ", {mode = "v", auto = true})<cr>