Skip to content

Using hyphen in TODO keyword causes highlight errors #356

@akinsho

Description

@akinsho

Describe the bug

I have just attempted to add IN-PROGRESS as a todo keyword, unfortunately this causes the following error

image

Which I believe is likely from trying to use something like OrgTODOIN-PROGRESS directly as a highlight name.

Steps to reproduce

  1. Use the following config for orgmode
require('orgmode').setup({
    org_todo_keywords = {
      'TODO(t)',
      'WAITING',
      'IN-PROGRESS',
      '|',
      'DONE(d)',
    },
    org_todo_keyword_faces = {
      ['IN-PROGRESS'] = ':foreground royalblue :weight bold',
    },
})
  1. Open an orgmode file, or the agenda.
  2. See the error

Expected behavior

The name should be normalized to remove any values that aren't valid in a highlight group. I believe this was discussed in #299, but perhaps the fix was not applied to the keyword faces

Emacs functionality

This appears to work without issue and this seems directly related to vim highlight group name mechanics

Minimal init.lua

vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.cmd([[set packpath=/tmp/nvim/site]])

local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'

local function load_plugins()
  require('packer').startup({
    {
      'wbthomason/packer.nvim',
      { 'nvim-treesitter/nvim-treesitter' },
      { 'kristijanhusak/orgmode.nvim', branch = 'master' },
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. '/plugin/packer_compiled.lua',
    },
  })
end

_G.load_config = function()
  require('orgmode').setup_ts_grammar()
  require('nvim-treesitter.configs').setup({
    highlight = {
      enable = true,
      additional_vim_regex_highlighting = { 'org' },
    },
  })

  vim.cmd([[packadd nvim-treesitter]])
  vim.cmd([[runtime plugin/nvim-treesitter.lua]])
  vim.cmd([[TSUpdateSync org]])

  -- Close packer after install
  if vim.bo.filetype == 'packer' then
    vim.api.nvim_win_close(0, true)
  end

  require('orgmode').setup({
   org_todo_keywords = {
      'TODO(t)',
      'WAITING',
      'IN-PROGRESS',
      '|',
      'DONE(d)',
    },
    org_todo_keyword_faces = {
      ['IN-PROGRESS'] = ':foreground royalblue :weight bold',
    },
  })

  -- Reload current file if it's org file to reload tree-sitter
  if vim.bo.filetype == 'org' then
    vim.cmd([[edit!]])
  end
end

if vim.fn.isdirectory(install_path) == 0 then
  vim.fn.system({ 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path })
  load_plugins()
  require('packer').sync()
  vim.cmd([[autocmd User PackerCompileDone ++once lua load_config()]])
else
  load_plugins()
  load_config()
end

Screenshots and recordings

No response

OS / Distro

macOS Big Sur

Neovim version/commit

                                                                                                                                                                    NVIM v0.8.0-dev+1941-gb7084fef4                                                                                                                                                                                                                                                                                                                         

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions