Skip to content

Instantly share code, notes, and snippets.

@ashnur
Created June 21, 2020 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashnur/e7db927ac308bb105b92a5eb9228fd84 to your computer and use it in GitHub Desktop.
Save ashnur/e7db927ac308bb105b92a5eb9228fd84 to your computer and use it in GitHub Desktop.
set nocompatible
filetype plugin indent on " Load plugins according to detected filetype.
set timeoutlen=766 " time is money
set ttimeoutlen=30 " less time more money
set number " where am I?
set relativenumber " where code is?
set scrolloff=500 " keep in center
set autoindent " Indent according to previous line.
set expandtab " Use spaces instead of tabs.
set softtabstop=2 " Tab key indents by 2 spaces.
set tabstop=2
set softtabstop=0
set smarttab
set shiftwidth=2 " >> indents by 2 spaces.
set shiftround " >> indents to next multiple of 'shiftwidth'.
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
set backspace =indent,eol,start " Make backspace work as you would expect.
set hidden " Switch between buffers without having to save first.
set laststatus =2 " Always show statusline.
set display =lastline " Show as much as possible of the last line.
set showmode " Show current mode in command-line.
set showcmd " Show already typed keys when more are expected.
set incsearch " Highlight while searching with / or ?.
set hlsearch " Keep matches highlighted.
set ignorecase " lazysearcher
set wildignore+=*/.git/*,*/tmp/*,*.swp
set ttyfast " Faster redrawing.
set lazyredraw " Only redraw when necessary.
set splitbelow " Open new windows below the current window.
set splitright " Open new windows right of the current window.
set wrapscan " Searches wrap around end-of-file.
set report =0 " Always report changed lines.
set synmaxcol =200 " Only highlight the first 200 columns.
set list " Show non-printable characters.
if has('multi_byte') && &encoding ==# 'utf-8'
let &listchars = 'tab:▸ ,extends:❯,precedes:❮,nbsp:±'
else
let &listchars = 'tab:> ,extends:>,precedes:<,nbsp:.'
endif
" The fish shell is not very compatible to other shells and unexpectedly
" breaks things that use 'shell'.
if &shell =~# 'fish$'
set shell=/bin/bash
endif
" Put all temporary files under the same directory.
" https://github.com/mhinz/vim-galore#handling-backup-swap-undo-and-viminfo-files
set backup
set backupdir =$HOME/.cache/.vim/files/backup/
set backupext =-vimbackup
set backupskip =
set directory =$HOME/.cache/.vim/files/swap/
set updatecount =100
set undofile
set undodir =$HOME/.cache/.vim/files/undo/
set viminfo ='100,n$HOME/.cache/.vim/files/info/viminfo
set fileencoding=utf-8 " Set utf-8 encoding on write
set packpath^=~/.cache/.vim
set runtimepath+=~/.cache/dein/repos/github.com/Shougo/dein.vim
if dein#load_state('~/.cache/dein')
call dein#begin('~/.cache/dein')
call dein#add('~/.cache/dein/repos/github.com/Shougo/dein.vim')
call dein#add('flrnprz/candid.vim') " dark theme
call dein#add('NLKNguyen/papercolor-theme') " light theme
call dein#add('freeo/vim-kalisi') " light theme
call dein#add('mhartington/oceanic-next') "dark theme
call dein#add('francoiscabrol/ranger.vim') " netrw replacement for directory navigation (what is the difference between editing a text file and navigating a directory)
call dein#add('rbgrouleff/bclose.vim') " Leader bd -> deletes the buffer but the window is not closed
call dein#add('itchyny/lightline.vim')
call dein#add('neomake/neomake')
call dein#add('jsfaint/gen_tags.vim')
call dein#add('tpope/vim-commentary')
call dein#add('tpope/vim-surround')
call dein#add('tpope/vim-markdown')
call dein#add('tpope/vim-eunuch') " :Delete :Unlink :Move :Rename :Chmod :Mkdir :Cfind :Clocate :Lfind / :Llocate :Wall :Sudowrite :Sudoedit
call dein#add('tpope/vim-ragtag') " django html
" call dein#add('tpope/vim-unimpaired') " bracket shortcuts
call dein#add('tpope/vim-sleuth') " source dependent indentation
" call dein#add('guns/vim-sexp')
" call dein#add('tpope/vim-sexp-mappings-for-regular-people') "
call dein#add('easymotion/vim-easymotion')
call dein#add('Olical/vim-enmasse')
call dein#add('Olical/vim-syntax-expand')
call dein#add('ctrlpvim/ctrlp.vim')
call dein#add('mhinz/vim-signify')
call dein#add('junegunn/vim-easy-align')
call dein#add('ycm-core/YouCompleteMe', { 'build': './install.py --js-completer' })
call dein#add('eraserhd/parinfer-rust', {'build': 'cargo build --release'})
call dein#add('liuchengxu/vim-clap', {'build': ':Clap install-binary'})
" call dein#add('liquidz/vim-iced')
" https://puredanger.github.io/tech.puredanger.com/2011/09/02/clojure-hills-of-abstraction/
call dein#add('Olical/conjure', {'rev': 'v3.4.0'})
call dein#add('suan/vim-instant-markdown', {'rtp': 'after'})
call dein#end()
call dein#save_state()
endif
packloadall
silent! helptags ALL
let mapleader="\<SPACE>"
let maplocalleader = ","
function! Clean_dein() abort
call dein#recache_runtimepath()
call map(dein#check_clean(), "delete(v:val, 'rf')")
endfunction
" Required for operations modifying multiple buffers like rename.
set hidden
" SHORTCUTS
"
" SPC f r Reveal current file on NERDTree
" :nnoremap <leader>fr
" SPC f s Save current buffer
" SPC f S Save current buffer
:nnoremap <leader>fs :w<CR>
" SPC f t Toggle NERDTree
" SPC f n Synchronize NERDTree with project root
" SPC f e d Open $MYVIMRC
:nnoremap <leader>fed :e ~/.config/nvim/init.vim<CR>
" SPC f e U Update plugins
:nnoremap <leader>feU :call dein#update()<CR>
" SPC f e c clear plugins
:nnoremap <leader>fec :call Clean_dein()<CR>
" SPC f e R Reload config file
:nnoremap <leader>feR :so ~/.config/nvim/init.vim<CR>
" SPC bn next buffer
:nnoremap <leader>bn :bn<CR>
" SPC bp prev buffer
:nnoremap <leader>bp :bp<CR>
" Eyecandy
set termguicolors " MY EYES
" set background=dark
set background=light
syntax on " Enable syntax highlighting.
set signcolumn=yes
" colorscheme candid
colorscheme PaperColor
" colorscheme OceanicNext
" colorscheme kalisi
" let g:lightline = {'colorscheme':'candid'}
set cursorline " Find the current line quickly.
" highlight CursorLine guifg=NONE guibg=NONE gui=NONE,NONE guibg=Grey25
" highlight CursorColumn guifg=NONE guibg=NONE gui=NONE,NONE term=bold cterm=bold guibg=Grey25
" highlight CursorLine guifg=NONE guibg=NONE gui=NONE,NONE guibg=Grey25
" highlight CursorColumn guifg=NONE guibg=NONE gui=NONE,NONE term=bold cterm=bold guibg=Grey25
if exists('+cursorline')
set cursorline cursorcolumn
endif
set cmdheight=2
" Miscellaneous
" suppress the annoying 'match x of y', 'The only match' and 'Pattern not
" found' messages
set shortmess+=c
" CTRL-C doesn't trigger the InsertLeave autocmd . map to <ESC> instead.
inoremap <c-c> <ESC>
" 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>")
" Use <TAB> to select the popup menu:
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
au BufNewFile,BufRead *.mjs set filetype=javascript
let g:ranger_replace_netrw = 1 " open ranger when vim open a directory
" To get correct comment highlighting, add:
autocmd FileType json syntax match Comment +\/\/.\+$+
" vim easy align
" 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)
" ctrlp
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
" let g:ctrlp_user_command = 'rg "%s" -l --no-heading --hidden -g "" '
if executable('rg')
set grepprg=rg\ --color=never\ --hidden\ --no-heading\ -l
let g:ctrlp_user_command = 'rg %s --files --color=never --glob "" --hidden --no-heading -'
let g:ctrlp_use_caching = 0
endif
" let g:ctrlp_user_command = 'rg --files-with-matches ".*" "%s"'
" let g:ctrlp_user_command = 'rg -l --no-heading --hidden -g "" --files-with-matches ".*" --files "%s"'
" neomake
nmap <localleader>nmo :lopen<CR> " open location window
nmap <localleader>nmc :lclose<CR> " close location window
nmap <localleader>nm, :ll<CR> " go to current error/warning
nmap <localleader>nmn :lnext<CR> " next error/warning
nmap <localleader>nmp :lprev<CR> " previous error/warning
" eslint
let g:neomake_javascript_eslint_maker = {
\ 'args': ['--format=compact'],
\ 'errorformat': '%E%f: line %l\, col %c\, Error - %m,' .
\ '%W%f: line %l\, col %c\, Warning - %m,%-G,%-G%*\d problems%#',
\ 'cwd': '%:p:h',
\ 'output_stream': 'stdout',
\ }
let g:neomake_javascript_enabled_makers = ['eslint']
let g:neomake_open_list = 2
let g:neomake_joker_maker = {
\ 'exe': 'joker',
\ 'args': ['--lint'],
\ 'errorformat': 'jkr %f:%l:%c: %*[^ ] %t%*[^:]: %m',
\ }
let g:neomake_cljkondo_maker = {
\ 'exe': 'clj-kondo',
\ 'args': ['--lint'],
\ 'errorformat': '%f:%l:%c:\ Parse\ %t%*[^:]:\ %m,%f:%l:%c:\ %t%*[^:]:\ %m',
\ }
let g:neomake_clojure_enabled_makers = [ 'cljkondo']
call neomake#configure#automake('nrw')
autocmd! BufWritePost,BufEnter * Neomake
" autocmd FileType javascript.jsx,javascript setlocal formatprg=prettier\ --stdin\ --trailing-comma=all\ --no-semi
" autocmd FileType javascript setlocal formatprg=./node_modules/.bin/prettier-eslint\ --stdin
autocmd FileType json set formatprg=jq
" autocmd BufWritePre *.js :normal gggqG
" autocmd FileType javascript let &l:formatprg = g:prettier_eslint_path2.' --stdin --eslint-config-path '. g:eslintrc_full_path
" conceal
" Map the conceal characters to their expanded forms.
" inoremap <silent> @ <C-r>=syntax_expand#expand("@", "this")<CR>
" inoremap <silent> # <C-r>=syntax_expand#expand("#", "prototype")<CR>
" inoremap <silent> < <C-r>=syntax_expand#expand_head("<", "return")<CR>
" " Keeps everything concealed at all times. Even when my cursor is on the word.
" set conceallevel=1
" set concealcursor=nvic
" " JavaScript thanks to pangloss/vim-javascript
" let g:javascript_conceal_function = "λ"
" let g:javascript_conceal_this = "@"
" let g:javascript_conceal_return = "<"
" let g:javascript_conceal_prototype = "#"
"
"
" UNIMPAIRED
"
"
"
" nnoremap <leader>fr gggqG
nnoremap ; :
" Open file menu
nnoremap <Leader>o :CtrlP<CR>
" Open buffer menu
nnoremap <Leader>b :CtrlPBuffer<CR>
" Open most recently used files
" nnoremap <Leader>f :CtrlPMRUFiles<CR>
nnoremap <leader>cs :let @/ = ""<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment