This is another VIM configuation plugin for NCL (NCAR Command Language). It is better to work with Neocomplete(Neocomplcache) and Neosnippet.
This configure is specified for NCL users, which provide:
-
NCL syntax highlight(as discribed in the official editor enhancement pages)
-
View the official function, precedure, resource manual through tags jump(Shortcut: g])!
-
Expand snippets for ncl languages.
-
It can work in Uinx-Like System, I test it in mac OS X and Linux.The compatibility in Windows(Gvim) is unkonwn.
If you use Vundle to manager your vim plugins, Please add the Plugin 'dongli/vim-ncl'
in ~/.vimrc
, and your ~/.vimrc
looks like
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
" ---> Add you favorate vundle plugins here.
if has('lua')
Plugin 'Shougo/neocomplete.vim'
else
Plugin 'Shougo/neocomplcache.vim'
Plugin 'vim-scripts/AutoComplPop'
endif
Plugin 'ervandew/supertab'
Plugin 'Shougo/neosnippet.vim'
Plugin 'Shougo/neosnippet-snippets'
Plugin 'Shougo/context_filetype.vim'
Plugin 'dongli/vim-ncl'
"" ---> Add you favorate vundle plugins here.
call vundle#end()
filetype plugin on
then Install Plugins:
Launch vim
and run :PluginInstall
To install from command line: vim +PluginInstall +qall
git clone https://github.com/Shougo/neocomplete.vim ~/.vim/bundle/neocomplete.vim
git clone https://github.com/Shougo/neocomplcache.vim ~/.vim/bundle/neocomplcache.vim
git clone https://github.com/vim-scripts/AutoComplPop ~/.vim/bundle/AutoComplPop
git clone https://github.com/ervandew/supertab ~/.vim/bundle/supertab
git clone https://github.com/Shougo/neosnippet.vim ~/.vim/bundle/neosnippet.vim
git clone https://github.com/Shougo/neosnippet-snippets ~/.vim/bundle/neosnippet-snippets
git clone https://github.com/Shougo/context_filetype.vim ~/.vim/bundle/context_filetype.vim
git clone https://github.com/dongli/vim-ncl ~/.vim/bundle/vim-ncl
Download all packages listed in Method.2 and unzip it into $HOME/.vim/bundle
. After that, the directory tree is $HOME/.vim/bundle/
|─ AutoComplPop
|─ Vundle.vim
|─ context_filetype.vim
|─neocomplcache.vim
|─neocomplete.vim
|─ neosnippet-snippets
|─ neosnippet.vim
|─ supertab
|─ vim-ncl
Add those command lines in your .vimrc
when you finished installtion.
" ###################################################
" Vundle settings.
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin('~/.vim/bundle')
Plugin 'gmarik/Vundle.vim'
" ---> Add you favorate vundle plugins here.
if has('lua')
Plugin 'Shougo/neocomplete.vim' " the plugin need lua feature support
else
Plugin 'Shougo/neocomplcache.vim' "if no lua, use neocomplcache.vim instead"
Plugin 'vim-scripts/AutoComplPop'
endif
Plugin 'ervandew/supertab'
Plugin 'Shougo/neosnippet.vim'
Plugin 'Shougo/neosnippet-snippets'
Plugin 'Shougo/context_filetype.vim'
Plugin 'dongli/vim-ncl'
call vundle#end()
filetype plugin on
" Good defaults.
set smarttab
set expandtab
set autoindent
set smartindent
set backspace=indent,eol,start
set hlsearch
set number rnu
syntax on
" Jump to last edit location.
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
" Status bar.
set laststatus=2
set statusline=%F%m\ [type=%Y]\ [line=%l,column=%c,%p%%]
" echofunc
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
":inoremap { {}<ESC>i
":inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap < <><ESC>i
:inoremap > <c-r>=ClosePair('>')<CR>
function! ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf
" use mouse
if has('mouse') "
set mouse=a "
set selection=exclusive
set selectmode=mouse,key
endif
let g:SuperTabDefaultCompletionType = "<c-x><c-n>"
if has('lua')
" NeoComplete settings
" NeoComplete conflict with AutoComplPop"
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_smart_case = 1
let g:neocomplete#enable_cursor_hold_i = 1
" neosnippet mapping setting
inoremap <expr><C-g> neocomplete#undo_completion()
inoremap <expr><C-l> neocomplete#complete_common_string()
else
"NeoComplCache
let g:NeoComplCache_EnableAtStartup = 1
let g:neocomplcache_enable_auto_select = 0
let g:acp_enableAtStartup = 1
let g:NeoComplCache_DisableAutoComplete = 0
endif
" For conceal markers.neosnippet settings
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
"return (pumvisible() ? "\<C-y>" : "" ) . "\<CR>"
" For no inserting <CR> key.
return pumvisible() ? "\<C-y>" : "\<CR>"
endfunction
" use ; to expand the snippets, use other key to replace, change the ; to other key,Here is a detail explaination "
imap <expr>; neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: pumvisible() ? "\<C-p>" : "\;"
" \: pumvisible() ? "\<C-n>" : "\<TAB>"
smap <expr>; neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: "\<TAB>"
" ###################################################
When typing NCL functions,precedures,resources,press Ctrl + n(TAB)
or Ctrl + p
will complete the word. Example:
when the cursor is on NCL functions(precedures)
or NCL resources
text, press g]
in normal model, the cursor will jump to the document of the functions or resources. If the function (precedure) has more than one tag, you need to select it by typing the number of tags. Press Ctrl + t
in normal model, the cursor returns to the original file.
Example:
press g]
, then get this
Press 1
to enter the first tag file
Press Ctrl + t
to return the original file.
The gif below give the detail explanation.
Enter a keyword such as gsn_add_shapefile_polygons
, move cursor bebind the keyword, then press ;
to expand the snippets. And ;
can also mv cursor from the one argeument to the next argeument. In order to expand snippets successfully, ensure there is at least a blank before the keyword
.
- Li Dong dongli@lasg.iap.ac.cn