Last active
April 2, 2021 03:53
-
-
Save dnavas77/41a0b510747055efec3c7c16269435ae to your computer and use it in GitHub Desktop.
Neovim Config Mac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filetype off | |
syntax off | |
"~~~~~~~~~ Skip initialization for vim-tiny or vim-small. | |
if 0 | endif | |
if &compatible | |
set nocompatible | |
endif | |
set runtimepath^=~/.vim/bundle/neobundle.vim/ | |
call neobundle#begin(expand('~/.vim/bundle/')) | |
NeoBundleFetch 'Shougo/neobundle.vim' | |
NeoBundle 'tpope/vim-fugitive' | |
NeoBundle 'tpope/vim-repeat' | |
NeoBundle 'jreybert/vimagit' | |
NeoBundle 'fatih/vim-go' | |
" NeoBundle 'leafgarland/typescript-vim' | |
NeoBundle 'itchyny/lightline.vim' | |
NeoBundle 'tpope/vim-surround' | |
NeoBundle 'gregsexton/Matchtag' | |
NeoBundle 'tpope/vim-commentary' | |
NeoBundle 'raimondi/delimitmate' | |
" NeoBundle 'mileszs/ack.vim' | |
NeoBundle 'gorodinskiy/vim-coloresque' | |
NeoBundle 'flazz/vim-colorschemes' | |
" NeoBundle 'frigoeu/psc-ide-vim' | |
" NeoBundle 'raichoo/purescript-vim' | |
" NeoBundle 'vim-scripts/indentpython.vim' | |
" python pep8 support | |
" NeoBundle 'nvie/vim-flake8' | |
NeoBundle 'Shougo/deoplete.nvim' | |
NeoBundle 'tmhedberg/SimpylFold' | |
NeoBundle 'scrooloose/nerdtree' | |
NeoBundle 'mattn/emmet-vim' | |
" NeoBundle 'flowtype/vim-flow' | |
NeoBundle 'w0rp/ale' | |
NeoBundle 'hdevtools/hdevtools' | |
NeoBundle 'maxmellon/vim-jsx-pretty' | |
NeoBundle 'neovimhaskell/haskell-vim' | |
NeoBundle 'pangloss/vim-javascript' | |
NeoBundle 'chriskempson/base16-vim' | |
NeoBundle 'mustache/vim-mustache-handlebars' | |
call neobundle#end() | |
filetype plugin indent on | |
NeoBundleCheck | |
syntax on | |
"~~~~~~~~~ Enable Deoplete | |
let g:deoplete#enable_at_startup = 1 | |
let g:python3_host_prog = '/usr/local/bin/python3' | |
let g:python_host_prog = '/usr/local/bin/python2' | |
let g:deoplete#file#enable_buffer_path = 1 | |
"~~~~~~~~~ General NeoVim Settings | |
let mapleader = ';' | |
set termguicolors | |
set backspace=indent,eol,start | |
set shortmess=atI "don't show message at startup | |
set title "show filename in widow titlebar | |
set clipboard+=unnamedplus "allow copy from vim and paste into system | |
set autoindent | |
set smartindent | |
set lazyredraw | |
set nobackup | |
set nowb | |
set history=10000 | |
set noswapfile | |
set laststatus=2 | |
set noshowmode | |
set smarttab | |
set linebreak | |
set cindent | |
set showmatch | |
set mat=2 | |
set cc=80 | |
set textwidth=80 | |
set tabstop=2 | |
set shiftwidth=2 | |
set softtabstop=2 | |
set expandtab | |
set nowrap | |
set ignorecase | |
set smartcase | |
set hlsearch | |
set wildmenu | |
set modifiable | |
set belloff=all | |
"set number | |
"set cursorline | |
set foldmethod=indent | |
set foldlevel=99 | |
set fillchars+=stl:\ ,stlnc:\ | |
set timeoutlen=500 ttimeoutlen=500 | |
"set relativenumber | |
"set linespace=4 | |
"set cursorcolumn | |
" Highlight whitespace | |
highlight BadWhitespace ctermbg=red guibg=darkred | |
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h,*.hbs,*.js,*.elm,*.go match BadWhitespace /\s\+$/ | |
" Enable Vim Tag Matching | |
runtime macros/matchit.vim | |
" cd sets path to the path of the file in the current buffer. | |
nnoremap cd :cd %:p:h | |
set wildignore+=*/tmp/*,*.so,*.swp,*.zip | |
set wildignore+=**/node_modules " ignores node_modules | |
set wildignore+=**/bower_components " ignores bower_components | |
set wildignore+=**/tmp "ignores tmp created by Ember | |
set wildignore+=**/dist "ignores dist created by Ember | |
set wildignore+=**/.tmp "ignores tmp created by Ember | |
set wildignore+=**/.stack-work "ignores tmp created by Ember | |
" Better indentation | |
vnoremap < <gv | |
vnoremap > >gv | |
"~~~~~~~~~~~~ KEYBINDINGS ~~~~~~~~~~ | |
map q <Nop> | |
nnoremap <leader>rv :source $MYVIMRC<CR> | |
nnoremap <leader>av :tabnew $MYVIMRC<CR> | |
"nnoremap <leader>a :bprevious<CR> | |
nnoremap <leader>d :bnext<CR> | |
nnoremap <leader>t :tabnew<CR> | |
nnoremap <leader>w :bw<CR> | |
nnoremap <leader>q :q<CR> | |
nnoremap <leader>h :sp<CR> | |
nnoremap <leader>v :vsp<CR> | |
nnoremap <S-n> :tabprevious<CR> | |
nnoremap <S-m> :tabnext<CR> | |
nnoremap <space><space> :w<CR> | |
nnoremap <space> :set hlsearch! hlsearch?<CR> | |
" Maps Shift + [h,j,k,l] to resize splits | |
map <silent> <S-H> :vertical resize +2<CR> | |
map <silent> <S-J> :res -2<CR> | |
map <silent> <S-K> :res +2<CR> | |
map <silent> <S-L> :vertical resize -2<CR> | |
" Switch between opened buffers splits by holding Ctrl and using HJKL | |
nnoremap <C-J> <C-W>j | |
nnoremap <C-K> <C-W>k | |
nnoremap <C-L> <C-W>l | |
nnoremap <C-H> <C-W>h | |
inoremap ff <Esc> | |
vnoremap ff <Esc> | |
cnoremap ff <Esc> | |
" ~~~~~~~~ Ale Keybindings ~~~~~~~~~~~ | |
nmap <silent> <leader>a <Plug>(ale_next_wrap) | |
" ~~~~~~~~ Vim-Go Keybindings ~~~~~~~~~~~ | |
nnoremap <leader>gd :GoDef<CR> | |
"~~~~~~~~~ CtrlP | |
set runtimepath^=~/.vim/bundle/ctrlp.vim | |
let g:ctrlp_working_path_mode = 'ra' | |
let g:ctrlp_map = '<C-p>' | |
let g:ctrlp_cmd = 'CtrlP' | |
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard'] | |
"~~~~~~~~~ NERDTree | |
map <C-n> :NERDTreeToggle<CR> | |
let NERDTreeChDirMode=2 | |
let NERDTreeShowHidden=1 | |
nnoremap t :NERDTree %:p:h | |
"~~~~~~~~~ Plugin LIGHT LINE | |
let g:lightline = { | |
\ 'colorscheme': 'wombat', | |
\ 'active': { | |
\ 'left': [ [ 'mode', 'paste' ], | |
\ [ 'fugitive', 'readonly', 'filename', 'modified'] ], | |
\ 'right': [[ 'lineinfo' ], | |
\ [ 'fileencoding'], | |
\ [ 'ale' ] ] | |
\ }, | |
\ 'component': { | |
\ 'readonly': '%{&filetype=="help"?"":&readonly?"⭤":""}', | |
\ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}', | |
\ 'ale': '%{ALEGetStatusLine()}', | |
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}' | |
\ }, | |
\ 'component_visible_condition': { | |
\ 'readonly': '(&filetype!="help"&& &readonly)', | |
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))', | |
\ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())' | |
\ } | |
\ } | |
"~~~~~~~~~ SimplyFold | |
let g:SimpylFold_docstring_preview=1 | |
"~~~~~~~~~ Python Stuff | |
let python_highlight_all=1 | |
let g:SimpylFold_docstring_preview=1 | |
"python with virtualenv support | |
" py << EOF | |
" import os | |
" import sys | |
" if 'VIRTUAL_ENV' in os.environ: | |
" project_base_dir = os.environ['VIRTUAL_ENV'] | |
" activate_this = os.path.join(project_base_dir, 'bin/activate_this.py') | |
" execfile(activate_this, dict(__file__=activate_this)) | |
" EOF | |
au BufNewFile,BufRead *.py,*.go,*.elm,*.c,*.cpp: | |
\ set tabstop=4 | | |
\ set softtabstop=4 | | |
\ set shiftwidth=4 | | |
\ set expandtab | | |
\ set autoindent | | |
\ set fileformat=unix | |
au BufNewFile,BufRead *.js,*.html,*.css,*.hbs: | |
\ set tabstop=2 | | |
\ set softtabstop=2 | | |
\ set shiftwidth=2 | | |
\ set expandtab | | |
\ set autoindent | | |
\ set fileformat=unix | |
"~~~~~~~~~ JSX and Babel Stuff | |
let g:jsx_ext_required = 0 " Allow JSX in normal JS files | |
"~~~~~~~~~ Silver Searcher | |
" let g:ag_working_path_mode = 'r' | |
"~~~~~~~~~ Plugin ALE linter | |
let g:ale_sign_column_always = 1 | |
let g:ale_set_loclist = 0 | |
let g:ale_linters = { | |
\ 'javascript': ['eslint'], | |
\ 'html': [], | |
\ 'handlebars': [], | |
\ 'haskell': ['stack-ghc', 'hdevtools'], | |
\ 'scss': ['scss-lint'], | |
\ 'go': [] | |
\} | |
let g:ale_sign_error = '⨉' | |
let g:ale_sign_warning = '⚠' | |
set statusline+=%{ALEGetStatusLine()} | |
let g:ale_statusline_format = ['⨉ %d', '⚠ %d', '⬥ Ok'] | |
function! LinterStatus() abort | |
let l:counts = ale#statusline#Count(bufnr('')) | |
let l:all_errors = l:counts.error + l:counts.style_error | |
let l:all_non_errors = l:counts.total - l:all_errors | |
return l:counts.total == 0 ? 'OK' : printf( | |
\ '%dW %dE', | |
\ all_non_errors, | |
\ all_errors | |
\) | |
endfunction | |
" Run linters only when you save files | |
"let g:ale_lint_on_text_changed = 'never' | |
" Do not run linters on opening a file | |
"let g:ale_lint_on_enter = 0 | |
set statusline=%{LinterStatus()} | |
"~~~~~~~~ Set theme | |
set background=dark | |
colorscheme base16-dracula | |
===================== Update 4/1/21 ======================== | |
set tabstop=4 softtabstop=4 | |
set shiftwidth=4 | |
set expandtab | |
set smartindent | |
set exrc " automatically source vimrc in working folder | |
set guicursor= " remain cursor as block | |
set relativenumber | |
set nu | |
set nohlsearch | |
set hidden " keeps buffer in the background | |
set noerrorbells | |
set nowrap | |
set smartcase | |
" below work together for keeping history | |
set noswapfile | |
set nobackup | |
set undodir=~/.vim/undodir | |
set undofile | |
set incsearch " hightlight as you search | |
set scrolloff=8 " starts scrolling when you're 8 away from top/bottom | |
set noshowmode | |
set completeopt=menuone,noinsert,noselect | |
set signcolumn=yes " adds extra column, useful for linting | |
set colorcolumn=80 " set margin color, keep it at 80 :) | |
set cmdheight=2 " more space for displaying messages | |
set updatetime=50 " better user experience | |
set shortmess+=c " do not pass messages to ins-completion-menu | |
" PLUGINS (vim-plug) | |
if empty(glob('~/.vim/autoload/plug.vim')) | |
silent !curl -fLo ~/.vim/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('~/.vim/plugged') | |
Plug 'nvim-telescope/telescope.nvim' | |
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } | |
Plug 'gruvbox-community/gruvbox' | |
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | |
call plug#end() | |
colorscheme gruvbox | |
highlight Normal guibg=none | |
highlight Normal ctermbg=none | |
" remaps [ mode lhs rhs ] n = normal mode, nore=norecursive execution | |
let mapleader = " " " yup he uses space | |
"Nnoremap <leader>ps [some long command to use telescope] | |
" viml language | |
fun! TrimWhitespace() | |
Let l:save = winsaveview() | |
Keeppatterns %s/\s\+$//e | |
Call winrestview(l:save) | |
endfun | |
" Each time file is source, remove all listeners in this group | |
" re-attach them | |
augroup THE_PRIMEAGEN | |
autocmd! | |
autocmd BufWritePre * :call TrimWhitespace() | |
augroup END | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment