Skip to content

Instantly share code, notes, and snippets.

@mkcode
Created October 5, 2022 20:17
Show Gist options
  • Save mkcode/4d8077ddf473d0f4090607637a9b0493 to your computer and use it in GitHub Desktop.
Save mkcode/4d8077ddf473d0f4090607637a9b0493 to your computer and use it in GitHub Desktop.
Minimal yet functional config for VSpaceCode with VSCode-Neovim
" Our .vscode-neovim directory
let data_dir = '~/.vscode-neovim'
let plugFile = data_dir . '/plug.vim'
" Download plug.vim if it doesn't exist
" Then install the plugins in this file
if empty(glob(plugFile))
silent execute '!curl -fLo '.plugFile.' --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
execute "autocmd VimEnter * PlugInstall --sync | source " . expand('%:p')
endif
" Source vim-plug directly since we install it in a non-autoload directory
execute "source " . expand(plugFile)
call plug#begin(data_dir)
Plug 'chaoren/vim-wordmotion'
Plug 'justinmk/vim-sneak'
Plug 'rhysd/clever-f.vim'
Plug 'tpope/vim-surround'
call plug#end()
" Clever-f config
let g:clever_f_across_no_line = 0
let g:clever_f_chars_match_any_signs = 1
let g:clever_f_fix_key_direction = 0
let g:clever_f_mark_direct = 0
let g:clever_f_smart_case = 1
" Vim-sneak config
set ignorecase
let g:sneak#s_next = 1
let g:sneak#label = 1
let g:sneak#use_ic_scs = 1
map n <Plug>Sneak_;
map N <Plug>Sneak_,
" VSCode built-in commenting works way better than NERDcommenter
" Use C-/ to comment/uncomment
" Plug 'preservim/nerdcommenter'
" Sync vim yanking with system clipboard
set clipboard=unnamedplus
" Keybindings
let mapleader=";"
nnoremap <space> :call VSCodeNotify('vspacecode.space')<CR>
xmap <space> :call VSCodeNotify('vspacecode.space')<CR>
@mkcode
Copy link
Author

mkcode commented Oct 5, 2022

To Setup

  1. Add the above file to ~/.vscode-neovim-init.vim.

  2. Add the following to settings.json:

"vscode-neovim.neovimExecutablePaths.darwin": "/usr/local/bin/nvim",
"vscode-neovim.neovimInitVimPaths.darwin": "~/.vscode-neovim-init.vim",

I am using macOS with neovim installed via brew. Your executable path may be different.

  1. And the following to keybindings.json:
    {
        "command": "vscode-neovim.compositeEscape1",
        "key": "f",
        "when": "neovim.mode == insert && editorTextFocus",
        "args": "f"
    },
    {
        "command": "vscode-neovim.compositeEscape2",
        "key": "d",
        "when": "neovim.mode == insert && editorTextFocus",
        "args": "d"
    },
    {
        "command": "-vscode-neovim.send",
        "key": "ctrl+a"
    },
    {
        "command": "-vscode-neovim.ctrl-e",
        "key": "ctrl+e"
    },

@mkcode
Copy link
Author

mkcode commented Oct 5, 2022

Be sure to restart VSCode after changing .vscode-neovim-init.vim. It loads on startup.

@mkcode
Copy link
Author

mkcode commented Oct 5, 2022

And also, first step is to disable the vscodevim extension and enable the vscode-neovim extension.

@gdw2
Copy link

gdw2 commented Jan 15, 2024

After I do a / search, I expect n to be able to go to the next search result but it doesn't. Also, the major-mode leader, ,, doesn't work.

@mkcode
Copy link
Author

mkcode commented Jan 15, 2024

Hey @gdw2 - I abandoned this method a while ago. I found that I was not able to get vscode working reliably with a vim like setup. I’m now happily using neovim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment