diff --git a/vim/bundle/cute-python/README.markdown b/vim/bundle/cute-python/README.markdown new file mode 100644 index 0000000..9940c8f --- /dev/null +++ b/vim/bundle/cute-python/README.markdown @@ -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: + + + +*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 + diff --git a/vim/bundle/cute-python/after/syntax/python.vim b/vim/bundle/cute-python/after/syntax/python.vim new file mode 100644 index 0000000..7f5c6a1 --- /dev/null +++ b/vim/bundle/cute-python/after/syntax/python.vim @@ -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 "\" + +syntax match pyNiceOperator "\" conceal cchar=∈ +syntax match pyNiceOperator "\" conceal cchar=∨ +syntax match pyNiceOperator "\" 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 \)\@\)" conceal cchar=¬ +syntax match pyNiceOperator "\" 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 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 diff --git a/vim/bundle/cute-python/conceal-test.py b/vim/bundle/cute-python/conceal-test.py new file mode 100644 index 0000000..1d9c744 --- /dev/null +++ b/vim/bundle/cute-python/conceal-test.py @@ -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: