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

Bracket coloring in Lua files #1

Closed
zeitchef opened this issue Oct 30, 2021 · 6 comments
Closed

Bracket coloring in Lua files #1

zeitchef opened this issue Oct 30, 2021 · 6 comments

Comments

@zeitchef
Copy link

I've been waiting for someone to merge these two color palettes, so thanks!

I've noticed that matching braces {} are colored differently in some files (yellow in Lua - see screenshot), as opposed to JavaScript files for instance. Is that intentional?

Screen Shot 2021-10-30 at 23 53 21

If so, is there a way to override this behavior to have uniformity across all filetypes? Thanks!

@rmehri01
Copy link
Owner

No problem, I'm glad you like it! I believe that is intentional due to them being different in tree sitter. In Lua they are constructors while in JavaScript they are delimiters:

-- Constructor calls and definitions: `{}` in Lua, and Java constructors.
TSConstructor = { fg = onenord.yellow },

-- Punctuation delimiters: Periods, commas, semicolons, etc.
TSPunctDelimiter = { fg = onenord.dark_blue },
-- Brackets, braces, parentheses, etc.
TSPunctBracket = { fg = onenord.dark_blue },
-- Special punctuation that doesn't fit into the previous categories.
TSPunctSpecial = { fg = onenord.dark_blue },

I think that you can override TSConstructor using vim's highlight but I could provide a more convenient way to do it in Lua as a part of the config options if you think that would be helpful!

@rmehri01
Copy link
Owner

rmehri01 commented Oct 31, 2021

I went ahead and added a way to overwrite any of the highlight groups so you can give it a try if you'd like:

local colors = require("onenord.colors")

require("onenord").setup({
  custom_highlights = {
    TSConstructor = { fg = colors.dark_blue },
  },
})

@zeitchef
Copy link
Author

zeitchef commented Oct 31, 2021

Thanks for the quick response @rmehri01 - unfortunately, this is still not overwriting TSConstructor for me.

  use {
    'rmehri01/onenord.nvim',
    setup = function()
      local colors = require 'onenord.colors'

      require('onenord').setup {
        custom_highlights = {
          TSConstructor = { fg = colors.dark_blue },
        },
      }
    end,
  }

Have I just overlooked something?

EDIT: Sorry, I think this is a problem on my end with Packer.

@rmehri01
Copy link
Owner

Hey @zeitchef, I think you need to use config = rather than setup =. When I try it, setup = doesn't work since it runs before the plugin is loaded. I'm not sure if setup = is supposed to work or not but from what I've seen from other plugins, they seem to use config = but correct me if I'm wrong! This works for me:

use {
  "rmehri01/onenord.nvim",
  config = function()
    local colors = require("onenord.colors")

    require("onenord").setup({
      custom_highlights = {
        TSConstructor = { fg = colors.dark_blue },
      },
    })
  end,
}

@zeitchef
Copy link
Author

Thanks @rmehri01 - you're right, of course. Unfortunately, this somehow doesn't work for my setup. The only way I got it to work was to manually override the highlight:

vim.highlight.create('TSConstructor', { guifg = onenord.dark_blue }, false)

@rmehri01
Copy link
Owner

Hmm, I see. If you're okay with that then great but otherwise let me know if I can do anything else and I could give it a shot!

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

No branches or pull requests

2 participants