Skip to content

Highlights the background of s-expressions to help code readability

License

Notifications You must be signed in to change notification settings

ArijanJ/sexp-highlight.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

sexp-highlight.nvim

image

This is a small Neovim plugin which will highlight the background of your current s-expression.

It uses Treesitter for parsing the sexp trees, so you'll need a parser installed for your lisp of choice before using this.

I made this for Clojure in particular, but you can easily modify the is_list function in util.lua to change whether vectors/maps/sets should be highlighted separately (use :InspectTree)

Installation

  • Packer:
use { 'ArijanJ/sexp-highlight.nvim' }

...and other plugin managers should be in this ballpark as well :)

Usage

All you need to do is map a shortcut to this Lua function:

require('sexp-highlight').toggle_for_current_buffer()

As the name suggests, this'll toggle the plugin for the current buffer. To automate this, look into the BufNew autocmd (or open an issue, doesn't take much to pressure me).

Configuration

When caling toggle_for_current_buffer(), you can pass in a table with these options:

Option Description
levels How many levels of nested sexps should be highlighted (color stays the same for all further ones)
method "block" or "line", dictates whether the highlighted area will be a block (like visual block mode) or extend to the next line
colors { start = 30, step = 15 } - Arbitrary numbers for how much brighter the first layer will be than your background, and how much brighter each following level (step) will be
starting_color Forces a given starting color instead of your background color, format has to be a Lua number in hex format (0x000000, no quotes)

The default call (if you don't pass any options) would look something like this:

toggle_for_current_buffer({ 
    levels = 4,
    method = 'block',
    starting_color = [uses your background color],
    colors = { start = 25, step = 10}
 })

Light themes

Since this lightens your background color for each level, light themes are very likely to cause color overflows and mess everything up.

Workarounds to this include (and are very much limited to):

  • Using a dark theme!
  • Setting the starting_color to a darker one
  • Lowering colors.step
  • Lowering levels

image

About

Highlights the background of s-expressions to help code readability

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages