diff options
author | Tanguy Pruvot <tanguy.pruvot@gmail.com> | 2014-07-06 21:08:37 +0200 |
---|---|---|
committer | Tanguy Pruvot <tanguy.pruvot@gmail.com> | 2014-07-22 07:27:36 +0200 |
commit | 1a6456b1e85aecc01bc112d8a77312f176636ebc (patch) | |
tree | 5a270cade84d623865b57fa09668917abcf66096 | |
parent | 28c1d282af67aa77a36f97b4a96b0a6fef8dbe69 (diff) | |
download | android_external_vim-1a6456b1e85aecc01bc112d8a77312f176636ebc.tar.gz android_external_vim-1a6456b1e85aecc01bc112d8a77312f176636ebc.tar.bz2 android_external_vim-1a6456b1e85aecc01bc112d8a77312f176636ebc.zip |
runtime: add some plugins/autoload files, minimal help
wanted to add tar/gzip/zip support but plugins are
not compatible with busybox tools
Add spacehi.vim to show trailing spaces/tabs with <F9> key
Change-Id: I5881fe878852e6da400a11a9af347572af42fe16
-rw-r--r-- | runtime/autoload/spacehi.vim | 114 | ||||
-rw-r--r-- | src/Android.mk | 42 | ||||
-rw-r--r-- | vimrc.android | 4 |
3 files changed, 154 insertions, 6 deletions
diff --git a/runtime/autoload/spacehi.vim b/runtime/autoload/spacehi.vim new file mode 100644 index 000000000..ae2623508 --- /dev/null +++ b/runtime/autoload/spacehi.vim @@ -0,0 +1,114 @@ +" vim600: set foldmethod=marker: +" $Id: spacehi.vim,v 1.4 2014/07/08 15:37:13 laz Exp $ +" +" Description: Per buffer, togglable syntax highlighting of tabs and trailing +" spaces. +" Author: Adam Lazur <adam@lazur.org> +" Last Change: $Date: 2014/07/08 15:37:13 $ +" URL: http://adam.lazur.org/vim/spacehi.vim +" License: Redistribution and use of this file, with or without +" modification, are permitted without restriction. +" +" Section: Documentation {{{1 +" +" This plugin will highlight tabs and trailing spaces on a line, with the +" ability to toggle the highlighting on and off. Using highlighting to +" illuminate these characters is preferrable to using listchars and set list +" because it allows you to copy from the vim window without getting shrapnel +" in your buffer. +" +" NOTE: "set list" will override SpaceHi's highlighting. +" +" Highlighting can be turned on and off with the functions SpaceHi() and +" NoSpaceHi() respectively. You can also toggle the highlighting state by +" using ToggleSpaceHi(). By default, ToggleSpaceHi is bound to the key F3. +" +" You can customize the colors by setting the following variables to a string +" of key=val that would normally follow "highlight group" command: +" +" g:spacehi_spacecolor +" g:spacehi_tabcolor +" +" The defaults can be found in the "Default Global Vars" section below. +" +" You can give a list of filetypes to exclude +" +" If you want to highlight tabs and trailing spaces by default for every file +" that is syntax highlighted, you can add the following to your vimrc: +" +" autocmd syntax * SpaceHi +" +" The author currently uses the following (a little overboard) in his vimrc: +" +" autocmd BufNewFile,BufReadPost,FilterReadPost,FileReadPost,Syntax * SpaceHi +" au FileType help NoSpaceHi + +" Section: Plugin header {{{1 +" If we have already loaded this file, don't load it again. +if exists("loaded_spacehi") + finish +endif +if !has("syntax") + finish +else + let loaded_spacehi=1 +endif + +" Section: Default Global Vars {{{1 +if !exists("g:spacehi_tabcolor") + " highlight tabs with red underline + let g:spacehi_tabcolor="ctermfg=1 cterm=underline" + let g:spacehi_tabcolor=g:spacehi_tabcolor . " guifg=red gui=underline" +endif +if !exists("g:spacehi_spacecolor") + " highlight trailing spaces in blue underline + let g:spacehi_spacecolor="ctermfg=4 cterm=underline" + let g:spacehi_spacecolor=g:spacehi_spacecolor . " guifg=blue gui=underline" +endif + +" Section: Functions {{{1 +" Function: s:SpaceHi() {{{2 +" Turn on highlighting of spaces and tabs +fun s:SpaceHi() + " highlight tabs + syntax match spacehiTab /\t/ containedin=ALL + execute("highlight spacehiTab " . g:spacehi_tabcolor) + + " highlight trailing spaces + syntax match spacehiTrailingSpace /\s\+$/ containedin=ALL + execute("highlight spacehiTrailingSpace " . g:spacehi_spacecolor) + + let b:spacehi = 1 +endfun + +" Function: s:NoSpaceHi() {{{2 +" Turn off highlighting of spaces and tabs +fun s:NoSpaceHi() + syntax clear spacehiTab + syntax clear spacehiTrailingSpace + let b:spacehi = 0 +endfun + +" Function: s:ToggleSpaceHi() {{{2 +" Toggle highlighting of spaces and tabs +fun s:ToggleSpaceHi() + if exists("b:spacehi") && b:spacehi + call s:NoSpaceHi() + echo "spacehi off" + else + call s:SpaceHi() + echo "spacehi on" + endif +endfun + +" Section: Commands {{{1 +com! SpaceHi call s:SpaceHi() +com! NoSpaceHi call s:NoSpaceHi() +com! ToggleSpaceHi call s:ToggleSpaceHi() + +" Section: Default mappings {{{1 +" Only insert a map to ToggleSpaceHi if they don't already have a map to +" the function and don't have something bound to F9 +if !hasmapto('ToggleSpaceHi') && maparg("<F9>") == "" + map <silent> <unique> <F9> :ToggleSpaceHi<CR> +endif diff --git a/src/Android.mk b/src/Android.mk index 79e1dd976..905f52bdb 100644 --- a/src/Android.mk +++ b/src/Android.mk @@ -93,17 +93,16 @@ vim_runtime_files := \ indent.vim \ indoff.vim \ filetype.vim \ - ftoff.vim + ftoff.vim vim_colors_files := \ default.vim \ desert.vim vim_doc_files := \ - help.txt \ - version7.txt \ - tags \ - term.txt + help.txt intro.txt tags \ + motion.txt editing.txt scroll.txt \ + options.txt term.txt vim_syntax_files := \ awk.vim \ @@ -118,6 +117,7 @@ vim_syntax_files := \ xml.vim dtd.vim \ context.vim \ gitcommit.vim \ + help.vim \ javascript.vim \ java.vim \ manual.vim \ @@ -127,6 +127,12 @@ vim_syntax_files := \ syntax.vim \ vim.vim +vim_plugin_files := \ + matchparen.vim \ + +vim_autoload_files := \ + spacehi.vim \ + VIM_SHARED := $(TARGET_OUT)/usr/share/$(LOCAL_MODULE) VIM_RUNTIME_R := \ @@ -173,7 +179,31 @@ $(VIM_RUNTIME_S): $(LOCAL_INSTALLED_MODULE) ALL_DEFAULT_INSTALLED_MODULES += $(VIM_RUNTIME_S) +VIM_RUNTIME_P := \ + $(addprefix $(vim_runtime_path)/plugin/,$(vim_plugin_files)) +$(VIM_RUNTIME_P): VIM_BINARY := $(LOCAL_MODULE) +$(VIM_RUNTIME_P): $(LOCAL_INSTALLED_MODULE) + @echo "Install: $@ -> $(VIM_SHARED)/plugin/" + @mkdir -p $(VIM_SHARED)/plugin + $(hide) cp $@ $(VIM_SHARED)/plugin/ + +ALL_DEFAULT_INSTALLED_MODULES += $(VIM_RUNTIME_P) + + +VIM_RUNTIME_A := \ + $(addprefix $(vim_runtime_path)/autoload/,$(vim_autoload_files)) +$(VIM_RUNTIME_A): VIM_BINARY := $(LOCAL_MODULE) +$(VIM_RUNTIME_A): $(LOCAL_INSTALLED_MODULE) + @echo "Install: $@ -> $(VIM_SHARED)/autoload/" + @mkdir -p $(VIM_SHARED)/autoload + $(hide) cp $@ $(VIM_SHARED)/autoload/ + +ALL_DEFAULT_INSTALLED_MODULES += $(VIM_RUNTIME_A) + + ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \ $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) \ - $(VIM_RUNTIME_S) $(VIM_RUNTIME_C) $(VIM_RUNTIME_D) $(VIM_RUNTIME_R) + $(VIM_RUNTIME_R) $(VIM_RUNTIME_C) $(VIM_RUNTIME_D) \ + $(VIM_RUNTIME_S) $(VIM_RUNTIME_P) $(VIM_RUNTIME_A) + diff --git a/vimrc.android b/vimrc.android index fc6a1a18a..7363874f6 100644 --- a/vimrc.android +++ b/vimrc.android @@ -95,6 +95,10 @@ if has("multi_byte") set fileencodings=ucs-bom,utf-8,latin1 endif +if has("syntax") + source /system/usr/share/vim/autoload/spacehi.vim +endif + " Convenient command to see the difference between the current buffer and the " file it was loaded from, thus the changes you made. " Only define it when not defined already. |