Giter Site home page Giter Site logo

nvim-from-scratch's Introduction

nvim-from-scratch

Steps to create a basic neovim config from scratch

Make your life easier: ESC -> CAPSLOCK ๐Ÿ˜

Step 1: setup Python and wrap vim cmd

  • brew install neovim ripgrep

  • setup virtualenv

    python3 -m venv $HOME/.venv
    source "$HOME/.venv/bin/activate"
    rehash
    pip install --upgrade pip
    pip install pynvim

Step 2: boilerplate & basic config

Step 3: basic mappings

Window navigation

nmap <Space> <C-W>
map <unique> <silent> <C-W>Q :bd!<CR>
map <unique> <silent> <C-W>q :bd<CR>
map <C-W>+ :resize +10<CR>
map <C-W>- :resize -10<CR>
map <C-W>< :vertical resize -15<CR>
map <C-W>> :vertical resize +15<CR>

fzf

nnoremap vf :FZF<CR>
nnoremap vF :FZF -m<CR>

function! s:build_quickfix_list(lines)
  call setqflist(map(copy(a:lines), '{ "filename": v:val }'))
  copen
  cc
endfunction

let g:fzf_action = {
  \ 'ctrl-q': function('s:build_quickfix_list'),
  \ 'ctrl-t': 'tab split',
  \ 'ctrl-x': 'split',
  \ 'ctrl-v': 'vsplit' }

statusline

set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %{&paste==1?\"[PASTE]\":\"\"}%y%{\"[\".(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\"+b\":\"\").\",\".&ff.\"]\ \"}\ %{FugitiveStatusline()}\ %P

clear out v

nnoremap vv v
nnoremap vV V
nnoremap V <C-V>
nnoremap v <Nop>

inner and outer text object selection

Plug 'inkarkat/vim-ReplaceWithRegister'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
nmap s  <Plug>ReplaceWithRegisterOperator
nmap ss <Plug>ReplaceWithRegisterLine
xmap s  <Plug>ReplaceWithRegisterVisual
nnoremap s <Nop>

Step 4: undo and backup

./supplemental/02_backup-undo-setup.vim

Step 4: my plugins

Plug 'scrooloose/nerdtree'
Plug 'tpope/vim-fugitive'
Plug 'alvan/vim-closetag'
Plug 'tpope/vim-eunuch'
Plug 'gasparch/tagbar'
Plug 'tpope/vim-repeat'
Plug 'godlygeek/tabular'
Plug 'inkarkat/vim-ReplaceWithRegister'

Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'tmhedberg/matchit'
Plug 'jlanzarotta/bufexplorer'
Plug 'sjl/gundo.vim'
Plug 'samoshkin/vim-mergetool'

Step 5: completion & snippets

Plugins

Plug 'SirVer/ultisnips'
Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2-bufword'
Plug 'ncm2/ncm2-path'
Plug 'ncm2/ncm2-tern',  {'do': 'npm install'}
Plug 'ncm2/ncm2-jedi'
Plug 'ncm2/ncm2-ultisnips'
Plug 'ncm2/ncm2-cssomni'
Plug 'yuki-ycino/ncm2-dictionary'
Plug 'fgrsnau/ncm2-otherbuf'

mappings

inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <expr> <CR> (pumvisible() ? "\<c-y>\<cr>" : "\<CR>")
set completeopt=noinsert,menuone,noselect
autocmd BufEnter * call ncm2#enable_for_buffer()
call ncm2#override_source('bufword', {'priority': 7})

let g:UltiSnipsSnippetDirectories=[$HOME.'/.config/nvim/ultisnips']
let g:UltiSnipsSnippetsDir=$HOME.'/.config/nvim/ultisnips'
let g:UltiSnipsExpandTrigger="<c-k>"
let g:UltiSnipsListSnippets="<c-s-z>"
let g:UltiSnipsJumpForwardTrigger="<c-k>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"

Step 6: grep

"https://www.freecodecamp.org/news/how-to-search-project-wide-vim-ripgrep-ack/
Plug 'mileszs/ack.vim'
let g:ackprg = 'rg --vimgrep --smart-case'
let g:ack_use_cword_for_empty_search = 1
command Ak ":Ack!"
command -nargs=* Ak :call ack#Ack('grep!', <q-args>)

if there is time

  • startuptime
  • lua interface
  • python interface

Outlook

GitHub - neoclide/coc.nvim:

Resources

nvim-from-scratch's People

Contributors

jwbargsten avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.