iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🗒

[Lua] Disable Italics in Neovim

に公開

Introduction

I'm not a fan of italics, so I'll disable them (this does not apply to the terminal).

Implementation

Simply apply { italic = false, cterm = { italic = false } } to all highlights. Similarly, you can also disable bold, underline, and so on.

vim.api.nvim_create_autocmd({ 'ColorScheme' }, {
  callback = function()
    vim.fn.foreach(vim.api.nvim_get_hl(0, {}), function(hlname, def)
      local is_italic = def.italic or def.cterm and def.cterm.italic
      if not is_italic then
        return
      end

      local disabled_def = vim.tbl_deep_extend('force', def, { italic = false, cterm = { italic = false } })
      vim.api.nvim_set_hl(0, hlname, disabled_def)
    end)
  end,
})

Discussion