Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

Optimize highlights using global highlight group cache #108

Merged
merged 1 commit into from
Jul 29, 2021

Conversation

venkatakrishnaannam
Copy link
Contributor

Instead of creating all highlight groups, the commands for them are generated and cached in a global variable. While rendering statusline and tabline, the highlight groups used are created on demand.

Fixes #104.

Instead of creating all highlight groups, the commands for them are
generated and cached in a global variable. While rendering statusline
and tabline, the highlight groups used are created on demand.
@venkatakrishnaannam
Copy link
Contributor Author

venkatakrishnaannam commented Jul 26, 2021

Although the number of highlight groups reduced, no noticeable performance improvement was seen on large files. So, number of highlights was not the bottleneck. Will work on improving performance.

@datwaft datwaft self-requested a review July 27, 2021 15:20
@datwaft datwaft added the enhancement New feature or request label Jul 27, 2021
@datwaft datwaft changed the base branch from master to dev July 27, 2021 15:40
@datwaft
Copy link
Owner

datwaft commented Jul 27, 2021

Question, is this ready to be merged?

Fun fact, I cannot test this plugin using the classic nvim --cmd "set rtp+=." because of how I structured the plugin at the beginning (I am writing a refactor to solve this and other things) so I need to merge the PR to dev before testing.

@venkatakrishnaannam
Copy link
Contributor Author

This solves the number of highlights issue. Performance improvement still needs to be worked on. Other than that, this is ready to be merged.
It'd be good to know that it works somewhere other than my machine before merging.

Copy link
Owner

@datwaft datwaft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work properly in my computer.

image

I used this command to test the plugin (fun fact: I just needed to add set termguicolors to test the pull request without merging):

nvim --clean \
  --cmd "set rtp+=." \
  --cmd "source plugin/bubbly.vim" \
  --cmd "source test-configuration.lua"

The contents of test-configuration.lua were:

vim.opt.termguicolors = true
vim.g.bubbly_palette = {
  background = "#34343c",
  foreground = "#c5cdd9",
  black = "#3e4249",
  red = "#ec7279",
  green = "#a0c980",
  yellow = "#deb974",
  blue = "#6cb6eb",
  purple = "#d38aea",
  cyan = "#5dbbc1",
  white = "#c5cdd9",
  lightgrey = "#57595e",
  darkgrey = "#404247",
}
vim.g.bubbly_statusline = {
  'mode',

  'truncate',

  'path',

  'divisor',

  'filetype',
  'progress',
}

@datwaft
Copy link
Owner

datwaft commented Jul 29, 2021

I will now merge into datwaft:dev to test that it works using packer and then will merge to master.

I am thinking about refining this process, maybe using conventional commits and squashing the pull request.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Too many highlight groups created by bubbly
2 participants