您好,登錄后才能下訂單哦!
這篇文章主要介紹了樹莓派中如何搭建vim IDE,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
1.安裝vundle插件;
2.安裝vim-go;
3.安裝最為頭大的YouCompleteMe;
通過git clone 來離線安裝YouCompleteMe。步驟如下:
cd ~/.vim/bundle
然后執行
git clone https://gitee.com/Random_Coder/YouCompleteMe.git
把YouCompleteMe目錄的所有者改為當前用戶(bysu)
sudo chown -R bysu:bysu YouCompleteMe
然后執行
git submodule update --init --recursive
報上面的錯一般是因為curl的postBuffer的默認值太小和git clone速度太慢,可能被限制了,現在貼出這兩方面的解決方案。
postBuffer的默認值太小:
在這里,筆者把postBuffer的值配置成500M,對筆者來說已經夠了。可以根據你需要下載的文件大小,將postBuffer值配置成合適的大小。
git config --global http.postBuffer 524288000
這樣已經配置好了,如果你不確定,可以根據以下命令查看postBuffer。
git config --list
————————————————
版權聲明:本文為CSDN博主「Jane.zhong」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/dzhongjie/article/details/81152983
git clone速度太慢
1、查找域名對應的ip地址,并修改hosts文件
先執行 pacman -Sy dnsutils 安裝dnsutils,要不會提示沒有nslookup命令。 ifconfig,route在net-tools中,nslookup,dig在dnsutils中,ftp,telnet等在inetutils中,ip命令在iproute2中;netcfg
nslookup github.global.ssl.fastly.Net
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: github.global.ssl.fastly.Net
Address: 151.101.229.194
nslookup github.com
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: github.com
Address: 13.229.188.59
sudo vim /etc/hosts
在文末加上下面兩行,下面分別對應上面查出來標了底色部分的內容。然后重啟網絡服務,archlinux上重啟網絡服務的命令找到了,但是提示不對,反正我是直接重啟了的。
解決掉git clone慢的問題后,可以直接通過git clone把相關文件下到對應的目錄
cd /home/bysu/.vim/bundle/YouCompleteMe/third_party git clone https://github.com/Valloric/ycmd
繼續執行
git submodule update --init --recursive
不行就多試幾次,搞完之后,要安裝
編譯之前先安裝: cmake gcc
sudo pacman -Sy cmake gcc
安裝完后,開始執行下面進行編譯
cd ~/.vim/bundle/YouCompleteMe ./install.py ##########如果需要支持golang######## ./install.py --go-completer ##########如果需要同時支持多種語言如:golang,java,C######## ./install.py --go-completer --java-completer --clangd-completer ##########如果需要插件當前支持的所有語言######## ./install.py --all
開始編譯之后,我被卡在了45%那個地方,我以為是樹莓派性能太差了的原因,第二天起來還是在45%,打算留個三天三夜,誰知道過一兩個小時就報錯了。這個時候連報錯都覺得是好消息——報錯沒關系,就怕卡在那里又沒錯誤。
[ 42%] Building CXX object BoostParts/CMakeFiles/BoostParts.dir/libs/regex/src/regex_raw_buffer.cpp.o [ 45%] Building CXX object BoostParts/CMakeFiles/BoostParts.dir/libs/regex/src/regex_traits_defaults.cpp.o c++: fatal error: Killed signal terminated program cc1plus compilation terminated. make[3]: *** [BoostParts/CMakeFiles/BoostParts.dir/build.make:232: BoostParts/CMakeFiles/BoostParts.dir/libs/regex/src/instances.cpp.o] Error 1 make[3]: *** Waiting for unfinished jobs.... make[3]: Leaving directory '/tmp/ycm_build_galdq8zl' make[2]: *** [CMakeFiles/Makefile2:115: BoostParts/CMakeFiles/BoostParts.dir/all] Error 2 make[2]: Leaving directory '/tmp/ycm_build_galdq8zl' make[1]: *** [CMakeFiles/Makefile2:149: ycm/CMakeFiles/ycm_core.dir/rule] Error 2 make[1]: Leaving directory '/tmp/ycm_build_galdq8zl' make: *** [Makefile:131: ycm_core] Error 2 ERROR: the build failed. NOTE: it is *highly* unlikely that this is a bug but rather that this is a problem with the configuration of your system or a missing dependency. Please carefully read CONTRIBUTING.md and if you're sure that it is a bug, please raise an issue on the issue tracker, including the entire output of this script and the invocation line used to run it.
搜索發現是因為樹莓派內存不足引起報錯。
解決方案: 通過增加swap交換分區來解決
sudo fdisk -l #########上面命令執行后,輸出如下################# Disk /dev/mmcblk0: 29.74 GiB, 31914983424 bytes, 62333952 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xa1b33fd1 Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 2048 206847 204800 100M c W95 FAT32 (LBA) /dev/mmcblk0p2 206848 62333951 62127104 29.6G 83 Linux ######################### sudo mkdir -p /var/cache/swap/ sudo dd if=/dev/mmcblk0 of=/var/cache/swap/swap0 bs=1M count=512 #/dev/mmcblk0根據上面命令查看 sudo chmod 0600 /var/cache/swap/swap0 sudo mkswap /var/cache/swap/swap0 sudo swapon /var/cache/swap/swap0 但是這樣并不能在系統重啟的時候自動掛載交換分區, 這樣我們就需要修改 fstab. 修改 /etc/fstab 文件, 新增如下內容: /var/cache/swap/swap0 none swap sw 0 0 這樣每次重啟的時候就會自動掛載swap文件了 ———————————————— 版權聲明:本文為CSDN博主「little_stupid_child」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。 原文鏈接:https://blog.csdn.net/little_stupid_child/article/details/79188015
如果報下面的錯,則按照sudo pacman -Sy make
(1/1) Arming ConditionNeedsUpdate... [bysu@alarm YouCompleteMe]$ ./install.py --go-completer --java-completer --clangd-completer Searching Python 3.8 libraries... Found Python library: /usr/lib/libpython3.8.so Found Python headers folder: /usr/include/python3.8 CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool. CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage -- Configuring incomplete, errors occurred! See also "/tmp/ycm_build_v8ewnuk5/CMakeFiles/CMakeOutput.log". ERROR: the build failed.
再重新編譯,這次100%了,總算成功了。
[ 88%] Building CXX object ycm/CMakeFiles/ycm_core.dir/Result.cpp.o [ 90%] Building CXX object ycm/CMakeFiles/ycm_core.dir/Utils.cpp.o [ 92%] Building CXX object ycm/CMakeFiles/ycm_core.dir/Word.cpp.o [ 95%] Building CXX object ycm/CMakeFiles/ycm_core.dir/versioning.cpp.o [ 97%] Building CXX object ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o [100%] Linking CXX shared library /home/bysu/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_core.so make[3]: Leaving directory '/tmp/ycm_build_u4swi38l' [100%] Built target ycm_core make[2]: Leaving directory '/tmp/ycm_build_u4swi38l' make[1]: Leaving directory '/tmp/ycm_build_u4swi38l' CMake Error: The source directory "/home/bysu/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/cregex" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI. ERROR: the build failed.
哈哈哈,功夫不負有心人啊!慢著“ERROR: the build failed.”是什么鬼?竟然構建失敗了!!!!
通過搜索
CMake Error: The source directory "/home/bysu/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/cregex" does not appear to contain CMakeLists.txt.發現這是因為 ~/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/cregex/ 的內部文件沒有clone下來
解決方案:rm -rf ~/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/cregex (即刪除掉) 再運行git submodule update --init --recursive 然后就可以 ./install.py --go-completer --clang-completer 成功編譯了 ———————————————— 版權聲明:本文為CSDN博主「鈴舟BXVII」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。 原文鏈接:https://blog.csdn.net/weixin_41912158/article/details/88371350
-- Generating done -- Build files have been written to: /tmp/regex_build_znc86h74 make[1]: Entering directory '/tmp/regex_build_znc86h74' make[2]: Entering directory '/tmp/regex_build_znc86h74' make[3]: Entering directory '/tmp/regex_build_znc86h74' Scanning dependencies of target _regex make[3]: Leaving directory '/tmp/regex_build_znc86h74' make[3]: Entering directory '/tmp/regex_build_znc86h74' [ 66%] Building C object CMakeFiles/_regex.dir/regex_3/_regex.c.o [ 66%] Building C object CMakeFiles/_regex.dir/regex_3/_regex_unicode.c.o [100%] Linking C shared library /home/bysu/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/cregex/regex_3/_regex.so make[3]: Leaving directory '/tmp/regex_build_znc86h74' [100%] Built target _regex make[2]: Leaving directory '/tmp/regex_build_znc86h74' make[1]: Leaving directory '/tmp/regex_build_znc86h74' go: downloading golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7
下面是我目前的.vimrc的配置,效果如下:
syntax on "設置編碼" set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936 set termencoding=utf-8 set encoding=utf-8 "顯示行號" set nu "突出顯示當前行 set cursorline "搜索高亮 set hlsearch "啟用鼠標 set mouse=a set selection=exclusive set selectmode=mouse,key "顯示括號匹配 set showmatch "設置Tab長度為4空格" set tabstop=4 "設置自動縮進長度為4空格" set shiftwidth=4 "繼承前一行的縮進方式,適用于多行注釋" set autoindent "設置粘貼模式 set paste "顯示空格和tab鍵在Vim中通過鼠標右鍵粘貼時會在行首多出許多縮進和空格,通過s et paste可以在插入模式下粘貼內容時不會有任何格式變形、胡亂縮進等問題 set listchars=tab:>-,trail:- "總是顯示狀態欄" set laststatus=2 "顯示光標當前位置" set ruler "------------start-godef代碼跳轉------- let g:godef_split=0 "0是當前,1是橫分屏,2是新開一個標簽窗口,3是豎分屏,按ctrl+o返回 let g:godef_same_file_in_same_window=1 """函數在同一個文件中時不需要打開新窗口 "------end_godef------------ "==========快捷鍵============= let mapleader = ',' "-------按鍵映射---------- "快捷鍵退出 autocmd FileType * nmap <Leader>qq :q!<CR> autocmd FileType * nmap <Leader>wq :wq<CR> "nmap <F8> :TagbarToggle<CR> "顯示代碼結構 imap <C-o> :q! "跳轉后返回關閉 let g:miniBufExplMapWindowNavVim = 1 "------------start---打開默認高亮------------- let g:go_highlight_structs = 1 let g:go_highlight_functions = 1 let g:go_highlight_methods = 1 let g:go_highlight_fields = 1 let g:go_highlight_types = 1 let g:go_highlight_operators = 1 let g:go_highlight_build_constraints = 1 "autocmd FileType go nmap <leader>r <Plug>(go-run) %<CR> autocmd FileType go nmap <Leader>gr :!go run %<CR> autocmd FileType go nmap <leader>gb <Plug>(go-build) %<CR> autocmd FileType go nmap <leader>gt <Plug>(go-test) %<CR> autocmd FileType python nmap <leader>pr :!python %<CR> "-------------end--打開默認高亮-------------- "--------------start---NERDTreeToggle------------ "去除第一行的幫助提示 let NERDTreeMinimalUI=1 "let g:NERDTreeWinPos='left' let NERDTreeWinSize=20 " Initial NERDTree width " beautiful let g:NERDChristmasTree=1 "----按<F4>打開NERDTree----- ""map <F4> :NERDTreeToggle<CR> ""autocmd FileType * nmap <Leader>nt :NERDTreeToggle<CR> "----打開vim后,默認開啟NERDTree,且光標在右側 autocmd VimEnter * NERDTree wincmd w autocmd VimEnter * wincmd w "自動退出 ""autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") &&b:NERDTreeType == "primary") | q | endif "--------------end-----NERDTreeToggle------------- "-------start-Tagbar------------ ""let g:tagbar_vertical = 0 "let g:tagbar_left = 1 let g:tagbar_width = 30 "去除第一行的幫助信息 let g:tagbar_compact = 1 "當編輯代碼時,在Tagbar自動追蹤變量 let g:tagbar_autoshowtag = 1 "個人愛好,展開關閉文件夾的圖標 "let g:tagbar_iconchars = ['?', '?'] "<F3>作為toggle ""nmap <F3> :TagbarToggle<CR> ""autocmd FileType * nmap <Leader>tb :TagbarOpen<CR> "打開vim時自動打開 autocmd VimEnter * nested :TagbarOpen ""wincmd l "如果不加這句,打開vim的時候當前光標會在Nerdtree區域 ""autocmd VimEnter * wincmd l nnoremap<leader>n :exe'NERDTreeToggle'<CR> "nnoremap<leader>n :exe'NERDTreeClose'<CR> nnoremap<leader>t :exe'TagbarToggle'<CR> "nnoremap<leader>t :exe'TagbarClose'<CR> let g:tagbar_sort = 0 "close the sort autocmd BufReadPost .go,.java,.py,.cpp,.c,.h,.hpp,.cc call tagbar#autoopen() "------快捷鍵同時打開或關閉nerdtree、tagbar------------- function! ToggleNERDTreeAndTagbar() let w:jumpbacktohere = 1 " Detect which plugins are open if exists('t:NERDTreeBufName') let nerdtree_open = bufwinnr(t:NERDTreeBufName) != -1 else let nerdtree_open = 0 endif let tagbar_open = bufwinnr('__Tagbar__') != -1 " Perform the appropriate action if nerdtree_open && tagbar_open NERDTreeClose TagbarClose elseif nerdtree_open TagbarOpen elseif tagbar_open NERDTree else NERDTree TagbarOpen endif " Jump back to the original window for window in range(1, winnr('$')) execute window . 'wincmd w' if exists('w:jumpbacktohere') unlet w:jumpbacktohere break endif endfor endfunction "調用上面的函數,實現開關nerdtree nnoremap <leader>\ :call ToggleNERDTreeAndTagbar()<CR> "-------------------------------- "------start--expand-region--快速區域選擇------ vmap v <Plug>(expand_region_expand) vmap V <Plug>(expand_region_shrink) "------end--expand-region--快速區域選擇------ "--start-minibufExplorer-vim中創建多了小窗口--- let g:miniBufExplMapWindowNavVim = 1 let g:miniBufExplMapWindowNavArrows = 1 let g:miniBufExplMapCTabSwitchBufs = 1 let g:miniBufExplModSelTarget = 1 let g:miniBufExplMoreThanOne = 0 map <F5> :MBEbp<CR> map <F6> :MBEbn<CR> "讓vimrc配置變更立即生效" "autocmd BufWritePost $MYVIMRC source $MYVIMRC "----------gotar--------ctars------------ let g:tagbar_type_go = { \ 'ctagstype' : 'go', \ 'kinds' : [ \ 'p:package', \ 'i:imports:1', \ 'c:constants', \ 'v:variables', \ 't:types', \ 'n:interfaces', \ 'w:fields', \ 'e:embedded', \ 'm:methods', \ 'r:constructor', \ 'f:functions' \ ], \ 'sro' : '.', \ 'kind2scope' : { \ 't' : 'ctype', \ 'n' : 'ntype' \ }, \ 'scope2kind' : { \ 'ctype' : 't', \ 'ntype' : 'n' \ }, \ 'ctagsbin' : 'gotags', \ 'ctagsargs' : '-sort -silent' \ } "---------start-------ctag----gotar--------- "----start_YouCompleteMe set runtimepath+=~/.vim/bundle/YouCompleteMe let g:ycm_collect_identifiers_from_tags_files = 1 " 開啟 YCM 基于標簽引擎 "-------------start_YouCompleteMe set runtimepath+=~/.vim/bundle/YouCompleteMe let g:ycm_collect_identifiers_from_tags_files = 1 " 開啟 YCM 基于標簽引擎 let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注釋與字符串中的內容也用于補全 let g:syntastic_ignore_files=[".*\.py$"] let g:ycm_seed_identifiers_with_syntax = 1 " 語法關鍵字補全 let g:ycm_complete_in_comments = 1 " 在注釋輸入中也能補全 let g:ycm_complete_in_strings = 1 " 在字符串輸入中也能補全 let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注釋和字符串中的文字也會被收入補全 let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py' let g:ycm_show_diagnostics_ui = 0 " 禁用語法檢查 inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" | " 回車即選中當前項 nnoremap <c-j> :YcmCompleter GoToDefinitionElseDeclaration<CR>| " 跳轉到定義處 let g:ycm_min_num_of_chars_for_completion=2 " 從第2個鍵入字符就開始羅列匹配項 let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/.ycm_extra_conf.py' "YCM配置文件的路徑 " 跳轉快捷鍵 nnoremap <c-k> :YcmCompleter GoToDeclaration<CR>| nnoremap <c-h> :YcmCompleter GoToDefinition<CR>| nnoremap <c-j> :YcmCompleter GoToDefinitionElseDeclaration<CR>| " 停止提示是否載入本地ycm_extra_conf文件 let g:ycm_confirm_extra_conf = 0 " 語法關鍵字補全 let g:ycm_seed_identifiers_with_syntax = 1 " 彈出列表時選擇第1項的快捷鍵(默認為<TAB>和<Down>), 沒有這個會攔截掉tab, 導致其他插件的tab不能用. let g:ycm_key_list_select_completion = ['<C-n>', '<Down>'] " 彈出列表時選擇前1項的快捷鍵(默認為<S-TAB>和<UP>) let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>'] " 主動補全, 默認為<C-Space> let g:ycm_key_invoke_completion = ['<C-Space>'] " 停止顯示補全列表(防止列表影響視野), 可以按<C-Space>重新彈出 let g:ycm_key_list_stop_completion = ['<C-y>'] "-------------end_YouCompleteMe "--------------start_winManagerWindowLayout-------------------------------------------------- "let g:winManagerWindowLayout='NERDTree|Tagbar' "let g:winManagerWidth=30 "let g:AutoOpenWinManager = 1 "這里要配合修改winmanager.vim文件,見下方說明" "let g:NERDTree_title = "[NERDTree]" function! NERDTree_Start() exe 'q' "執行一個退出命令,關閉自動出現的窗口" exe 'NERDTree' endfunction function! NERDTree_IsValid() return 1 endfunction "noremap <f5> :NERDTreeFind<cr> "let g:Tagbar_title = "[Tagbar]" function! Tagbar_Start() exe 'q' "執行一個退出命令,關閉自動出現的窗口" exe 'TagbarOpen' endfunction function! Tagbar_IsValid() return 1 endfunction "let g:tagbar_vertical = 30 "--------------end_winManagerWindowLayout-------------------------------------------------- "============管理插件========== " 你在此設置運行時路徑 set rtp+=/home/bysu/.vim/bundle/Vundle.vim call vundle#begin() " 在這里面輸入安裝的插件 " Vundle 本身就是一個插件 Plugin 'VundleVim/Vundle.vim' Plugin 'fatih/vim-go' "目錄樹 Plugin 'preservim/nerdtree' "代碼提示 Bundle 'Blackrush/vim-gocode' "函數追蹤/代碼跳轉 Bundle 'dgryski/vim-godef' "顯示代碼結構 Plugin 'majutsushi/tagbar' "YouCompleteMe補全 "Plugin 'ycm-core/YouCompleteMe' "多光標同時編輯 Bundle 'terryma/vim-multiple-cursors' "支持git Plugin 'Xuyuanp/nerdtree-git-plugin' "快速選中臨近區域 Plugin 'terryma/vim-expand-region' "括號自動補全 Bundle 'Raimondi/delimitMate' "在vim中創建多了小窗口 Bundle 'fholgado/minibufexpl.vim' "所有插件都應該在這一行之前 call vundle#end() "filetype off filetype plugin indent on
感謝你能夠認真閱讀完這篇文章,希望小編分享的“樹莓派中如何搭建vim IDE”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,更多相關知識等著你來學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。