Skip to content

Commit

Permalink
2013-03-17 update
Browse files Browse the repository at this point in the history
  • Loading branch information
ma6174 committed Mar 17, 2013
1 parent 640abdb commit 847bbde
Show file tree
Hide file tree
Showing 39 changed files with 1,258 additions and 17 deletions.
84 changes: 68 additions & 16 deletions .vimrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"golang
"
set rtp+=$GOROOT/misc/vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 显示相关
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set cul "高亮光标所在行
Expand All @@ -17,7 +20,7 @@ set scrolloff=3 " 光标移动到buffer的顶部和底部时保持3行距离
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")} "状态行显示的内容
set laststatus=2 " 启动显示状态行(1),总是显示状态行(2)
"set foldenable " 允许折叠
"set foldmethod=manual " 手动折叠
""set foldmethod=manual " 手动折叠
set nocompatible "去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限
" 显示中文帮助
if version >= 603
Expand Down Expand Up @@ -62,6 +65,7 @@ set iskeyword+=_,$,@,%,#,-

"markdown配置
au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} set filetype=mkd
au BufRead,BufNewFile *.{go} set filetype=go
"rkdown to HTML
nmap md :!~/.vim/markdown.pl % > %.html <CR><CR>
nmap fi :!firefox %.html & <CR><CR>
Expand Down Expand Up @@ -126,11 +130,16 @@ endfunc
:nmap <silent> <F9> <ESC>:Tlist<RETURN>
map! <C-Z> <Esc>zzi
map! <C-O> <C-Y>,
map <C-A> ggVGY
map! <C-A> <Esc>ggVGY
map <C-A> ggVG$"+y
map <F12> gg=G
" 选中状态下 Ctrl+c 复制
map <C-v> "*pa
imap <C-v> <Esc>"*pa
imap <C-a> <Esc>^
imap <C-e> <Esc>$
vmap <C-c> "+y
set mouse=v
"set clipboard=unnamed
"去空行
nnoremap <F2> :g/^\s*$/d<CR>
"比较文件
Expand All @@ -146,19 +155,22 @@ func! CompileRunGcc()
exec "w"
if &filetype == 'c'
exec "!g++ % -o %<"
exec "! ./%<"
exec "!time ./%<"
elseif &filetype == 'cpp'
exec "!g++ % -o %<"
exec "! ./%<"
exec "!time ./%<"
elseif &filetype == 'java'
exec "!javac %"
exec "!java %<"
exec "!time java %<"
elseif &filetype == 'sh'
:!./%
:!time bash %
elseif &filetype == 'python'
exec "!python2.7 %"
exec "!time python2.7 %"
elseif &filetype == 'html'
exec "!firefox % &"
elseif &filetype == 'go'
" exec "!go build %<"
exec "!time go run %"
elseif &filetype == 'mkd'
" exec "!touch ~/temp.html"
" exec "!perl ~/.vim/markdown.pl % > /tmp/temp.html<"<CR>
Expand Down Expand Up @@ -208,9 +220,9 @@ set cursorline " 突出显示当前行
set magic " 设置魔术
set guioptions-=T " 隐藏工具栏
set guioptions-=m " 隐藏菜单栏
set foldcolumn=0
set foldmethod=indent
set foldlevel=3
""set foldcolumn=0
""set foldmethod=indent
""set foldlevel=3
" 不要使用vi的键盘模式,而是vim自己的
set nocompatible
" 去掉输入错误的提示声音
Expand Down Expand Up @@ -249,8 +261,6 @@ set matchtime=1
set scrolloff=3
" 为C程序提供自动缩进
set smartindent
" 高亮显示普通txt文件(需要txt.vim脚本)
au BufRead,BufNewFile * setfiletype txt
"自动补全
"":inoremap ( ()<ESC>i
"":inoremap ) <c-r>=ClosePair(')')<CR>
Expand All @@ -277,8 +287,8 @@ let Tlist_Sort_Type = "name" " 按照名称排序
let Tlist_Use_Right_Window = 1 " 在右侧显示窗口
let Tlist_Compart_Format = 1 " 压缩方式
let Tlist_Exist_OnlyWindow = 1 " 如果只有一个buffer,kill窗口也kill掉buffer
let Tlist_File_Fold_Auto_Close = 0 " 不要关闭其他文件的tags
let Tlist_Enable_Fold_Column = 0 " 不要显示折叠树
""let Tlist_File_Fold_Auto_Close = 0 " 不要关闭其他文件的tags
""let Tlist_Enable_Fold_Column = 0 " 不要显示折叠树
"let Tlist_Show_One_File=1 "不同时显示多个文件的tag,只显示当前文件的
"设置tags
"set tags=tags
Expand Down Expand Up @@ -356,3 +366,45 @@ let &termencoding=&encoding
autocmd FileType python set omnifunc=pythoncomplete#Complete


"set nocompatible " be iMproved
"filetype off " required!

set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'

" My Bundles here:
"
" original repos on github
Bundle 'tpope/vim-fugitive'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
"ndle 'tpope/vim-rails.git'
" vim-scripts repos
Bundle 'L9'
Bundle 'FuzzyFinder'
" non github repos
Bundle 'git://git.wincent.com/command-t.git'
Bundle 'Auto-Pairs'
Bundle 'python-imports.vim'
Bundle 'CaptureClipboard'
Bundle 'ctrlp-modified.vim'
Bundle 'last_edit_marker.vim'
"Bundle 'Python-mode-klen'
Bundle 'SQLComplete.vim'
"Bundle 'djangojump'
" ...

filetype plugin indent on " required!
"
" Brief help
" :BundleList - list configured bundles
" :BundleInstall(!) - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
" :BundleClean(!) - confirm(or auto-approve) removal of unused bundles
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Bundle command are not allowed..
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
* vim插件
* zsh配置文件

## 使用方法:
1. 安装ctags:`sudo apt-get install ctags`
- clone配置文件:`cd ~/ && git clone git://github.com/ma6174/vim.git`
- `mv ~/vim ~/.vim`
- `mv ~/.vim/.vimrc ~/`

## 2013年3月17日更新:
1. 增加go语言插件
- 增加bundle支持
- 修复小bug

##2012年7月28日更新:
1. 增加vimim输入法
* 增加多个pyhon插件,目前支持编码检测,自动增加文件头,自动补全,错误检测,一键执行python脚本
Expand Down
49 changes: 49 additions & 0 deletions autoload/go/complete.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
" Copyright 2011 The Go Authors. All rights reserved.
" Use of this source code is governed by a BSD-style
" license that can be found in the LICENSE file.
"
" This file provides a utility function that performs auto-completion of
" package names, for use by other commands.

let s:goos = $GOOS
let s:goarch = $GOARCH

if len(s:goos) == 0
if exists('g:golang_goos')
let s:goos = g:golang_goos
elseif has('win32') || has('win64')
let s:goos = 'windows'
elseif has('macunix')
let s:goos = 'darwin'
else
let s:goos = '*'
endif
endif

if len(s:goarch) == 0
if exists('g:golang_goarch')
let s:goarch = g:golang_goarch
else
let s:goarch = '*'
endif
endif

function! go#complete#Package(ArgLead, CmdLine, CursorPos)
let goroot = $GOROOT
if len(goroot) == 0
" should not occur.
return []
endif
let ret = {}
let root = expand(goroot.'/pkg/'.s:goos.'_'.s:goarch)
for i in split(globpath(root, a:ArgLead.'*'), "\n")
if isdirectory(i)
let i .= '/'
elseif i !~ '\.a$'
continue
endif
let i = substitute(substitute(i[len(root)+1:], '[\\]', '/', 'g'), '\.a$', '', 'g')
let ret[i] = i
endfor
return sort(keys(ret))
endfunction
1 change: 1 addition & 0 deletions bundle/.vundle/script-names.vim-scripts.org.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions bundle/Auto-Pairs
Submodule Auto-Pairs added at c5b4f9
1 change: 1 addition & 0 deletions bundle/CaptureClipboard
Submodule CaptureClipboard added at f76094
1 change: 1 addition & 0 deletions bundle/FuzzyFinder
Submodule FuzzyFinder added at b9f165
1 change: 1 addition & 0 deletions bundle/L9
Submodule L9 added at c822b0
1 change: 1 addition & 0 deletions bundle/PHP-correct-Indenting
Submodule PHP-correct-Indenting added at 0b9c64
1 change: 1 addition & 0 deletions bundle/SQLComplete.vim
Submodule SQLComplete.vim added at f30188
1 change: 1 addition & 0 deletions bundle/command-t
Submodule command-t added at 07087e
1 change: 1 addition & 0 deletions bundle/ctrlp-modified.vim
Submodule ctrlp-modified.vim added at 175c0d
1 change: 1 addition & 0 deletions bundle/last_edit_marker.vim
Submodule last_edit_marker.vim added at 6e6b33
1 change: 1 addition & 0 deletions bundle/php.vim
Submodule php.vim added at 66a448
1 change: 1 addition & 0 deletions bundle/php.vim-for-php5
Submodule php.vim-for-php5 added at 59dced
1 change: 1 addition & 0 deletions bundle/php_funcinfo.vim
Submodule php_funcinfo.vim added at f8229c
1 change: 1 addition & 0 deletions bundle/phpcomplete.vim
Submodule phpcomplete.vim added at 616e13
1 change: 1 addition & 0 deletions bundle/phpcs.vim
Submodule phpcs.vim added at f34406
1 change: 1 addition & 0 deletions bundle/python-imports.vim
Submodule python-imports.vim added at aca7be
1 change: 1 addition & 0 deletions bundle/sparkup
Submodule sparkup added at 5041a1
1 change: 1 addition & 0 deletions bundle/vim-easymotion
Submodule vim-easymotion added at 667a66
1 change: 1 addition & 0 deletions bundle/vim-fugitive
Submodule vim-fugitive added at 6f380f
1 change: 1 addition & 0 deletions bundle/vundle
Submodule vundle added at c9d971
23 changes: 23 additions & 0 deletions ftdetect/gofiletype.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
" We take care to preserve the user's fileencodings and fileformats,
" because those settings are global (not buffer local), yet we want
" to override them for loading Go files, which are defined to be UTF-8.
let s:current_fileformats = ''
let s:current_fileencodings = ''

" define fileencodings to open as utf-8 encoding even if it's ascii.
function! s:gofiletype_pre()
let s:current_fileformats = &g:fileformats
let s:current_fileencodings = &g:fileencodings
set fileencodings=utf-8 fileformats=unix
setlocal filetype=go
endfunction

" restore fileencodings as others
function! s:gofiletype_post()
let &g:fileformats = s:current_fileformats
let &g:fileencodings = s:current_fileencodings
endfunction

au BufNewFile *.go setlocal filetype=go fileencoding=utf-8 fileformat=unix
au BufRead *.go call s:gofiletype_pre()
au BufReadPost *.go call s:gofiletype_post()
44 changes: 44 additions & 0 deletions ftplugin/go/fmt.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
" Copyright 2011 The Go Authors. All rights reserved.
" Use of this source code is governed by a BSD-style
" license that can be found in the LICENSE file.
"
" fmt.vim: Vim command to format Go files with gofmt.
"
" This filetype plugin add a new commands for go buffers:
"
" :Fmt
"
" Filter the current Go buffer through gofmt.
" It tries to preserve cursor position and avoids
" replacing the buffer with stderr output.
"

command! -buffer Fmt call s:GoFormat()

function! s:GoFormat()
let view = winsaveview()
silent %!gofmt
if v:shell_error
let errors = []
for line in getline(1, line('$'))
let tokens = matchlist(line, '^\(.\{-}\):\(\d\+\):\(\d\+\)\s*\(.*\)')
if !empty(tokens)
call add(errors, {"filename": @%,
\"lnum": tokens[2],
\"col": tokens[3],
\"text": tokens[4]})
endif
endfor
if empty(errors)
% | " Couldn't detect gofmt error format, output errors
endif
undo
if !empty(errors)
call setloclist(0, errors, 'r')
endif
echohl Error | echomsg "Gofmt returned error" | echohl None
endif
call winrestview(view)
endfunction

" vim:ts=4:sw=4:et
13 changes: 13 additions & 0 deletions ftplugin/go/godoc.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
" Copyright 2011 The Go Authors. All rights reserved.
" Use of this source code is governed by a BSD-style
" license that can be found in the LICENSE file.
"
" godoc.vim: Vim command to see godoc.

if exists("b:did_ftplugin")
finish
endif

silent! nmap <buffer> <silent> K <Plug>(godoc-keyword)
" vim:ts=4:sw=4:et
Loading

0 comments on commit 847bbde

Please sign in to comment.