-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
485 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,83 @@ | ||
``` | ||
_ _______ | ||
/.\\ / ___ \_________ _ | ||
___ ___ \_/ \ | / \ ____ \/ | _____ | ||
/ \ / \ \ \ | | O | _________/\_| / | o\ | ||
| _ | | \ _| \--\ | \___/ / _/ _/ / | ||
| | | | \ \ | o | \ \ /\ /.\ / | | | ||
| |_| | _\ \ /--/ \ \\ \ \/\ \_// | | | ||
| _ | | \ | / / \ \\ \ \ \ / | | ||
|_| |_| \___/ _/ / \ _ \ \-\ | o\_ | ||
/ \ / | /.\ | |o| /_____\ | ||
for Vim9 | o |_ _____/ \_/ | /-/ | | | ||
by Knosowski \_/__|__ |____ ______/ / / |_____| | ||
|___ ___\ | \_____ | / | | ||
| \__ | \___________/ | o \__ | ||
|______| | | \______\ | ||
industrial robot programming | | | | | ||
|___________| |_____| | ||
``` | ||
# kawasaki-as-for-vim | ||
|
||
Vim plugins (syntax, indent and more) for Kawasaki AS language | ||
|
||
## Introduction: | ||
|
||
Kawasaki AS for [Vim][10] (7.4 or later) is a collection of Vim scripts to help | ||
programming [Kawasaki industrial robots][9]. | ||
|
||
It provides | ||
* syntax highlighting, | ||
* indenting, | ||
* support for commentary [vimscript #3695][7] | ||
|
||
|
||
## Installation: | ||
|
||
### Installation with [vim-plug][14]: ~ | ||
|
||
Put this in your .vimrc: > | ||
|
||
call plug#begin('~/.vim/plugged') | ||
Plug 'KnoP-01/kawasaki-as-for-vim' | ||
call plug#end() | ||
|
||
For the first installation run: > | ||
|
||
:PlugInstall | ||
|
||
Update every once in a while with: > | ||
|
||
:PlugUpdate | ||
|
||
### Manual installation: ~ | ||
|
||
Extract the most recent [release][1] and copy the folders | ||
`/doc`, `/ftdetect`, `/ftplugin`, `/indent` and `/syntax` | ||
into your `~/.vim/` or `%USERPROFILE%\vimfiles\` directory. | ||
Overwrite kawasaki\_as.\* files from older installation. | ||
|
||
Put the following in your .vimrc: > | ||
|
||
syntax on " syntax and filetype on in that order | ||
filetype plugin indent on " syntax and filetype on in that order | ||
|
||
## Self promotion | ||
|
||
If you like this plugin please Star it. If you don't but you think it could be | ||
useful if this or that would be different, don't hesitate to email me or even | ||
better open an [issue][5]. With a little luck and good timing you may find me | ||
on ircs://irc.libera.chat:6697/#vim as KnoP in case you have any questions. | ||
|
||
[1]: https://github.com/KnoP-01/kawasaki-as-for-vim/releases/latest | ||
<!-- [2]: https://github.com/KnoP-01/kawasaki-as-for-vim#FAQ --> | ||
<!-- [3]: https://github.com/KnoP-01/kawasaki-as-for-vim/blob/master/doc/kawasaki-as.txt#L203 --> | ||
<!-- [4]: https://www.vim.org/scripts/script.php?script_id=5348 --> | ||
[5]: https://github.com/KnoP-01/kawasaki-as-for-vim/issues | ||
[7]: https://github.com/tpope/vim-commentary | ||
<!-- [8]: https://www.vim.org/scripts/script.php?script_id=39 --> | ||
[9]: https://kawasakirobotics.com/products-robots/ | ||
[10]: https://www.vim.org/ | ||
<!-- [11]: https://github.com/andymass/vim-matchup --> | ||
<!-- [12]: https://github.com/tpope/vim-endwise --> | ||
[14]: https://github.com/junegunn/vim-plug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
" Vim file type detection file | ||
" Language: Kawasaki AS-language | ||
" Maintainer: Patrick Meiser-Knosowski <[email protected]> | ||
" Version: 1.0.0 | ||
" Last Change: 23. Mar 2023 | ||
" | ||
|
||
let s:keepcpo = &cpo | ||
set cpo&vim | ||
|
||
" no augroup! see :h ftdetect | ||
au! BufNewFile,BufRead *.as,*.pg setf kawasaki_as | ||
|
||
let &cpo = s:keepcpo | ||
unlet s:keepcpo | ||
|
||
" vim:sw=2 sts=2 et |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
" Vim file type plugin | ||
" Language: Kawasaki AS-language | ||
" Maintainer: Patrick Meiser-Knosowski <[email protected]> | ||
" Version: 1.0.0 | ||
" Last Change: 21. Mar 2023 | ||
" | ||
|
||
" Init {{{ | ||
|
||
" Only do this when not done yet for this buffer | ||
if exists("b:did_ftplugin") | ||
finish | ||
endif | ||
let b:did_ftplugin = 1 | ||
|
||
let s:keepcpo = &cpo | ||
set cpo&vim | ||
|
||
" }}} init | ||
|
||
" Vim Settings {{{ | ||
|
||
" default on; no option | ||
setlocal commentstring=;%s | ||
setlocal comments=:\; | ||
let b:undo_ftplugin = "setlocal com< cms<" | ||
|
||
" auto insert comment char when i_<CR>, o or O on a comment line | ||
if get(g:,'asAutoComment',1) | ||
setlocal formatoptions+=r | ||
setlocal formatoptions+=o | ||
let b:undo_ftplugin = b:undo_ftplugin." fo<" | ||
endif | ||
|
||
" format comments | ||
if get(g:,'asFormatComments',1) | ||
if &textwidth ==# 0 | ||
" 78 Chars | ||
setlocal textwidth=78 | ||
let b:undo_ftplugin = b:undo_ftplugin." tw<" | ||
endif | ||
setlocal formatoptions-=t | ||
setlocal formatoptions+=l | ||
setlocal formatoptions+=j | ||
if stridx(b:undo_ftplugin, " fo<")==(-1) | ||
let b:undo_ftplugin = b:undo_ftplugin." fo<" | ||
endif | ||
endif " format comments | ||
|
||
" }}} Vim Settings | ||
|
||
" Move Around and Function Text Object key mappings {{{ | ||
|
||
if get(g:,'asMoveAroundKeyMap',1) | ||
nnoremap <silent><buffer> ]] :<C-U> call search('^\.' , 'sw')<cr> | ||
onoremap <silent><buffer> ]] :<C-U>exe "normal! v" <Bar>call search('\(\ze\n\.\\|\%$\)', 'eW')<cr> | ||
xnoremap <silent><buffer> ]] :<C-U>exe "normal! gv"<Bar>call search('\(^\.\\|\%$\)' , 'sW')<cr> | ||
nnoremap <silent><buffer> [[ :<C-U> call search('^\.' , 'bsw')<cr> | ||
onoremap <silent><buffer> [[ :<C-U> call search('^\.' , 'bW')<cr> | ||
xnoremap <silent><buffer> [[ :<C-U>exe "normal! gv"<Bar>call search('^\.' , 'bsW')<cr> | ||
nnoremap <silent><buffer> ][ :<C-U> call search('.*\(\n\.\\|\%$\)' , 'sw')<cr> | ||
onoremap <silent><buffer> ][ :<C-U>exe "normal! v" <Bar>call search('\(\n\.\\|\%$\)' , 'sW')<cr> | ||
xnoremap <silent><buffer> ][ :<C-U>exe "normal! gv"<Bar>call search('\(\n\.\\|\%$\)' , 'sW')<cr> | ||
nnoremap <silent><buffer> [] :<C-U> call search('^\.\n\w\+:\n\n' , 'besw')<cr> | ||
onoremap <silent><buffer> [] :<C-U>exe "normal! V" <Bar>call search('^\.\n\w\+:\n\n' , 'besW')<cr> | ||
xnoremap <silent><buffer> [] :<C-U>exe "normal! gv"<Bar>call search('^\.\n\w\+:\n\n' , 'besW')<cr> | ||
endif | ||
|
||
" }}} Move Around and Function Text Object key mappings | ||
|
||
" Finish {{{ | ||
let &cpo = s:keepcpo | ||
unlet s:keepcpo | ||
" }}} Finish | ||
|
||
" vim:sw=2 sts=2 et fdm=marker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
" Vim indent file | ||
" Language: Kawasaki AS-language | ||
" Maintainer: Patrick Meiser-Knosowski <[email protected]> | ||
" Version: 1.0.0 | ||
" Last Change: 23. Mar 2023 | ||
|
||
" Only load this indent file when no other was loaded. | ||
if exists("b:did_indent") | ||
finish | ||
endif | ||
let b:did_indent = 1 | ||
|
||
setlocal nolisp | ||
setlocal nocindent | ||
setlocal nosmartindent | ||
setlocal autoindent | ||
setlocal indentexpr=GetAsIndent() | ||
setlocal indentkeys=!^F,o,O,=~end,0=~else,0=~value,0=~any | ||
let b:undo_indent = "setlocal lisp< cindent< smartindent< autoindent< indentexpr< indentkeys<" | ||
|
||
if get(g:,'asSpaceIndent',1) | ||
" Use spaces, not tabs, for indention, 2 is enough. | ||
" More or even tabs would waste valuable space on the teach pendant. | ||
setlocal softtabstop=2 | ||
setlocal shiftwidth=2 | ||
setlocal expandtab | ||
setlocal shiftround | ||
let b:undo_indent = b:undo_indent." softtabstop< shiftwidth< expandtab< shiftround<" | ||
endif | ||
|
||
" Only define the function once. | ||
if exists("*GetAsIndent") | ||
finish | ||
endif | ||
|
||
let s:keepcpo = &cpo | ||
set cpo&vim | ||
|
||
function GetAsIndent() abort | ||
|
||
let currentLine = getline(v:lnum) | ||
if currentLine =~? '^;' && !get(g:, 'asCommentIndent', 1) | ||
" If current line has a ; in column 1 and is no fold, keep zero indent. | ||
" This may be usefull if code is commented out at the first column. | ||
return 0 | ||
endif | ||
|
||
" Find a non-blank line above the current line. | ||
let preNoneBlankLineNum = s:AsPreNoneBlank(v:lnum - 1) | ||
if preNoneBlankLineNum == 0 | ||
" At the start of the file use zero indent. | ||
return 0 | ||
endif | ||
|
||
let preNoneBlankLine = getline(preNoneBlankLineNum) | ||
let ind = indent(preNoneBlankLineNum) | ||
|
||
" Define add 'shiftwidth' pattern | ||
let addShiftwidthPattern = '\c\v^\s*(' | ||
if get(g:, 'asIndentBetweenDef', 1) | ||
let addShiftwidthPattern ..= '\.program>' | ||
let addShiftwidthPattern ..= '|' | ||
endif | ||
let addShiftwidthPattern ..= 'if>|while>|for>' | ||
let addShiftwidthPattern ..= '|else>' | ||
let addShiftwidthPattern ..= '|value>|any>' | ||
let addShiftwidthPattern ..= ')' | ||
|
||
" Define Subtract 'shiftwidth' pattern | ||
let subtractShiftwidthPattern = '\c\v^\s*(' | ||
if get(g:, 'asIndentBetweenDef', 1) | ||
let subtractShiftwidthPattern ..= '\.end>' | ||
let subtractShiftwidthPattern ..= '|' | ||
endif | ||
let subtractShiftwidthPattern ..= 'end>' | ||
let subtractShiftwidthPattern ..= '|else(if)?>' | ||
let subtractShiftwidthPattern ..= '|value>|any>>' | ||
let subtractShiftwidthPattern ..= ')' | ||
|
||
" Add shiftwidth | ||
if preNoneBlankLine =~? addShiftwidthPattern | ||
let ind += &sw | ||
endif | ||
|
||
" Subtract shiftwidth | ||
if currentLine =~? subtractShiftwidthPattern | ||
let ind = ind - &sw | ||
endif | ||
|
||
" First value after a case gets the indent of the case. | ||
if currentLine =~? '\c\v^\s*value>' | ||
\&& preNoneBlankLine =~? '\c\v^\s*case>' | ||
let ind = ind + &sw | ||
endif | ||
|
||
return ind | ||
endfunction | ||
|
||
" This function works almost like prevnonblank() but handles | ||
" comments like blank lines | ||
function s:AsPreNoneBlank(lnum) abort | ||
|
||
let nPreNoneBlank = prevnonblank(a:lnum) | ||
|
||
while nPreNoneBlank > 0 && getline(nPreNoneBlank) =~? '^\s*;' | ||
" Previouse none blank line a comment. Look further aback. | ||
let nPreNoneBlank = prevnonblank(nPreNoneBlank - 1) | ||
endwhile | ||
|
||
return nPreNoneBlank | ||
endfunction | ||
|
||
let &cpo = s:keepcpo | ||
unlet s:keepcpo | ||
|
||
" vim:sw=2 sts=2 et |
Oops, something went wrong.