Skip to content

Custom Themer block

undermouse edited this page Jul 20, 2022 · 3 revisions

Custom Themer block allows you to inject your own code into files, allowing to create fully customizable templates for each file.

To create a custom block, you should put this into your files config:

files:
  nvim:
    # Let's assume you've already defined a themer block inside of init.vim
    path: "~/.config/nvim/init.vim"
    comment: "\""
    format: "let <key> = \"<value>\""
    custom: |
      " Setup Nvim colors with Themer
      " <name> is the current theme:
      colorscheme <name>
      hi Keyword guibg=<foreground>
      " Will place all variables definitions from the current theme, according
      " to `format` (see above `custom` block`)  
      " This is basically the default themer block
      <vars>

As you can see, you can use some variables inside of custom block:

  • <name> contains a name for the current theme you've defined inside themes block.
  • <vars> is a default themer block that would've injected without custom block, it's built based on the format setting
  • <var>, where var is anything will map to variable inside theme. It's not like <vars>, you'll just get a value from this call

Custom blocks are usefull when need to place additional logic inside your config file besides just variables. It example above, you can see I set coloscheme inside Nvim config by calling colorcheme <name>. So when I call themer set dracula, Nvim will have dracula theme

Clone this wiki locally