Skip to content

Commit

Permalink
v1.1 syntax after *sh
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronspring committed Oct 20, 2016
1 parent c8fb99b commit ec5b3a3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 46 deletions.
36 changes: 1 addition & 35 deletions .vim/syntax/cdo.vim → .vim/after/syntax/sh.vim
Original file line number Diff line number Diff line change
Expand Up @@ -85,35 +85,6 @@ syn keyword cdoKeyword abs acos add addc adipot adisit aexpr aexprf after afterb
\ zonstd zonstd1 zonsum zonvar zonvar1

" match brackets
syn match cdoOperator "(/"
syn match cdoOperator "\/)"
syn match cdoOperator "\\"
syn match cdoOperator "{"
syn match cdoOperator "\}"


" cdo numbers (ripped off from fortran.vim)
syn match cdoNumber display "\<\d\+\(_\a\w*\)\=\>"
syn match cdoNumber display "\<\d\+[deq][-+]\=\d\+\(_\a\w*\)\=\>"
syn match cdoNumber display "\.\d\+\([deq][-+]\=\d\+\)\=\(_\a\w*\)\=\>"
syn match cdoNumber display "\<\d\+\.\([deq][-+]\=\d\+\)\=\(_\a\w*\)\=\>"
syn match cdoNumber display "\<\d\+\.\d\+\([dq][-+]\=\d\+\)\=\(_\a\w*\)\=\>"
syn match cdoNumber display "\<\d\+\.\d\+\(e[-+]\=\d\+\)\=\(_\a\w*\)\=\>"


" pattern matching for comments
syn match cdoComment "^\ *#.*$"
syn match cdoComment "#.*"

" pattern matching for placeholders
syn region cdoVariable start=+${+ end=+}+
"syn region cdoVariable start=+regexdollarsign+ end=+regexspace+

" pattern matching for strings
syn region cdoString start=+"+ end=+"+
syn region cdoString start=+'+ end=+'+

" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
Expand All @@ -126,12 +97,7 @@ if version >= 508 || !exists("did_cdo_syn_inits")
endif

HiLink cdoBUILTIN Function
HiLink cdoKeyword Function "Keyword
HiLink cdoOperator Operator
HiLink cdoNumber Number
HiLink cdoComment Comment
HiLink cdoString String
HiLink cdoVariable Function
HiLink cdoKeyword Function

delcommand HiLink
endif
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ The current setting completes up to the last common string and then shows a menu
<br>

For syntax highlighting: <br>
1. coming soon <br>
1. Copy the file ".vim/after/syntax/sh.vim" and make sure your ".vimrc" contains```
syntax on
```
This works for '*.bash', '*.ksh' and '*.sh'-files.
Operating instructions
Expand Down Expand Up @@ -92,6 +95,7 @@ Changelog
* v0.1: basic auto-complete function based on cdoCompletion.bash as of 2016/09/06
* v0.2: some MPI-ESM variables included for HAMOCC: 2d, 3d and sediment; MPIOM: 2d, 3d and ECHAM6: BOT, LOG, ...; checkout this repositories ".vim/dictionary"
* v1.0: completly new approach: uses all 'cdo --operators' listings installed on your machine, requires cdo-1.7.1 or later, also completes variables gathered by 'cdo vardes files', requires '*.sh' files, variable_completion and cdo_completion can be enabled or disabled in .vimrc
* v1.1 syntax included: is applied after the current '?sh' syntax, so cdoKeywords are included
Working on
----------
Expand Down
11 changes: 8 additions & 3 deletions add_cdo_complete_to_your_vimrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
syntax on

" format intendation in whole document with "gg=G" or single line with "gg"
filetype plugin indent on

"++++++++++++++++++++++++++++++++++++
"++++++++++ CDO COMPLETION ++++++++++
"++++++++++++++++++++++++++++++++++++
Expand All @@ -6,7 +11,7 @@
" * you hit <C-X><C-U>
" * cdo_completion is enabled
" * cdo_version is later than 1.7.1
" * filename extension is 'sh'
" * filename extension is 'sh', should also work for ksh and bash, if not change the repositories filename .vim/after/syntax/sh.vim accordingly
"
" also a variable completion for your most-used files is done if
" * filepath of those datasets is set
Expand Down Expand Up @@ -101,9 +106,9 @@ if bufname("%")[-2:] == 'sh' && s:cdo_completion == 'ENABLE'
endif
endfun
endif "for check cdo_version > 1.7.1
" if filename is not *.sh
" if filename is not *sh, eg. .bash, .sh, .ksh
else
silent echo "if you want to use cdo completion, please change filename to *.sh or change your .vimrc"
silent echo "if you want to use cdo completion, please change filename to *sh or change your .vimrc"
endif

"++++++++++++++++++++++++++++++++++++
Expand Down
9 changes: 2 additions & 7 deletions example.vimrc
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
" +++++++++++ SYNTAX ++++++++++++++
au BufRead,BufNewFile *.sh set filetype=cdo
au! Syntax newlang source $VIM/cdo.vim
syntax on

" format intendation in whole document with "gg=G" or single line with "gg"
filetype plugin indent on

" general completion options
set completeopt=longest,menu

" autointend
set ai
set ru

set showmatch

"tab = 4 spaces
set tabstop=4
set tabstop=2

" autocompletion for file
set autochdir
Expand Down

0 comments on commit ec5b3a3

Please sign in to comment.