" NEOVIM SETTINGS - settings regarding Neovim itself " Set leader key to comma, since the default sucks for nordic keyboards let mapleader = ',' " This setting makes search case-insensitive when all characters in the string " being searched are lowercase. However, the search becomes case-sensitive if " it contains any capital letters. This makes searching more convenient. set ignorecase set smartcase " Enable searching as you type, rather than waiting till you press enter. set incsearch " Always show 4 lines above and below the cursor set scrolloff=4 " Allow using uppercase :W to save command W call VSCodeCall('workbench.action.files.save') " Make yank use system clipboard as default :nnoremap y (v:register ==# '"' ? '"+' : '') . 'y' :nnoremap yy (v:register ==# '"' ? '"+' : '') . 'yy' :nnoremap Y (v:register ==# '"' ? '"+' : '') . 'Y' :xnoremap y (v:register ==# '"' ? '"+' : '') . 'y' :xnoremap Y (v:register ==# '"' ? '"+' : '') . 'Y' " Map 'gp' to paste from system clipboard :nnoremap gp (v:register ==# '"' ? '"+' : '') . 'p' :nnoremap gP (v:register ==# '"' ? '"+' : '') . 'P' :xnoremap gp (v:register ==# '"' ? '"+' : '') . 'p' :xnoremap gP (v:register ==# '"' ? '"+' : '') . 'P' " Map leader bindings to VSCode commands nnoremap p call VSCodeNotify('workbench.action.quickOpen') nnoremap b call VSCodeNotify('workbench.action.showAllEditors') nnoremap o call VSCodeNotify('workbench.action.quickOpen') nnoremap f call VSCodeNotify('workbench.action.findInFiles') nnoremap : call VSCodeNotify('workbench.action.showCommands') nnoremap c call VSCodeNotify('workbench.action.showCommands') nnoremap d call VSCodeNotify('workbench.view.scm') nnoremap n call VSCodeNotify('workbench.action.toggleSidebarVisibility') " Disable arrow keys in normal mode - enforce hjkl instead nnoremap :echoe "Use h" nnoremap :echoe "Use l" nnoremap :echoe "Use k" nnoremap :echoe "Use j" " PLUGINS - installation and configuration " Install Plug (plugin manager) if not already installed let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' if empty(glob(data_dir . '/autoload/plug.vim')) silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' autocmd VimEnter * q endif " Install plugins automatically when launching Neovim autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) \| PlugInstall --sync | source $MYVIMRC \| endif " Fetch plugins with Plug call plug#begin() " Add two-character motions with s and S Plug 'ggandor/leap.nvim' Plug 'tpope/vim-repeat' " Easy commenting/uncommenting Plug 'numToStr/Comment.nvim' " Easy handling of surroundings (tags, brackets etc.) Plug 'tpope/vim-surround' " End of plugin fetching call plug#end() " Configure leap lua require('leap').add_default_mappings() " Configure Comment.nvim lua require('Comment').setup()