]> Zhao Yanbai Git Server - acecode.git/commitdiff
add vim plugin document
authoracezhao <acezhao@tencent.com>
Wed, 27 Mar 2019 06:19:47 +0000 (14:19 +0800)
committeracezhao <acezhao@tencent.com>
Wed, 27 Mar 2019 06:19:47 +0000 (14:19 +0800)
documents/vim-plugin.md [new file with mode: 0644]
learn/doc/vimrc
learn/go/closure.go [new file with mode: 0644]
learn/go/variadicfunc.go [new file with mode: 0644]

diff --git a/documents/vim-plugin.md b/documents/vim-plugin.md
new file mode 100644 (file)
index 0000000..5ed4316
--- /dev/null
@@ -0,0 +1,102 @@
+# 安装vim插件
+
+
+## 安装插件总管
+
+`git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim`
+
+在`~/.vimrc`中添加如下代码
+```
+set nocompatible              " be iMproved, required
+filetype off
+set rtp+=~/.vim/bundle/Vundle.vim
+call vundle#begin()
+Plugin 'VundleVim/Vundle.vim'
+Plugin 'fatih/vim-go'
+Plugin 'Valloric/YouCompleteMe'
+Plugin 'Lokaltog/vim-powerline'
+Plugin 'scrooloose/nerdtree'
+Plugin 'Yggdroot/indentLine'
+call vundle#end()
+filetype plugin indent on
+```
+
+
+## 安装vim-go
+
+在`~/.vimrc` 中添加如下代码
+
+```
+call plug#begin()
+
+" ....
+
+call plug#end()
+```
+之间添加`Plugin 'fatih/vim-go'`
+
+退出,再打开vim,执行 `:PluginInstall`
+
+
+# 安装yourcompleteme
+
+如上
+```Plug 'Valloric/YouCompleteMe'```
+
+再`:PlugInstall`
+
+重启vim,输入指令重启ycm服务器 `:YcmRestartServer`
+
+编译的命令:
+```
+cd ~/.vim/bundle/YouCompleteMe
+./install.py --clang-completer
+```
+
+参数 --clang-completer是为了加上C系列语言的自动补全,如果不需要可以不加
+
+
+```
+" 解决 No .ycm_extra_conf.py detected
+let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py"
+
+" 设置回车为补全确认键
+let g:ycm_key_list_stop_completion = ['<CR>']
+```
+
+
+
+## 安装vim-powerline
+```Plugin 'Lokaltog/vim-powerline'```
+
+```
+set laststatus=2   " Always show the statusline
+set encoding=utf-8 " Necessary to show Unicode glyphs
+set t_Co=256
+let g:Powerline_symbols= 'unicode'
+```
+
+
+## 安装NERDTree
+
+```Plugin 'scrooloose/nerdtree'```
+
+```
+" NERDTree 插件的相关配置
+"F2开启和关闭树"
+map <F2> :NERDTreeToggle<CR>
+let NERDTreeChDirMode=1
+"显示书签"
+let NERDTreeShowBookmarks=1
+"设置忽略文件类型"
+let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']
+"窗口大小"
+let NERDTreeWinSize=25
+```
+
+## 安装indentline
+
+```Plugin 'Yggdroot/indentLine'```
+
+
+```:echo has("conceal")``` 如果为0表示vim不带conceal功能,就没法用indentline
index 1e3f596e08bb5943b3c16c4bfd9eddf454645e9f..436087c06d09aa76b37a7c7d82d1ec80a743d346 100644 (file)
@@ -68,6 +68,7 @@ let &guicursor = &guicursor . ",a:blinkon0"
 set number        " 显示行号
 " set autoindent    " 自动对齐
 set smartindent
+
 set tabstop=4     " TAB的宽度
 set shiftwidth=4
 set expandtab     " TAB用空格代替,否则可用 set noexpandtab
@@ -78,14 +79,6 @@ set cursorline
 "hi CursorColumn ctermbg=lightgreen cterm=BOLD
 set viminfo='1000,<500
 
-" 需要安装bundle/vundle vim-go 到~/.vim/
-"filetype off
-"set rtp+=~/.vim/bundle/vundle/
-"call vundle#rc()
-"Bundle 'gmarik/vundle'
-"Plugin 'fatih/vim-go'
-"filetype plugin indent on
-
 " 以下是让mac vim支持中文输入
 set encoding=utf-8  " 默认UTF-8
 set fenc=utf-8      " 默认以UTF-8新建文件
@@ -115,5 +108,52 @@ autocmd FileType asm set expandtab
 " 连续按两次jj表示按ESC,进入命令模式
 imap jj <Esc>
 
+
 " set paste 会使 imap jj <Esc>失效
 "set paste
+
+
+filetype off
+set rtp+=~/.vim/bundle/Vundle.vim
+call vundle#begin()
+Plugin 'VundleVim/Vundle.vim'
+Plugin 'fatih/vim-go'
+Plugin 'Valloric/YouCompleteMe'
+Plugin 'Lokaltog/vim-powerline'
+Plugin 'scrooloose/nerdtree'
+call vundle#end()
+filetype plugin indent on
+
+" youcompleteme插件相关配置
+let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py"
+" 设置回车为补全确认键
+let g:ycm_key_list_stop_completion = ['<CR>']
+
+" vim-powerline插件相关配置
+set laststatus=2   " Always show the statusline
+set encoding=utf-8 " Necessary to show Unicode glyphs
+set t_Co=256
+let g:Powerline_symbols= 'unicode'
+
+" NERDTree 插件的相关配置
+"F2开启和关闭树"
+map <F2> :NERDTreeToggle<CR>
+let NERDTreeChDirMode=1
+"显示书签"
+let NERDTreeShowBookmarks=1
+"设置忽略文件类型"
+let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']
+"窗口大小"
+let NERDTreeWinSize=25
+
+"let g:indentLine_setColors = 0
+"let g:indentLine_color_term = 239
+"let g:indentLine_bgcolor_term = 202
+"let g:indentLine_bgcolor_gui = '#FF5F00'
+"let g:indentLine_char = '|'
+let g:indentLine_color_term = 239
+"let g:indentLine_char_list = ['|', '¦', '┆', '┊']
+"let g:indentLine_enabled=1
+let g:indentLine_char='┆'
+let g:indentLine_enabled = 1
+let g:indentLine_showFirstIndentLevel = 1
diff --git a/learn/go/closure.go b/learn/go/closure.go
new file mode 100644 (file)
index 0000000..34e9832
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * ------------------------------------------------------------------------
+ *   File Name: closure.go
+ *      Author: Zhao Yanbai
+ *              2019-03-18 11:01:25 星期一 CST
+ * Description: none
+ * ------------------------------------------------------------------------
+ */
+package main
+import (
+       "fmt"
+)
+
+
+func Accumulate(value int) func() int {
+    return func() int {
+        value++;
+        return value;
+    }
+}
+
+func main() {
+       defer fmt.Println("Program Exited...")
+
+    accumulatorA := Accumulate(1)
+
+    fmt.Println(accumulatorA())
+    fmt.Println(accumulatorA())
+
+    fmt.Printf("%p\n", accumulatorA);
+
+
+    accumulatorB := Accumulate(1024)
+
+    fmt.Println(accumulatorB())
+    fmt.Println(accumulatorB())
+
+    fmt.Printf("%p\n", accumulatorB);
+}
diff --git a/learn/go/variadicfunc.go b/learn/go/variadicfunc.go
new file mode 100644 (file)
index 0000000..458f972
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * ------------------------------------------------------------------------
+ *   File Name: variadicfunc.go
+ *      Author: Zhao Yanbai
+ *              2019-03-18 15:16:04 星期一 CST
+ * Description: none
+ * ------------------------------------------------------------------------
+ */
+package main
+import (
+       "fmt"
+)
+
+func sum(vals ...int) int {
+    total := 0
+
+    for _, v := range(vals) {
+        total += v
+    }
+
+    return total
+}
+
+
+func rawPrintType(args ...interface{}) {
+    for _, s := range args {
+        fmt.Printf("%T\n", s)
+    }
+}
+
+
+func printType(args ...interface{}) {
+    rawPrintType(args...);
+}
+
+
+func main() {
+       defer fmt.Println("Program Exited...")
+
+    fmt.Println(sum(1, 2, 3, 4, 5))
+
+    var a struct { }
+
+    printType(1, 1.0, true, a)
+}