项目作者: wandercn

项目描述 :
my vim conf for golang IDE and rust IDE
高级语言: Vim script
项目地址: git://github.com/wandercn/go-ide-vim.conf.git
创建时间: 2021-06-25T07:59:36Z
项目社区:https://github.com/wandercn/go-ide-vim.conf

开源协议:Apache License 2.0

下载


go-ide-vim.conf

my vim conf for golang IDE and rust IDE

supported languages

  • Golang
  • Rust
  • C
  • Python
  • Java
  • JavaScript
  • TypeScript

requirements

vim 8.0 +python3 +lua

iTerm2 (Support true color)

  1. brew install macvim
  1. vim --version
  2. VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 01 2021 08:32:44)
  3. macOS version - x86_64
  4. 包含补丁: 1-2681
  5. 编译者 Homebrew
  6. 巨型版本 MacVim 图形界面。 可使用(+)与不可使用(-)的功能:
  7. +acl +file_in_path -mouse_sysmouse -tag_old_static
  8. +arabic +find_in_path +mouse_urxvt -tag_any_white
  9. +autocmd +float +mouse_xterm +tcl
  10. +autochdir +folding +multi_byte +termguicolors
  11. -autoservername -footer +multi_lang +terminal
  12. +balloon_eval +fork() -mzscheme +terminfo
  13. +balloon_eval_term +fullscreen +netbeans_intg +termresponse
  14. +browse +gettext +num64 +textobjects
  15. ++builtin_terms -hangul_input +odbeditor +textprop
  16. +byte_offset +iconv +packages +timers
  17. +channel +insert_expand +path_extra +title
  18. +cindent +ipv6 +perl +toolbar
  19. +clientserver +job +persistent_undo +transparency
  20. +clipboard +jumplist +popupwin +user_commands
  21. +cmdline_compl +keymap +postscript +vartabs
  22. +cmdline_hist +lambda +printer +vertsplit
  23. +cmdline_info +langmap +profile +virtualedit
  24. +comments +libcall -python +visual
  25. +conceal +linebreak +python3 +visualextra
  26. +cryptv +lispindent +quickfix +viminfo
  27. +cscope +listcmds +reltime +vreplace
  28. +cursorbind +localmap +rightleft +wildignore
  29. +cursorshape +lua +ruby +wildmenu
  30. +dialog_con_gui +menu +scrollbind +windows
  31. +diff +mksession +signs +writebackup
  32. +digraphs +modify_fname +smartindent -X11
  33. +dnd +mouse -sound -xfontset
  34. -ebcdic +mouseshape +spell +xim
  35. +emacs_tags +mouse_dec +startuptime -xpm
  36. +eval -mouse_gpm +statusline -xsmp
  37. +ex_extra -mouse_jsbterm -sun_workshop -xterm_clipboard
  38. +extra_search +mouse_netterm +syntax -xterm_save
  39. -farsi +mouse_sgr +tag_binary

Plugin Manager

  1. curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
  2. https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

install

  1. git clone https://github.com/wandercn/go-ide-vim.conf.git ./vim_conf && mv ./vim_conf/.vimrc $HOME/.vimrc
  2. vim +PlugInstall

install YouCompleteMe

  1. cd ~/.vim/plugged/YouCompleteMe/
  2. ./install.py --all

YouCompleteMe 如果编译安装不成功,不想折腾的,可以考虑用coc.nvim做代码补全。快捷键基本一样,vimrc配置在 rust-ide-with-coc

Shortcut key description

快捷键 功能说明 en-us description 对应编程语言
gr 查看引用列表 GoToReferences any
[Control] + n 浏览引用列表,查看下一个 view references list, next one any
[Control] + m 浏览引用列表,查看上一个 view references list, previou one any
ca 关闭引用列表 close references list any
gd 查看定义 GoToDefinition any
gi 查看接口类型实现 GoToImplementation any
rn 标识符重命名 RefactorRename any
[Space] + b 编译代码 Build Code Rust,Go
[Space] + r 运行代码 Run Code Rust,Go
[Space] + t 运行测试 Run Test Code Rust,Go
tg 打开/关闭TagBar查看器 open/close TagBar Viewer any
[Control] + z 打开/关闭NeoTree浏览器 open/close NeoTree any
[Control] + o 回退光标到上一次所在文件位置 Rewind the cursor to the last file location any
[Control] + p 打开快速文件搜索. Open a quick file search any
:noh 关闭搜索匹配的文字高亮效果. Turn off the text highlighting effect for search matches any
:MarkdownPreview 打开MarkDown文档实时预览,会在浏览器打开页面。 Open MarkDown documents for live preview MarkDown
[Shift] + p + m 打开vim内部MarkDown预览窗口 Open the vim internal MarkDown preview window MarkDown
[F9] 设置调试断点 set breakpoint Rust,Go
[F5] 启动图形化调试 start graphical debugger Rust,Go
[Space] + c + c 注释单行代码 Comment one line of code any
[Space] + c + m 注释多行代码 Comment multiline code any
[Space] + c + u 取消注释代码 Uncomment code any

FAQ

  1. let g:rustfmt_autosave =1 开启保存很慢超过3秒钟,怎么处理?

    set foldmethod =syntax “基于语法进行代码折叠 ,这个设置引起的。改成 set foldmethod = indent 或者manual就能解决问题。

    Debug Code

图形化Debug代码

怎么debug rust ?

插件准备

在Vim中用命令 :VimspectorInstall CodeLLDB 安装必要插件,Vimspector官方说明

  1. 新建配置文件

需要在每个项目目录下创建独立的.vimspector.json

Rust项目配置内容参考如下,gostdmain 项目名称需要根据实际修改。

  1. {
  2. "configurations": {
  3. "launch": {
  4. "adapter": "CodeLLDB",
  5. "configuration": {
  6. "request": "launch",
  7. "program": "${workspaceRoot}/target/debug/gostdmain"
  8. }
  9. }
  10. }
  11. }
  1. 设置断点

在代码需要调试行,按键盘功能键F9设置断点显示为红点,如下图:

  1. 启动调试

按键盘功能键F5, 启动图形化调试界面,如下图:

其他步骤点击界面显示的按钮就可以了,比敲命令调试方便高效多了。

怎么debug go ?

插件准备

在Vim中用命令 :VimspectorInstall vscode-go 安装必要插件,Vimspector官方说明

Delve installed, e.g. go get -u github.com/go-delve/delve/cmd/dlv

  1. 新建配置文件

Go虽然用dlv命令调试也算比较方便的,但是图形化调试还是更高效点。

其他步骤与debug rust一样。

区别就一点,debug配置文件内容不一样。在go项目目录下创建.vimspector.json

Go项目配置内容参考如下, dlvToolPath对应的值就是你dlv工具的安装位置。

  1. {
  2. "configurations": {
  3. "run": {
  4. "adapter": "vscode-go",
  5. "configuration": {
  6. "request": "launch",
  7. "program": "${fileDirname}",
  8. "mode": "debug",
  9. "dlvToolPath": "$HOME/go/bin/dlv"
  10. }
  11. }
  12. }
  13. }

screen

Go

Rust

C

Python

Java

JavaScript and TypeScript

tagbar

TagBar for Go

TagBar for Rust