diff options
Diffstat (limited to 'xxx/vim-old/vim-potion/ftplugin/potion')
| -rw-r--r-- | xxx/vim-old/vim-potion/ftplugin/potion/folding.vim | 38 | ||||
| -rw-r--r-- | xxx/vim-old/vim-potion/ftplugin/potion/running.vim | 6 | ||||
| -rw-r--r-- | xxx/vim-old/vim-potion/ftplugin/potion/sections.vim | 47 |
3 files changed, 91 insertions, 0 deletions
diff --git a/xxx/vim-old/vim-potion/ftplugin/potion/folding.vim b/xxx/vim-old/vim-potion/ftplugin/potion/folding.vim new file mode 100644 index 0000000..d4cb32b --- /dev/null +++ b/xxx/vim-old/vim-potion/ftplugin/potion/folding.vim @@ -0,0 +1,38 @@ +setlocal foldmethod=expr +setlocal foldexpr=GetPotionFold(v:lnum) + +function! s:NextNonBlankLine(lnum) + let numlines = line('$') + let current = a:lnum + 1 + + while current <= numlines + if getline(current) =~? '\v\S' + return current + endif + + let current += 1 + endwhile + + return -2 +endfunction + +function! s:IndentLevel(lnum) + return indent(a:lnum) / &shiftwidth +endfunction + +function! GetPotionFold(lnum) + if getline(a:lnum) =~? '\v^\s*$' + return '-1' + endif + + let this_indent = <SID>IndentLevel(a:lnum) + let next_indent = <SID>IndentLevel(<SID>NextNonBlankLine(a:lnum)) + + if next_indent == this_indent + return this_indent + elseif next_indent < this_indent + return this_indent + elseif next_indent > this_indent + return '>' . next_indent + endif +endfunction diff --git a/xxx/vim-old/vim-potion/ftplugin/potion/running.vim b/xxx/vim-old/vim-potion/ftplugin/potion/running.vim new file mode 100644 index 0000000..d70adc0 --- /dev/null +++ b/xxx/vim-old/vim-potion/ftplugin/potion/running.vim @@ -0,0 +1,6 @@ +if !exists("g:potion_command") + let g:potion_command = "potion" +endif + +nnoremap <buffer> <localleader>r :call potion#running#PotionCompileAndRunFile()<cr> +nnoremap <buffer> <localleader>b :call potion#running#PotionShowBytecode()<cr> diff --git a/xxx/vim-old/vim-potion/ftplugin/potion/sections.vim b/xxx/vim-old/vim-potion/ftplugin/potion/sections.vim new file mode 100644 index 0000000..200415c --- /dev/null +++ b/xxx/vim-old/vim-potion/ftplugin/potion/sections.vim @@ -0,0 +1,47 @@ +function! s:NextSection(type, backwards, visual) + + if a:visual + normal! gv + endif + + if a:type == 1 + let pattern = '\v(\n\n^\S|%^)' + let flags = 'e' + elseif a:type == 2 + let pattern = '\v^\S.*\=.*:$' + let flags = '' + endif + + if a:backwards + let dir = '?' + else + let dir = '/' + endif + + execute 'silent normal! ' . dir . pattern . dir . flags . "\r" + +endfunction + +noremap <script> <buffer> <silent> ]] + \ :call <SID>NextSection(1, 0, 0)<cr> + +noremap <script> <buffer> <silent> [[ + \ :call <SID>NextSection(1, 1, 0)<cr> + +noremap <script> <buffer> <silent> ][ + \ :call <SID>NextSection(2, 0, 0)<cr> + +noremap <script> <buffer> <silent> [] + \ :call <SID>NextSection(2, 1, 0)<cr> + +vnoremap <script> <buffer> <silent> ]] + \ :<c-u>call <SID>NextSection(1, 0, 1)<cr> + +vnoremap <script> <buffer> <silent> [[ + \ :<c-u>call <SID>NextSection(1, 1, 1)<cr> + +vnoremap <script> <buffer> <silent> ][ + \ :<c-u>call <SID>NextSection(2, 0, 1)<cr> + +vnoremap <script> <buffer> <silent> [] + \ :<c-u>call <SID>NextSection(2, 1, 1)<cr> |
