Squashed 'vim/bundle/cute-python/' content from commit 313a810d8
git-subtree-dir: vim/bundle/cute-python git-subtree-split: 313a810d858b0e1b8e20e7435bb5f728fb042dd8
This commit is contained in:
commit
aa183fa52d
46
README.markdown
Normal file
46
README.markdown
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
This syntax file displays unicode characters for some Python operators and
|
||||||
|
built-in functions, turning the following:
|
||||||
|
|
||||||
|
```python
|
||||||
|
map (lambda x: x, [1,2,3])
|
||||||
|
|
||||||
|
def foo(e, a):
|
||||||
|
if e in [1,2,3] and not a:
|
||||||
|
return math.sqrt(math.pi)
|
||||||
|
else:
|
||||||
|
return sum([1,2,3])
|
||||||
|
```
|
||||||
|
|
||||||
|
into
|
||||||
|
|
||||||
|
```python
|
||||||
|
map (λ x: x, [1,2,3])
|
||||||
|
|
||||||
|
def foo(e, a):
|
||||||
|
if e ∈ [1,2,3] ∧ ¬a:
|
||||||
|
return √(π)
|
||||||
|
else:
|
||||||
|
return ∑([1,2,3])
|
||||||
|
```
|
||||||
|
|
||||||
|
Screenshot:
|
||||||
|
|
||||||
|
<img src="http://hamberg.no/erlend/files/cute_python.png" title="Screenshot" />
|
||||||
|
|
||||||
|
*This does not – at any point – alter your source code*. It simply uses Vim's
|
||||||
|
"conceal" feature to “hide” `in` behind `∈`, etc. Whenever the cursor is at
|
||||||
|
a line with concealed text, the text will be expanded.
|
||||||
|
|
||||||
|
To install, simply put `python.vim` in `~/.vim/after/syntax` or use something
|
||||||
|
like [Pathogen](https://github.com/tpope/vim-pathogen) (recommended).
|
||||||
|
|
||||||
|
Vim ≥ 7.3 is required.
|
||||||
|
|
||||||
|
The branch `moresymbols` includes commits from various people that add even more
|
||||||
|
conceal replacements. I try to maintain a healthy balance in the `master`
|
||||||
|
branch, but if you like to conceal even more operators or don't mind slight
|
||||||
|
inaccuracies in what mathematical symbols are used to represent, you should have
|
||||||
|
a look at the extra symbols in the `moresymbols` branch.
|
||||||
|
|
||||||
|
This plug-in is very much inspired by
|
||||||
|
<http://github.com/Twinside/vim-haskellConceal>
|
||||||
35
after/syntax/python.vim
Normal file
35
after/syntax/python.vim
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
" we need the conceal feature (vim ≥ 7.3)
|
||||||
|
if !has('conceal')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
" remove the keywords. we'll re-add them below
|
||||||
|
syntax clear pythonOperator
|
||||||
|
|
||||||
|
syntax match pythonOperator "\<is\>"
|
||||||
|
|
||||||
|
syntax match pyNiceOperator "\<in\>" conceal cchar=∈
|
||||||
|
syntax match pyNiceOperator "\<or\>" conceal cchar=∨
|
||||||
|
syntax match pyNiceOperator "\<and\>" conceal cchar=∧
|
||||||
|
" include the space after “not” – if present – so that “not a” becomes “¬a”.
|
||||||
|
" also, don't hide “not” behind ‘¬’ if it is after “is ”.
|
||||||
|
syntax match pyNiceOperator "\%(is \)\@<!\<not\%( \|\>\)" conceal cchar=¬
|
||||||
|
syntax match pyNiceOperator "\<not in\>" conceal cchar=∉
|
||||||
|
syntax match pyNiceOperator "<=" conceal cchar=≤
|
||||||
|
syntax match pyNiceOperator ">=" conceal cchar=≥
|
||||||
|
" only conceal “==” if alone, to avoid concealing SCM conflict markers
|
||||||
|
syntax match pyNiceOperator "=\@<!===\@!" conceal cchar=≡
|
||||||
|
syntax match pyNiceOperator "!=" conceal cchar=≢
|
||||||
|
|
||||||
|
syntax keyword pyNiceOperator sum conceal cchar=∑
|
||||||
|
syntax match pyNiceOperator "\<\%(math\.\)\?sqrt\>" conceal cchar=√
|
||||||
|
syntax match pyNiceKeyword "\<\%(math\.\)\?pi\>" conceal cchar=π
|
||||||
|
|
||||||
|
syntax keyword pyNiceStatement lambda conceal cchar=λ
|
||||||
|
|
||||||
|
hi link pyNiceOperator Operator
|
||||||
|
hi link pyNiceStatement Statement
|
||||||
|
hi link pyNiceKeyword Keyword
|
||||||
|
hi! link Conceal Operator
|
||||||
|
|
||||||
|
setlocal conceallevel=1
|
||||||
61
conceal-test.py
Normal file
61
conceal-test.py
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
# conceal test -- lines should match
|
||||||
|
|
||||||
|
"""
|
||||||
|
if a is not None: pass """
|
||||||
|
if a is not None: pass
|
||||||
|
|
||||||
|
"""
|
||||||
|
if b is None: pass """
|
||||||
|
if b is None: pass
|
||||||
|
|
||||||
|
"""
|
||||||
|
if 3 ∈ [1,2,3]: pass """
|
||||||
|
if 3 in [1,2,3]: pass
|
||||||
|
|
||||||
|
"""
|
||||||
|
if 4 ∉ [1,2,3]: pass """
|
||||||
|
if 4 not in [1,2,3]: pass
|
||||||
|
|
||||||
|
"""
|
||||||
|
if a ≡ b: pass """
|
||||||
|
if a == b: pass
|
||||||
|
|
||||||
|
"""
|
||||||
|
√(7) """
|
||||||
|
sqrt(7)
|
||||||
|
|
||||||
|
"""
|
||||||
|
π """
|
||||||
|
pi
|
||||||
|
|
||||||
|
"""
|
||||||
|
map (λ x: x, [1,2,3]) """
|
||||||
|
map (lambda x: x, [1,2,3])
|
||||||
|
|
||||||
|
"""
|
||||||
|
a ∧ b """
|
||||||
|
a and b
|
||||||
|
|
||||||
|
"""
|
||||||
|
a ∨ b """
|
||||||
|
a or b
|
||||||
|
|
||||||
|
"""
|
||||||
|
∑([1,2,3]) """
|
||||||
|
sum([1,2,3])
|
||||||
|
|
||||||
|
"""
|
||||||
|
if a ≢ b: pass """
|
||||||
|
if a != b: pass
|
||||||
|
|
||||||
|
"""
|
||||||
|
if a ≥ b: pass """
|
||||||
|
if a >= b: pass
|
||||||
|
|
||||||
|
"""
|
||||||
|
if a ≤ b: pass """
|
||||||
|
if a <= b: pass
|
||||||
|
|
||||||
|
"""
|
||||||
|
if e ∈ [1,2,3] ∧ ¬a: """
|
||||||
|
if e in [1,2,3] and not a:
|
||||||
Loading…
Reference in New Issue
Block a user