树莓派中如何搭建vimIDE
这篇文章主要介绍了树莓派中如何搭建vim IDE,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。
创新互联自2013年起,先为湘东等服务建站,湘东等地企业,进行企业商务咨询服务。为湘东企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
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 * nmapqq :q! autocmd FileType * nmap wq :wq "nmap :TagbarToggle "显示代码结构 imap :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 r (go-run) % autocmd FileType go nmap gr :!go run % autocmd FileType go nmap gb (go-build) % autocmd FileType go nmap gt (go-test) % autocmd FileType python nmap pr :!python % "-------------end--打开默认高亮-------------- "--------------start---NERDTreeToggle------------ "去除第一行的帮助提示 let NERDTreeMinimalUI=1 "let g:NERDTreeWinPos='left' let NERDTreeWinSize=20 " Initial NERDTree width " beautiful let g:NERDChristmasTree=1 "----按 打开NERDTree----- ""map :NERDTreeToggle ""autocmd FileType * nmap nt :NERDTreeToggle "----打开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 = ['▸', '▾'] " 作为toggle ""nmap :TagbarToggle ""autocmd FileType * nmap tb :TagbarOpen "打开vim时自动打开 autocmd VimEnter * nested :TagbarOpen ""wincmd l "如果不加这句,打开vim的时候当前光标会在Nerdtree区域 ""autocmd VimEnter * wincmd l nnoremap n :exe'NERDTreeToggle' "nnoremap n :exe'NERDTreeClose' nnoremap t :exe'TagbarToggle' "nnoremap t :exe'TagbarClose' 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 \ :call ToggleNERDTreeAndTagbar() "-------------------------------- "------start--expand-region--快速区域选择------ vmap v (expand_region_expand) vmap V (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 :MBEbp map :MBEbn "让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 pumvisible() ? "\ " : "\ " | " 回车即选中当前项 nnoremap :YcmCompleter GoToDefinitionElseDeclaration | " 跳转到定义处 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 :YcmCompleter GoToDeclaration | nnoremap :YcmCompleter GoToDefinition | nnoremap :YcmCompleter GoToDefinitionElseDeclaration | " 停止提示是否载入本地ycm_extra_conf文件 let g:ycm_confirm_extra_conf = 0 " 语法关键字补全 let g:ycm_seed_identifiers_with_syntax = 1 " 弹出列表时选择第1项的快捷键(默认为 和 ), 没有这个会拦截掉tab, 导致其他插件的tab不能用. let g:ycm_key_list_select_completion = [' ', ' '] " 弹出列表时选择前1项的快捷键(默认为 和 ) let g:ycm_key_list_previous_completion = [' ', ' '] " 主动补全, 默认为 let g:ycm_key_invoke_completion = [' '] " 停止显示补全列表(防止列表影响视野), 可以按 重新弹出 let g:ycm_key_list_stop_completion = [' '] "-------------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 :NERDTreeFind "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”这篇文章对大家有帮助,同时也希望大家多多支持创新互联,关注创新互联行业资讯频道,更多相关知识等着你来学习!
网站名称:树莓派中如何搭建vimIDE
文章位置:http://azwzsj.com/article/jhceso.html