olimorris / onedarkpro.nvim

🎨 Atom's iconic One Dark theme. Cacheable, fully customisable, Tree-sitter and LSP semantic token support. Comes with variants
MIT License
804 stars 44 forks source link

[Bug]: No Markdown Highlighting #222

Closed n-crespo closed 9 months ago

n-crespo commented 9 months ago

Your minimal.lua config

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  {
    "olimorris/onedarkpro.nvim",
    opts = {
      -- Your OneDarkPro config goes here
    },
    config = true,
  },

  { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },

  -- add any other plugins here
  { "catppuccin/nvim", name = "catppuccin", priority = 1000 },
{
  "folke/tokyonight.nvim",
  lazy = false,
  priority = 1000,
  opts = {},
},
{ "EdenEast/nightfox.nvim" }, -- lazy
}

require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

-- setup treesitter
local ok, treesitter = pcall(require, "nvim-treesitter.configs")
if ok then
  treesitter.setup({
    ensure_installed = "markdown",
    ignore_install = { "phpdoc" }, -- list of parser which cause issues or crashes
    highlight = { enable = true },
  })
end

vim.cmd("colorscheme onedark")

Error messages

No response

Describe the bug

What I expect to happen:

Syntax highlighting on markdown files, similar to below: (this is with tokyonight_night enabled with the minimal configuration)

image

Below is an image from a week ago with onedark_dark from my default configuration:

image

The default configuration: (none of the custom highlighting works either)

local md_highlight = "#14161a"
return {
  -- theme of choice, transparent, italic comments, markdown italic support
  "olimorris/onedarkpro.nvim",
  name = "onedarkpro",
  priority = 1000, -- Ensure it loads first
  config = function()
    require("onedarkpro").setup({
      styles = { -- For example, to apply bold and italic, use "bold,italic"
        comments = "italic", -- Style that is applied to comments
        virtual_text = "bold", -- Style that is applied to virtual text
      },
      options = {
        cursorline = false, -- Use cursorline highlighting?
        transparency = true, -- Use a transparent background?
        terminal_colors = true, -- Use the theme's colors for Neovim's :terminal?
        highlight_inactive_windows = false, -- When the window is out of focus, change the normal background?
        bold = true,
        italic = true,
        underline = true,
        undercurl = true,
      },
      highlights = {
        ["@text.emphasis"] = { italic = true },
        ["@tag.html"] = { fg = "#89ca78" },

        ["@text.todo.unchecked"] = { bg = md_highlight },
        Headline = { bg = md_highlight },
        CodeBlock = { bg = md_highlight },

        WhichKeyFloat = { bg = nil }, -- transparent whichkey
        TabLineSel = { bg = "#22272f", bold = true },
        MiniStatuslineModeNormal = { bg = "#22272f" },
        LazyButton = { bg = "#22272f" },
        TreeSitterContext = { bg = "#22272f" },
      },
    })
    vim.cmd.colorscheme("onedark_dark")
  end,
}

What actually happens:

No highlighting:

image

I could not re-create functional markdown highlighting with the minimal configuration, but I have been using this color scheme for a long time in my regular config and only today has markdown highlighting not worked.

Reproduce the bug

Steps to reproduce:

Open any markdown file with this color scheme enabled.

Final checks

olimorris commented 9 months ago

Firstly, thanks for flagging this. There was a change in the markdown Tree-sitter parser in the last day or two unfortunately. Hopefully the latest commit resolves it.

If you notice any highlights that haven't been applied, can you do :Inspect and let me know what the highlight groups are and what the colors should be?

n-crespo commented 9 months ago

Here are some, and a) I don't fully remember what most of them were supposed to look like and b) there may be more highlights I don't have listed

(I could use a color picker but I'll get slight variations in the hex codes, but I think the following has some standard colors in it that would be consistent with the rest of the color scheme)

local onedark = require("onedarkpro.helpers").get_colors("onedark_dark")
old highlight group name new highlight group name fix
@text.todo.unchecked @markup.list.checked.markdown links to @markup markdown I don't know what this used to look like, but the highlight name changed (this is checkboxes)
@text.emphasis @markup.italic.markdown_inline links to @markup markdown_inline should be italic
@tag.html @tag.html This works properly
idk @markup.heading.2.markdown links to @markup markdown some kind of light green? I don't have a way to make the theme work properly so I'm not sure what the exact color is. This one probably is onedark.green (this applies to all headers)
idk @markup.strong.markdown_inline links to @markup markdown_inline should be bolded
idk @markup.list.markdown links to @markup markdown should be some type of red, probably onedark.red (this is the bullet points)
idk @markup.link.label.markdown_inline Should be some shade of blue, probably onedark.blue (this is text inside square brackets)
idk @markup.raw.markdown_inline Should be some shade of green, probably onedark.green (inline code)
idk @markup.link.markdown_inline and @markup.link.url.markdown_inline should be some shade of pink, probably onedark.pink (if that exists?) (this is a URL)
idk @markup.quote.markdown This didn't have any highlighting in the old theme, but since it is a quote it could have a fg like this: "#757876" (this is a quote >)

Hope this helps a bit at least! Is the problem just that the highlight names have changed?

olimorris commented 9 months ago

Right I've moved my earlier additions to the treesitter.lua file and referenced them as per https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md#highlights. Also added some of your suggestions...great spot.

Any adjustments you wish to make should be possible via your config...I've tested the following and it works as expected:

local md_highlight = "#14161a"
return {
  {
    "olimorris/onedarkpro.nvim",
    priority = 1000, -- Ensure it loads first
    opts = {
      styles = { -- For example, to apply bold and italic, use "bold,italic"
        comments = "italic", -- Style that is applied to comments
        virtual_text = "bold", -- Style that is applied to virtual text
      },
      options = {
        cursorline = false, -- Use cursorline highlighting?
        transparency = true, -- Use a transparent background?
        terminal_colors = true, -- Use the theme's colors for Neovim's :terminal?
        highlight_inactive_windows = false, -- When the window is out of focus, change the normal background?
        bold = true,
        italic = true,
        underline = true,
        undercurl = true,
      },
      highlights = {
        ["@text.emphasis"] = { italic = true },
        ["@tag.html"] = { fg = "#89ca78" },

        ["@text.todo.unchecked"] = { bg = md_highlight },
        Headline = { bg = md_highlight },
        CodeBlock = { bg = md_highlight },

        WhichKeyFloat = { bg = nil }, -- transparent whichkey
        TabLineSel = { bg = "#22272f", bold = true },
        MiniStatuslineModeNormal = { bg = "#22272f" },
        LazyButton = { bg = "#22272f" },
        TreeSitterContext = { bg = "#22272f" },
      },
    },
    config = function(_, opts)
      require("onedarkpro").setup(opts)

      vim.cmd([[colorscheme onedark_dark]])
    end,
  },
}
n-crespo commented 9 months ago

Looks great! Thanks for everything and for the quick response time!

n-crespo commented 9 months ago

Btw, not sure it's worth the effort for changing this, but the colors for the part of markdown links inside of the square brackets and text inside the parenthesis are switched:

image

For reference, here how it used to be (switched around)

image