Closed benbrastmckie closed 1 month ago
About the delay, would you mind posting a recording (like a gif)?
About your second question, where exactly would you like the icon? The specific type of the entry is specified in brackets, like in the images encapsulated in the README.md
: [a]
, [B]
, etc. Would you simply like an entry type-specific icon?
I haven't set up any screen recording stuff on my current system but here are two images that should give a sense of it:
In this first one, I have just opened vim and trying to autocomplete. No matter how long I wait, it won't generate the info window. Once I exit out and then try to complete the citation again, then it work great as in the second photo below.
In place of '[article]' I was hoping to just see some icon for articles since especially '[incollection]' takes up a lot of room. Here is a photo of that happening:
![Uploading Screenshot from 2024-03-01 21-43-10.png…]()
I have also noticed that 'et al.' is appended to every bib entry even if there is only one author. Not to sure why that is but would be happy to poke around.
What you describe definitely isn't standard behavior. If the bibliography is particularly long, it could take some time to parse everything and display it but, sooner or later, it should indeed be displayed. I need additional information to be able to reproduce this.
vim_item.kind
, for bibliographic entries, is not set to its type (article, book, ...), but simply to Text
. The field you are interested in is vim_item.menu
. This snippets are a working implementation of what you asked for. Notice, though, that the keys in the vimtex_icons
table are different from yours. For some reason you see the type as unabbreviated ([article]
), while I see the standard vimtex abbreviation ([a]
); I've looked at your config and I can't understand why. These are the abbreviations:
a article
B book
k booklet
f conference
b inbook
c incollection
p inproceedings
m manual
Master mastersthesis
- misc
PhD phdthesis
P proceedings
r techreport
u unpublished
This is my implementation:
local vimtex_icons = {
a = "",
B = "",
c = "",
}
local test_fn = function(str)
if str == nil then
return ""
end
if name then
return ""
end
local type = ((str:match("^%[(.-)%]")):gsub("%[", "")):gsub("%]", "")
if vimtex_icons[type] ~= nil then
logger(string.find(str, "^%[(.-)%]"))
str = string.gsub(str, "^%[(.-)%]", "[" .. vimtex_icons[type] .. "]")
end
return str
end
vim_item.menu = ({
buffer = "[Buffer]",
nvim_lsp = "[LSP]",
luasnip = "[LuaSnip]",
nvim_lua = "[Nvim lua]",
--vimtex = "[Vimtex]" .. (vim_item.menu ~= nil and vim_item.menu or ""),
---vimtex = vim_item.menu,
vimtex = test_fn(vim_item.menu, entry.source.name)
})[entry.source.name]
Hey thanks so much for this! I tried poked around with this but couldn't get it to work. One question: the function test_fn
supposed to take name
as an argument? Seems like that is how it is used below in setting vimtex
equal to it. Was confused about that.
I will try to keep digging to see where the problem is with the strange behavior I'm getting. It does work well, don't get me wrong, just some strange behavior around the edges. Unfortunately I'm completely slammed right now, but will try to find some time to keep troubleshooting it.
Thanks again for your help!
Yes, sorry, the function takes name
as an argument. If you fix this issue, does it work?
strange behavior around the edges
This is exactly what I've been trying to exterminate. When you can, feel free to send some debug information.
I am not sure if this is a bug or not, or if there is anything to be done, but I've noticed that if I open nvim and go to cite something right away, when I cycle through possible completions, it doesn't open up the information menu. If I exit out and try again, then everything works. I have also noticed that If I wait 30sec or so before trying to cite something, then everything works.
This is not at all a problem, just wanted to mention it in case that is helpful. Feel free to close immediately if there is nothing to be done.
One other question I had is if it is possible to replace '[article]' or '[book]' etc., with a nerdfont icon. Here is what I tried (first three entries) and seems to work for other sources (I guess nerdfont icons don't work here):
''' local kind_icons = { article = "", book = "", incollection = "", Function = "", Constructor = "", Text = "", Method = "", Field = "", ETC }
'''
Thanks for the help. Been loving the plugin!