From ec5b3a337453c0bdba3a38ad63524f8dca0b27ab Mon Sep 17 00:00:00 2001 From: aaronspring Date: Fri, 21 Oct 2016 00:40:35 +0200 Subject: [PATCH] v1.1 syntax after *sh --- .vim/{syntax/cdo.vim => after/syntax/sh.vim} | 36 +------------------- README.md | 6 +++- add_cdo_complete_to_your_vimrc | 11 ++++-- example.vimrc | 9 ++--- 4 files changed, 16 insertions(+), 46 deletions(-) rename .vim/{syntax/cdo.vim => after/syntax/sh.vim} (86%) diff --git a/.vim/syntax/cdo.vim b/.vim/after/syntax/sh.vim similarity index 86% rename from .vim/syntax/cdo.vim rename to .vim/after/syntax/sh.vim index f2e2648..dbb56aa 100644 --- a/.vim/syntax/cdo.vim +++ b/.vim/after/syntax/sh.vim @@ -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 @@ -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 diff --git a/README.md b/README.md index cb447f8..e5d523f 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,10 @@ The current setting completes up to the last common string and then shows a menu
For syntax highlighting:
-1. coming soon
+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 @@ -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 ---------- diff --git a/add_cdo_complete_to_your_vimrc b/add_cdo_complete_to_your_vimrc index b82b33b..68fc7ff 100644 --- a/add_cdo_complete_to_your_vimrc +++ b/add_cdo_complete_to_your_vimrc @@ -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 ++++++++++ "++++++++++++++++++++++++++++++++++++ @@ -6,7 +11,7 @@ " * you hit " * 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 @@ -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 "++++++++++++++++++++++++++++++++++++ diff --git a/example.vimrc b/example.vimrc index 005bcf3..30f19ec 100644 --- a/example.vimrc +++ b/example.vimrc @@ -1,13 +1,8 @@ -" +++++++++++ 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 @@ -15,7 +10,7 @@ set ru set showmatch "tab = 4 spaces -set tabstop=4 +set tabstop=2 " autocompletion for file set autochdir