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

Since I'm not a fan of italics, I'll disable them (not targeting those in the terminal).

Implementation

Simply apply { italic = false, cterm = { italic = false } } to all highlights. Similarly, bold, underline, etc., can be disabled as well.

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