Skip to content

Instantly share code, notes, and snippets.

@kensleDev
Last active May 30, 2022 15:35
Show Gist options
  • Save kensleDev/f6a6c7710d633acc4ccf9b158011a329 to your computer and use it in GitHub Desktop.
Save kensleDev/f6a6c7710d633acc4ccf9b158011a329 to your computer and use it in GitHub Desktop.
VSCode neovim init
" Navigate with jkl; instead of hjkl
noremap ; l
noremap l k
noremap k j
noremap j h
noremap h ;
" navigate splits
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Enable CursorLine
set cursorline
" Default Colors for CursorLine
highlight CursorLine ctermbg=Yellow ctermfg=None
"VSCode
function! s:split(...) abort
let direction = a:1
let file = a:2
call VSCodeCall(direction == 'h' ? 'workbench.action.splitEditorDown' : 'workbench.action.splitEditorRight')
if file != ''
call VSCodeExtensionNotify('open-file', expand(file), 'all')
endfunction
function! s:splitNew(...)
let file = a:2
call s:split(a:1, file == '' ? '__vscode_new__' : file)
endfunction
function! s:closeOtherEditors()
call VSCodeNotify('workbench.action.closeEditorsInOtherGroups')
call VSCodeNotify('workbench.action.closeOtherEditors')
endfunction
function! s:manageEditorSize(...)
let count = a:1
let to = a:2
for i in range(1, count ? count : 1)
call VSCodeNotify(to == 'increase' ? 'workbench.action.increaseViewSize' : 'workbench.action.decreaseViewSize')
endfor
endfunction
command! -complete=file -nargs=? Split call <SID>split('h', <q-args>)
command! -complete=file -nargs=? Vsplit call <SID>split('v', <q-args>)
command! -complete=file -nargs=? New call <SID>split('h', '__vscode_new__')
command! -complete=file -nargs=? Vnew call <SID>split('v', '__vscode_new__')
command! -bang Only if <q-bang> == '!' | call <SID>closeOtherEditors() | else | call VSCodeNotify('workbench.action.joinAllGroups') | endif
nnoremap <silent> <C-w>s :call <SID>split('h')<CR>
xnoremap <silent> <C-w>s :call <SID>split('h')<CR>
nnoremap <silent> <C-w>v :call <SID>split('v')<CR>
xnoremap <silent> <C-w>v :call <SID>split('v')<CR>
nnoremap <silent> <C-w>n :call <SID>splitNew('h', '__vscode_new__')<CR>
xnoremap <silent> <C-w>n :call <SID>splitNew('h', '__vscode_new__')<CR>
" Bind C-/ to vscode commentary since calling from vscode produces double comments due to multiple cursors
" xnoremap <silent> <C-/> :call Comment()<CR>
" nnoremap <silent> <C-/> :call Comment()<CR>
nnoremap <silent> <C-w>_ :<C-u>call VSCodeNotify('workbench.action.toggleEditorWidths')<CR>
nnoremap <silent> <Space> :call VSCodeNotify('whichkey.show')<CR>
xnoremap <silent> <Space> :call VSCodeNotify('whichkey.show')<CR>
call plug#begin()
Plug 'ggandor/lightspeed.nvim'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
" Initialize plugin system
call plug#end()

Install Scoop

[environment]::setEnvironmentVariable('SCOOP','C:\scoop','User')

iex (new-object net.webclient).downloadstring('https://get.scoop.sh')

Install neovim

scoop install neovim

Copy init.vim

C:\Users\juliani\AppData\Local\nvim\init.vim

Install vimplug

iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |`
    ni "$(@($env:XDG_DATA_HOME, $env:LOCALAPPDATA)[$null -eq $env:XDG_DATA_HOME])/nvim-data/site/autoload/plug.vim" -Force

Install plugins

  • Open terminal
  • launch neovim
  • Run:
:PlugInstall

Launch VSCode and update settings

Neovim init vim paths: Win32
C:\Users\REPLACE_USERNAME\AppData\Local\nvim\init.vim

Neovim Executable paths: Win32
C:\Users\REPLACE_USERNAME\scoop\apps\neovim\0.7.0\bin\nvim.exe

Restart Vscode

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