
SpaceVIM入门
Layer & PluginsH1
显示所有Layer信息
bash
SPC h l
显示所有Plugin信息
bash
<Leader> f p
常用操作H1
fx 查找后会标红,再次按f/F继续前后查找这个单词
clever-f
导航树H1
ctrl-r 刷新sv 垂直分割打开sg 水平分割打开
< 调整导航树宽度
note: 在编辑窗口sv/sg前面添加<Leader>也可以分割窗口
查看H1
spc s s 查找当前文件spc f o 文件树种查找当前buffer的文件
移动H1
[ e Move line up] e Move line down
复制H1
Ctrl-c Copy full path of current buffer to X11 clipboard<Leader> y Copy selection to X11 clipboard (“+y)<Leader> p Paste selection from X11 clipboard (“+p)
搜索H1
文本
bash
spc s /spc p /
文件
bash
spc p f
配置H1
所有g:spacevim_xxx都可以直接init.yoml中以xxx的形式配置
自定义配置H1
~/.SpaceVim.d/ 已经被添加到runtimepath中,所以符合runtimepath子目录的目录中的脚本都会被加载
所以官方的自定义做法是在[options]中定义
bash
bootstrap_before = "myspacevim#before"bootstrap_after = "myspacevim#after"
然后在SpaceVim.d/autoload/myspacevim.vim中定义
bash
function! myspacevim#before() abortlet g:neomake_enabled_c_makers = ['clang']nnoremap jk <Esc>endfunctionfunction! myspacevim#after() abortiunmap jkendfunction
defxH1
基本操作H1
新建文件夹 K新建文件 N移动文件 M P
显示图标H1
bash
enable_vimfiler_filetypeicon = true
光标和图片重叠比较丑,配置文件~/.SpaceVi/config/plugins/defx.vim中添加space即可
bash
function! s:setcolum() abortif g:spacevim_enable_vimfiler_filetypeicon && !g:spacevim_enable_vimfiler_gitstatusreturn 'space:indent:icons:filename:type'elseif !g:spacevim_enable_vimfiler_filetypeicon && g:spacevim_enable_vimfiler_gitstatusreturn 'space:indent:icons:filename:type'elseif g:spacevim_enable_vimfiler_filetypeicon && g:spacevim_enable_vimfiler_gitstatusreturn 'space:indent:git:icons:filename:type'elsereturn 'mark:indent:icon:filename:type'endifendfunction
cocH1
Configuration file resolve
There’re two types of user configuration files.
- The user configuration is named as coc-settings.json and placed inside the folder $XDG_CONFIG_HOME/nvim or $HOME/.config/nvim by default(or $HOME/.vim for vim). Run the command :CocConfig to open your user configuration file.
- The workspace configuration should be named coc-settings.json and be in the directory .vim. After a file is opened in vim, this directory is resolved from the parent directories of that file. Run the command :CocLocalConfig to open your workspace configuration file.
.vim或者nvim已经被spacevim占用了,所以无法配置coc-settings.json,只能自己在配置文件是调用方法来配置
bash
inoremap <silent><expr> <c-space> coc#refresh()call coc#config('coc.preferences', {\ "autoTrigger": "always",\ "maxCompleteItemCount": 10,\ "codeLens.enable": 1,\ "diagnostic.virtualText": 1,\ "list.source.files.excludePatterns": ["**/node_modules/**"],\})let s:coc_extensions = [\ 'coc-dictionary',\ 'coc-json',\ 'coc-ultisnips',\ 'coc-tag',\]for extension in s:coc_extensionscall coc#add_extension(extension)endfor
https://github.com/SpaceVim/SpaceVim/issues/2564
使用coc当Fuzzy finderH1
~/.SpaceVim.d/autoload/myspacevim.vim
bash
call SpaceVim#custom#SPC('nnoremap', ['p', 'f'], 'CocList files', 'File files in the directory of the current buffer', 1)
TypescriptH1
VIM默认的脚本会把tsx文件的ft设置为typescriptreact,无论是语法高亮还是lsp都会无法正常工作,
- leafgarland/typescript-vim ft=typescript
- coc-tsserver typescript.jsx/typescript.tsx
因此需要把ft设置为typescript.tsx。
jsx
au BufNewFile,BufRead *.tsx setf typescript.tsx
修正H2
tsx需要vim-jsx-typescript来高亮tsx文件中的jsx语法,vim-jsx-typescript只支持typescriptreact。
也可以使用vim-jsx-pretty,它支持javascriptreact、typescriptreact、jsx、tsx。
这两个支持只是高亮jsx/tsx文件中的jsx语法,javascript或者typescript本身还是需要其他的插件来支持的。新版本的vim目前支持了javascriptreact中的javascript高亮
jsx
// neovim/0.4.4/share/nvim/runtime/syntax/javascriptreact.vimruntime! syntax/javascript.vim
但是typecriptreact则没有对应的文件,才会导致tsx文件的中的基础ts语法没有高亮。因此可以类似地添加一个typescriptreact.vim
ReactH1
bash
[[custom_plugins]]name = "MaxMEllon/vim-jsx-pretty"merged = false
标签自动补全H1
coc-html支持标签自动补全,但是需要开启
bash
call coc#config('html.autoClosingTags', v:true)
自动关闭标签和AutoPair的<>补全一般是冲突的,一般自动关闭标签是输入>时触发的,自动补全了>后,要么就无法触发了,要么触发后会多一个>。因此需要关闭AutoPair的<补全
一般使用coc-pairs补全即可,可以关闭delimitMate
bash
let g:spacevim_autocomplete_parens = 0
coc-setting.josn
bash
"pairs.enableCharacters":["(", "[", "{", "'", "\"", "`"]
coc-html的自动补全无法兼容jsx,jsx中使用closetag.vim
bash
call s:Declare('g:closetag_filetypes', 'html,xhtml,phtml,javascript')
补全快捷键H1
Ctrl-n select next candidateCtrl-p select previous candidateM-/ Expand a snippet if text before point is a prefix of a snippet
autocomplete layer通过设置auto_completion_return_key_behavior决定tab的行为
- complete 补全当前选中
- cycle 循环补全列表
- smart 尝试expand snippets, cycle
补全列表是输出的时候自动弹出的,如果不小心关闭没有快捷键再次触发补全
比较理想的使用coc + coc-snippets:
- Ctrl-Space 触发补全
- Ctrl-n/Ctrl-p 遍历补全列表
- tab选中补全或者扩展snippets
补全列表未弹出的情况下
- tab 扩展snippets
因此,最终需要设置如下关闭autocomplete layer的tab行为
bash
g:auto_completion_return_key_behavior = nil
通过脚本设置tab的行为
bash
inoremap <silent><expr> <TAB>\ pumvisible() ? coc#_select_confirm() :\ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :\ <SID>check_back_space() ? "\<TAB>" :\ coc#refresh()function! s:check_back_space() abortlet col = col('.') - 1return !col || getline('.')[col - 1] =~# '\s'endfunction
如果希望tab需要类似autocomplete layer的cycle的遍历补全列表
bash
inoremap <silent><expr> <TAB>\ pumvisible() ? "\<C-n>" :[\ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :]可选\ <SID>check_back_space() ? "\<TAB>" :\ coc#refresh()inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
VIM8H1
VIM下,defx、denite等插件都需要pynvim(vim python plugin)、nvim-yarp(remote plugin)、vim-hug-neovim-rpc,而默认的配置中,只在启用了deoplete时才会启用这两个插件
bash
// autoload/SpaceVim/layers/autocomplete.vimelseif g:spacevim_autocomplete_method ==# 'deoplete'call add(plugins, [g:_spacevim_root_dir . 'bundle/deoplete.nvim', {\ 'on_event' : 'InsertEnter',\ 'loadconf' : 1,\ }])if !has('nvim')call add(plugins, [g:_spacevim_root_dir . 'bundle/nvim-yarp', {'merged': 0}])call add(plugins, [g:_spacevim_root_dir . 'bundle/vim-hug-neovim-rpc', {'merged': 0}])endif
把他们添加到autoload/SpaceVim/layers/core.vim中
评论
新的评论
上一篇
VIM 文件类型检测
:filetype on 启用文件类型识别后,VIM会尝试设置文件的 filetype 选项,这将会触发 FileType 事件,然后能够正确启用语法高亮等。识别文件文件是一般是通过文件扩展名(当前也根据文件内容) autocmd BufNewFile,BufRead *.…
下一篇
sonarqube
痛点 现代的开发模型都会多个分支,但是sonarqube的社区办是不支持多分支的。如果只针对master分支扫描,就会导致功能分支合并后能发现代码问题,并且这个时候才检出的问题如果全改会耗费很大的精力,这个不改那个不改的话最终又无法实施下去了;如果所有分支都扫描,sonarqu…
