Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update syntax highlighting #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions compiler/se.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
" Vim compiler file
" Compiler: se (Liberty Eiffel Compiler)
" Maintainer: Doug Kearns <dougkearns@gmail.com>
" Last Change: 2013 Jun 29
" URL: https://github.com/eiffelhub/vim-eiffel

if exists("current_compiler")
finish
endif
let current_compiler = "se"

if exists(":CompilerSet") != 2 " older Vim always used :setlocal
command -nargs=* CompilerSet setlocal <args>
endif

let s:cpo_save = &cpo
set cpo-=C

CompilerSet makeprg=se\ c

CompilerSet errorformat=%W******\ Warning:\ %m,
\%E******\ Fatal\ Error:\ %m,
\%E******\ Error:\ %m,
\%ZLine\ %l\ column\ %c\ in\ %.%#\ (%f)\ %\\=:,
\%ZLine\ %l\ columns\ %c\\,\ %\\d%\\+\ %.%#\ (%f)\ %\\=:,
\%+C%*[^\ ]%.%#,
\%-GThe\ source\ lines\ involved,
\%-G%.%#

let &cpo = s:cpo_save
unlet s:cpo_save
66 changes: 66 additions & 0 deletions doc/syntax.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
EIFFEL *eiffel.vim* *ft-eiffel-syntax*

By default Eiffel Software's dialect of the language is assumed.
Alternatively, if you are using Liberty Eiffel support for its differences can
be enabled by setting the following variable in your startup file: >

:let eiffel_liberty=1

While Eiffel is not case-sensitive, its style guidelines are, and the
syntax highlighting file encourages their use. This also allows for
highlighting class names differently. If you want to disable case-sensitive
highlighting, add the following line to your startup file: >

:let eiffel_ignore_case=1

Case still matters for class names and TODO marks in comments.

Setting this variable has no effect when *eiffel_liberty* is set as Liberty
Eiffel is always case-sensitive.

Conversely, for even stricter checks, add one of the following lines: >

:let eiffel_strict=1
:let eiffel_pedantic=1

Setting eiffel_strict will only catch improper capitalization for the
five predefined words "Current", "Void", "Result", "Precursor", and
"NONE", to warn against their accidental use as feature or class names.

Setting eiffel_pedantic will enforce adherence to the Eiffel style
guidelines fairly rigorously (like arbitrary mixes of upper- and
lowercase letters as well as outdated ways to capitalize keywords).

If you want to use the lower-case version of "Current", "Void",
"Result", and "Precursor", you can use >

:let eiffel_lower_case_predef=1

instead of completely turning case-sensitive highlighting off.

Folding of multiline syntax regions can be enabled with: >

:let eiffel_fold=1

and the specific regions that are considered foldable can be specified with: >

:let eiffel_fold_groups=[group1,...]

The following groups are supported: >

Group Description ~
*note* A class-level notes clause
*class* The class header along with any formal generic list
*obsolete* The class-level obsolete mark
*inherit* An inherit clause (also insert when *eiffel_liberty* is set)
*create* A creation clause
*convert* The converter clause
*feature* A feature clause
*feature-body* A feature declaration
*invariant* The class-level invariant clause

The default value is "note,obsolete,inherit,create,convert,feature,feature-body,invariant"

Comments and strings are always foldable.

vim:tw=78:sw=4:ts=8:ft=help:norl:
103 changes: 86 additions & 17 deletions ftplugin/eiffel.vim
Original file line number Diff line number Diff line change
@@ -1,28 +1,97 @@
" Vim filetype plugin file
" Vim filetype plugin
" Language: Eiffel
" Maintainer: Jocelyn Fiat <jfiat@eiffel.com>
" (https://github.com/eiffelhub/vim-eiffel)
" URL: https://github.com/eiffelhub/vim-eiffel
" Last Change: Tue 22 Apr 2003 09:50:08
" Maintainer: Doug Kearns <dougkearns@gmail.com>
" Last Change: 2010 Aug 29
" URL: https://github.com/eiffelhub/vim-eiffel

" Only do this when not done yet for this buffer
if exists("b:did_ftplugin")
if (exists("b:did_ftplugin"))
finish
endif

" Don't load another plugin for this buffer
let b:did_ftplugin = 1

" Matchit handling
let s:cpo_save = &cpo
set cpo&vim

setlocal comments=:--
setlocal commentstring=--\ %s

" The following lines enable the macros/matchit.vim plugin for
" extended matching with the % key.
setlocal formatoptions-=t formatoptions+=croql

if exists("loaded_matchit")
if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
let b:browsefilter = "Eiffel Source Files (*.e)\t*.e\n" .
\ "Eiffel Control Files (*.ecf, *.ace, *.xace)\t*.ecf;*.ace;*.xace\n" .
\ "All Files (*.*)\t*.*\n"
endif

if exists("loaded_matchit") && !exists("b:match_words")
let b:match_ignorecase = 0
if !exists("b:match_words") |
let b:match_words = '\<\%(do\|if\|from\|check\|inspect\)\>:' . '\<\%(else\|elseif\|until\|loop\|when\):'. '\<end\>'
endif
" Silly \%^ trick to match note at head of pair and in middle prevents
" 'g%' wrapping from 'note' to 'end'
let b:match_words = '\%^:' .
\ '\<\%(^note\|indexing\|class\|^obsolete\|inherit\|insert\|^create\|convert\|feature\|^invariant\)\>:' .
\ '^end\>,' .
\ '\<\%(do\|deferred\|external\|once\%(\s\+"\)\@!\|check\|debug\|if\|inspect\|from\|across\)\>:' .
\ '\%(\%(^\s\+\)\@<=\%(then\|until\|loop\)\|\%(then\|until\|loop\)\s\+[^ -]\|' .
\ '\<\%(ensure\%(\s\+then\)\=\|rescue\|_then\|elseif\|else\|when\|\s\@<=invariant\|_until\|_loop\|variant\|_as\|alias\)\>\):' .
\ '\s\@<=end\>'
let b:match_skip = 's:\<eiffel\%(Comment\|String\|Operator\)\>'
noremap [% <Nop>
noremap ]% <Nop>
vnoremap a% <Nop>
endif

let b:undo_ftplugin = "setl fo< com< cms<" .
\ "| unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip"

if !exists("g:no_plugin_maps") && !exists("g:no_eiffel_maps")
function! s:DoMotion(pattern, count, flags) abort
normal! m'
for i in range(a:count)
call search(a:pattern, a:flags)
endfor
endfunction

let sections = '^\%(note\|indexing\|' .
\ '\%(\%(deferred\|expanded\|external\|frozen\)\s\+\)*class\|' .
\ 'obsolete\|inherit\|insert\|create\|convert\|feature\|' .
\ 'invariant\|end\)\>'

nnoremap <silent> <buffer> ]] :<C-U>call <SID>DoMotion(sections, v:count1, 'W')<CR>
xnoremap <silent> <buffer> ]] :<C-U>exe "normal! gv"<Bar>call <SID>DoMotion(sections, v:count1, 'W')<CR>
nnoremap <silent> <buffer> [[ :<C-U>call <SID>DoMotion(sections, v:count1, 'Wb')<CR>
xnoremap <silent> <buffer> [[ :<C-U>exe "normal! gv"<Bar>call <SID>DoMotion(sections, v:count1, 'Wb')<CR>

function! s:DoFeatureMotion(count, flags)
let view = winsaveview()
call cursor(1, 1)
let [features_start, _] = searchpos('^feature\>')
call search('^\s\+\a') " find the first feature
let spaces = indent(line('.'))
let [features_end, _] = searchpos('^\%(invariant\|note\|end\)\>')
call winrestview(view)
call s:DoMotion('\%>' . features_start . 'l\%<' . features_end . 'l^\s*\%' . (spaces + 1) . 'v\zs\a', a:count, a:flags)
endfunction

nnoremap <silent> <buffer> ]m :<C-U>call <SID>DoFeatureMotion(v:count1, 'W')<CR>
xnoremap <silent> <buffer> ]m :<C-U>exe "normal! gv"<Bar>call <SID>DoFeatureMotion(v:count1, 'W')<CR>
nnoremap <silent> <buffer> [m :<C-U>call <SID>DoFeatureMotion(v:count1, 'Wb')<CR>
xnoremap <silent> <buffer> [m :<C-U>exe "normal! gv"<Bar>call <SID>DoFeatureMotion(v:count1, 'Wb')<CR>

let comment_block_start = '^\%(\s\+--.*\n\)\@<!\s\+--'
let comment_block_end = '^\s\+--.*\n\%(\s\+--\)\@!'

nnoremap <silent> <buffer> ]- :<C-U>call <SID>DoMotion(comment_block_start, 1, 'W')<CR>
xnoremap <silent> <buffer> ]- :<C-U>exe "normal! gv"<Bar>call <SID>DoMotion(comment_block_start, 1, 'W')<CR>
nnoremap <silent> <buffer> [- :<C-U>call <SID>DoMotion(comment_block_end, 1, 'Wb')<CR>
xnoremap <silent> <buffer> [- :<C-U>exe "normal! gv"<Bar>call <SID>DoMotion(comment_block_end, 1, 'Wb')<CR>

let b:undo_ftplugin = b:undo_ftplugin .
\ "| silent! execute 'unmap <buffer> [[' | silent! execute 'unmap <buffer> ]]'" .
\ "| silent! execute 'unmap <buffer> [m' | silent! execute 'unmap <buffer> ]m'" .
\ "| silent! execute 'unmap <buffer> [-' | silent! execute 'unmap <buffer> ]-'"
endif

let &cpo = s:cpo_save
unlet s:cpo_save

endif " exists("loaded_matchit")
" vim: nowrap sw=2 sts=2 ts=8
Loading