• Stars
    star
    486
  • Rank 89,934 (Top 2 %)
  • Language
    Vim Script
  • Created about 10 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Semantic Highlighting for Vim

Semantic-Highlight.vim

Where every variable is a different color, an idea popularized by Evan Brooks' blog post.

Install

Vundle or Neobundle:

Plugin 'jaxbot/semantic-highlight.vim'

Pathogen:

git clone https://github.com/jaxbot/semantic-highlight.vim.git

Usage

In a file, run :SemanticHighlight to convert variables into colors. Run :SemanticHighlightRevert to revert.

You can also map :SemanticHighlightToggle to a shortcut to toggle the effect on and off:

:nnoremap <Leader>s :SemanticHighlightToggle<cr>

Customization

Set g:semanticTermColors and/or g:semanticGUIColors to a list of colors, then run RebuildSemanticColors to flush the cache. The color lists look like:

let s:semanticGUIColors = [ '#72d572', '#c5e1a5', '#e6ee9c', '#fff59d', '#ffe082', '#ffcc80', '#ffab91', '#bcaaa4', '#b0bec5', '#ffa726', '#ff8a65', '#f9bdbb', '#f9bdbb', '#f8bbd0', '#e1bee7', '#d1c4e9', '#ffe0b2', '#c5cae9', '#d0d9ff', '#b3e5fc', '#b2ebf2', '#b2dfdb', '#a3e9a4', '#dcedc8' , '#f0f4c3', '#ffb74d' ]

or

let g:semanticTermColors = [28,1,2,3,4,5,6,7,25,9,10,34,12,13,14,15,16,125,124,19]

Either list can also be set in your vimrc

Language support

This plugin is language agnostic, meaning it will work on any language with words. However, some languages have been tweaked by default to disable highlighting of language keywords.

Current language support with keyword blacklists:

  • C
  • C++
  • CoffeeScript
  • Go
  • Java
  • JavaScript
  • PHP
  • Python
  • Ruby
  • Rust
  • Scala
  • TypeScript

This can be customized locally by populating g:semanticBlacklistOverride like so:

let g:semanticBlacklistOverride = {
	\ 'javascript': [
	\	'setTimeout',
	\	'break',
	\	'dance',
	\ ]
\ }

If you want to add language support to the plugin itself, feel free to edit autoload/blacklist.vim and submit a pull request with your changes. Help is appreciated!

Adding characters to be included in highlights

Some languages, such as PHP and JavaScript, allow special characters to be used in variable names.

Consider the following:

var $someObject = '1231';
var someObject = 1231;

Without the autocommand outlined below, only the someObject portion of the variable would be semantically highlighted, and highlighted the same colour as the $-free variable. To have the preceding $ included in the semantic highlight, use the following snippet in your vimrc:

autocmd FileType javascript setlocal iskeyword+=$

Kudos

Big thanks to John Leimon, whose Semantic C/C++ Vimscript was inspirational in the construction of this one.

Also big thanks to everyone who submitted bugs, suggestions, and pull requests!

About me

I'm Jonathan. I like to hack around with Vim, Node.js, embedded hardware, and Glass. If any of that sounds interesting, follow me!

More Repositories

1

browserlink.vim

Live browser editing for Vim
JavaScript
710
star
2

github-issues.vim

Github issue lookup in Vim
Python
405
star
3

syntastic-react

React.js JSX support for Syntastic
JavaScript
93
star
4

vimfiles

vim, tmux, zsh
Vim Script
61
star
5

selective-undo.vim

Selective undo for Vim
Vim Script
53
star
6

hangouts-bot

Node.js hangouts code
JavaScript
45
star
7

chrome-devtools.vim

Vim Script
24
star
8

ADB-File-Browser-OSX

AFT replacement for OSX
JavaScript
21
star
9

glass-prism

Google Glass Node.js framework
JavaScript
13
star
10

wph-seveneighter

C#
12
star
11

irssi-pushbullet-notifications

Quick Irssi script that redirects mentions and PMs to Pushbullet
Perl
11
star
12

glass-qrlens

QR Code scanner for Glass
Java
9
star
13

wear-LeafStatus

Quick Leaf Notifications app for Nissan Leaf cars
Java
9
star
14

quickglass

Quickly build voice triggers for Google Glass
Java
8
star
15

glass-barcode

Easy QR and barcode source for Google Glass
Java
5
star
16

gtop

Server monitoring and administration for Google Glass
JavaScript
5
star
17

udacity-car-projects

Projects from Udacity's Self-Driving Car Nanodegree
C++
5
star
18

glass-trello

Experimental Trello integration with Google Glass
JavaScript
5
star
19

colorpicker-windows-commandline

A quick color picker that can be called from the Windows command line. Returns the chosen color.
C#
5
star
20

medli

Source for my previous PHP-based blog
PHP
4
star
21

glass-mint

Mint.com integration for Glass
JavaScript
4
star
22

u2f-node-example

JavaScript
4
star
23

hubot-rain-alert

Live rain alerts for Hubot
CoffeeScript
4
star
24

orangemelt

A simple HTML5 collaboration game I made. Live: http://jaxbot.me/orangemelt
JavaScript
3
star
25

forthelazy

A series of "___ for the lazy" coding reference sheets
3
star
26

glass-lowbrightness

An experiment that puts Glass in low brightness mode to save power
Java
3
star
27

vim-getting-started

Getting Started Tutorial for the Vim Text Editor
CSS
3
star
28

reacterest

React.js and Flux example
JavaScript
3
star
29

wear-WearTap

Java
3
star
30

glass-vegeta

Ok Glass, what is his power level?
Groovy
3
star
31

epoch-to-human.vim

Quick conversion from Unix time to human time string. WIP.
Vim Script
2
star
32

moderate

JavaScript
2
star
33

cs-algorithms-multilang

Various practice algorithms in various languages, just cus.
C
2
star
34

glass-LeafControl

Java
2
star
35

vim-talk

JavaScript
2
star
36

PyconAutoWifi

Java
2
star
37

glasscoin

Proof of concept Bitcoin ticker for Glass using Mirror API
JavaScript
2
star
38

hubot-orlandodevs

CoffeeScript
2
star
39

uptime

Little uptime tracker for my RPi
JavaScript
2
star
40

glass-ucfwebcams

UCF Webcams on Glass
Java
2
star
41

dobble

A PHP social network site I made between Summer 2011 and 2012
PHP
2
star
42

wheresmysurface

Simple GPS/WiFi location tracking for Windows 8 devices. I use it for anti-theft of my Surface Pro 2
C#
2
star
43

android-contextual-examples

For a presentation
Java
1
star
44

reacterest-css-in-js

JavaScript
1
star
45

glass-presentation

Java
1
star
46

fizzfeed

Example blog in Koa using Harmony ES6 Node.js/Io.js
CSS
1
star
47

cat-classifier

Automatically determine which cat is eating all the food with Tensorflow
Python
1
star
48

SlackPack

Swift
1
star
49

macfiles

Shell
1
star
50

wiimote-presentation-remote

A userscript that allows using a Wii remote for presentations. Very hacky.
JavaScript
1
star
51

serverfiles

Random configurations I keep on my server
Nginx
1
star
52

tesla-cpo-history

JavaScript
1
star
53

hub.vim

Vim Script
1
star
54

minimal-vimrc

A minimal vimrc I wrote as part of a tutorial
Vim Script
1
star
55

my-lolcommits

Simple site for my lolcommits
PHP
1
star
56

wear-Vespr

When Vespr WiFi is detected, show a notification with your Vespr QR code on it.
Java
1
star
57

club

Club site
CSS
1
star
58

reactyl

JavaScript
1
star
59

knighthacks-git-tutorial

This is a fake repo that will be deleted.
1
star
60

spacebarteam

JavaScript
1
star
61

octoglass

JavaScript
1
star
62

viscendroid

Java
1
star
63

viscen

WIP home automation and monitoring stuff, specific to my setup mostly
PHP
1
star
64

test

A repository for testing various Github things
JavaScript
1
star