Skip to content

Instantly share code, notes, and snippets.

@elpddev
Last active August 8, 2020 08:27
Show Gist options
  • Select an option

  • Save elpddev/ebdc690a5b604d6ed6ab1607eb073afd to your computer and use it in GitHub Desktop.

Select an option

Save elpddev/ebdc690a5b604d6ed6ab1607eb073afd to your computer and use it in GitHub Desktop.
#vim #cheatsheet

SpaceVim Cheatsheet

Install

Neovim

https://github.com/neovim/neovim/releases

Spacevim

curl -sLf https://spacevim.org/install.sh | bash

Navigation

Keyboard shortcut for Window Jump

Shortcuts can be put in the myspacevim#before function in ~/.Spacevim.d/autoload/myspacevim.vim file.

  nmap <c-h> <c-w>h
  nmap <c-l> <c-w>l
  nmap <c-k> <c-w>k
  nmap <c-j> <c-w>j

Search

Search word ander cursor in project

SPACE + s + a + P

Clear search results

SPACE + s + c

Custom Config

In init.toml:

[[options]]
  bootstrap_after = "myconfig#after"       

In ~/.Spacevim.d/autoload/myspacevim.vim

function! myspacevim#before() abort
   ...some config logic
endfunction

Custom Menu

To create a custom menu, for example Coc commands

  1. create myspacevim.vim file in .Spacevim.d/autoload
  2. add a before funciton that initialize the custom menu.
  3. load the funciton in the init.tml
function! myspacevim#before() abort
  call SpaceVim#custom#SPCGroupName(['k'], '+Coc')
  call SpaceVim#custom#SPC('nore', ['k', 'j'], ":call CocAction('jumpDefinition')", 'jump to definition', 1)
  call SpaceVim#custom#SPC('nore', ['k', 'f'], ':CocFix', 'autofix suggestion', 1)
endfunction

Snippets

Editing

On a specific file type, entering command :NeoSnippetEdit. It will open an editor in the default location for a snippets file for the specific file type.

Examples

https://github.com/honza/vim-snippets/blob/master/UltiSnips/html.snippets

Q&A

silver search not working

Need to install silver searhcer independently.

https://github.com/ggreer/the_silver_searcher

apt-get install silversearcher-ag

Copy to clipboard not working (neovim)

https://github.com/neovim/neovim/issues/7945#issuecomment-361970165

sudo apt install xsel

To copy to clipboard, yank to clipboard buffer. + y.

typescript lint not working

Need to install ts-node, typescript

npm i -g ts-node typescript

Need to install yats maybe.

wsdjeg/SpaceVim#3221 (comment)

[[custom_plugins]] # causes errors with neoformat
    name = "HerringtonDarkholme/yats.vim"
    merge = 0

Need to install coc tsserver maybe.

wsdjeg/SpaceVim#2564

https://github.com/neoclide/coc-tsserver

:CocInstall coc-tsserver

Using language server, the + l does not show many options, but coc commands works. They can be configured as shortcuts.

CocFix autofix suggestions (ex. imports)

CocDiagnostics show language errors.

[[layers]] 
  name = 'lsp'
  filetypes = [
    'typescript',
  ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment