Skip to content

Commit ec5b3a3

Browse files
author
aaronspring
committed
v1.1 syntax after *sh
1 parent c8fb99b commit ec5b3a3

4 files changed

Lines changed: 16 additions & 46 deletions

File tree

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -85,35 +85,6 @@ syn keyword cdoKeyword abs acos add addc adipot adisit aexpr aexprf after afterb
8585
\ zonstd zonstd1 zonsum zonvar zonvar1
8686
8787

88-
" match brackets
89-
syn match cdoOperator "(/"
90-
syn match cdoOperator "\/)"
91-
syn match cdoOperator "\\"
92-
syn match cdoOperator "{"
93-
syn match cdoOperator "\}"
94-
95-
96-
" cdo numbers (ripped off from fortran.vim)
97-
syn match cdoNumber display "\<\d\+\(_\a\w*\)\=\>"
98-
syn match cdoNumber display "\<\d\+[deq][-+]\=\d\+\(_\a\w*\)\=\>"
99-
syn match cdoNumber display "\.\d\+\([deq][-+]\=\d\+\)\=\(_\a\w*\)\=\>"
100-
syn match cdoNumber display "\<\d\+\.\([deq][-+]\=\d\+\)\=\(_\a\w*\)\=\>"
101-
syn match cdoNumber display "\<\d\+\.\d\+\([dq][-+]\=\d\+\)\=\(_\a\w*\)\=\>"
102-
syn match cdoNumber display "\<\d\+\.\d\+\(e[-+]\=\d\+\)\=\(_\a\w*\)\=\>"
103-
104-
105-
" pattern matching for comments
106-
syn match cdoComment "^\ *#.*$"
107-
syn match cdoComment "#.*"
108-
109-
" pattern matching for placeholders
110-
syn region cdoVariable start=+${+ end=+}+
111-
"syn region cdoVariable start=+regexdollarsign+ end=+regexspace+
112-
113-
" pattern matching for strings
114-
syn region cdoString start=+"+ end=+"+
115-
syn region cdoString start=+'+ end=+'+
116-
11788
" Define the default highlighting.
11889
" For version 5.7 and earlier: only when not done already
11990
" For version 5.8 and later: only when an item doesn't have highlighting yet
@@ -126,12 +97,7 @@ if version >= 508 || !exists("did_cdo_syn_inits")
12697
endif
12798

12899
HiLink cdoBUILTIN Function
129-
HiLink cdoKeyword Function "Keyword
130-
HiLink cdoOperator Operator
131-
HiLink cdoNumber Number
132-
HiLink cdoComment Comment
133-
HiLink cdoString String
134-
HiLink cdoVariable Function
100+
HiLink cdoKeyword Function
135101

136102
delcommand HiLink
137103
endif

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ The current setting completes up to the last common string and then shows a menu
4747
<br>
4848

4949
For syntax highlighting: <br>
50-
1. coming soon <br>
50+
1. Copy the file ".vim/after/syntax/sh.vim" and make sure your ".vimrc" contains```
51+
syntax on
52+
```
53+
This works for '*.bash', '*.ksh' and '*.sh'-files.
5154
5255
5356
Operating instructions
@@ -92,6 +95,7 @@ Changelog
9295
* v0.1: basic auto-complete function based on cdoCompletion.bash as of 2016/09/06
9396
* 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"
9497
* 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
98+
* v1.1 syntax included: is applied after the current '?sh' syntax, so cdoKeywords are included
9599
96100
Working on
97101
----------

add_cdo_complete_to_your_vimrc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
syntax on
2+
3+
" format intendation in whole document with "gg=G" or single line with "gg"
4+
filetype plugin indent on
5+
16
"++++++++++++++++++++++++++++++++++++
27
"++++++++++ CDO COMPLETION ++++++++++
38
"++++++++++++++++++++++++++++++++++++
@@ -6,7 +11,7 @@
611
" * you hit <C-X><C-U>
712
" * cdo_completion is enabled
813
" * cdo_version is later than 1.7.1
9-
" * filename extension is 'sh'
14+
" * filename extension is 'sh', should also work for ksh and bash, if not change the repositories filename .vim/after/syntax/sh.vim accordingly
1015
"
1116
" also a variable completion for your most-used files is done if
1217
" * filepath of those datasets is set
@@ -101,9 +106,9 @@ if bufname("%")[-2:] == 'sh' && s:cdo_completion == 'ENABLE'
101106
endif
102107
endfun
103108
endif "for check cdo_version > 1.7.1
104-
" if filename is not *.sh
109+
" if filename is not *sh, eg. .bash, .sh, .ksh
105110
else
106-
silent echo "if you want to use cdo completion, please change filename to *.sh or change your .vimrc"
111+
silent echo "if you want to use cdo completion, please change filename to *sh or change your .vimrc"
107112
endif
108113

109114
"++++++++++++++++++++++++++++++++++++

example.vimrc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
1-
" +++++++++++ SYNTAX ++++++++++++++
2-
au BufRead,BufNewFile *.sh set filetype=cdo
3-
au! Syntax newlang source $VIM/cdo.vim
41
syntax on
52

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

8-
" general completion options
9-
set completeopt=longest,menu
10-
116
" autointend
127
set ai
138
set ru
149

1510
set showmatch
1611

1712
"tab = 4 spaces
18-
set tabstop=4
13+
set tabstop=2
1914

2015
" autocompletion for file
2116
set autochdir

0 commit comments

Comments
 (0)