-
-
Save kexposito/6a22cf04e83402c64b77c1434e63bef5 to your computer and use it in GitHub Desktop.
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
" noremap <Up> <Nop> | |
" noremap <Down> <Nop> | |
" noremap <Left> <Nop> | |
" noremap <Right> <Nop> | |
"Buffers" | |
map ]b :bnext<CR> | |
map [b :bprev<CR> | |
map <C-b> :CtrlPBuffer<CR> | |
" same insert cursor all modes | |
set guicursor= | |
" use mouse to move | |
set mouse=a | |
"relative number | |
set number relativenumber | |
set numberwidth=1 | |
",e mapping to open file current dir | |
map ,e :e <C-R>=expand("%:p:h") . "/" <CR> | |
map ,vs :vs <C-R>=expand("%:p:h") . "/" <CR> | |
" yank text | |
set cpoptions+=y | |
set clipboard=unnamed | |
syntax enable | |
" line number at bottom | |
set showcmd | |
" Config alternative escape options | |
imap jj <Esc> | |
imap kk <Esc> | |
imap kj <Esc> | |
imap jk <Esc> | |
" Allow 10 lines margin when scrolling | |
set scrolloff=10 | |
"highlight matching [{}] | |
set showmatch | |
" indent using 2 spaces | |
set sw=2 | |
" MyComd | |
cmap hember e ~/.config/nvim/docs/ember.wiki | |
" set autoindent | |
set ignorecase | |
set hlsearch | |
" Set split separator to Unicode box drawing character | |
set encoding=utf8 | |
set fillchars=vert:│ | |
" Always show status | |
" set laststatus=2G | |
" Override color scheme to make split the same color as tmux's default | |
autocmd ColorScheme * highlight VertSplit cterm=NONE ctermfg=Green ctermbg=NONE | |
" change order of lines | |
vnoremap J :m '>+1<CR>gv=gv | |
vnoremap K :m '<-2<CR>gv=gv | |
nmap J :m '>+1<CR>gv=gv | |
nmap K :m '<-2<CR>gv=gv | |
nmap <silent> ,/ :nohlsearch<CR> | |
let mapleader=" " | |
nmap <Leader>+h ^ | |
nmap <Leader>+l $ | |
vmap <Leader>+h ^ | |
vmap <Leader>+l $ | |
call plug#begin("~/.vim/plugged") | |
Plug 'scrooloose/nerdtree' | |
Plug 'https://github.com/altercation/vim-colors-solarized' | |
Plug 'jpo/vim-railscasts-theme' | |
Plug 'overcache/NeoSolarized' | |
Plug 'https://github.com/tpope/vim-rails' | |
Plug 'https://github.com/bronson/vim-trailing-whitespace' | |
Plug 'https://github.com/tpope/vim-commentary' | |
Plug 'ctrlpvim/ctrlp.vim' | |
Plug 'https://github.com/tpope/vim-fugitive' | |
Plug 'easymotion/vim-easymotion' | |
Plug 'christoomey/vim-tmux-navigator' | |
Plug 'morhetz/gruvbox' | |
" Plug 'jiangmiao/auto-pairs' | |
Plug 'https://github.com/dhruvasagar/vim-zoom' | |
" Plug 'https://github.com/mustache/vim-mustache-handlebars' | |
Plug 'joukevandermaas/vim-ember-hbs' | |
Plug 'https://github.com/pangloss/vim-javascript' | |
" Plug 'https://github.com/othree/yajs.vim' | |
" | |
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' } | |
"Neovim 0.5 | |
Plug 'nvim-lua/popup.nvim' | |
Plug 'nvim-lua/plenary.nvim' | |
Plug 'nvim-telescope/telescope.nvim' | |
Plug 'dracula/vim', { 'as': 'dracula' } | |
" Harpoon | |
Plug 'ThePrimeagen/harpoon' | |
Plug 'elixir-editors/vim-elixir' | |
Plug 'vimwiki/vimwiki' | |
" Plug 'https://github.com/alvan/vim-closetag' | |
" Plug 'kdheepak/lazygit.nvim' | |
" React | |
Plug 'maxmellon/vim-jsx-pretty' | |
" COC | |
" Use release branch (recommend) | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
" Or build from source code by using yarn: https://yarnpkg.com | |
Plug 'neoclide/coc.nvim', {'branch': 'master', 'do': 'yarn install --frozen-lockfile'} | |
" LazyGit | |
Plug 'kdheepak/lazygit.nvim' | |
call plug#end() | |
"" | |
"" Whitespace | |
"" | |
set wrap " wrap lines, use set nowrap to avoid wrapping | |
set softtabstop=2 " use mix of spaces and tabs | |
set shiftwidth=2 " an autoindent (with <<) is two spaces | |
set expandtab " use spaces, not tabs | |
set backspace=indent,eol,start " backspace through everything in insert mode | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Lazy Git | |
" let g:lazygit_floating_window_winblend = 0 " transparency of floating window | |
" let g:lazygit_floating_window_scaling_factor = 0.9 " scaling factor for floating window | |
" let g:lazygit_floating_window_corner_chars = ['╭', '╮', '╰', '╯'] " customize lazygit popup window corner characters | |
" let g:lazygit_floating_window_use_plenary = 0 " use plenary.nvim to manage floating window if available | |
" let g:lazygit_use_neovim_remote = 1 " fallback to 0 if neovim-remote is not installed | |
nnoremap <silent> <leader>gg :LazyGit<CR> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Mustache Abbreviations | |
" let g:mustache_abbreviations = 0 | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" EasyMotion | |
nmap <Leader>s <Plug>(easymotion-s2) | |
" <Leader>f{char} to move to {char} | |
map <Leader>f <Plug>(easymotion-bd-f) | |
nmap <Leader>f <Plug>(easymotion-overwin-f) | |
" Gif config | |
map / <Plug>(easymotion-sn) | |
omap / <Plug>(easymotion-tn) | |
" Move to line | |
map <Leader>L <Plug>(easymotion-bd-jk) | |
nmap <Leader>L <Plug>(easymotion-overwin-line) | |
" Move to word | |
map <Leader>w <Plug>(easymotion-bd-w) | |
nmap <Leader>w <Plug>(easymotion-overwin-w) | |
" These `n` & `N` mappings are options. You do not have to map `n` & `N` to EasyMotion. | |
" Without these mappings, `n` & `N` works fine. (These mappings just provide | |
" different highlight method and have some other features ) | |
map n <Plug>(easymotion-next) | |
map N <Plug>(easymotion-prev) | |
" <Leader><Leader>w(<Plug>(easymotion-w)) <- :D | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" CtrlpVim | |
let g:ctrlp_map = '<c-p>' | |
let g:ctrlp_cmd = 'CtrlP' | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Gruvbox | |
" colorscheme gruvbox | |
" let g:gruvbox_constrat_dark = "hard" | |
" Gruvbox colorscheme with italics and true colors | |
" scriptencoding utf-8 | |
" let &t_8f = '[38;2;%lu;%lu;%lum' | |
" let &t_8b = '[48;2;%lu;%lu;%lum' | |
" scriptencoding | |
" " set termguicolors | |
" let g:gruvbox_contrast_dark="hard" | |
" let g:gruvbox_italic = 1 | |
" colorscheme gruvbox | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Railcast | |
colorscheme railscasts | |
set background=dark | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Dracula | |
" colorscheme dracula | |
" set background=dark | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" NerdTree | |
nnoremap <C-n> :NERDTreeToggle<CR> | |
" cloase vim when nerdtree is open and no other content | |
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | |
let g:NERDTreeStatusline = '%#NonText#' | |
"""Vim zoom""" | |
" set statusline+=%{zoom#statusline()} | |
nmap <Leader>m <Plug>(zoom-toggle) | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Vim Mustache Handlebars | |
let g:mustache_abbreviations = 1 | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Telescope | |
" Find files using Telescope command-line sugar. | |
nnoremap <leader>p <cmd>Telescope find_files<cr> | |
nnoremap <leader>b <cmd>Telescope buffers show_all_buffers=true<cr> | |
nnoremap <leader>c <cmd>Telescope git_commits<cr> | |
nnoremap <leader>g <cmd>Telescope live_grep<cr> | |
lua require('telescope').setup{defaults = { file_ignore_patterns = { 'node_modules', 'node_modules/', 'node%_modules' }}} | |
" nnoremap <leader>b <cmd>lua require('telescope.builtin').buffers{ show_all_buffers = true }<cr> | |
" nnoremap <leader>p <cmd>lua require('telescope.builtin').find_files()<cr> | |
" nnoremap <leader>g <cmd>lua require('telescope.builtin').live_grep()<cr> | |
" " nnoremap <leader>b <cmd>lua require('telescope.builtin').buffers()<cr> | |
" nnoremap <leader>h <cmd>lua require('telescope.builtin').help_tags()<cr> | |
" | |
" | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" WikiVim | |
set nocompatible | |
filetype plugin on | |
syntax on | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Vim Fugitive Ggrep navigation | |
nmap [q <cmd>:cprev<cr> | |
nmap ]q <cmd>:cnext<cr> | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""coc | |
" Set internal encoding of vim, not needed on neovim, since coc.nvim using some | |
" unicode characters in the file autoload/float.vim | |
set encoding=utf-8 | |
" TextEdit might fail if hidden is not set. | |
set hidden | |
" Some servers have issues with backup files, see #649. | |
set nobackup | |
set nowritebackup | |
" Give more space for displaying messages. | |
set cmdheight=2 | |
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable | |
" delays and poor user experience. | |
set updatetime=300 | |
" Don't pass messages to |ins-completion-menu|. | |
set shortmess+=c | |
" Always show the signcolumn, otherwise it would shift the text each time | |
" diagnostics appear/become resolved. | |
if has("nvim-0.5.0") || has("patch-8.1.1564") | |
" Recently vim can merge signcolumn and number column into one | |
set signcolumn=number | |
else | |
set signcolumn=yes | |
endif | |
" Use tab for trigger completion with characters ahead and navigate. | |
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by | |
" other plugin before putting this into your config. | |
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. | |
if has('nvim') | |
inoremap <silent><expr> <c-space> coc#refresh() | |
else | |
inoremap <silent><expr> <c-@> coc#refresh() | |
endif | |
" 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>" | |
" Move between errors | |
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) | |
" 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') | |
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 | |
" 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) | |
" Map function and class text objects | |
" NOTE: Requires 'textDocument.documentSymbol' support from the language server. | |
xmap if <Plug>(coc-funcobj-i) | |
omap if <Plug>(coc-funcobj-i) | |
xmap af <Plug>(coc-funcobj-a) | |
omap af <Plug>(coc-funcobj-a) | |
xmap ic <Plug>(coc-classobj-i) | |
omap ic <Plug>(coc-classobj-i) | |
xmap ac <Plug>(coc-classobj-a) | |
omap ac <Plug>(coc-classobj-a) | |
" 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 | |
" Use CTRL-S for selections ranges. | |
" Requires 'textDocument/selectionRange' support of language server. | |
nmap <silent> <C-s> <Plug>(coc-range-select) | |
xmap <silent> <C-s> <Plug>(coc-range-select) | |
" Add `:Format` command to format current buffer. | |
command! -nargs=0 Format :call CocAction('format') | |
" Add `:Fold` command to fold current buffer. | |
command! -nargs=? Fold :call CocAction('fold', <f-args>) | |
" Add `:OR` command for organize imports of the current buffer. | |
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') | |
" Mappings for CoCList | |
" Show all diagnostics. | |
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr> | |
" Manage extensions. | |
nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr> | |
" Show commands. | |
nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr> | |
" Find symbol of current document. | |
nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr> | |
" Search workspace symbols. | |
nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr> | |
" Do default action for next item. | |
nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR> | |
" Do default action for previous item. | |
nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR> | |
" Resume latest coc list. | |
nnoremap <silent><nowait> <space>r :<C-u>CocListResume<CR> | |
""" Customize colors | |
hi Pmenu ctermbg=black ctermfg=white | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""' MArkdownVim MArkdown | |
" set to 1, nvim will open the preview window after entering the markdown buffer | |
" default: 0 | |
let g:mkdp_auto_start = 0 | |
" set to 1, the nvim will auto close current preview window when change | |
" from markdown buffer to another buffer | |
" default: 1 | |
let g:mkdp_auto_close = 1 | |
" set to 1, the vim will refresh markdown when save the buffer or | |
" leave from insert mode, default 0 is auto refresh markdown as you edit or | |
" move the cursor | |
" default: 0 | |
let g:mkdp_refresh_slow = 0 | |
" set to 1, the MarkdownPreview command can be use for all files, | |
" by default it can be use in markdown file | |
" default: 0 | |
let g:mkdp_command_for_global = 0 | |
" set to 1, preview server available to others in your network | |
" by default, the server listens on localhost (127.0.0.1) | |
" default: 0 | |
let g:mkdp_open_to_the_world = 0 | |
" use custom IP to open preview page | |
" useful when you work in remote vim and preview on local browser | |
" more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9 | |
" default empty | |
let g:mkdp_open_ip = '' | |
" specify browser to open preview page | |
" default: '' | |
let g:mkdp_browser = '' | |
" set to 1, echo preview page url in command line when open preview page | |
" default is 0 | |
let g:mkdp_echo_preview_url = 0 | |
" a custom vim function name to open preview page | |
" this function will receive url as param | |
" default is empty | |
let g:mkdp_browserfunc = '' | |
" options for markdown render | |
" mkit: markdown-it options for render | |
" katex: katex options for math | |
" uml: markdown-it-plantuml options | |
" maid: mermaid options | |
" disable_sync_scroll: if disable sync scroll, default 0 | |
" sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle' | |
" middle: mean the cursor position alway show at the middle of the preview page | |
" top: mean the vim top viewport alway show at the top of the preview page | |
" relative: mean the cursor position alway show at the relative positon of the preview page | |
" hide_yaml_meta: if hide yaml metadata, default is 1 | |
" sequence_diagrams: js-sequence-diagrams options | |
" content_editable: if enable content editable for preview page, default: v:false | |
" disable_filename: if disable filename header for preview page, default: 0 | |
let g:mkdp_preview_options = { | |
\ 'mkit': {}, | |
\ 'katex': {}, | |
\ 'uml': {}, | |
\ 'maid': {}, | |
\ 'disable_sync_scroll': 0, | |
\ 'sync_scroll_type': 'middle', | |
\ 'hide_yaml_meta': 1, | |
\ 'sequence_diagrams': {}, | |
\ 'flowchart_diagrams': {}, | |
\ 'content_editable': v:false, | |
\ 'disable_filename': 0 | |
\ } | |
" use a custom markdown style must be absolute path | |
" like '/Users/username/markdown.css' or expand('~/markdown.css') | |
let g:mkdp_markdown_css = '' | |
" use a custom highlight style must absolute path | |
" like '/Users/username/highlight.css' or expand('~/highlight.css') | |
let g:mkdp_highlight_css = '' | |
" use a custom port to start server or random for empty | |
let g:mkdp_port = '' | |
" preview page title | |
" ${name} will be replace with the file name | |
let g:mkdp_page_title = '「${name}」' | |
" recognized filetypes | |
" these filetypes will have MarkdownPreview... commands | |
let g:mkdp_filetypes = ['markdown'] | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" LazyGit | |
nnoremap <silent> <leader>gg :LazyGit<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment