Skip to content
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

Improve non-treesitter support #6

Closed
mvllow opened this issue Aug 14, 2021 · 14 comments
Closed

Improve non-treesitter support #6

mvllow opened this issue Aug 14, 2021 · 14 comments
Assignees

Comments

@mvllow
Copy link
Member

mvllow commented Aug 14, 2021

Although treesitter is common amongst neovim users, the native highlight groups should be more consistent.

@mvllow mvllow self-assigned this Aug 14, 2021
@sorachii
Copy link
Contributor

sorachii commented Nov 2, 2021

Hi!

I came across that markdown files are not exactly covered for some reason. I'll attach screenshot tomorrow. What can I do if I'd like to help improve on this?

Best regards

@mvllow
Copy link
Member Author

mvllow commented Nov 4, 2021

Any additions are welcome and appreciated. If you have questions on how to add something let us know; as far as what to add, that’s up to you and your judgement 😌

We generally want to avoid non-neutral colours for large blocks of text (eg. markdown paragraphs) but headings, links etc. are all open to be added/changed.

@sorachii
Copy link
Contributor

sorachii commented Nov 6, 2021

It would be my first neovim theme contribution. I am interested in working on it. Is there any good resource you'd suggest before starting? I am quite busy so it might take me some time to implement it.

@mvllow
Copy link
Member Author

mvllow commented Nov 6, 2021

Sure thing, you should only need to modify ./lua/rose-pine/theme.lua. If you look at lines 125-130 (at the time of writing) there are some html groups, eg. htmlTag = { fg = p.subtle },. You could add your markdown highlight groups under those with a similar format.

To find highlight groups to add, open a markdown file in neovim and do :highlight markdown<Tab> (tab completing through all available options). You could then do :highlight markdownBold guifg=#fa8072 to see bold text in a markdown file turn salmon coloured.

Next, add the group to that theme.lua file mentioned above, using whatever colours you want in the Rosé Pine palette. For example:

  ...
  htmlTagName = { fg = p.foam },

  -- This would be your new line
  markdownBold = { fg = p.iris },

  DiagnosticHint = { fg = groups.hint },
  ...

Finally, if you want to test locally, update your plugin config to point to your local version of the theme. Using packer:

-- use('rose-pine/neovim')
use('~/dev/local-theme')

A bit much, so please feel free to reach out with any questions. Hope this helps 😌

@sorachii
Copy link
Contributor

sorachii commented Nov 6, 2021

Wow. I was not expecting this detailed instructions. I really appreciate it! I am sure this puts me on the right track. 😊

@sorachii
Copy link
Contributor

sorachii commented Nov 7, 2021

Hi @mvllow!

Tried fidgeting with the markdown highlight groups but for some reason it wont use what I set either on the :nvim command line nor what I set in ~/git/rose-pine-markdown-fork/lua/rose-pine/theme.lua.

On the following theme, gruvbox-material, I can see that nvim uses the highlightgroups I would like to set but when I set it, it won't work.

2021-11-07 14_24_22-gruvbox-material-markdown

Here you can see nvim with rose-pine on the left, just installed vim without config on the right. When I set highlight colors on regular vim like you showed, it works but not on nvim.
2021-11-07 14_42_37-markdown-highlights-nvim-vim

I am on v0.6.0-dev+518-g1dbbaf89b build.
Here are the highlight changes I tested and would be cool if I can see them work so I can conftinue with more highlights.
Do you have any tips on why it is not working?

@sorachii
Copy link
Contributor

sorachii commented Nov 7, 2021

Found the issue. For some reason the highlight group in nvim for markdown headers is not markdownH1, instead htmlH1. I'll continue the work. :)

@sorachii
Copy link
Contributor

sorachii commented Nov 7, 2021

What is a good way to figure out what highlight groups are I am looking for apart from trying out a bunch, then stumbling upon the ones I am looking for?

@mvllow
Copy link
Member Author

mvllow commented Nov 7, 2021

I would take a look at some other themes. For example, tokyonight.nvim has the following:

    htmlH1 = { fg = c.magenta, style = "bold" },
    htmlH2 = { fg = c.blue, style = "bold" },

    -- mkdHeading = { fg = c.orange, style = "bold" },
    -- mkdCode = { bg = c.terminal_black, fg = c.fg },
    mkdCodeDelimiter = { bg = c.terminal_black, fg = c.fg },
    mkdCodeStart = { fg = c.teal, style = "bold" },
    mkdCodeEnd = { fg = c.teal, style = "bold" },
    -- mkdLink = { fg = c.blue, style = "underline" },

    markdownHeadingDelimiter = { fg = c.orange, style = "bold" },
    markdownCode = { fg = c.teal },
    markdownCodeBlock = { fg = c.teal },
    markdownH1 = { fg = c.magenta, style = "bold" },
    markdownH2 = { fg = c.blue, style = "bold" },
    markdownLinkText = { fg = c.blue, style = "underline" },

I think it should be enough to try :hi markdown<Tab>, :hi mkd<Tab> and :hi html<Tab> to see available groups. I wish there was a guide with more exact information, every theme seems to be different.

@sorachii
Copy link
Contributor

sorachii commented Nov 7, 2021

I think I found a cool solution to get highlight group from under the cursor.
nvim-treesitter/playground

@sorachii
Copy link
Contributor

sorachii commented Nov 7, 2021

What should I do in order to separate the syntax group of dark/light bg or Regular/Dawn/Night themes?
The same highlight group colors doesn't play well with dark and light themes:

2021-11-07 21_06_19-light-bad
2021-11-07 21_09_26-dark-good

We could separate the highlight groups by rose-pine variant or background light/dark just like the palette in lua/rose-pine/palette.lua. There might be better solution, that is why I am asking you. :)

@mvllow
Copy link
Member Author

mvllow commented Nov 7, 2021

That should be handled for you by using p.foam for example in your theme. So testing locally mkdListItemLine = { fg = p.foam } would be similar to :hi mkdListItemLine guifg=#9ccfd8 for Rosé Pine and :hi mkdListItemLine guifg=#56949f for Rosé Pine Dawn. Hope that makes sense 😌

Edit: this would be a good time to add your local fork to your plugins:

require('packer').startup(function(use)
	use({
		'~/path/to-your-fork',
		config = function()
			vim.cmd('colorscheme rose-pine')
		end,
	})
end

If using packer, this may require a :PackerCompile every time you update a colour in theme.lua.

@sorachii
Copy link
Contributor

sorachii commented Nov 7, 2021

I appreciate your answer.

I see it handles tones but I was thinking it could be nice to use love, rose,
gold, iris mainly for the Dawn theme and colder tones like pine, foam, iris for
Regular and Moon themes.

I am continuing with the tone shifting approach for now, just wanted to share
this idea.

@mvllow
Copy link
Member Author

mvllow commented Nov 7, 2021

I would say let's stick to same colours for each variant now but I like your idea of having a tailored experience per variant. May revisit in the future – will need to refactor our other syntax themes to match.

sorachii added a commit to sorachii/rose-pine-markdown-fork that referenced this issue Nov 8, 2021
mvllow pushed a commit that referenced this issue Nov 8, 2021
* Added markdown highlights.

* enchancement: Improve non-treesitter support(#6)

Added markdown highlight groups.
@mvllow mvllow closed this as completed Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants