Skip to content

Instantly share code, notes, and snippets.

@xykj61
Created July 31, 2018 20:13
Show Gist options
  • Save xykj61/acae778ba112f62769443f5bef5ead1e to your computer and use it in GitHub Desktop.
Save xykj61/acae778ba112f62769443f5bef5ead1e to your computer and use it in GitHub Desktop.
~/.config/nvim/init.vim - Neovim configuration.
" ~/.config/nvim/init.vim
"" Basics
"" Vim is old.
""
"" Disable compatibility with legacy Vi.
""
set nocompatible
"" Administravia.
""
"" Turn on filetype detection and allow loading
"" of language-specific indentation files.
""
filetype indent on
"" Preserve history.
""
"" Set history cap to 10,000 entries back.
""
set history=10000
"" Improve literacy.
""
"" Turn syntax highlighting on.
""
syntax on
"" Improve feedback.
""
"" Show matching parentheses and brackets upon hover.
""
set showmatch
"" Show the last command entered in the bottom right corner.
""
set showcmd
"" Draw a horizontal highlight on the line the cursor is
"" currently on.
""
set cursorline
highlight CursorLine term=bold cterm=bold
"" Provide graphical menu of matches in searches.
""
set wildmenu
"" Improve search
""
"" Search as characters are entered.
""
set incsearch
"" Highlight search matches.
""
set hlsearch
"" Improve performance
""
"" Only redraw the screen when you need to.
""
set lazyredraw
"" Help me read fast.
""
"" Set text width to 80 characters wide.
"" (This options wraps at word boundaries.)
""
set textwidth=80
"" Wrapping text using textwidth requires "t" in formatoptions.
"" It is by default, but add "t" just in case needed.
""
set formatoptions+=t
"" A long line already longer than the text width is not wrapped
"" when text is added if formatoptions contains "l".
"" Remove "l" from formatoptions so long lines will be wrapped.
""
set formatoptions-=l
"" Borders.
""
"" Set the wrap margin to 2 characters wide.
""
set wrapmargin=2
"" Set soft wrapping on.
""
set wrap
set linebreak
set nolist
"" Turn on line numbering.
""
set number
"" Turn on relative numbering.
""
set relativenumber
"" Set the line numbers to 4 spaces.
""
set numberwidth=4
"" Hide windows (instead of closing) when opening new ones.
""
set hidden
"" You use tabs? Ew.
""
"" Set number of visual spaces per TAB to 4.
""
set tabstop=4
"" Set number of spaces inserted per TAB when editing to 2.
""
set softtabstop=2
"" Use the TAB key to insert spaces, not TAB characters (a cardinal sin).
""
set expandtab
"" Origami.
""
"" Show all folds.
""
set foldenable
"" Open most folds by default by setting the starting fold level
"" to 10.
""
set foldlevelstart=10
"" Set maximum number of nested folds to 10.
""
set foldnestmax=10
"" Fold based on indentation.
"" (**May need to change this to marker for C and Hoon**.)
""
set foldmethod=indent
"" Mappings
""
"" Speed
""
"" Map leader key to ";" .
""
let mapleader=";"
"" Press 'fd' fast in insert mode to escape.
""
inoremap fd <esc>
"" Set time length for mapped sequence to complete to 50ms.
""
set timeoutlen=50
"" Set time length for key-code sequence to complete to 50ms.
""
set ttimeoutlen=50
"" Feedback
""
"" Visually select the block of characters added the last time
"" I was in insert mode.
""
nnoremap gV `[v`]
"" Search
""
"" Clear search highlight.
""
nnoremap <leader><space> :nohlsearch<CR>
"" Folding
""
"" Open/close folds.
""
nnoremap <space> za
"" Plug
"" https://github.com/junegunn/vim-plug
""
"" Automatic installation
"" https://github.com/junegunn/vim-plug/wiki/tips
"" https://github.com/junegunn/vim-plug#neovim
""
if empty(glob('~/.local/share/nvim/site/autoload/plug.vim'))
silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source ~/.config/nvim/init.vim
endif
"" Specify a directory for plugins
"" https://github.com/junegunn/vim-plug#example
""
call plug#begin('~/.local/share/nvim/plugged')
"" Plugins
""
"" vim-easy-align
"" https://github.com/junegunn/vim-easy-align
""
Plug 'junegunn/vim-easy-align'
"" fzf
"" https://github.com/junegunn/fzf
""
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
"" goyo
"" https://github.com/junegunn/goyo.vim
""
Plug 'junegunn/goyo.vim'
"" nerdtree
"" https://github.com/scrooloose/nerdtree
""
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
"" hoon.vim
"" https://github.com/urbit/hoon.vim
Plug 'urbit/hoon.vim'
"" Initialize plugin system
""
call plug#end()
"" Plug Mappings
""
"" nerdtree
"" https://github.com/scrooloose/nerdtree/wiki/F.A.Q.
""
"" Open/close NerdTree.
""
noremap <C-n> :NERDTreeToggle<CR>
"" vim-easy-align
"" https://github.com/junegunn/vim-easy-align
""
"" Start interactive EasyAlign in visual mode (e.g. vipga)
"" https://github.com/junegunn/vim-easy-align#quick-start-guide
""
xmap ga <Plug>(EasyAlign)
"" Start interactive EasyAlign for a motion/text object (e.g. gaip)
"" https://github.com/junegunn/vim-easy-align#quick-start-guide
""
nmap ga <Plug>(EasyAlign)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment