Skip to content

Instantly share code, notes, and snippets.

@Sebastian1011
Last active December 1, 2023 13:50
Show Gist options
  • Save Sebastian1011/9f7b6d13213124dbbec098c5867acddc to your computer and use it in GitHub Desktop.
Save Sebastian1011/9f7b6d13213124dbbec098c5867acddc to your computer and use it in GitHub Desktop.
Vim guides

Install Neovim on Mac

install nvim

$ brew install neovim

add vimrc

$ cp vimrc ~/.vimrc

Install vim-plug

$ sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
       https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'

install ctags

$ brew install universal-ctags

init nvim use vimrc

$ mkdir -p ~/.config/nvim && ln -s ~/.vimrc ~/.config/nvim/init.vim

call plug#begin('~/.vim/plugged')
"-------------------=== Code Navigation ===-------------
Plug 'preservim/nerdtree'
" Plug 'majutsushi/tagbar'
"-------------------- themes
" Plug 'vim-airline/vim-airline'
" Plug 'vim-airline/vim-airline-themes'
" Plug 'powerline/powerline'
" Plug 'flazz/vim-colorschemes'
Plug 'NLKNguyen/papercolor-theme'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'rust-lang/rust.vim'
" Plug 'nathanaelkane/vim-indent-guides'
Plug 'yggdroot/indentline'
"---------------- language support
" Plug 'rykka/riv.vim'
" Plug 'mitsuhiko/vim-sparkup'
" Plug 'python-mode/python-mode'
" Plug 'vim-syntastic/syntastic'
" Plug 'valloric/youcompleteme'
Plug 'github/copilot.vim'
Plug 'joshdick/onedark.vim'
Plug 'ludovicchabant/vim-gutentags'
call plug#end()
syntax on
" ------------- nerdtree short cut ----------------
" nnoremap <leader>n :NERDTreeFocus<CR>
nnoremap <C-n> :NERDTree<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
" nnoremap <C-f> :NERDTreeFind<CR>
"you complete me
set encoding=utf-8
set t_Co=256 " set 256 colors
"colorscheme monokai
set background=dark
colorscheme onedark
set modeline
set number
set tabstop=4 " 4 whitespaces for tabs visual presentation
set shiftwidth=4 " shift lines by 4 spaces
set smarttab " set tabs for a shifttabs logic
set expandtab " expand tabs into spaces
set autoindent " indent when moving to the next line while writing code
set cursorline " shows line under the cursor's line
set showmatch " shows matching part of bracket pairs (), [], {}
set clipboard=unnamed " use system clipboard
let g:ycm_python_binary_path = '/usr/bin/python3'
let g:ycm_path_to_python_interpreter = '/usr/bin/python3'
" Additional mappings for Esc (useful for MacBook with touch bar)
"inoremap jj <Esc>
"inoremap jk <Esc>
"=====================================================
" AirLine settings
"=====================================================
"let g:airline_theme='badwolf'
"let g:airline#extensions#tabline#enabled=1
"let g:airline#extensions#tabline#left_sep = ' '
"let g:airline#extensions#tabline#left_alt_sep = '|'
"let g:airline#extensions#tabline#formatter = 'default'
"let g:airline#extensions#tabline#formatter='unique_tail'
"let g:airline_powerline_fonts=1
"=====================================================
"" TagBar settings
"=====================================================
"let g:tagbar_autofocus=0
"let g:tagbar_width=42
"autocmd BufEnter *.py :call tagbar#autoopen(0)
"=====================================================
"" NERDTree settings
"=====================================================
let NERDTreeIgnore=['\.pyc$', '\.pyo$', '__pycache__$'] " Ignore files in NERDTree
let NERDTreeWinSize=40
let NERDTreeShowHidden=1
nmap <C-n> :NERDTreeToggle<CR>
" autocmd VimEnter * if !argc() | NERDTree | endif " Load NERDTree only if vim is run without arguments
" nmap " :NERDTreeToggle<CR>
let g:indent_guides_enable_on_vim_startup = 1
" hi IndentGuidesOdd ctermbg=black
hi IndentGuidesEven ctermbg=darkgrey
" hi IndentGuidesEven ctermbg='black'
let g:indent_guides_auto_colors = 1
let g:indent_guides_guide_size = 1
" let g:indent_guides_color_change_percent = 50
" hi IndentGuidesOdd guibg=red ctermbg=3
" hi IndentGuidesEven guibg=green ctermbg=4
let g:indentLine_char_list = ['|', '¦', '┆', '┊']
" Config ctags
set statusline+=%{gutentags#statusline()}
set tags=./.tags;,.tags
" gutentags ignore dir
let g:gutentags_project_root = ['.root', '.svn', '.git', '.hg', '.project']
" tag file name
let g:gutentags_ctags_tagfile = '.tags'
" put all tags files into ~/.cache/tags
let s:vim_tags = expand('~/.cache/tags')
let g:gutentags_cache_dir = s:vim_tags
"ctag config
let g:gutentags_ctags_extra_args = ['--fields=+niazS', '--extra=+q']
let g:gutentags_ctags_extra_args += ['--c++-kinds=+px']
let g:gutentags_ctags_extra_args += ['--c-kinds=+px']
" if not exist ~/.cache/tags then create
if !isdirectory(s:vim_tags)
silent! call mkdir(s:vim_tags, 'p')
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment