Last active
December 11, 2021 18:15
-
-
Save jeffschwartz/bb06949720b52e83e0a80dee5b6506a4 to your computer and use it in GitHub Desktop.
My ~/.config/nvim/init.vim
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
"" | |
" init.vim | |
"" | |
"" | |
" Plugins via vim-plug | |
" Specify a directory for plugins | |
" - For Neovim: ~/.local/share/nvim/plugged | |
" - Avoid using standard Vim directory | |
" names like 'plugin' | |
"" | |
call plug#begin('~/.local/share/nvim/plugged') | |
" sass/css Colors | |
Plug 'gko/vim-coloresque' | |
" Color Picker; | |
Plug 'KabbAmine/vCoolor.vim' | |
" VIM Repeat - Cosco dependency for repeat action | |
Plug 'tpope/vim-repeat' | |
" Colon and semicolon insertion | |
Plug 'lfilho/cosco.vim' | |
" Auto Pairs - insert or delete brackets, parens, quotes in pair | |
Plug 'jiangmiao/auto-pairs' | |
" Airline Status Bar | |
Plug 'vim-airline/vim-airline' | |
" COC Auto Completion | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
" Auto Save | |
Plug '907th/vim-auto-save' | |
" Emmet | |
Plug 'mattn/emmet-vim' | |
" Surround | |
Plug 'tpope/vim-surround' | |
" Commentary | |
Plug 'tpope/vim-commentary' | |
" NERDTree File System Manager | |
Plug 'scrooloose/nerdtree' | |
" NERDTree Git Integration | |
Plug 'Xuyuanp/nerdtree-git-plugin' | |
" Markdown Support | |
" Plug 'gabrielelana/vim-markdown' | |
" Markdown Preview | |
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() } } | |
" Gitgutter | |
Plug 'airblade/vim-gitgutter' | |
" fugitive | |
Plug 'tpope/vim-fugitive' | |
" umimpaired | |
Plug 'tpope/vim-unimpaired' | |
" " spell check | |
" Plug 'inkarkat/vim-ingo-library' "required for vim-SpellCheck | |
" Plug 'inkarkat/vim-SpellCheck' | |
" Gruvbox color scheme | |
Plug 'gruvbox-community/gruvbox' | |
" Plug 'morhetz/gruvbox' | |
" Cobalt2 color scheme | |
"Plug 'herrbischoff/cobalt2.vim' | |
" One Dark color scheme | |
"Plug 'joshdick/onedark.vim' | |
" One Light/One Dark 256 color scheme | |
" Plug 'rakr/vim-one' | |
" Dracula Dark Theme | |
" Plug 'dracula/vim', { 'as': 'dracula' } | |
" PaleNight | |
" Plug 'drewtempelmeyer/palenight.vim' | |
" Run your favorite search tool from Vim, with an enhanced results list | |
Plug 'mileszs/ack.vim' | |
" FZF Fuzzy Finder | |
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } | |
Plug 'junegunn/fzf.vim' | |
" VimWiki | |
Plug 'vimwiki/vimwiki' | |
" Calendar | |
Plug 'mattn/calendar-vim' | |
" Targets - adds various additional text objects | |
Plug 'wellle/targets.vim' | |
" Yank Highlighting | |
Plug 'machakann/vim-highlightedyank' | |
" Diffview.nvim - a single tabpage interface to | |
" cycle through diffs for all modified files for | |
" any git rev - requires Neovim >= 0.5.0 | |
" Plug 'sindrets/diffview.nvim' | |
call plug#end() | |
" Enable file type detectio:autocmd!n | |
filetype on | |
"" | |
" AG (Silver Searcher) Support | |
" See: https://github.com/ggreer/the_silver_searcher | |
"" | |
" if executable('ag') | |
" let g:ackprg = 'ag --vimgrep' | |
" endif | |
let g:ackprg = 'ag --vimgrep' | |
"" | |
" FZF | |
"" | |
" Configure FZF's Interface | |
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.9 } } | |
let $FZF_DEFAULT_OPTS="--ansi --preview-window 'right:60%' --layout reverse --margin=1,4" | |
command! -bang -nargs=? -complete=dir Files | |
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0) | |
"" | |
" Python Support | |
"" | |
let g:python_host_prog = '/usr/local/bin/python2.7' | |
let g:python3_host_prog = '/usr/local/bin/python3' | |
"" | |
" NERDTree Highlight The Current File | |
"" | |
" Call NERDTreeFind if current window contains a modifiable | |
" file, and we're not in vimdiff else call NERDTree | |
" I modified the code that I found at | |
" https://stackoverflow.com/questions/7692233/nerdtree-reveal-file-in-tree | |
" to work my way! | |
function! SyncTree() | |
if &modifiable && strlen(expand('%')) > 0 && !&diff | |
NERDTreeFind | |
else | |
NERDTree | |
endif | |
endfunction | |
"" | |
" VimWiki Configuration | |
" See: https://github.com/vimwiki/vimwiki | |
"" | |
let g:vimwiki_list = [{'path': '~/vimwiki/', | |
\ 'syntax': 'markdown', 'ext': '.md'}] | |
" \ 'syntax': 'markdown', 'ext': '.md'}] | |
let g:vimwiki_global_ext = 0 | |
" autocmd FileType vimwiki setl conceallevel=1 | |
"" | |
" Set Leader | |
"" | |
nnoremap <space> <Nop> | |
let mapleader = "\<space>" | |
" nnoremap <nowait> <space> / | |
set list | |
set listchars=tab:>\ ,trail:• | |
"" | |
" COC Basic Config - copied | |
" from https://github.com/neoclide/coc.nvim | |
" Interface To LSP | |
"" | |
" Don't want to be prompted when having not saved the current file before | |
" editing a new file. Also if hidden is not set, the COC interface TextEdit | |
" might fail. | |
set hidden | |
" confirm unsaved changes when abandoning a buffer | |
set confirm | |
" Some servers have issues with backup files, see #649 | |
set nobackup | |
set nowritebackup | |
" Better display for messages | |
set cmdheight=2 | |
" You will have bad experience for diagnostic messages when it's default 4000. | |
set updatetime=300 | |
" don't give |ins-completion-menu| messages. | |
set shortmess+=c | |
" always show signcolumns | |
set signcolumn=yes | |
" Use tab for trigger completion with characters ahead and navigate. | |
function! s:check_back_space() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~ '\s' | |
endfunction | |
inoremap <silent><expr> <Tab> | |
\ pumvisible() ? "\<C-n>" : | |
\ <SID>check_back_space() ? "\<Tab>" : | |
\ coc#refresh() | |
" Use <c-space> to trigger completion. | |
inoremap <silent><expr> <c-space> coc#refresh() | |
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position. | |
" Coc only does snippet and additional edit on confirm. | |
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" | |
" Or use `complete_info` if your vim support it, like: | |
" inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>" | |
" Use `[g` and `]g` to navigate diagnostics | |
nmap <silent> [g <Plug>(coc-diagnostic-prev) | |
nmap <silent> ]g <Plug>(coc-diagnostic-next) | |
" 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) | |
" Use K to show documentation in preview window | |
nnoremap <silent> K :call <SID>show_documentation()<CR> | |
function! s:show_documentation() | |
if (index(['vim','help'], &filetype) >= 0) | |
execute 'h '.expand('<cword>') | |
else | |
call CocAction('doHover') | |
endif | |
endfunction | |
" Highlight symbol under cursor on CursorHold | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
" Remap for rename current word | |
nmap <leader>rn <Plug>(coc-rename) | |
" Remap for format selected region | |
xmap <leader>f <Plug>(coc-format-selected) | |
nmap <leader>f <Plug>(coc-format-selected) | |
augroup mygroup | |
autocmd! | |
" Setup formatexpr specified filetype(s). | |
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') | |
" Update signature help on jump placeholder | |
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') | |
augroup end | |
" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph | |
xmap <leader>a <Plug>(coc-codeaction-selected) | |
nmap <leader>a <Plug>(coc-codeaction-selected) | |
" Remap for do codeAction of current line | |
nmap <leader>ac <Plug>(coc-codeaction) | |
" Fix autofix problem of current line | |
nmap <leader>qf <Plug>(coc-fix-current) | |
" Create mappings for function text object, requires document symbols feature of languageserver. | |
xmap if <Plug>(coc-funcobj-i) | |
xmap af <Plug>(coc-funcobj-a) | |
omap if <Plug>(coc-funcobj-i) | |
omap af <Plug>(coc-funcobj-a) | |
" Use <C-d> for select selections ranges, needs server support, like: coc-tsserver, coc-python | |
nmap <silent> <C-d> <Plug>(coc-range-select) | |
xmap <silent> <C-d> <Plug>(coc-range-select) | |
" Use `:Format` to format current buffer | |
command! -nargs=0 Format :call CocAction('format') | |
" Use `:Fold` to fold current buffer | |
command! -nargs=? Fold :call CocAction('fold', <f-args>) | |
" use `:OR` for organize import of current buffer | |
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') | |
" Using CocList | |
" Show all diagnostics | |
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr> | |
" Manage extensions | |
nnoremap <silent> <space>e :<C-u>CocList extensions<cr> | |
" Show commands | |
nnoremap <silent> <space>c :<C-u>CocList commands<cr> | |
" Find symbol of current document | |
nnoremap <silent> <space>o :<C-u>CocList outline<cr> | |
" Search workspace symbols | |
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr> | |
" Do default action for next item. | |
nnoremap <silent> <space>j :<C-u>CocNext<CR> | |
" Do default action for previous item. | |
nnoremap <silent> <space>k :<C-u>CocPrev<CR> | |
" Resume latest coc list | |
nnoremap <silent> <space>p :<C-u>CocListResume<CR> | |
"" | |
" My Settings | |
"" | |
" cause Vim to treat all numerals as decimal, regardless of whether they are | |
" octal (i.e. have leading zeros) | |
set nrformats= | |
" a saner autocomplete option menu | |
"set completeopt=menuone,longest | |
set completeopt=menuone,noinsert,noselect | |
" make "find"ing work better | |
set path+=** | |
set wildmenu | |
" true color support | |
set termguicolors | |
" colorscheme | |
" colorscheme dracula | |
" colorscheme cobalt2 | |
" colorscheme palenight | |
let g:gruvbox_contrast_dark='hard' "set darkest contrast | |
colorscheme gruvbox | |
" set background=light " for the light version | |
set background=dark " for the dark version | |
" Transparent Background | |
hi Normal guibg=NONE ctermbg=NONE | |
" Automatic toggling between line number modes | |
set number relativenumber | |
augroup numbertoggle | |
autocmd! | |
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber | |
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber | |
augroup END | |
" " Toggle between gk and k, gj and j | |
" function! GToggle() | |
" if(maparg("k") !="") | |
" unmap k | |
" else | |
" nmap k gk | |
" endif | |
" if(maparg("j") !="") | |
" unmap j | |
" else | |
" nmap j gj | |
" endif | |
" endfunc | |
" nnoremap <leader>nt :call GToggle()<cr> | |
" display the ruler in the status bar | |
set ruler | |
" hybrid cursor support | |
set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50 | |
\,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor | |
\,sm:block-blinkwait175-blinkoff150-blinkon175 | |
" Enable Auto Save | |
let g:auto_save = 0 | |
" Status Line | |
set laststatus=2 | |
set statusline=%t[%{strlen(&fenc)?&fenc:'none'},%{&ff}]%h%m%r%y%=%c,%l/%L\ %P | |
" Add status line support, for integration with other plugin, checkout `:h coc-status` | |
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} | |
" spaces | |
set tabstop=4 expandtab shiftwidth=4 smarttab | |
" copy & paste to the clipboard | |
set clipboard+=unnamedplus | |
" syntax highlighting | |
syntax on | |
" Auto colon and semicolon insertion | |
autocmd FileType javascript,css,scss,json nmap <silent> <Leader>c <Plug>(cosco-commaOrSemiColon) | |
autocmd FileType javascript,css,scss,json imap <silent> <Leader>c <c-o><Plug>(cosco-commaOrSemiColon) | |
let g:cosco_ignore_comment_lines = 1 " Default : 0 | |
let g:auto_comma_or_semicolon = 0 " Default : 0 | |
" Remove trailing white space from lines when writing the buffer | |
autocmd FileType c,cpp,java,php,html,markdown,vim autocmd BufWritePre <buffer> %s/\s\+$//e | |
" AirLine | |
function! AirlineInit() | |
let g:airline_section_b = airline#section#create(['branch',' ','hunks']) | |
endfunction | |
autocmd VimEnter * call AirlineInit() | |
let g:airline_powerline_fonts = 1 | |
" Airline shows modes so there is no need to show the mode on the last line | |
set noshowmode | |
" Show the tabline | |
"set showtabline=0 | |
" Quit NERDTree after opening file | |
let g:NERDTreeQuitOnOpen = 1 | |
" Ignored Files | |
set wildignore=*/node_modules/* | |
" No New Line At End Of File; | |
set nofixeol | |
" Have Vim wrap (wrap) lines longer than the width of the window and | |
" have Vim break (linebreak) long lines at word boundaries when wrap | |
" is turned on | |
set wrap linebreak | |
"bn Display The File Name In The Terminal Tab | |
set title | |
" Gitgutter | |
set updatetime=100 | |
" Mouse Support | |
set mouse=a | |
" Higlight Cursor Line In The Current Window | |
augroup CursorLine | |
au! | |
au VimEnter,WinEnter,BufWinEnter * setlocal cursorline | |
au WinLeave * setlocal nocursorline | |
augroup END | |
" Better Searching | |
set hlsearch | |
set incsearch | |
set ignorecase | |
set smartcase | |
set inccommand=nosplit "see http://vimcasts.org/episodes/neovim-eyecandy/ for desciption | |
" Force A Minimum Window Width | |
" set winwidth=110 | |
"" | |
" Basic Key Mappings | |
"" | |
" Saner Omni Completion Completion | |
" See: https://vim.fandom.com/wiki/Make_Vim_completion_popup_menu_work_just_like_in_an_IDE | |
" open omni completion menu closing previous if open and opening new menu without changing the text | |
" inoremap <expr> <C-Space> (pumvisible() ? (col('.') > 1 ? '<Esc>i<Right>' : '<Esc>i') : '') . | |
" \ '<C-x><C-o><C-r>=pumvisible() ? "\<lt>C-n>\<lt>C-p>\<lt>Down>" : ""<CR>' | |
" " open user completion menu closing previous if open and opening new menu without changing the text | |
" inoremap <expr> <S-Space> (pumvisible() ? (col('.') > 1 ? '<Esc>i<Right>' : '<Esc>i') : '') . | |
" \ '<C-x><C-u><C-r>=pumvisible() ? "\<lt>C-n>\<lt>C-p>\<lt>Down>" : ""<CR>' | |
" Scrolling in insert mode | |
inoremap <C-E> <C-X><C-E> | |
inoremap <C-Y> <C-X><C-Y> | |
" Make editing and sourcing ~/.config/nvim/init.vim easier | |
command! Config execute ":e ~/.config/nvim/init.vim" | |
command! Source execute ":source ~/.config/nvim/init.vim" | |
" VimWiki - remap | |
:nmap gwq <Plug>VimwikiUISelect | |
:map gww <Plug>VimwikiIndex | |
" FZF - Fuzzy File Find | |
" Note: the FZF_DEFAULT_COMMAND is set in ~/.bash_profile and not here | |
nnoremap <C-p> :Files<CR> | |
nnoremap <C-h> :Files ~<CR> | |
" Buffer Navigation | |
nmap <leader>bp :bprevious<CR> | |
nmap <leader>bn :bnext<CR> | |
nmap <leader>bd :bdelete<CR> | |
nmap <leader>ba :%bdelete<CR> | |
nmap <leader>bb <C-^> | |
nmap <leader>bl :ls<CR> | |
"delete all buffers except the current one | |
nmap <leader>bo :w <bar> %bd <bar> e# <bar> bd#<CR> | |
nnoremap <F5> :buffers<CR>:buffer<Space> | |
" Paging | |
nmap <space>f <C-f> | |
nmap <space>b <C-b> | |
" Windows | |
" Split window | |
nnoremap <leader>ws :split<Return><C-w>w | |
nnoremap <leader>wv :vsplit<Return><C-w>w | |
" Move to window | |
nnoremap <leader>wn <C-w>w | |
nnoremap <leader>wh <C-w>h | |
nnoremap <leader>wk <C-w>k | |
nnoremap <leader>wj <C-w>j | |
nnoremap <leader>wl <C-w>l | |
nnoremap <leader>wr <C-w>r | |
nnoremap <leader>w= <C-w>= | |
" Close window | |
nnoremap <leader>wc :close<Return> | |
" Close<leader> all other windows | |
nnoremap <leader>wo <C-w>o | |
" Tabs | |
nnoremap <leader>tn :tabn<CR> | |
nnoremap <leader>tp :tabp<CR> | |
" Escape | |
imap jj <Esc> | |
" Better | |
vnoremap < <gv | |
vnoremap > >gv | |
" Yank to the end of the line | |
nnoremap Y y$ | |
" Up/Down To Eliminates the need to use gj and gk in paragraphs and soft wrapped lines | |
" nmap k gk | |
" nmap j gj | |
" No Higlighted Search | |
nmap <leader>n :nohlsearch<cr> | |
" GitGutter Hunk Commands | |
nmap ghp <Plug>(GitGutterPreviewHunk) | |
nmap ghs <Plug>(GitGutterStageHunk) | |
nmap ghu <Plug>(GitGutterUndoHunk) | |
" Emmet <Tab> To Expand Emmet Abbreviation | |
imap <expr> <tab> emmet#expandAbbrIntelligent("\<tab>") | |
" Coc | |
nnoremap <leader>f :Format<CR> | |
" NERDTree | |
nnoremap <silent> <leader>t :call SyncTree()<CR> | |
" Spell Checking | |
map <silent> <leader>s :setlocal spell! spelllang=en_us<CR> | |
" Change, Go Next The Current Word CGN without having to first do a search! | |
nnoremap <F6> :let @/= expand('<cword>')<cr>cgn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment