From f70d5dc9b1f546bcfae67f067fe2e3b67f94ca45 Mon Sep 17 00:00:00 2001 From: Miguel Date: Wed, 3 Nov 2021 19:59:44 +0100 Subject: improving dotfiles --- xxx/vim-old/vim-potion/autoload/potion/running.vim | 33 ++++++++ xxx/vim-old/vim-potion/doc/potion.txt | 99 ++++++++++++++++++++++ xxx/vim-old/vim-potion/ftdetect/potion.vim | 1 + xxx/vim-old/vim-potion/ftplugin/potion/folding.vim | 38 +++++++++ xxx/vim-old/vim-potion/ftplugin/potion/running.vim | 6 ++ .../vim-potion/ftplugin/potion/sections.vim | 47 ++++++++++ xxx/vim-old/vim-potion/syntax/potion.vim | 37 ++++++++ xxx/vim-old/vim-potion/syntax/potionbytecode.vim | 18 ++++ 8 files changed, 279 insertions(+) create mode 100644 xxx/vim-old/vim-potion/autoload/potion/running.vim create mode 100644 xxx/vim-old/vim-potion/doc/potion.txt create mode 100644 xxx/vim-old/vim-potion/ftdetect/potion.vim create mode 100644 xxx/vim-old/vim-potion/ftplugin/potion/folding.vim create mode 100644 xxx/vim-old/vim-potion/ftplugin/potion/running.vim create mode 100644 xxx/vim-old/vim-potion/ftplugin/potion/sections.vim create mode 100644 xxx/vim-old/vim-potion/syntax/potion.vim create mode 100644 xxx/vim-old/vim-potion/syntax/potionbytecode.vim (limited to 'xxx/vim-old/vim-potion') 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 + 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 r for running the currently opened potion file. +Press b for showing its compiled bytecode in a new window. + +Set your maplocalleader in your .vimrc like this: +> + let maplocalleader="\" +< + +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 = IndentLevel(a:lnum) + let next_indent = IndentLevel(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 r :call potion#running#PotionCompileAndRunFile() +nnoremap b :call potion#running#PotionShowBytecode() 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