diff options
Diffstat (limited to 'xxx/vim-old/vim-potion')
| -rw-r--r-- | xxx/vim-old/vim-potion/autoload/potion/running.vim | 33 | ||||
| -rw-r--r-- | xxx/vim-old/vim-potion/doc/potion.txt | 99 | ||||
| -rw-r--r-- | xxx/vim-old/vim-potion/ftdetect/potion.vim | 1 | ||||
| -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 | ||||
| -rw-r--r-- | xxx/vim-old/vim-potion/syntax/potion.vim | 37 | ||||
| -rw-r--r-- | xxx/vim-old/vim-potion/syntax/potionbytecode.vim | 18 |
8 files changed, 279 insertions, 0 deletions
diff --git a/xxx/vim-old/vim-potion/autoload/potion/running.vim b/xxx/vim-old/vim-potion/autoload/potion/running.vim new file mode 100644 index 0000000..562f713 --- /dev/null +++ b/xxx/vim-old/vim-potion/autoload/potion/running.vim @@ -0,0 +1,33 @@ +function! potion#running#PotionCompileAndRunFile() + write + silent !clear + execute "!" . g:potion_command . " " . bufname("%") +endfunction + +function! potion#running#PotionShowBytecode() + + write + + " Get the bytecode. + let bytecode = system(g:potion_command . " -c -V " . bufname("%") . " 2>&1") + + " Check returned string for errors. + if bytecode=~#"Syntax error" + let bytecode = "SYNTAX ERROR!! Check your potion." + endif + + " Open a new split and set it up or use existing one! + let potbufnr=bufwinnr('__Potion_Bytecode__') + if potbufnr==#-1 + vsplit __Potion_Bytecode__ + else + execute potbufnr.'wincmd w' + endif + normal! ggdG + setlocal filetype=potionbytecode + setlocal buftype=nofile + + " Insert the bytecode. + call append(0, split(bytecode, '\v\n')) + +endfunction diff --git a/xxx/vim-old/vim-potion/doc/potion.txt b/xxx/vim-old/vim-potion/doc/potion.txt new file mode 100644 index 0000000..4cd9191 --- /dev/null +++ b/xxx/vim-old/vim-potion/doc/potion.txt @@ -0,0 +1,99 @@ +*potion.txt* basic functionality for the potion programming language +======================================================================== +INTRO *PotionIntro* + + ___ _ _ ~ + / _ \___ | |_(_) ___ _ __ ~ + / /_)/ _ \| __| |/ _ \| '_ \ ~ + / ___/ (_) | |_| | (_) | | | | ~ + \/ \___/ \__|_|\___/|_| |_| ~ + + + Functionality for the Potion programming language. + Includes syntax highlighting, code folding, and more! + + Coded by Michal Idziorek <m.i@gmx.at> + along the "Learn Vimscript the Hard Way" tutorial: + http://learnvimscriptthehardway.stevelosh.com + + +======================================================================== +CONTENTS *PotionContents* + + 1. Usage .............. |PotionUsage| + 2. Installation ....... |PotionInstall| + 3. Files .............. |PotionFiles| + 4. Credits ............ |PotionCredits| + + +======================================================================== +USAGE *PotionUsage* + +This plugin will automatically provide syntax highlighting and folding +for potion files (files ending in .pn). + +It remaps the section movement commands, to provide easy navigation +through potion files: +> + [[ ]] [] ][ +< + +The plugin offers mappings for invoking the potion compiler as well: + +Press <localleader>r for running the currently opened potion file. +Press <localleader>b for showing its compiled bytecode in a new window. + +Set your maplocalleader in your .vimrc like this: +> + let maplocalleader="\<space>" +< + +You can set the path to the potion binary in your .vimrc too: +> + let g:potion_command = "/home/miguel/int/dev/potion/bin/potion" +< + +Otherwise the following default value will be used: +> + let g:potion_command = "potion" +< + +======================================================================== +INSTALLATION *PotionInstall* + +Use Tim Pope's marvellous 'pathogen.vim' to simply put the potion plugin +into its own private directory. You can get Pathogen on GitHub: +> + https://github.com/tpope/vim-pathogen +< + +Use git to clone the plugin directly into its target directory to keep +it up to date easily. +> + ~/.vim/bundle/potion/ +< + +======================================================================== +FILES *PotionFiles* + +The potion plugin ships with the following files: + +doc/potion.txt ................ Documentation (this file) +ftdetect/potion.vim ........... Detection of potion files by .pn ending +syntax/potion.vim ............. Syntax highlighting for .pn files +syntax/potionbytecode.vim ..... Syntax highlighting for bytecode +ftplugin/potion/folding.vim ... Folding functionality +ftplugin/potion/sections.vim .. Section movement via [[,]],[],][ +ftplugin/potion/running.vim ... Mappings for running the potion compiler +autoload/potion/running.vim ... Functions for running the compiler + + +======================================================================== +CREDITS *PotionCredits* + +This is my very first Vim plugin and it emerged during the course +of reading Steve Losh' wonderful Vimscript tutorial: +> + "Learn Vimscript the Hard Way". + http://learnvimscriptthehardway.stevelosh.com +< diff --git a/xxx/vim-old/vim-potion/ftdetect/potion.vim b/xxx/vim-old/vim-potion/ftdetect/potion.vim new file mode 100644 index 0000000..a3a3170 --- /dev/null +++ b/xxx/vim-old/vim-potion/ftdetect/potion.vim @@ -0,0 +1 @@ +au BufNewFile,BufRead *.pn setfiletype potion 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> diff --git a/xxx/vim-old/vim-potion/syntax/potion.vim b/xxx/vim-old/vim-potion/syntax/potion.vim new file mode 100644 index 0000000..2ca9dbc --- /dev/null +++ b/xxx/vim-old/vim-potion/syntax/potion.vim @@ -0,0 +1,37 @@ +if exists("b:current_syntax") + finish +endif + +syntax keyword potionKeyword loop times to while +syntax keyword potionKeyword if elsif else +syntax keyword potionKeyword class return +syntax keyword potionFunction print join string + +syntax match potionOperator "\v\." +syntax match potionOperator "\v:" +syntax match potionOperator "\v\=" +syntax match potionOperator "\v\*" +syntax match potionOperator "\v/" +syntax match potionOperator "\v\+" +syntax match potionOperator "\v-" +syntax match potionOperator "\v\?" +syntax match potionOperator "\v\*\=" +syntax match potionOperator "\v/\=" +syntax match potionOperator "\v\+\=" +syntax match potionOperator "\v-\=" + +syntax match potionNumber "\v\d+" +syntax match potionNumber "\v0x\x+" + +syntax region potionString start=/\v"/ skip=/\v\\./ end=/\v"/ + +syntax match potionComment "\v#.*$" + +highlight link potionString String +highlight link potionOperator Operator +highlight link potionKeyword Keyword +highlight link potionFunction Function +highlight link potionComment Comment +highlight link potionNumber Number + +let b:current_syntax = "potion" diff --git a/xxx/vim-old/vim-potion/syntax/potionbytecode.vim b/xxx/vim-old/vim-potion/syntax/potionbytecode.vim new file mode 100644 index 0000000..24e2e44 --- /dev/null +++ b/xxx/vim-old/vim-potion/syntax/potionbytecode.vim @@ -0,0 +1,18 @@ +" minimalistic syntax highlighting for testing purposes + +if exists("b:current_syntax") + finish +endif + +syntax keyword potionKeyword code assign + + +syntax match potionNumber "\v\d+" +syntax region potionString start=/\v"/ skip=/\v\\./ end=/\v"/ + + +highlight link potionString String +highlight link potionKeyword Keyword +highlight link potionNumber Number + +let b:current_syntax = "potionbytecode" |
