Skip to content

romgrk/pp.vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pp.vim - pretty printer

===========================

A better echo

command! Pp [args...]

Where args is a comma-separated list of vim expressions that will be eveluated. You can also use it as nnoremap i|replacement for call command, it will show a pretty return value.

" An example:
:Pp [1, 2, '3', {'a': 4}], function('search'), "special\nchar"

alt text

pp.vim defines the global dict g:pp, which contains the functions for printing/parsing.

:Pp g:pp

alt text

Settings

theme:

You can define your theme by:

  • defining a global func PPtheme
  • calling pp#theme(dict)
  • setting g:pp['theme']
" pp.theme =>

let theme = {}
let theme['Name']            = 'Normal'
let theme['String']          = 'String'
let theme['Number']          = 'Number'
let theme['Float']           = 'Number'
let theme['Function']        = 'Function'
let theme['FuncIdentifier']  = 'Identifier'
let theme['List']            = 'Enum'
let theme['Dict']            = 'Structure'
let theme['SpecialChar']     = 'SpecialChar'
let theme['Separator']       = 'Comment'
let theme['Delimiter']       = 'Delimiter'
let theme['StringDelimiter'] = 'StringDelimiter'

You can also get the pretty theme by calling pp#prettyTheme().

Functionnal

  • pp#() : returns pp dict

  • pp#print(...): the function called by Pp command

  • pp#dump(obj[, depth=2]): prints obj

  • pp#theme(): returns current theme

  • pp#theme(t): sets pp['theme'] to t

Calling pp object functions:

let obj   = {'some': {'object': {'very': {'deeply': 'recursive'}}}}
let depth = 4
call pp.dump(obj, depth)
" (Pp command default is depth=2)
" Don't tell anyone, but if ever you need to print a message 
" with highlight:
call pp._('Keyword', 'text to print')

alt text

About

pretty-printer with real colors.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published