├── README └── after └── syntax └── haskell.vim /README: -------------------------------------------------------------------------------- 1 | Use Vim 7.3 Conceal feature to display unicode operator 2 | in Haskell without changing the underlying file. 3 | 4 | GitHub: https://github.com/Twinside/vim-haskellConceal 5 | 6 | ## Installation 7 | 8 | Decompress in your ~/vimfiles or ~/.vim, if you're using 9 | pathogen (you should), put it in ~/.vim/bundle/haskellConceal 10 | folder 11 | 12 | -------------------------------------------------------------------------------- /after/syntax/haskell.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " What Is This: Add some conceal operator for your haskell files 3 | " File: haskell.vim (conceal enhancement) 4 | " Author: Vincent Berthoux 5 | " Last Change: 2011-09-07 6 | " Version: 1.3.2 7 | " Require: 8 | " set nocompatible 9 | " somewhere on your .vimrc 10 | " 11 | " Vim 7.3 or Vim compiled with conceal patch. 12 | " Use --with-features=big or huge in order to compile it in. 13 | " 14 | " Usage: 15 | " Drop this file in your 16 | " ~/.vim/after/syntax folder (Linux/MacOSX/BSD...) 17 | " ~/vimfiles/after/syntax folder (Windows) 18 | " 19 | " For this script to work, you have to set the encoding 20 | " to utf-8 :set enc=utf-8 21 | " 22 | " Additional: 23 | " * if you want to avoid the loading, add the following 24 | " line in your .vimrc : 25 | " let g:no_haskell_conceal = 1 26 | " Changelog: 27 | " - 1.3.1: putting undefined in extra conceal, not appearing on windows 28 | " - 1.3: adding new arrow characters used by GHC in Unicode extension. 29 | " - 1.2: Fixing conceal level to be local (thx Erlend Hamberg) 30 | " - 1.1: Better handling of non utf-8 systems, and avoid some 31 | " concealing operations on windows on some fonts 32 | " 33 | if exists('g:no_haskell_conceal') || !has('conceal') || &enc != 'utf-8' 34 | finish 35 | endif 36 | 37 | " vim: set fenc=utf-8: 38 | syntax match hsNiceOperator "\\\ze[[:alpha:][:space:]_([]" conceal cchar=λ 39 | syntax match hsNiceOperator "<-" conceal cchar=← 40 | syntax match hsNiceOperator "->" conceal cchar=→ 41 | syntax match hsNiceOperator "\" conceal cchar=∑ 42 | syntax match hsNiceOperator "\" conceal cchar=∏ 43 | syntax match hsNiceOperator "\" conceal cchar=√ 44 | syntax match hsNiceOperator "\" conceal cchar=π 45 | syntax match hsNiceOperator "==" conceal cchar=≡ 46 | syntax match hsNiceOperator "\/=" conceal cchar=≠ 47 | syntax match hsNiceOperator ">>" conceal cchar=» 48 | 49 | let s:extraConceal = 1 50 | " Some windows font don't support some of the characters, 51 | " so if they are the main font, we don't load them :) 52 | if has("win32") 53 | let s:incompleteFont = [ 'Consolas' 54 | \ , 'Lucida Console' 55 | \ , 'Courier New' 56 | \ ] 57 | let s:mainfont = substitute( &guifont, '^\([^:,]\+\).*', '\1', '') 58 | for s:fontName in s:incompleteFont 59 | if s:mainfont ==? s:fontName 60 | let s:extraConceal = 0 61 | break 62 | endif 63 | endfor 64 | endif 65 | 66 | if s:extraConceal 67 | syntax match hsNiceOperator "\" conceal cchar=⊥ 68 | 69 | " Match greater than and lower than w/o messing with Kleisli composition 70 | syntax match hsNiceOperator "<=\ze[^<]" conceal cchar=≤ 71 | syntax match hsNiceOperator ">=\ze[^>]" conceal cchar=≥ 72 | 73 | syntax match hsNiceOperator "=>" conceal cchar=⇒ 74 | syntax match hsNiceOperator "=\zs<<" conceal cchar=« 75 | 76 | syntax match hsNiceOperator ">>>" conceal cchar=⋙ 77 | 78 | " Redfining to get proper '::' concealing 79 | syntax match hs_DeclareFunction /^[a-z_(]\S*\(\s\|\n\)*::/me=e-2 nextgroup=hsNiceOperator contains=hs_FunctionName,hs_OpFunctionName 80 | syntax match hsNiceOperator "\:\:" conceal cchar=∷ 81 | 82 | syntax match hsNiceoperator "++" conceal cchar=⧺ 83 | syntax match hsNiceOperator "\" conceal cchar=∀ 84 | syntax match hsNiceOperator "-<" conceal cchar=↢ 85 | syntax match hsNiceOperator ">-" conceal cchar=↣ 86 | syntax match hsNiceOperator "-<<" conceal cchar=⤛ 87 | syntax match hsNiceOperator ">>-" conceal cchar=⤜ 88 | " the star does not seem so good... 89 | " syntax match hsNiceOperator "*" conceal cchar=★ 90 | syntax match hsNiceOperator "`div`" conceal cchar=÷ 91 | 92 | " Only replace the dot, avoid taking spaces around. 93 | syntax match hsNiceOperator /\s\.\s/ms=s+1,me=e-1 conceal cchar=∘ 94 | syntax match hsNiceOperator "\.\." conceal cchar=‥ 95 | 96 | syntax match hsQQEnd "|\]" contained conceal cchar=〛 97 | " sy match hsQQEnd "|\]" contained conceal=〚 98 | 99 | syntax match hsNiceOperator "`elem`" conceal cchar=∈ 100 | syntax match hsNiceOperator "`notElem`" conceal cchar=∉ 101 | syntax match hsNiceOperator "`union`" conceal cchar=∪ 102 | syntax match hsNiceOperator "`intersect`" conceal cchar=∩ 103 | syntax match hsNiceOperator "\\\\\ze[[:alpha:][:space:]_([]" conceal cchar=∖ 104 | 105 | syntax match hsNiceOperator "||\ze[[:alpha:][:space:]_([]" conceal cchar=∨ 106 | syntax match hsNiceOperator "&&\ze[[:alpha:][:space:]_([]" conceal cchar=∧ 107 | syntax match hsNiceOperator "\" conceal cchar=¬ 108 | 109 | syntax match hsNiceOperator "!!" conceal cchar=‼ 110 | 111 | syntax match hsNiceOperator "-o" conceal cchar=⊸ 112 | endif 113 | 114 | hi link hsNiceOperator Operator 115 | hi! link Conceal Operator 116 | setlocal conceallevel=2 117 | 118 | --------------------------------------------------------------------------------