Skip to content

Instantly share code, notes, and snippets.

@buddylindsey
Last active December 4, 2019 16:04
Show Gist options
  • Save buddylindsey/b1fbddf07cef9625b4ef28b40f3e9762 to your computer and use it in GitHub Desktop.
Save buddylindsey/b1fbddf07cef9625b4ef28b40f3e9762 to your computer and use it in GitHub Desktop.
Neovim init
{
"coc.preferences.formatOnType": true,
"coc.preferences.formatOnSaveFiletypes": ["python"],
"coc.preferences.jumpCommand": "tab drop",
"diagnostic.displayByAle": true,
"diagnostic.errorSign": "⛔️ ",
"diagnostic.warningSign": "⚠️ ",
"diagnostic.infoSign": "ℹ️ ",
"diagnostic.hintSign": "",
"list.source.grep.command": "ag",
"python.venvFolders": [".venv"],
"suggest.enablePreview": true,
"python.formatting.provider": "black",
"coc.preferences.formatOnSave": ["py"],
"python.jediEnabled": false
}
" put file in $HOME/.config/nvim/init.vim
let VIMSHARE = $HOME.'/.local/share/nvim/'
" If vim-plug is not installed install it
if empty(glob(VIMSHARE.'site/autoload/plug.vim'))
execute 'silent !curl -fLo '.VIMSHARE.'site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin(VIMSHARE.'plugged')
" Vim
Plug 'scrooloose/nerdtree'
Plug 'terryma/vim-multiple-cursors'
Plug 'machakann/vim-highlightedyank'
Plug 'mhinz/vim-grepper', { 'on': ['Grepper', '<plug>(GrepperOperator)'] }
Plug 'editorconfig/editorconfig-vim'
Plug 'AndrewRadev/switch.vim'
" git
Plug 'tpope/vim-fugitive'
" Linting
Plug 'jiangmiao/auto-pairs'
Plug 'fisadev/vim-isort'
Plug 'luochen1990/rainbow'
" Highlighters
Plug 'othree/html5.vim'
Plug 'elzr/vim-json'
Plug 'lepture/vim-jinja'
Plug 'tweekmonster/django-plus.vim'
Plug 'wavded/vim-stylus'
Plug 'groenewege/vim-less'
Plug 'chr4/nginx.vim'
Plug 'hashivim/vim-terraform'
Plug 'leafgarland/typescript-vim'
Plug 'peitalin/vim-jsx-typescript'
Plug 'vim-python/python-syntax'
Plug 'jparise/vim-graphql'
" Autocomplete and Discovery
Plug 'mattn/emmet-vim'
Plug 'scrooloose/nerdcommenter'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Themes
Plug 'morhetz/gruvbox'
Plug 'sickill/vim-monokai'
call plug#end()
" General
set number
set cursorline
syntax on
let mapleader = ","
if exists('+termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
colorscheme monokai
" Indentation
filetype plugin on
filetype plugin indent on
set expandtab
set formatoptions=rq
set shiftwidth=2
set softtabstop=2
set tabstop=2
set autoindent
set smarttab
" Python
autocmd FileType python set shiftwidth=4
autocmd FileType python set softtabstop=4
autocmd FileType python set tabstop=8
" PHP
autocmd FileType php set shiftwidth=4
autocmd FileType php set softtabstop=4
autocmd FileType php set tabstop=4
autocmd FileType php set noexpandtab
autocmd FileType php set noeol
autocmd FileType php set binary
" Stylus
autocmd BufNewFile,BufReadPost *.styl set filetype=stylus
" C-lang dervitives
autocmd FileType c,cpp,java,php autocmd BufWritePre <buffer> :%s/\s\+$//e
" GraphQL
autocmd BufNewFile,BufRead *.tsx,*.jsx set filetype=typescript.tsx
" Deoplete auto-completion
" let g:deoplete#enable_at_startup = 1
" let g:deoplete#sources#jedi#show_docstring = 1
" autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif
" Python Environments
" Should not need this since python 2 should never be used again
" let g:python_host_prog = VIMSHARE.'python-environments'
" Check if python3 and py3 vim environment exists. If not created it first.
if empty(glob(VIMSHARE.'python-environments')) && executable('python3')
execute 'silent !mkdir -p '.VIMSHARE.'python-environments'
execute 'silent !cd '.VIMSHARE.'python-environments && python3 -m venv py3'
execute 'silent !'.VIMSHARE.'python-environments/py3/bin/pip install flake8 mypy jedi isort pynvim'
endif
let g:python3_host_prog = VIMSHARE.'python-environments/py3/bin/python'
" Neoformat
" Enable alignment
" let g:neoformat_basic_format_align = 1
" Enable tab to spaces conversion
" let g:neoformat_basic_format_retab = 1
" Enable trimmming of trailing whitespace
" let g:neoformat_basic_format_trim = 1
" Jedi-vim
" disable autocompletion, cause we use deoplete for completion
" let g:jedi#completions_enabled = 0
" open the go-to function in split, not another buffer
" let g:jedi#use_splits_not_buffers = "right"
" neomake
" let g:neomake_python_enabled_makers = ['flake8']
" call neomake#configure#automake('nrwi', 500)
" nerdtree
map <leader>p :NERDTreeToggle<CR>
let g:NERDTreeDirArrowExpandable = ''
let g:NERDTreeDirArrowCollapsible = ''
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let NERDTreeIgnore = ['\.pyc$', '__pycache__']
" NERDTress File highlighting
function! NERDTreeHighlightFile(extension, fg, bg, guifg, guibg)
exec 'autocmd FileType nerdtree highlight ' . a:extension .' ctermbg='. a:bg .' ctermfg='. a:fg .' guibg='. a:guibg .' guifg='. a:guifg
exec 'autocmd FileType nerdtree syn match ' . a:extension .' #^\s\+.*'. a:extension .'$#'
endfunction
call NERDTreeHighlightFile('jade', 'green', 'none', 'green', '#151515')
call NERDTreeHighlightFile('ini', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('md', 'blue', 'none', '#3366FF', '#151515')
call NERDTreeHighlightFile('yml', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('config', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('conf', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('json', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('html', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('styl', 'cyan', 'none', 'cyan', '#151515')
call NERDTreeHighlightFile('css', 'cyan', 'none', 'cyan', '#151515')
call NERDTreeHighlightFile('coffee', 'Red', 'none', 'red', '#151515')
call NERDTreeHighlightFile('js', 'Red', 'none', '#ffa500', '#151515')
call NERDTreeHighlightFile('php', 'Magenta', 'none', '#ff00ff', '#151515')
call NERDTreeHighlightFile('py', 'green', 'none', 'green', '#151515')
" GitGutter Settings
" set updatetime=100
" Grepper
if !executable('ack')
echoerr 'ack is not installed'
endif
nnoremap <leader>a :Grepper -tool ack<cr>
nnoremap <leader>* :Grepper -tool ack -cword -noprompt<cr>
" Editorconfig
let g:EditorConfig_exclude_patterns = ['fugitive://.\*', 'scp://.\*']
" Rainbow
let g:rainbow_active = 1
let g:rainbow_conf = {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
\ 'ctermfgs': ['green', 'red', 'yellow', 'blue', 'brown', 'darkmagenta', 'darkcyan',
\ 'darkgray', 'darkgreen', 'lightyellow', 'darkblue', 'magenta', 'cyan'],
\}
" Emmet
" expand w/ Ctrl-e
let g:user_emmet_expandabbr_key='<c-e>'
"Highlight end of line whitespace in red
highlight BadWhitespace ctermbg=red guibg=red
let m = matchadd('BadWhitespace', '\s\+$')
"Highlight tabs used instead of spaces in red
let m = matchadd('BadWhitespace', '^\t\+')
" CoC
nnoremap <silent> K :call <SID>show_documentation()<CR>
let g:coc_global_extensions = [
\ 'coc-json',
\ 'coc-python',
\ 'coc-git',
\ 'coc-yank',
\ 'coc-lists',
\ 'coc-css',
\ 'coc-marketplace',
\ 'coc-github',
\]
" Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocActionAsync('doHover')
endif
endfunction
"Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
"Switch
let g:switch_mapping = '='
let g:switch_reverse_mapping = '+'
let g:switch_no_builtins = 1
let g:switch_custom_definitions = [
\ ['&&', '||'],
\ {'\<on\>': 'off', '\<off\>': 'on'},
\ {'\<On\>': 'Off', '\<Off\>': 'On'},
\ {'\<yes\>': 'no', '\<no\>': 'yes'},
\ {'\<Yes\>': 'No', '\<No\>': 'Yes'},
\ {'\<true\>': 'false', '\<false\>': 'true'},
\ {'\<True\>': 'False', '\<False\>': 'True'},
\ {
\ '\(\k\+\) is \(not\)\@!\(\k\+\)': '\1 is not \3',
\ '\(\k\+\) is not \(\k\+\)': '\1 is \2',
\ },
\ ]
" Pythonsense
map <buffer> [M <Plug>(PythonsenseEndOfPythonFunction)
" python-syntax
let g:python_highlight_all = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment