├── README.md
├── after
└── syntax
│ └── scala.vim
└── screenshot.png
/README.md:
--------------------------------------------------------------------------------
1 | This syntax file displays unicode characters for some Scala operators and
2 | built-in functions, turning the following:
3 |
4 | ```scala
5 | foo =>
6 | foo <- bar
7 | foo -> bar
8 | 2 <= 5
9 | 5 >= 2
10 | 2 == 2
11 | 2 === 2l
12 | 2 != 3
13 | 2 =/= 2l
14 | foo && bar
15 | foo || bar
16 | foo map bar
17 | foo flatMap bar
18 | ```
19 |
20 | into
21 |
22 | ```scala
23 | foo ⇒
24 | foo ← bar
25 | foo → bar
26 | 2 ≤ 5
27 | 5 ≥ 2
28 | 2 ≟ 2
29 | 2 ≡ 2l
30 | 2 ≠ 3
31 | 2 ≢ 2l
32 | foo ∧ bar
33 | foo ∨ bar
34 | foo ∘ bar
35 | foo ⤜ bar
36 | ```
37 |
38 |
39 | Screenshot:
40 |
41 |
42 |
43 | *This does not – at any point – alter your source code*. It simply uses Vim's
44 | "conceal" feature to “hide” `map` behind `∘`, etc. Whenever the cursor is at
45 | a line with concealed text, the text will be expanded.
46 |
47 | To install, simply put `scala.vim` in `~/.vim/after/syntax` or use something
48 | like [Pathogen](https://github.com/tpope/vim-pathogen) (recommended).
49 |
50 | Vim ≥ 7.3 is required.
51 |
52 | This plug-in is very much inspired by
53 |
54 | and
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/after/syntax/scala.vim:
--------------------------------------------------------------------------------
1 | "=============================================================================
2 | " What Is This: Add some conceal operator for your scala files
3 | " File: scala.vim (conceal enhancement)
4 | " Author: Michael Pollmeier
5 | " Last Change: 2013-11-09
6 | " Version: 1.0.0
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 | " * This plug-in is very much inspired by Vincent Berthoux's http://github.com/Twinside/vim-haskellConceal
24 | " * if you want to avoid the loading, add the following
25 | " line in your .vimrc :
26 | " let g:no_scala_conceal = 1
27 | "
28 | if exists('g:no_scala_conceal') || !has('conceal') || &enc != 'utf-8'
29 | finish
30 | endif
31 |
32 | syntax match scalaNiceOperator "<-" conceal cchar=←
33 | syntax match scalaNiceOperator "->" conceal cchar=→
34 | syntax match scalaNiceOperator "==" conceal cchar=≟
35 | syntax match scalaNiceOperator "===" conceal cchar=≡
36 | syntax match scalaNiceOperator "!=" conceal cchar=≠
37 | syntax match scalaNiceOperator "=/=" conceal cchar=≢
38 | syntax match scalaNiceOperator ">>" conceal cchar=»
39 | syntax match scalaNiceOperator "&&" conceal cchar=∧
40 | syntax match scalaNiceOperator "||" conceal cchar=∨
41 |
42 | let s:extraConceal = 1
43 | " Some windows font don't support some of the characters,
44 | " so if they are the main font, we don't load them :)
45 | if has("win32")
46 | let s:incompleteFont = [ 'Consolas'
47 | \ , 'Lucida Console'
48 | \ , 'Courier New'
49 | \ ]
50 | let s:mainfont = substitute( &guifont, '^\([^:,]\+\).*', '\1', '')
51 | for s:fontName in s:incompleteFont
52 | if s:mainfont ==? s:fontName
53 | let s:extraConceal = 0
54 | break
55 | endif
56 | endfor
57 | endif
58 |
59 | if s:extraConceal
60 | " Match greater than and lower than w/o messing with Kleisli composition
61 | syntax match scalaNiceOperator "<=\ze[^<]" conceal cchar=≤
62 | syntax match scalaNiceOperator ">=\ze[^>]" conceal cchar=≥
63 |
64 | syntax match scalaNiceOperator "=>" conceal cchar=⇒
65 | syntax match scalaNiceOperator "=\zs<<" conceal cchar=«
66 |
67 | " Redfining to get proper '::' concealing
68 | syntax match hs_DeclareFunction /^[a-z_(]\S*\(\s\|\n\)*::/me=e-2 nextgroup=scalaNiceOperator contains=hs_FunctionName,hs_OpFunctionName
69 | syntax match scalaNiceOperator "\:\:" conceal cchar=∷
70 |
71 | syntax match scalaNiceOperator "++" conceal cchar=⧺
72 | syntax match scalaNiceOperator "forall" conceal cchar=∀
73 |
74 | "syntax match scalaNiceOperator /\s\.\s/ms=s+1,me=e-1 conceal cchar=∘
75 | syntax match scalaNiceOperator "map\ze[ ({]" conceal cchar=∘
76 | syntax match scalaNiceOperator "flatMap\ze[ ({]" conceal cchar=⤜
77 |
78 | syntax match scalaNiceOperator "exists" conceal cchar=∈
79 | endif
80 |
81 | hi link scalaNiceOperator Operator
82 | hi! link Conceal Operator
83 | setlocal conceallevel=2
84 |
85 |
--------------------------------------------------------------------------------
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mpollmeier/vim-scalaConceal/e47ef05f8f8531362c590beaf7f2caf4d79e2d7f/screenshot.png
--------------------------------------------------------------------------------