34 changed files with 3502 additions and 220 deletions
@ -1,63 +1,4 @@
@@ -1,63 +1,4 @@
|
||||
set makeprg=ghc\ %\ -o\ %< " Компилятор |
||||
|
||||
set foldexpr=HaskellFold(v:lnum) |
||||
set foldmethod=expr |
||||
|
||||
" ============================================================================= |
||||
" Descriptions: Provide a function providing folding information for haskell |
||||
" files. |
||||
" Maintainer: Vincent B (twinside@gmail.com) |
||||
" Warning: Assume the presence of type signatures on top of your functions to |
||||
" work well. |
||||
" Usage: drop in ~/vimfiles/plugin or ~/.vim/plugin |
||||
" Version: 1.0 |
||||
" Changelog: - 1.0 : initial version |
||||
" ============================================================================= |
||||
if exists("g:__HASKELLFOLD_VIM__") |
||||
finish |
||||
endif |
||||
let g:__HASKELLFOLD_VIM__ = 1 |
||||
|
||||
" Top level bigdefs |
||||
fun! s:HaskellFoldMaster( line ) "{{{ |
||||
return a:line =~ '^data\s' |
||||
\ || a:line =~ '^type\s' |
||||
\ || a:line =~ '^newdata\s' |
||||
\ || a:line =~ '^class\s' |
||||
\ || a:line =~ '^instance\s' |
||||
\ || a:line =~ '^[^:]\+\s*::' |
||||
endfunction "}}} |
||||
|
||||
" Top Level one line shooters. |
||||
fun! s:HaskellSnipGlobal(line) "{{{ |
||||
return a:line =~ '^module' |
||||
\ || a:line =~ '^import' |
||||
\ || a:line =~ '^infix[lr]\s' |
||||
endfunction "}}} |
||||
|
||||
" The real folding function |
||||
fun! HaskellFold( lineNum ) "{{{ |
||||
let line = getline( a:lineNum ) |
||||
|
||||
" Beginning of comment |
||||
if line =~ '^\s*--' |
||||
return 2 |
||||
endif |
||||
|
||||
if s:HaskellSnipGlobal( line ) |
||||
return 0 |
||||
endif |
||||
|
||||
if line =~ '^\s*$' |
||||
let nextline = getline(a:lineNum + 1) |
||||
if s:HaskellFoldMaster( nextline ) > 0 || s:HaskellSnipGlobal( nextline ) > 0 |
||||
\ || nextline =~ "^--" |
||||
return 0 |
||||
else |
||||
return -1 |
||||
endif |
||||
endif |
||||
|
||||
return 1 |
||||
endfunction "}}} |
||||
call SetHaskellFolding() |
||||
|
||||
|
@ -0,0 +1,83 @@
@@ -0,0 +1,83 @@
|
||||
Show git diff for Git Rebase Interactive |
||||
======================================= |
||||
|
||||
`auto-git-diff` is a vim plugin which shows git diff between each commit and |
||||
its parent commit below the commit list window of git rebase interactive. |
||||
|
||||
When you move a text-cursor in `git-rebase-todo` file, `auto-git-diff` gets |
||||
a commit hash of the line where the cursor exists and update the diff window. |
||||
|
||||
|
||||
 |
||||
|
||||
## Variables |
||||
|
||||
- `g:auto_git_diff_disable_auto_update` |
||||
|
||||
If this variable is set to 1, the diff window won't update automatically. You |
||||
can update the diff window manually with the following key mapping: |
||||
`<Plug>(auto_git_diff_manual_update)`. |
||||
|
||||
- `g:auto_git_diff_show_window_at_right` |
||||
|
||||
If this variable is set to 1, the diff window will be created at right on the |
||||
commit list window. |
||||
|
||||
- `g:auto_git_diff_command_options` |
||||
|
||||
The options passed to `git diff` command. If this variable is not defined, |
||||
`--stat -p --submodule -C -C` will be used. |
||||
|
||||
## Mappings |
||||
|
||||
- `<Plug>(auto_git_diff_manual_update)` |
||||
|
||||
This key mapping updates the diff window manully. |
||||
|
||||
- `<Plug>(auto_git_diff_scroll_down_1)` |
||||
- `<Plug>(auto_git_diff_scroll_up_1)` |
||||
- `<Plug>(auto_git_diff_scroll_down_half)` |
||||
- `<Plug>(auto_git_diff_scroll_up_half)` |
||||
- `<Plug>(auto_git_diff_scroll_down_page)` |
||||
- `<Plug>(auto_git_diff_scroll_up_page)` |
||||
|
||||
These key mappings scroll the diff window without moving the cursor into the |
||||
window. `_1` means scrolling one line (`<C-e>` or `<C-y>`), `_half` means |
||||
scrolling half a page (`<C-d>` or `<C-u>`) and `_page` means scrolling one page |
||||
(`<C-f>` or `<C-b>`). |
||||
|
||||
Following is an example to configure the mappings in your `vimrc`. |
||||
|
||||
```vim |
||||
function! s:setup_auto_git_diff() abort |
||||
nmap <buffer><C-l> <Plug>(auto_git_diff_scroll_manual_update) |
||||
nmap <buffer><C-n> <Plug>(auto_git_diff_scroll_down_half) |
||||
nmap <buffer><C-p> <Plug>(auto_git_diff_scroll_up_half) |
||||
endfunction |
||||
autocmd FileType gitrebase call <SID>setup_auto_git_diff() |
||||
``` |
||||
|
||||
## License |
||||
|
||||
The MIT License (MIT) |
||||
Copyright (c) 2015 hotwatermorning |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining |
||||
a copy of this software and associated documentation files (the |
||||
"Software"), to deal in the Software without restriction, including |
||||
without limitation the rights to use, copy, modify, merge, publish, |
||||
distribute, sublicense, and/or sell copies of the Software, and to |
||||
permit persons to whom the Software is furnished to do so, subject to |
||||
the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be |
||||
included in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
|
@ -0,0 +1,132 @@
@@ -0,0 +1,132 @@
|
||||
let s:save_cpo = &cpo |
||||
let s:previous_hash_string = "" |
||||
set cpo&vim |
||||
|
||||
nnoremap <silent> <Plug>(auto_git_diff_manual_update) :<C-u>call auto_git_diff#show_git_diff()<CR> |
||||
|
||||
" Get commit hash from current line. |
||||
" The first colomn(pick, r, ...) can be empty. |
||||
function! s:get_git_hash() abort |
||||
return matchstr(getline('.'), '^\(\w\+\>\)\=\(\s*\)\zs\x\{4,40\}\>\ze') |
||||
endfunction |
||||
|
||||
" Find the preview window. |
||||
" If not found, return zero. |
||||
function! s:find_preview_window() abort |
||||
for nr in range(1, winnr('$')) |
||||
if getwinvar(nr, "&pvw") == 1 |
||||
" found a preview |
||||
return nr |
||||
endif |
||||
endfor |
||||
return 0 |
||||
endfunction |
||||
|
||||
" Execute git diff between hash~1 and hash with options a:opts, |
||||
" and show the result into the preview window. |
||||
function! s:show_git_diff_impl(hash, vertsplit, opts) abort |
||||
|
||||
let wn = s:find_preview_window() |
||||
|
||||
if wn == 0 |
||||
" The preview window is not found. |
||||
" => Open new window |
||||
|
||||
if a:vertsplit |
||||
rightbelow vnew |
||||
else |
||||
rightbelow new |
||||
endif |
||||
|
||||
silent! setlocal previewwindow bufhidden=delete nobackup noswf nobuflisted nowrap buftype=nofile |
||||
|
||||
let wn = bufwinnr('%') |
||||
else |
||||
" Preview window is found" |
||||
" Move to the window |
||||
silent execute wn."wincmd w" |
||||
endif |
||||
|
||||
let out = s:get_git_diff(a:hash, a:opts) |
||||
|
||||
if v:shell_error |
||||
setlocal ft= |
||||
else |
||||
setlocal ft=diff |
||||
endif |
||||
|
||||
setlocal modifiable |
||||
|
||||
silent! % delete _ |
||||
silent! $ put=out |
||||
silent! 1 delete _ |
||||
|
||||
setlocal nomodifiable |
||||
|
||||
noremap <buffer> q :bw<cr> |
||||
|
||||
silent wincmd p |
||||
endfunction |
||||
|
||||
function! s:get_git_diff(hash, opts) abort |
||||
let prefix = has("win32") ? "set LANG=C & " : "env LANG=C " |
||||
|
||||
let diff_command = "git diff ".a:opts." ".a:hash."~1 ".a:hash |
||||
silent let out = system(prefix.diff_command) |
||||
if !v:shell_error |
||||
return out |
||||
endif |
||||
let save_out = out |
||||
|
||||
let empty_tree_sha1_hex = "4b825dc642cb6eb9a060e54bf8d69288fbee4904" |
||||
let diff_command = "git diff ".a:opts." ".empty_tree_sha1_hex." ".a:hash |
||||
silent let out = system(prefix.diff_command) |
||||
if !v:shell_error |
||||
return out |
||||
endif |
||||
|
||||
return save_out |
||||
endfunction |
||||
|
||||
function! auto_git_diff#show_git_diff() abort |
||||
|
||||
let hash_string = s:get_git_hash() |
||||
if hash_string == "" || hash_string == s:previous_hash_string |
||||
return |
||||
else |
||||
let s:previous_hash_string = hash_string |
||||
endif |
||||
|
||||
call s:show_git_diff_impl( s:get_git_hash() |
||||
\ , get(g:, "auto_git_diff_show_window_at_right", 0) |
||||
\ , get(g:, "auto_git_diff_command_options", "--stat -p --submodule -C -C") |
||||
\ ) |
||||
endfunction |
||||
|
||||
" Called when text-cursor is moved. |
||||
function! auto_git_diff#auto_update_git_diff() abort |
||||
|
||||
if get(g:, "auto_git_diff_disable_auto_update", 0) |
||||
return |
||||
endif |
||||
|
||||
if mode() != "n" |
||||
return |
||||
endif |
||||
|
||||
call auto_git_diff#show_git_diff() |
||||
endfunction |
||||
|
||||
function! auto_git_diff#scroll_in_preview_window(map) abort |
||||
if s:find_preview_window() == 0 |
||||
return |
||||
endif |
||||
wincmd P |
||||
sandbox let input = eval('"\<'.a:map.'>"') |
||||
execute "normal!" input |
||||
wincmd p |
||||
endfunction |
||||
|
||||
let &cpo = s:save_cpo |
||||
unlet s:save_cpo |
||||
|
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
if exists("g:did_auto_git_diff") | finish | endif |
||||
let g:did_auto_git_diff = 1 |
||||
|
||||
augroup auto_git_diff_command_group |
||||
autocmd! |
||||
autocmd CursorMoved git-rebase-todo call auto_git_diff#auto_update_git_diff() |
||||
autocmd FileType gitrebase setlocal nowarn nowb |
||||
augroup END |
||||
|
||||
nnoremap <silent><Plug>(auto_git_diff_scroll_down_1) :<C-u>call auto_git_diff#scroll_in_preview_window("C-e")<CR> |
||||
nnoremap <silent><Plug>(auto_git_diff_scroll_up_1) :<C-u>call auto_git_diff#scroll_in_preview_window("C-y")<CR> |
||||
nnoremap <silent><Plug>(auto_git_diff_scroll_down_half) :<C-u>call auto_git_diff#scroll_in_preview_window("C-d")<CR> |
||||
nnoremap <silent><Plug>(auto_git_diff_scroll_up_half) :<C-u>call auto_git_diff#scroll_in_preview_window("C-u")<CR> |
||||
nnoremap <silent><Plug>(auto_git_diff_scroll_down_page) :<C-u>call auto_git_diff#scroll_in_preview_window("C-f")<CR> |
||||
nnoremap <silent><Plug>(auto_git_diff_scroll_up_page) :<C-u>call auto_git_diff#scroll_in_preview_window("C-b")<CR> |
||||
|
@ -0,0 +1,147 @@
@@ -0,0 +1,147 @@
|
||||
## Vim Haskell Conceal+ |
||||
|
||||
This bundle provides extended Haskell Conceal feature for Vim. The feature |
||||
is used to display unicode operators in Haskell code without changing the |
||||
underlying file. |
||||
|
||||
This package offers more (and, more importantly, configurable) features |
||||
than the |
||||
[baseline vim-haskellConcealbundle](https://github.com/Twinside/vim-haskellConceal). |
||||
The baseline bundle has numerous forks, which is possible to combine, so |
||||
everyone is welcome to share, improve or contribute new notations to this |
||||
Conceal Plus package. |
||||
|
||||
GitHub: https://github.com/enomsg/vim-haskellConcealPlus |
||||
|
||||
### Why Concealing |
||||
|
||||
- Using things like '->' instead real arrows '→' was never a deliberate |
||||
choice, but a choice made due to limitations of teletypewriters and |
||||
input inconvenience. |
||||
|
||||
- With concealing you don't have to deal with cumbersome unicode-input |
||||
methods, yet you can enjoy proper notation. |
||||
|
||||
- It is not only about aesthetics. Excess of multi-character functions may |
||||
create visual noise, which negatively affects readability. Using special |
||||
symbols and true arrows, together with colors and bold/italic face seems |
||||
to improve the situation. The image shows Vim with and without |
||||
concealing, both running in a plain terminal emulator: |
||||
|
||||
 |
||||
|
||||
- Using concealing instead of *-unicode* versions of packages also has |
||||
some advantages. Mainly, concealing does not require any changes to the |
||||
source code, it is backwards-compatible with idiomatic code. Secondly, |
||||
with concealing no special input methods are needed. Plus, currently |
||||
some features are hardly possible without editor's concealing (e.g. |
||||
power superscripts). |
||||
|
||||
### Installation |
||||
|
||||
Using Vim built-in `pack` support: |
||||
|
||||
``` |
||||
$ mkdir -p ~/.vim/pack/vim-haskellConcealPlus/start |
||||
$ cd ~/.vim/pack/vim-haskellConcealPlus/start |
||||
$ git clone https://github.com/enomsg/vim-haskellConcealPlus |
||||
$ echo "syn on" >> ~/.vimrc # If not already in .vimrc |
||||
$ echo "setlocal conceallevel=2" >> ~/.vimrc # If not already in .vimrc |
||||
$ echo "set concealcursor=nciv" >> ~/.vimrc # Optional |
||||
``` |
||||
|
||||
### Available Options |
||||
|
||||
'q' option to disable concealing of scientific constants (e.g. π) |
||||
'℘' option to disable concealing of powerset function |
||||
'𝐒' option to disable String type to 𝐒 concealing |
||||
'𝐓' option to disable Text type to 𝐓 concealing |
||||
'𝐄' option to disable Either/Right/Left to 𝐄/𝑅/𝐿 concealing |
||||
'𝐌' option to disable Maybe/Just/Nothing to 𝐌/𝐽/𝑁 concealing |
||||
'A' option to not try to preserve indentation |
||||
's' option to disable space consumption after ∑,∏,√ and ¬ functions |
||||
'*' option to enable concealing of asterisk with '⋅' sign |
||||
'x' option to disable default concealing of asterisk with '×' sign |
||||
'E' option to enable ellipsis concealing with ‥ (two dot leader) |
||||
'e' option to disable ellipsis concealing with … (ellipsis sign) |
||||
'⇒' option to disable `implies` concealing with ⇒ |
||||
'⇔' option to disable `iff` concealing with ⇔ |
||||
'r' option to disable return (η) and join (µ) concealing |
||||
'b' option to disable bind (left and right) concealing |
||||
'f' option to enable formal (★) right bind concealing |
||||
'c' option to enable encircled b/d (ⓑ/ⓓ) for right and left binds |
||||
'h' option to enable partial concealing of binds (e.g. »=) |
||||
'C' option to enable encircled 'm' letter ⓜ concealing for fmap |
||||
'l' option to disable fmap/lift concealing with ↥ |
||||
'↱' option to disable mapM/forM concealing with ↱/↰ |
||||
'w' option to disable 'where' concealing with "due to"/∵ symbol |
||||
'-' option to disable subtract/(-) concealing with ⊟ |
||||
'I' option to enable alternative ':+' concealing with with ⨢ |
||||
'i' option to disable default concealing of ':+' with ⅈ |
||||
'R' option to disable realPart/imagPart concealing with ℜ/ℑ |
||||
'T' option to enable True/False constants concealing with bold 𝐓/𝐅 |
||||
't' option to disable True/False constants concealing with italic 𝑇/𝐹 |
||||
'B' option to disable Bool type to 𝔹 concealing |
||||
'Q' option to disable Rational type to ℚ concealing |
||||
'Z' option to disable Integer type to ℤ concealing |
||||
'N' option to disable Natural, Nat types to ℕ concealing |
||||
'D' option to disable Double type to 𝔻 concealing |
||||
'C' option to disable Complex type to ℂ concealing |
||||
'1' option to disable numeric superscripts concealing, e.g. x² |
||||
'a' option to disable alphabet superscripts concealing, e.g. xⁿ |
||||
|
||||
The flags can be specified via hscoptions variable. For example, *let |
||||
hscoptions="fc"* in your *~/.vimrc*. |
||||
|
||||
### Known Issues and Hints: |
||||
|
||||
- Concealing may seriously mess up indentation. By default the bundle |
||||
tries to preserve spaces for commonly troublesome symbols (e.g. ->, <- |
||||
and => arrows). But to be sure about indentation, you still have to see |
||||
the non-concealed code. *set conceallevel=0* might be handy in these |
||||
cases. |
||||
|
||||
- *set concealcursor=nciv* seem to not play well with Vim matchparen |
||||
feature (which is enabled by default). You can either disable concealing |
||||
under the cursor, or disable matchparen by adding *let |
||||
loaded_matchparen=1* at the very top of your *~/.vimrc*. |
||||
|
||||
- With *set concealcursor=nciv* navigation through concealed parts of code |
||||
might be somewhat irritating because the cursor behaves a bit |
||||
differently. It becomes less of an issue if you are used to Vim's *w/b* |
||||
commands (word forward/backward). You can also try *set |
||||
concealcursor=ncv* instead. |
||||
|
||||
- Finding proper fonts might be a pain. Most of modern, so called |
||||
programming fonts (*Inconsolata*, *Anonymous Pro*, etc.) often lack |
||||
decent unicode support. As a recommendation, try *DejaVu Sans Mono*. |
||||
|
||||
**Update**: thanks to [monospacifier](https://github.com/cpitclaudel/monospacifier) |
||||
package, fonts are no longer a problem. Pick your favourite font, then in |
||||
addition download one of the "monospacified" fallback fonts, save into |
||||
`~/.fonts`, and adjust fontconfig, e.g. |
||||
`~/.config/fontconfig/fonts.conf`: |
||||
|
||||
``` |
||||
<?xml version="1.0"?><!DOCTYPE fontconfig SYSTEM "fonts.dtd"> |
||||
<fontconfig> |
||||
<dir>~/.fonts</dir> |
||||
<alias> |
||||
<family>monospace</family> |
||||
<prefer> |
||||
<family>TeX Gyre Schola Math monospacified for DejaVu Sans Mono</family> |
||||
</prefer> |
||||
</alias> |
||||
</fontconfig> |
||||
``` |
||||
|
||||
- Most of the terminal emulators have one or more issues with regard to the |
||||
unicode characters handling. Emulators that don't have problems with unicode |
||||
might be pretty slow. As a recommendation, try xst, or *evilvte* (it has weird |
||||
configuration, but draws things correctly) or *lxterminal* (seems to be quite |
||||
capable, but limited configurability) or any other terminal emulator that |
||||
happened to work for you. |
||||
|
||||
[xst](https://github.com/gnotclub/xst) is known to work well with DejaVu Sans |
||||
Mono, plus [monospacified](https://github.com/cpitclaudel/monospacifier) fonts |
||||
as a fallback. |
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
{-# LANGUAGE ExistentialQuantification, RankNTypes #-} |
||||
import Control.Applicative |
||||
import Data.Monoid |
||||
import Control.Monad.ST.Lazy |
||||
import Control.Monad |
||||
import Numeric |
||||
import Data.Complex |
||||
import Data.List |
||||
|
||||
factorial :: Integer -> Integer |
||||
factorial n = product as |
||||
where as = [n, n-1..1] |
||||
|
||||
integral :: (Num a, Enum a) => (a -> a) -> a -> (a,a) -> a |
||||
integral f dx (a,b) = sum ((\x -> f(x)*dx) <$> ab) |
||||
where ab = [a,a+dx..b-dx] |
||||
|
||||
isValid :: Integer -> Bool -> Bool -> Bool |
||||
isValid a b c = (a >= 0 && a <= 10) || (b && not c) |
||||
|
||||
rs :: forall a. (forall s. ST s a) -> a |
||||
rs = runST |
||||
|
||||
main :: IO () |
||||
main = do |
||||
let tau = 2*pi |
||||
putSL $ showF 2 $ integral sin 0.001 (pi,tau) |
||||
print $ unsafe [pi,tau] |
||||
print $ factorial <$> [1..13`div`2] |
||||
print $ texNum . showF 2 <$> (mag <$> [1,2] <*> [3,4]) |
||||
print $ Just True >>= (\x -> return $ x `elem` [True, False, False]) |
||||
>>= (\x -> if x /= True |
||||
then Nothing |
||||
else return True) |
||||
>>= (\x -> return $ isValid 1 True x) |
||||
print $ [1,2] `union` [3,4] == [-9,-8..4] `intersect` [1,2..9] |
||||
print $ (++"il") <$> (Just "fa" >> guard False >> return undefined) |
||||
print $ realPart(4:+2) == imagPart(2:+4) |
||||
print $ liftM3 (\x y z -> x+y+z) [1] [2] [39] |
||||
putSL $ "Hask" <> "ell" |
||||
where |
||||
mag a b = sqrt(a^2 + b^2) |
||||
showF n f = showFFloat (Just n) f empty |
||||
unsafe xs = (xs!!0,xs!!1) |
||||
texNum num = "$\\num{" ++ num ++ "}$" |
||||
putSL = putStrLn |
@ -0,0 +1,90 @@
@@ -0,0 +1,90 @@
|
||||
{-# LANGUAGE ExistentialQuantification, RankNTypes #-} |
||||
import Control.Applicative |
||||
>> import Control.Applicative |
||||
import Data.Monoid |
||||
>> import Data.Monoid |
||||
import Control.Monad.ST.Lazy |
||||
>> import Control.Monad.ST.Lazy |
||||
import Control.Monad |
||||
>> import Control.Monad |
||||
import Numeric |
||||
>> import Numeric |
||||
import Data.Complex |
||||
>> import Data.Complex |
||||
import Data.List |
||||
>> import Data.List |
||||
|
||||
factorial :: Integer -> Integer |
||||
factorial n = product as |
||||
where as = [n, n-1..1] |
||||
|
||||
>> factorial :: Integer -> Integer |
||||
>> factorial n = product as |
||||
>> where as = [n, n-1..1] |
||||
|
||||
integral :: (Num a, Enum a) => (a -> a) -> a -> (a,a) -> a |
||||
integral f dx (a,b) = sum ((\x -> f(x)*dx) <$> ab) |
||||
where ab = [a,a+dx..b-dx] |
||||
|
||||
>> integral :: (Num a, Enum a) => (a -> a) -> a -> (a,a) -> a |
||||
>> integral f dx (a,b) = sum ((\x -> f(x)*dx) <$> ab) |
||||
>> where ab = [a,a+dx..b-dx] |
||||
|
||||
isValid :: Integer -> Bool -> Bool -> Bool |
||||
isValid a b c = (a >= 0 && a <= 10) || (b && not c) |
||||
|
||||
>> isValid :: Integer -> Bool -> Bool -> Bool |
||||
>> isValid a b c = (a >= 0 && a <= 10) || (b && not c) |
||||
|
||||
rs :: forall a. (forall s. ST s a) -> a |
||||
rs = runST |
||||
>> rs :: forall a. (forall s. ST s a) -> a |
||||
>> rs = runST |
||||
|
||||
main :: IO () |
||||
main = do |
||||
let tau = 2*pi |
||||
putSL $ showF 2 $ integral sin 0.001 (pi,tau) |
||||
print $ unsafe [pi,tau] |
||||
print $ factorial <$> [1..13`div`2] |
||||
print $ texNum . showF 2 <$> (mag <$> [1,2] <*> [3,4]) |
||||
print $ Just True >>= (\x -> return $ x `elem` [True, False, False]) |
||||
>>= (\x -> if x /= True |
||||
then Nothing |
||||
else return True) |
||||
>>= (\x -> return $ isValid 1 True x) |
||||
print $ [1,2] `union` [3,4] == [-9,-8..4] `intersect` [1,2..9] |
||||
print $ (++"il") <$> (Just "fa" >> guard False >> return undefined) |
||||
print $ realPart(4:+2) == imagPart(2:+4) |
||||
print $ liftM3 (\x y z -> x+y+z) [1] [2] [39] |
||||
putSL $ "Hask" <> "ell" |
||||
where |
||||
mag a b = sqrt(a^2 + b^2) |
||||
showF n f = showFFloat (Just n) f empty |
||||
unsafe xs = (xs!!0,xs!!1) |
||||
texNum num = "$\\num{" ++ num ++ "}$" |
||||
putSL = putStrLn |
||||
|
||||
>> main :: IO () |
||||
>> main = do |
||||
>> let tau = 2*pi |
||||
>> putSL $ showF 2 $ integral sin 0.001 (pi,tau) |
||||
>> print $ unsafe [pi,tau] |
||||
>> print $ factorial <$> [1..13`div`2] |
||||
>> print $ texNum . showF 2 <$> (mag <$> [1,2] <*> [3,4]) |
||||
>> print $ Just True >>= (\x -> return $ x `elem` [True, False, False]) |
||||
>> >>= (\x -> if x /= True |
||||
>> then Nothing |
||||
>> else return True) |
||||
>> >>= (\x -> return $ isValid 1 True x) |
||||
>> print $ [1,2] `union` [3,4] == [-9,-8..4] `intersect` [1,2..9] |
||||
>> print $ (++"il") <$> (Just "fa" >> guard False >> return undefined) |
||||
>> print $ realPart(4:+2) == imagPart(2:+4) |
||||
>> print $ liftM3 (\x y z -> x+y+z) [1] [2] [39] |
||||
>> putSL $ "Hask" <> "ell" |
||||
>> where |
||||
>> mag a b = sqrt(a^2 + b^2) |
||||
>> showF n f = showFFloat (Just n) f empty |
||||
>> unsafe xs = (xs!!0,xs!!1) |
||||
>> texNum num = "$\\num{" ++ num ++ "}$" |
||||
>> putSL = putStrLn |
After Width: | Height: | Size: 181 KiB |
@ -0,0 +1,6 @@
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh |
||||
|
||||
rm s{l,r}.png |
||||
convert -crop 490x685+0+35 l.png sl.png |
||||
convert -crop 640x685+0+35 r.png sr.png |
||||
convert sl.png sr.png +append demo.png |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash |
||||
set -e |
||||
|
||||
tag=test |
||||
|
||||
docker build -t "$tag" - << EOF_DOCKERFILE |
||||
from debian:buster |
||||
|
||||
run apt-get update |
||||
|
||||
run apt-get install -y locales |
||||
run echo en_US.UTF-8 UTF-8 > /etc/locale.gen |
||||
run dpkg-reconfigure locales --frontend=noninteractive |
||||
|
||||
run apt-get install -y vim |
||||
run apt-get install -y git |
||||
run apt-get install -y screen |
||||
|
||||
run useradd -m -s /bin/bash user |
||||
env SHELL /bin/bash |
||||
env LANG en_US.UTF-8 |
||||
env LC_CTYPE en_US.UTF8 |
||||
|
||||
user user |
||||
run mkdir -p ~/.vim/pack/vim-haskellConcealPlus/start && \ |
||||
cd ~/.vim/pack/vim-haskellConcealPlus/start && \ |
||||
git clone https://github.com/enomsg/vim-haskellConcealPlus |
||||
run echo "syn on\nsetlocal conceallevel=2\nset concealcursor=nciv" > ~/.vimrc |
||||
# Run in screen as it handles terminal capabilities better than most of the raw |
||||
# terminals. |
||||
cmd screen vim ~/.vim/pack/vim-haskellConcealPlus/start/vim-haskellConcealPlus/demo.hs |
||||
#cmd bash |
||||
EOF_DOCKERFILE |
||||
|
||||
docker run \ |
||||
-e TERM="$TERM" \ |
||||
-w /home/user \ |
||||
-it "$tag" "$@" |
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash |
||||
set -e |
||||
|
||||
tag=test |
||||
|
||||
docker build -t "$tag" - << EOF_DOCKERFILE |
||||
from debian:buster |
||||
|
||||
run apt-get update |
||||
|
||||
run apt-get install -y locales |
||||
run echo en_US.UTF-8 UTF-8 > /etc/locale.gen |
||||
run dpkg-reconfigure locales --frontend=noninteractive |
||||
|
||||
run apt-get install -y vim |
||||
run apt-get install -y vim-pathogen |
||||
run apt-get install -y git |
||||
run apt-get install -y screen |
||||
|
||||
run useradd -m -s /bin/bash user |
||||
env SHELL /bin/bash |
||||
env LANG en_US.UTF-8 |
||||
env LC_CTYPE en_US.UTF8 |
||||
|
||||
user user |
||||
run mkdir -p ~/.vim/bundle && cd ~/.vim/bundle && git clone https://github.com/enomsg/vim-haskellConcealPlus |
||||
run echo "execute pathogen#infect()\nsyn on\nsetlocal conceallevel=2\nset concealcursor=nciv" > ~/.vimrc |
||||
# Run in screen as it handles terminal capabilities better than most of the raw |
||||
# terminals. |
||||
cmd screen vim ~/.vim/bundle/vim-haskellConcealPlus/demo.hs |
||||
#cmd bash |
||||
EOF_DOCKERFILE |
||||
|
||||
docker run \ |
||||
-e TERM="$TERM" \ |
||||
-w /home/user \ |
||||
-it "$tag" "$@" |
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
# haskellFold |
||||
|
||||
Provide a better folding for haskell file. The folded lines are transformed |
||||
to display the type signature (if any) of the function, providing a great |
||||
overview of your file content. |
||||
|
||||
You can get a shorter version of the foldtext (only the first relevant line) |
||||
by setting `g:haskellFold_ShortText = 1` |
||||
|
||||
# Installation |
||||
|
||||
Drop the file in ~/.vim/plugin or ~/vimfiles/plugin folder, or if you |
||||
use pathogen into the ~/.vim/bundle/vim-haskellFold or |
||||
~/vimfiles/bundle/vim-haskellFold |
@ -0,0 +1,121 @@
@@ -0,0 +1,121 @@
|
||||
" ============================================================================= |
||||
" Descriptions: Provide a function providing folding information for haskell |
||||
" files. |
||||
" Maintainer: Vincent B (twinside@gmail.com) |
||||
" Warning: Assume the presence of type signatures on top of your functions to |
||||
" work well. |
||||
" Usage: drop in ~/vimfiles/plugin or ~/.vim/plugin |
||||
" Version: 1.2 |
||||
" Changelog: - 1.2 : Reacting to file type instead of file extension. |
||||
" - 1.1 : Adding foldtext to bet more information. |
||||
" - 1.0 : initial version |
||||
" ============================================================================= |
||||
" Top level bigdefs |
||||
fun! s:HaskellFoldMaster( line ) "{{{ |
||||
return a:line =~# '^data\s' |
||||
\ || a:line =~# '^type\s' |
||||
\ || a:line =~# '^newtype\s' |
||||
\ || a:line =~# '^class\s' |
||||
\ || a:line =~# '^instance\s' |
||||
\ || a:line =~ '^[^:]\+\s*::' |
||||
endfunction "}}} |
||||
|
||||
" Top Level one line shooters. |
||||
fun! s:HaskellSnipGlobal(line) "{{{ |
||||
return a:line =~# '^module' |
||||
\ || a:line =~# '^import' |
||||
\ || a:line =~# '^infix[lr]\s' |
||||
endfunction "}}} |
||||
|
||||
" The real folding function |
||||
fun! haskellFold#HaskellFold( lineNum ) "{{{ |
||||
let line = getline( a:lineNum ) |
||||
|
||||
" Beginning of comment |
||||
if line =~ '^\s*--' || line =~ '^\s*{-' |
||||
return 2 |
||||
endif |
||||
|
||||
if line =~ '^import' |
||||
return 2 |
||||
endif |
||||
|
||||
if s:HaskellSnipGlobal( line ) |
||||
return 0 |
||||
endif |
||||
|
||||
if line =~ '^\s*$' |
||||
let nextline = getline(a:lineNum + 1) |
||||
if s:HaskellFoldMaster( nextline ) > 0 || s:HaskellSnipGlobal( nextline ) > 0 |
||||
\ || nextline =~ "^--" || nextline =~ "^{-" |
||||
return 0 |
||||
else |
||||
return -1 |
||||
endif |
||||
endif |
||||
|
||||
return 1 |
||||
endfunction "}}} |
||||
|
||||
" This function skim over function definitions |
||||
" skiping comments line : |
||||
" -- .... |
||||
" and merging lines without first non space element, to |
||||
" catch the full type expression. |
||||
fun! haskellFold#HaskellFoldText() "{{{ |
||||
let i = v:foldstart |
||||
let retVal = '' |
||||
let began = 0 |
||||
|
||||
let commentOnlyLine = '^\s*--.*$' |
||||
let monoLineComment = '\s*--.*$' |
||||
let nonEmptyLine = '^\s\+\S' |
||||
let emptyLine = '^\s*$' |
||||
let multilineCommentBegin = '^\s*{-' |
||||
let multilineCommentEnd = '-}' |
||||
|
||||
let short = get(g:, 'haskellFold_ShortText', 0) |
||||
let isMultiLine = 0 |
||||
|
||||
let line = getline(i) |
||||
while i <= v:foldend |
||||
|
||||
if isMultiLine |
||||
if line =~ multilineCommentEnd |
||||
let isMultiLine = 0 |
||||
let line = substitute(line, '.*-}', '', '') |
||||
|
||||
if line =~ emptyLine |
||||
let i = i + 1 |
||||
let line = getline(i) |
||||
end |
||||
else |
||||
let i = i + 1 |
||||
let line = getline(i) |
||||
end |
||||
else |
||||
if line =~ multilineCommentBegin |
||||
let isMultiLine = 1 |
||||
continue |
||||
elseif began == 0 && !(line =~ commentOnlyLine) |
||||
let retVal = substitute(line, monoLineComment, ' ','') |
||||
let began = 1 |
||||
elseif began != 0 && line =~ nonEmptyLine && !short |
||||
let tempVal = substitute( line, '\s\+\(.*\)$', ' \1', '' ) |
||||
let retVal = retVal . substitute(tempVal, '\s\+--.*', ' ','') |
||||
elseif began != 0 |
||||
break |
||||
endif |
||||
|
||||
let i = i + 1 |
||||
let line = getline(i) |
||||
endif |
||||
endwhile |
||||
|
||||
if retVal == '' |
||||
" We didn't found any meaningfull text |
||||
return foldtext() |
||||
endif |
||||
|
||||
return retVal |
||||
endfunction "}}} |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
call SetHaskellFolding() |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
if exists("g:__HASKELLFOLD_VIM__") |
||||
finish |
||||
endif |
||||
|
||||
let g:__HASKELLFOLD_VIM__ = 1 |
||||
|
||||
fun! SetHaskellFolding() "{{{ |
||||
setlocal foldexpr=haskellFold#HaskellFold(v:lnum) |
||||
setlocal foldtext=haskellFold#HaskellFoldText() |
||||
setlocal foldmethod=expr |
||||
endfunction "}}} |
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
Copyright (c) 2018, Tobias Wolf |
||||
All rights reserved. |
||||
|
||||
Contains syntax portions licensed from: |
||||
https://github.com/fatih/vim-go |
||||
|
||||
Copyright (c) 2015, Fatih Arslan |
||||
All rights reserved. |
||||
|
||||
Redistribution and use in source and binary forms, with or without |
||||
modification, are permitted provided that the following conditions are met: |
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this |
||||
list of conditions and the following disclaimer. |
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, |
||||
this list of conditions and the following disclaimer in the documentation |
||||
and/or other materials provided with the distribution. |
||||
|
||||
* Neither the name of the copyright holder nor the names of its |
||||
contributors may be used to endorse or promote products derived from |
||||
this software without specific prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
# vim-helm |
||||
vim syntax for helm templates (yaml + gotmpl + sprig + custom) |
||||
|
||||
Install via vundle: |
||||
|
||||
```vim |
||||
Plugin 'towolf/vim-helm' |
||||
``` |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
autocmd BufRead,BufNewFile */templates/*.yaml,*/templates/*.tpl set ft=helm |
@ -0,0 +1,95 @@
@@ -0,0 +1,95 @@
|
||||
if exists("b:current_syntax") |
||||
finish |
||||
endif |
||||
|
||||
if !exists("main_syntax") |
||||
let main_syntax = 'yaml' |
||||
endif |
||||
|
||||
let b:current_syntax = '' |
||||
unlet b:current_syntax |
||||
runtime! syntax/yaml.vim |
||||
|
||||
let b:current_syntax = '' |
||||
unlet b:current_syntax |
||||
syntax include @Yaml syntax/yaml.vim |
||||
|
||||
syn case match |
||||
|
||||
" Go escapes |
||||
syn match goEscapeOctal display contained "\\[0-7]\{3}" |
||||
syn match goEscapeC display contained +\\[abfnrtv\\'"]+ |
||||
syn match goEscapeX display contained "\\x\x\{2}" |
||||
syn match goEscapeU display contained "\\u\x\{4}" |
||||
syn match goEscapeBigU display contained "\\U\x\{8}" |
||||
syn match goEscapeError display contained +\\[^0-7xuUabfnrtv\\'"]+ |
||||
|
||||
hi def link goEscapeOctal goSpecialString |
||||
hi def link goEscapeC goSpecialString |
||||
hi def link goEscapeX goSpecialString |
||||
hi def link goEscapeU goSpecialString |
||||
hi def link goEscapeBigU goSpecialString |
||||
hi def link goSpecialString Special |
||||
hi def link goEscapeError Error |
||||
|
||||
" Strings and their contents |
||||
syn cluster goStringGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU,goEscapeError |
||||
syn region goString contained start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup |
||||
syn region goRawString contained start=+`+ end=+`+ |
||||
|
||||
hi def link goString String |
||||
hi def link goRawString String |
||||
|
||||
" Characters; their contents |
||||
syn cluster goCharacterGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU |
||||
syn region goCharacter contained start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@goCharacterGroup |
||||
|
||||
hi def link goCharacter Character |
||||
|
||||
" Integers |
||||
syn match goDecimalInt contained "\<\d\+\([Ee]\d\+\)\?\>" |
||||
syn match goHexadecimalInt contained "\<0x\x\+\>" |
||||
syn match goOctalInt contained "\<0\o\+\>" |
||||
syn match goOctalError contained "\<0\o*[89]\d*\>" |
||||
syn cluster goInt contains=goDecimalInt,goHexadecimalInt,goOctalInt |
||||
" Floating point |
||||
syn match goFloat contained "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>" |
||||
syn match goFloat contained "\<\.\d\+\([Ee][-+]\d\+\)\?\>" |
||||
syn match goFloat contained "\<\d\+[Ee][-+]\d\+\>" |
||||
" Imaginary literals |
||||
syn match goImaginary contained "\<\d\+i\>" |
||||
syn match goImaginary contained "\<\d\+\.\d*\([Ee][-+]\d\+\)\?i\>" |
||||
syn match goImaginary contained "\<\.\d\+\([Ee][-+]\d\+\)\?i\>" |
||||
syn match goImaginary contained "\<\d\+[Ee][-+]\d\+i\>" |
||||
|
||||
hi def link goInt Number |
||||
hi def link goFloat Number |
||||
hi def link goImaginary Number |
||||
|
||||
" Token groups |
||||
syn cluster gotplLiteral contains=goString,goRawString,goCharacter,@goInt,goFloat,goImaginary |
||||
syn keyword gotplControl contained if else end range with template include tpl required define |
||||
syn keyword gotplFunctions contained and call html index js len not or print printf println urlquery eq ne lt le gt ge |
||||
syn keyword goSprigFunctions contained abbrev abbrevboth add add1 adler32sum ago append atoi b32dec b32enc b64dec b64enc base biggest buildCustomCert camelcase cat ceil clean coalesce \contains compact date dateInZone dateModify date_in_zone date_modify default derivePassword dict dir div empty ext fail first float64 floor fromJson fromYaml genCA genPrivateKey genSelfSignedCert genSignedCert has hasKey hasPrefix hasSuffix hello htmlDate htmlDateInZone indent initial initials int int64 isAbs join kebabcase keys kindIs kindOf last list lower max merge mergeOverwrite min mod mul nindent nospace now omit pick pluck plural prepend quote randAlpha randAlphaNum randAscii randNumeric regexFind regexFindAll regexMatch regexReplaceAll regexReplaceAllLiteral regexSplit repeat replace rest reverse round semver semverCompare set sha1sum sha256sum shuffle slice snakecase sortAlpha split splitList splitn squote sub substr swapcase ternary title toDate toJson toPrettyJson toString toStrings toToml toYaml trim trimAll trimPrefix trimSuffix trimall trunc tuple typeIs typeIsLike typeOf uniq unixEpoch unset until untilStep untitle upper uuidv4 values without wrap wrapWith |
||||
syn match goTplVariable contained /\$[a-zA-Z0-9_]*\>/ |
||||
syn match goTplIdentifier contained /\.[^\s}]+\>/ |
||||
|
||||
" hi def link gotplControl Keyword |
||||
" hi def link gotplFunctions Function |
||||
" hi def link goSprigFunctions Function |
||||
" hi def link goTplVariable Special |
||||
hi def link gotplControl goConditional |
||||
hi def link gotplFunctions goConditional |
||||
hi def link goSprigFunctions goConditional |
||||
hi def link goTplVariable goStatement |
||||
|
||||
syn region gotplAction start="{{\(-? \)\?" end="\( -?\)\?}}" contains=@gotplLiteral,gotplControl,gotplFunctions,goSprigFunctions,gotplVariable,goTplIdentifier containedin=yamlFlowString display |
||||
syn region gotplAction start="\[\[\(-? \)\?" end="\( -?\)\?\]\]" contains=@gotplLiteral,gotplControl,gotplFunctions,goSprigFunctions,gotplVariable containedin=yamlFlowString display |
||||
syn region goTplComment start="{{\(-? \)\?/\*" end="\*/\( -?\)\?}}" display |
||||
syn region goTplComment start="\[\[\(-? \)\?/\*" end="\*/\( -?\)\?\]\]" display |
||||
|
||||
hi def link goTplAction Operator |
||||
hi def link goTplComment Comment |
||||
let b:current_syntax = "helm" |
||||
|
||||
" vim: sw=2 ts=2 et |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue