-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added functionilty for ansi code highlighting #132
base: main
Are you sure you want to change the base?
Conversation
Hello, sorry for the late reply. Could you please remove all of the text formatting in your PR and leaving only what is needed for the new feat to work? |
Hello, sure thing, my auto format went a little crazy haha, I'll get this done sometime this evening. |
Hey @brenoprata10 , Should be all good to go now :) |
Thanks for your contribution, I will review/test till the end of the week 👍 |
Hey o/ |
---@usage get_ansi_named_color_value("\033[31m") => Returns '#FF0000' | ||
function M.get_ansi_named_color_value(color) | ||
local color_code = nil | ||
if string.match(color, "\\033[[0-9;]*m") then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you could reuse M.ansi_regex = "\\033%[[0-9;]*m"
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey is this what you were meaning?
function M.get_ansi_named_color_value(color)
local color_code = nil
if string.match(color, patterns.ansi_regex) then
lua/nvim-highlight-colors/utils.lua
Outdated
-- Checking to match on ansi codes to remove naughty chars | ||
if string.match(color_value, "\\") then | ||
local g1, g2 = string.match(color_value, "([0-9]);?([0-9]+)m") | ||
if g1 and g2 then | ||
color_value = g1 .. g2 | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove naughty chars
using the gsub below? [!(),%s%.-/%%=:\"']+
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello
return 'nvim-highlight-colors-' .. string.gsub(color_value, "#", ""):gsub("\\[0-9]*%[", ""):gsub("[!(),%s%.-/%%=:\"';%[%]]+", "")
let me know if this is what you were after, i believe this should be more ideal
Hello, ive made the suggested changes, let me know if theres anything additional to change, ive tried to keep it minimal :) |
Hello,
Issue:
Whilst working with ANSI Color codes there was no functionality to highlight these colors
Fix:
Ive done my best to try add ansi code highlighting functionality for this package,
It should work as with the testing file all seems to be fine, although I dont do to much programming in lua.
Basically just using a lookup table so there may be codes missing. I'm not aware of a way to convert the ansi codes to hex so this seemed logical
If there is anything for me to fix / tidy up in order to be merged please let me know