Skip to content

Instantly share code, notes, and snippets.

@Nishith-Savla
Last active April 15, 2021 15:25
Show Gist options
  • Save Nishith-Savla/8a9d7786b7105ba44f698eff9875a0e2 to your computer and use it in GitHub Desktop.
Save Nishith-Savla/8a9d7786b7105ba44f698eff9875a0e2 to your computer and use it in GitHub Desktop.
My Neovim config
call plug#begin('~/AppData/Local/nvim-data/plugged')
" UI related
Plug 'joshdick/onedark.vim'
Plug 'iCyMind/NeoSolarized'
Plug 'chriskempson/base16-vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Better Visual Guide
Plug 'Yggdroot/indentLine'
" Better Search
"Plug 'haya14busa/incsearch.vim'
" powershell syntax highlighting
"Plug 'pprovost/vim-ps1'
Plug 'zigford/vim-powershell'
" syntax check
Plug 'w0rp/ale'
Plug 'jiangmiao/auto-pairs'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" File browsing
Plug 'scrooloose/nerdtree'
Plug 'preservim/nerdcommenter'
Plug 'ryanoasis/vim-devicons'
" Auto colorizer css
Plug 'norcalli/nvim-colorizer.lua'
" Snippets
Plug 'sirver/ultisnips'
Plug 'honza/vim-snippets'
" Autocomplete
Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2-bufword'
Plug 'ncm2/ncm2-path'
Plug 'ncm2/ncm2-jedi'
" Formater
Plug 'Chiel92/vim-autoformat'
Plug 'junegunn/vim-easy-align'
" FuzzyFinder
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
" Surrounder
Plug 'tpope/vim-surround'
" Multiple Cursors
Plug 'mg979/vim-visual-multi', {'branch': 'master'}
"Plug 'autozimu/LanguageClient-neovim', {
"\ 'branch': 'next',
"\ 'do': 'bash install.sh',
"\ }
" Time tracker
Plug 'wakatime/vim-wakatime'
call plug#end()
filetype plugin indent on
" Configurations Part
" UI configuration
syntax on
syntax enable
" colorscheme
let base16colorspace=256
colorscheme base16-gruvbox-dark-hard
set background=dark
" True Color Support if it's avaiable in terminal
if has("termguicolors")
set termguicolors
endif
"if has("gui_running")
"set guicursor=n-v-c-sm:block,i-ci-ve:block,r-cr-o:blocks
"endif
set number relativenumber
" set hidden
set mouse=a
" set noshowmode
" set noshowmatch
" set nolazyredraw
" Turn off backup
set nobackup
set noswapfile
set nowritebackup
" Search configuration
set ignorecase " ignore case when searching
set smartcase " turn on smartcase
" :h g:incsearch#auto_nohlsearch
"set hlsearch
"let g:incsearch#auto_nohlsearch = 1
"map n <Plug>(incsearch-nohl-n)
"map N <Plug>(incsearch-nohl-N)
"map * <Plug>(incsearch-nohl-*)
"map # <Plug>(incsearch-nohl-#)
"map g* <Plug>(incsearch-nohl-g*)
"map g# <Plug>(incsearch-nohl-g#)
" Tab and Indent configuration
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set autoindent
" vim-autoformat
nnoremap <M-F> :Autoformat<CR>
" NCM2
augroup NCM2
autocmd!
" enable ncm2 for all buffers
autocmd BufEnter * call ncm2#enable_for_buffer()
" :help Ncm2PopupOpen for more information
set completeopt=noinsert,menuone,noselect
" When the <Enter> key is pressed while the popup menu is visible, it only
" hides the menu. Use this mapping to close the menu and also start a new line.
inoremap <expr> <CR> (pumvisible() ? "\<c-y>\<cr>" : "\<CR>")
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" uncomment this block if you use vimtex for LaTex
" autocmd Filetype tex call ncm2#register_source({
" \ 'name': 'vimtex',
" \ 'priority': 8,
" \ 'scope': ['tex'],
" \ 'mark': 'tex',
" \ 'word_pattern': '\w+',
" \ 'complete_pattern': g:vimtex#re#ncm2,
" \ 'on_complete': ['ncm2#on_complete#omni', 'vimtex#complete#omnifunc'],
" \ })
" suppress the annoying 'match x of y', 'The only match' and 'Pattern not
" found' messages
set shortmess+=c
augroup END
" Ale
" let g:ale_lint_on_enter = 0
" let g:ale_lint_on_text_changed = 'never'
" let g:ale_echo_msg_error_str = 'E'
" let g:ale_echo_msg_warning_str = 'W'
" let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
" let g:ale_linters = {'python': ['flake8']:}
" Airline
let g:airline_left_sep = ''
let g:airline_right_sep = ''
let g:airline#extensions#ale#enabled = 1
let airline#extensions#ale#error_symbol = 'E:'
let airline#extensions#ale#warning_symbol = 'W:'
" NERDTree
let g:NERDTreeShowHidden = 1
let g:NERDTreeMinimalUI = 1
let g:NERDTreeIgnore = []
let g:NERDTreeStatusline = ''
" NERDCommenter
let g:NERDSpaceDelims=0
" Automaticaly close nvim if NERDTree is only thing left open
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" NERDTreeToggle
nnoremap <silent> <C-e> :NERDTreeToggle<CR>
" FuzzyFinder
nnoremap <C-G> :FZF<CR>
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-s': 'split',
\ 'ctrl-v': 'vsplit'
\}
" Completion
let g:coc_global_extensions = ['coc-emmet', 'coc-css', 'coc-html', 'coc-json', 'coc-prettier', 'coc-tsserver']
" Trigger configuration. You need to change this to something other than <tab> if you use one of the following:
" - https://github.com/Valloric/YouCompleteMe
" - https://github.com/nvim-lua/completion-nvim
let g:UltiSnipsExpandTrigger="<tab>"
"let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" Close preview window after completion is done
autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif
" Use <Tab> for confirm completion.
" Coc only does snippet and additional edit on confirm.
inoremap <expr> <Tab> pumvisible() ? "\<C-y>" : "\<Tab>"
" Make <CR> auto-select the first completion item and notify coc.nvim to
" format on enter, <cr> could be remapped by other vim plugin
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" GoTo code navigation.
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)
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
" 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>')
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Show signature help while editing
autocmd CursorHoldI * silent! call CocAction('showSignatureHelp')
let mapleader = "\<Space>"
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
nmap <F2> <Plug>(coc-rename)
" Formatting selected code.
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap keys for applying codeAction to the current buffer.
nmap <leader>ac <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf <Plug>(coc-fix-current)
nmap <silent><leader>h :noh<CR>
" Working with tabs
nmap <silent><leader>t :tabnew<CR>
nmap <silent><leader>n :tabn<CR>
nmap <silent><leader>p :tabp<CR>
nmap <silent><leader>x :tabc<CR>
" Remap <C-f> and <C-b> for scroll float windows/popups.
if has('nvim-0.4.0') || has('patch-8.2.0750')
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
endif
if (&term =~ '^xterm' && &t_Co == 256)
set t_ut= | set ttyscroll=1
endif
" Mapping Home and End keys
"map <home> 0
"cmap <home> 0
"map <end> $
"cmap <end> $
" Mapping Ctrl+s to save file
map <C-s> :w<CR>
" Mapping Ctrl+z to undo
imap <C-z> <M-u>a
nmap <CR> o<Esc>
nmap <C-CR> O<Esc>
lua require 'colorizer'.setup()
" Configurations and Keybindings
set clipboard=unnamed
set scrolloff=2
noremap U <C-r>
inoremap jj <Esc>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment