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

feat: allow multiple hlgroups inside one column #240

Merged
merged 3 commits into from
Dec 8, 2023

Conversation

Bekaboo
Copy link
Contributor

@Bekaboo Bekaboo commented Nov 30, 2023

This PR adds the ability to set multiple hlgroups inside one column.

Related to #212

Before:

image

After:

image

To achieve the effect of the second screenshot, one has to setup oil as follows:

local permission_hlgroups = {
  ['-'] = 'NonText',
  ['r'] = 'DiagnosticSignWarn',
  ['w'] = 'DiagnosticSignError',
  ['x'] = 'DiagnosticSignOk',
}

oil.setup({
  columns = {
    {
      'permissions',
      highlight = function(permission_str)
        local hls = {}
        for i = 1, #permission_str do
          local char = permission_str:sub(i, i)
          table.insert(hls, { permission_hlgroups[char], i - 1, i })
        end
        return hls
      end,
    },
    { 'size', highlight = 'Special' },
    { 'mtime', highlight = 'Number' },
    {
      'icon',
      default_file = icon_file,
      directory = icon_dir,
      add_padding = false,
    },
  },
  win_options = {
    number = false,
    relativenumber = false,
    signcolumn = 'no',
    foldcolumn = '0',
    statuscolumn = '',
  },
})

@Bekaboo
Copy link
Contributor Author

Bekaboo commented Dec 7, 2023

@stevearc Any improvements I can do to get this into master?

@Bekaboo
Copy link
Contributor Author

Bekaboo commented Dec 8, 2023

Thanks for the type fix, I was just trying to figure out how to fix it.

@stevearc
Copy link
Owner

stevearc commented Dec 8, 2023

Thanks for the PR!

Sorry for the wait, I'm stretched pretty thin at the moment

@stevearc stevearc merged commit a173b57 into stevearc:master Dec 8, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants