Add option to turn off icons rendering
ikalnytskyi opened this issue · 10 comments
Is it possible to add an option to turn off icons? I personally found them quite noisy especially when you are in a quite nested context. Currently it's inconvenient to override every single icon with empty string.
In fact, I think it would be super cool to provide some kind of formatting function that would receive a symbol name and a symbol kind and would return a formatted string. That would allow to (1) remove icons from rendering, (2) render icons at the end, (3) do not insert nasty whitespaces right after the icon and (4) easily integrate this plugin with other icon maps (i.e. lspkind like plugins).
E.g.
-- no icon
require("nvim-gps").setup({
format = function(symbol_kind, symbol_name)
return symbol_name
end,
})
-- 3rd party icon
local mygpsicons = require("my-gps-icons")
require("nvim-gps").setup({
format = function(symbol_kind, symbol_name)
return string.format("%s %s", mygpsicons[symbol_kind], symbol_name)
end,
})
Hmm.. Definitely an interesting idea 🤔
If it's ok with you I can work on it and submit a PR.
PRs are always welcome 😄
But thinking more on this, the option will only be useful for removing icons or putting them to end. I am not sure if its worth it to add a separate option just to accommodate this.
I think a better solution would be to make a different function that returns the data in a table format. For example if the get_location
returns class-icon class-name > method-icon method-name
then the new function will return it something like this
{
{
icon = class-icon,
scope = class-name
},
{
icon = method-icon,
scope = method-name
}
}
I think this will be a more generalized solution for people who want something other than the regular output provided by get_location
. Let me know your thoughts on this.
I'm not sure I'm following you. Basically you're suggesting to have a function to format the whole location, not only a location segment. Is that right? I'm not sure I understand your example though.
I'm not sure I'm following you. Basically you're suggesting to have a function to format the whole location, not only a location segment. Is that right? I'm not sure I understand your example though.
So one function lets say get_location_table
will return the context information to the end user in a table format and the get_location
function will return a string as it does right now. So the idea being, the end user can use the information in the table however they please.
Example:
get_location
returns foo > bar
the get_location_table
will return the following table for the same.
{
{
icon = " ",
scope = "foo"
},
{
icon = " ",
scope = "bar"
}
}
Ah, sorry, I've got confused by scope
name since I didn't expect it to contain a symbol name.
Returning table, for instance, won't help you to put the icon at the end or remove the white-space after the item. But I agree that controlling segmented to render could be useful too. In fact, I think representation level should be easily changed by user. One idea I had in my is to have a location line like foo.bar
where you have only a single icon and that icon of the leave node.
Returning table, for instance, won't help you to put the icon at the end or remove the white-space after the item
Yep, that would be up to the user to do string concatenations the way they like their location info to look.
One idea I had in my is to have a location line like foo.bar where you have only a single icon and that icon of the leave node.
This too can be easily achieved by the end user once they have the information in table format.
I also would love to have an option to disable icons globally :) I previously turned them off manually but with the recent updates that adds more icons it's not very practical anymore.
Sorry this took so long, I have been busy lately. I have a pull request ready, I will merge it once I feel its working fine.