Skip to content

Syntax highlighting

Gonzalo Larumbe edited this page Sep 14, 2023 · 4 revisions

verilog-ext provides many faces that inherit from existing ones in Emacs 29. This is done in order to avoid having default faces that might not be suitable for different themes.

The default values for these faces can be customized with very little configuration.

Configuration

First make sure that font-lock has been included in verilog-ext-feature-list before running verilog-ext-mode-setup.

There are two methods to configure faces:

  • Via M-x customize-group RET verilog-ext-font-lock.

    • Customize faces and save configuration once you get the desired result
  • Through elisp code

    • Below there is a snippet with a configuration example that works well with a dark background:
    (set-face-attribute 'verilog-ext-font-lock-grouping-keywords-face nil :foreground "dark olive green")
    (set-face-attribute 'verilog-ext-font-lock-punctuation-face nil       :foreground "burlywood")
    (set-face-attribute 'verilog-ext-font-lock-operator-face nil          :foreground "burlywood" :weight 'extra-bold)
    (set-face-attribute 'verilog-ext-font-lock-brackets-face nil          :foreground "goldenrod")
    (set-face-attribute 'verilog-ext-font-lock-parenthesis-face nil       :foreground "dark goldenrod")
    (set-face-attribute 'verilog-ext-font-lock-curly-braces-face nil      :foreground "DarkGoldenrod2")
    (set-face-attribute 'verilog-ext-font-lock-port-connection-face nil   :foreground "bisque2")
    (set-face-attribute 'verilog-ext-font-lock-dot-name-face nil          :foreground "gray70")
    (set-face-attribute 'verilog-ext-font-lock-brackets-content-face nil  :foreground "yellow green")
    (set-face-attribute 'verilog-ext-font-lock-width-num-face nil         :foreground "chartreuse2")
    (set-face-attribute 'verilog-ext-font-lock-width-type-face nil        :foreground "sea green" :weight 'bold)
    (set-face-attribute 'verilog-ext-font-lock-module-face nil            :foreground "green1")
    (set-face-attribute 'verilog-ext-font-lock-instance-face nil          :foreground "medium spring green")
    (set-face-attribute 'verilog-ext-font-lock-time-event-face nil        :foreground "deep sky blue" :weight 'bold)
    (set-face-attribute 'verilog-ext-font-lock-time-unit-face nil         :foreground "light steel blue")
    (set-face-attribute 'verilog-ext-font-lock-preprocessor-face nil      :foreground "pale goldenrod")
    (set-face-attribute 'verilog-ext-font-lock-modport-face nil           :foreground "light blue")
    (set-face-attribute 'verilog-ext-font-lock-direction-face nil         :foreground "RosyBrown3")
    (set-face-attribute 'verilog-ext-font-lock-typedef-face nil           :foreground "light blue")
    (set-face-attribute 'verilog-ext-font-lock-translate-off-face nil     :background "gray20" :slant 'italic)
    (set-face-attribute 'verilog-ext-font-lock-uvm-classes-face nil       :foreground "light blue")
    (set-face-attribute 'verilog-ext-font-lock-xilinx-attributes-face nil :foreground "orange1")

verilog-ts-mode

Syntax highlighting of verilog-ts-mode is independent of the verilog-ext font lock configuration.

To set it up there are also two methods:

  • Via M-x customize-group RET verilog-ts-faces.

    • Customize faces and save configuration once you get the desired result
  • Through elisp code

    • Below there is a snippet with a configuration example that works well with a dark background:
    (set-face-attribute 'verilog-ts-font-lock-grouping-keywords-face nil :foreground "dark olive green")
    (set-face-attribute 'verilog-ts-font-lock-punctuation-face nil       :foreground "burlywood")
    (set-face-attribute 'verilog-ts-font-lock-operator-face nil          :foreground "burlywood" :weight 'extra-bold)
    (set-face-attribute 'verilog-ts-font-lock-brackets-face nil          :foreground "goldenrod")
    (set-face-attribute 'verilog-ts-font-lock-parenthesis-face nil       :foreground "dark goldenrod")
    (set-face-attribute 'verilog-ts-font-lock-curly-braces-face nil      :foreground "DarkGoldenrod2")
    (set-face-attribute 'verilog-ts-font-lock-port-connection-face nil   :foreground "bisque2")
    (set-face-attribute 'verilog-ts-font-lock-dot-name-face nil          :foreground "gray70")
    (set-face-attribute 'verilog-ts-font-lock-brackets-content-face nil  :foreground "yellow green")
    (set-face-attribute 'verilog-ts-font-lock-width-num-face nil         :foreground "chartreuse2")
    (set-face-attribute 'verilog-ts-font-lock-width-type-face nil        :foreground "sea green" :weight 'bold)
    (set-face-attribute 'verilog-ts-font-lock-module-face nil            :foreground "green1")
    (set-face-attribute 'verilog-ts-font-lock-instance-face nil          :foreground "medium spring green")
    (set-face-attribute 'verilog-ts-font-lock-time-event-face nil        :foreground "deep sky blue" :weight 'bold)
    (set-face-attribute 'verilog-ts-font-lock-time-unit-face nil         :foreground "light steel blue")
    (set-face-attribute 'verilog-ts-font-lock-preprocessor-face nil      :foreground "pale goldenrod")
    (set-face-attribute 'verilog-ts-font-lock-modport-face nil           :foreground "light blue")
    (set-face-attribute 'verilog-ts-font-lock-direction-face nil         :foreground "RosyBrown3")
    (set-face-attribute 'verilog-ts-font-lock-translate-off-face nil     :background "gray20" :slant 'italic)
    (set-face-attribute 'verilog-ts-font-lock-attribute-face nil         :foreground "orange1")
Clone this wiki locally