datwaft / nvim.conf

datwaft's neovim configuration
114 stars 6 forks source link

`highlight!` macro doesn't set GUI options (bold/underline/italic) #16

Closed shaunsingh closed 2 years ago

shaunsingh commented 2 years ago

Hello, thank you once again for the excellent set of macros

I was recently trying out the highlight! macro, with the following code:

;; subtle delimiters
(highlight! MatchParen               [:underline] {:bg :#262626})

;; transparent vertical splits
(highlight! Vertsplit                [:none]      {:fg :#161616})

;; bold various syntax & TODO
(highlight! Todo                     [:bold]      {:fg :#42be65 :bg :#262626})
(highlight! TSSymbol                 [:bold]      {:fg :#3ddbd9})
(highlight! TSFunction               [:bold]      {:fg :#ff7eb6})

Which compiles to the following via hotpot:

vim.api.nvim_set_hl(0, "MatchParen", {bg = "#262626"})
vim.api.nvim_set_hl(0, "Vertsplit", {fg = "#161616"})
vim.api.nvim_set_hl(0, "Todo", {fg = "#42be65", bg = "#262626"})
vim.api.nvim_set_hl(0, "TSSymbol", {fg = "#3ddbd9"})
vim.api.nvim_set_hl(0, "TSFunction", {fg = "#ff7eb6"})
vim.api.nvim_set_hl(0, "Todo", {fg = "#42be65", bg = "#262626"})
vim.api.nvim_set_hl(0, "TSSymbol", {fg = "#3ddbd9"})
vim.api.nvim_set_hl(0, "TSFunction", {fg = "#ff7eb6"})

As you can see, bold/underline don't get passed to nvim_set_hl. Am I using it incorrectly by any chance?

datwaft commented 2 years ago

That is weird, I just did an small test and underline is included on the end result.

See the following screenshot:

image

Here is the code I used:

(do
  (macro highlight! [name attributes colors]
    (fn ->str [x] (tostring x))
    (let [name (->str name)
          colors (collect [_ v (ipairs attributes) :into colors] (->str v) true)]
      `(vim.api.nvim_set_hl 0 ,name ,colors)))
  (macrodebug (highlight! MatchParen [:underline] {:bg "#262626"})))

Here is the output:

(vim.api.nvim_set_hl 0 :MatchParen {:bg "#262626" :underline true})

The code of the macro is basically the same, I just removed the assertions and included the ->str function inside the macro (this is because macros can't access locals outside of themselves).

datwaft commented 2 years ago

It seems that Conjure shows a different output from the one Hotpot produces.

See the following screenshot (at the top the original module and at the bottom the compilation result):

image

Wierdly, if I run the module using :Fnl and macrodebug the macro expands properly.

datwaft commented 2 years ago

If I include macrodebug on the module and it's executed on startup the underline property is included.

image

When printing inside the macro the expected values are displayed:

image

image

I probably is an issue with Hotpot so a new issue should be opened, this is very weird.

datwaft commented 2 years ago

I opened the following Issue on Hotpot: https://github.com/rktjmp/hotpot.nvim/issues/57

datwaft commented 2 years ago

After a test this seems to be an issue with Fennel itself, so I will open a new issue on the Fennel repository.

datwaft commented 2 years ago

Here is the issue on the Fennel repository: https://github.com/bakpakin/Fennel/issues/425

shaunsingh commented 2 years ago

Thank you!

datwaft commented 2 years ago

FYI, https://github.com/bakpakin/Fennel/issues/425 has been fixed, but you need to have the nightly version of Fennel.

Hotpot now includes a nightly branch that uses that version of Fennel, so if you use that it should be fixed.

I will be closing this issue.

Btw, I moved my macros to datwaft/themis.nvim. I don't recommend you to use it directly as it's not made for external use, but you can fork it or use it as a reference for your configuration.

shaunsingh commented 2 years ago

Thank you. I've changed the branch to nightly and have copied over your new macros with some modifications (and proper credits, of course). I hope you don't mind, and thank you once again for the help!