Skip to content

Instantly share code, notes, and snippets.

@manji-0
Last active July 9, 2025 14:52
Show Gist options
  • Select an option

  • Save manji-0/505ed5cfc69334643e9e25a6ae242ad5 to your computer and use it in GitHub Desktop.

Select an option

Save manji-0/505ed5cfc69334643e9e25a6ae242ad5 to your computer and use it in GitHub Desktop.
Neovim init.vim configuration
" =============================================================================
" Neovim Init.vim Configuration
" =============================================================================
" =============================================================================
" General Settings
" =============================================================================
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
set bomb
set binary
set ttyfast
" Better Unix / Windows compatibility
set viewoptions=folds,options,cursor,unix,slash
set hidden
" Allow using mouse
set mouse=a
" =============================================================================
" Visual Settings
" =============================================================================
syntax enable
set nocursorline
set signcolumn=yes
set showcmd
set showmode
set showmatch
set laststatus=2
set wildmenu
set wildmode=list:longest,full
set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__
set title
set titlestring=%F
" Color scheme
set termguicolors
set background=dark
" =============================================================================
" Search Settings
" =============================================================================
set hlsearch
set incsearch
set ignorecase
set smartcase
" =============================================================================
" Tab and Indent Settings
" =============================================================================
set tabstop=2
set softtabstop=2
set shiftwidth=4
set expandtab
set smarttab
set autoindent
set smartindent
" =============================================================================
" Backup and Swap Settings
" =============================================================================
set nobackup
set nowritebackup
set noswapfile
" =============================================================================
" Undo Settings
" =============================================================================
if has('persistent_undo')
set undofile
set undodir=~/.config/nvim/undodir
if !isdirectory(&undodir)
call mkdir(&undodir, 'p')
endif
endif
" =============================================================================
" Split Settings
" =============================================================================
set splitbelow
set splitright
" =============================================================================
" Scrolling Settings
" =============================================================================
set scrolloff=8
set sidescrolloff=8
" =============================================================================
" Folding Settings
" =============================================================================
set foldmethod=indent
set foldlevel=99
set nofoldenable
" =============================================================================
" Performance Settings
" =============================================================================
set lazyredraw
set updatetime=300
set timeoutlen=500
" =============================================================================
" Clipboard Settings
" =============================================================================
if has('unnamedplus')
set clipboard=unnamed,unnamedplus
endif
" =============================================================================
" Plugin Manager (dein.vim)
" =============================================================================
" dein Scripts-----------------------------
if &compatible
set nocompatible " Be iMproved
endif
" Required:
let s:dein_base = '~/.cache/dein'
let s:dein_src = s:dein_base . '/repos/github.com/Shougo/dein.vim'
" Check if dein is installed
" if !isdirectory(s:dein_src)
" echo "Installing dein.vim..."
" echo ""
" call mkdir(s:dein_base, 'p')
" call system('git clone https://github.com/Shougo/dein.vim ' . s:dein_src)
" endif
" Add the dein installation directory into runtimepath
execute 'set runtimepath+=' . s:dein_src
" Required:
call dein#begin(s:dein_base)
" Let dein manage dein
call dein#add('Shougo/dein.vim')
" File navigation
call dein#add('preservim/nerdtree')
call dein#add('junegunn/fzf', {'build': './install --all'})
call dein#add('junegunn/fzf.vim')
" Status line
call dein#add('vim-airline/vim-airline')
call dein#add('vim-airline/vim-airline-themes')
" Git integration
call dein#add('airblade/vim-gitgutter')
" Syntax highlighting and language support
call dein#add('sheerun/vim-polyglot')
" Auto-completion
call dein#add('neoclide/coc.nvim', {'merged': 0, 'rev': 'release'})
" Color schemes
call dein#add('tanvirtin/monokai.nvim')
call dein#add('crusoexia/vim-monokai')
" Utilities
call dein#add('jiangmiao/auto-pairs')
call dein#add('preservim/tagbar')
call dein#add('editorconfig/editorconfig-vim')
" Indent visualization
call dein#add('lukas-reineke/indent-blankline.nvim')
" GitHub Copilot
call dein#add('github/copilot.vim')
" Required:
call dein#end()
" Required:
filetype plugin indent on
syntax enable
" If you want to install not installed plugins on startup.
if dein#check_install()
call dein#install()
endif
" End dein Scripts-------------------------
" =============================================================================
" Plugin Configuration
" =============================================================================
" Color scheme
colorscheme monokai_pro
" NERDTree
let g:NERDTreeShowHidden = 1
let g:NERDTreeMinimalUI = 1
let g:NERDTreeIgnore = ['\.pyc$', '__pycache__', 'node_modules']
let g:NERDTreeStatusline = ''
" Airline
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline_theme='molokai'
" FZF
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --glob "!.git/*"'
" CoC extensions
let g:coc_global_extensions = [
\ 'coc-json',
\ 'coc-git',
\ 'coc-eslint',
\ 'coc-tsserver',
\ 'coc-python',
\ 'coc-html',
\ 'coc-css',
\ 'coc-yaml',
\ 'coc-xml'
\ ]
" Indent Blankline configuration
lua << EOF
require("ibl").setup {
indent = {
char = "┊",
},
scope = {
enabled = true,
show_start = true,
show_end = false,
char = "┃",
},
}
EOF
" GitHub Copilot configuration
let g:copilot_no_tab_map = v:true
let g:copilot_assume_mapped = v:true
let g:copilot_tab_fallback = ""
" Copilot keymaps
imap <silent><script><expr> <C-J> copilot#Accept("\<CR>")
imap <C-]> <Plug>(copilot-next)
imap <C-[> <Plug>(copilot-previous)
imap <C-\> <Plug>(copilot-dismiss)
" =============================================================================
" Key Mappings
" =============================================================================
" Set leader key
let mapleader = " "
" Quick save and quit
nnoremap <leader>w :w<CR>
nnoremap <leader>q :q<CR>
nnoremap <leader>x :x<CR>
" Clear search highlight
nnoremap <leader><space> :nohlsearch<CR>
" Split navigation
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Buffer navigation
nnoremap <leader>bn :bnext<CR>
nnoremap <leader>bp :bprevious<CR>
nnoremap <leader>bd :bdelete<CR>
" NERDTree
nnoremap <leader>n :NERDTreeToggle<CR>
nnoremap <leader>nf :NERDTreeFind<CR>
" FZF
nnoremap <leader>f :Files<CR>
nnoremap <leader>b :Buffers<CR>
nnoremap <leader>g :Rg<CR>
nnoremap <leader>t :Tags<CR>
nnoremap <leader>m :Marks<CR>
" Tagbar
nnoremap <F8> :TagbarToggle<CR>
" Move lines up and down
nnoremap <A-j> :m .+1<CR>==
nnoremap <A-k> :m .-2<CR>==
vnoremap <A-j> :m '>+1<CR>gv=gv
vnoremap <A-k> :m '<-2<CR>gv=gv
" Indent/dedent in visual mode
vnoremap < <gv
vnoremap > >gv
" CoC mappings
" Use tab for trigger completion
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
" Use <c-space> to trigger completion
inoremap <silent><expr> <c-space> coc#refresh()
" 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)
" 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
" Symbol renaming
nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
" =============================================================================
" Auto Commands
" =============================================================================
" Remove trailing whitespace on save
autocmd BufWritePre * :%s/\s\+$//e
" Return to last edit position when opening files
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
" Highlight yanked text
augroup highlight_yank
autocmd!
autocmd TextYankPost * silent! lua vim.highlight.on_yank({timeout = 200})
augroup END
" =============================================================================
" File Type Specific Settings
" =============================================================================
" Python
autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8 softtabstop=4
" JavaScript/TypeScript
autocmd FileType javascript,typescript,typescriptreact,javascriptreact setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
" HTML/CSS
autocmd FileType html,css,scss,sass setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
" YAML
autocmd FileType yaml setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
" JSON
autocmd FileType json setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType json syntax match Comment +\/\/.\+$+
" Markdown
autocmd FileType markdown setlocal wrap linebreak
" =============================================================================
" End of Configuration
" =============================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment