onedark.nvim icon indicating copy to clipboard operation
onedark.nvim copied to clipboard

How to change the color of comments

Open vastray opened this issue 2 years ago • 3 comments

How to change comment color of multiline comments python? They are green by default. I want to change it to gray

class Tets:
    """
    multiline comment
    """

vastray avatar Nov 21 '22 08:11 vastray

totes, i thought maybe i had solved the defining comments by overriding the defaults with my init.lua but it seems that using TSPlaygroundToggle on a random python file that i added a multiline comment to. i get the same results that you mention above. if i'm reading output correctly it looks like maybe the treesitter parser is reading the multiline comment as a expression_statement

image

ipatch avatar Feb 28 '23 23:02 ipatch

and apparently doing a little more reading on this subject, those multiline comments are what i believe the python language refers to as docstrings

there does seem to be a workaround to label them as "code comments" to adjust the color if you choose to go that route.

https://github.com/nvim-treesitter/nvim-treesitter/issues/4392

ipatch avatar Mar 01 '23 00:03 ipatch

I hade the same problem but in reverse. Tried to change comments to dark green to not be the same color as whitespace. (not python-specific)

This worked for me:

image

Snippet from init.lua


  {
    -- Theme inspired by Atom
    'navarasu/onedark.nvim',
    priority = 1000,
    config = function()
      require('onedark').setup {
        -- Main options --
        style = 'warmer', -- Default theme style. Choose between 'dark', 'darker', 'cool', 'deep', 'warm', 'warmer' and 'light'
        transparent = false,  -- Show/hide background
        term_colors = true, -- Change terminal color as per the selected theme style
        ending_tildes = true, -- Show the end-of-buffer tildes. By default they are hidden
        cmp_itemkind_reverse = false, -- reverse item kind highlights in cmp menu

        -- toggle theme style ---
        toggle_style_key = nil, -- keybind to toggle theme style. Leave it nil to disable it, or set it to a string, for example "<leader>ts"
        toggle_style_list = {'dark', 'darker', 'cool', 'deep', 'warm', 'warmer', 'light'}, -- List of styles to toggle between

        -- Change code style ---
        -- Options are italic, bold, underline, none
        -- You can configure multiple style with comma separated, For e.g., keywords = 'italic,bold'
        code_style = {
            comments = 'none',
            keywords = 'none',
            functions = 'none',
            strings = 'none',
            variables = 'none'
        },

        -- Lualine options --
        lualine = {
            transparent = false, -- lualine center bar transparency
        },

        -- Custom Highlights --
        colors = {
          bright_orange = "#ff8800",    -- define a new color
          -- green = '#00ffaa',            -- redefine an existing color
          dark_green = '#475a39'
        }, -- Override default colors
        highlights = {
          ["comments"] = {fg = '$dark_green', fmt = 'none'},
          ["@comment"] = {fg = '$dark_green', fmt = 'none'},
          ["@lsp.type.comment"] = {fg = '$dark_green', fmt = 'none'},
          ["LineNr"] = {fg = '$light_grey', fmt = 'none'},
          ["Whitespace"] = {fg = '$grey', fmt = 'none'},
          -- ["@function"] = {fg = '#0000ff', sp = '$cyan', fmt = 'underline,italic'},
          -- ["@function.builtin"] = {fg = '#0059ff'}
        }, -- Override highlight groups

        -- Plugins Config --
        diagnostics = {
            darker = true, -- darker colors for diagnostic
            undercurl = true,   -- use undercurl instead of underline for diagnostics
            background = true,    -- use background color for virtual text
        },
      }
      require('onedark').load()
    end,
  },

davidwincent avatar Jun 15 '23 05:06 davidwincent