Skip to content

Instantly share code, notes, and snippets.

@skydevht
Last active May 8, 2020 16:45

Revisions

  1. skydevht revised this gist May 8, 2020. 1 changed file with 8 additions and 78 deletions.
    86 changes: 8 additions & 78 deletions init.vim
    Original file line number Diff line number Diff line change
    @@ -1,38 +1,27 @@
    " Plugins {{{1
    ": Plugins {{{1
    call plug#begin()

    " Language
    Plug 'sheerun/vim-polyglot'
    Plug 'reasonml-editor/vim-reason-plus'
    Plug 'mattn/emmet-vim'
    Plug 'tpope/vim-surround'
    Plug 'w0rp/ale'
    Plug 'fatih/vim-go', { 'tag': 'v1.21', 'do': ':GoUpdateBinaries', 'frozen': 1 }
    Plug 'ledger/vim-ledger'
    " Integration
    Plug 'tpope/vim-dispatch'
    Plug 'tpope/vim-projectionist'
    Plug 'tpope/vim-fugitive'
    Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
    Plug 'junegunn/fzf.vim'
    " Completion
    Plug 'SirVer/ultisnips'
    Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}}
    Plug 'mcchrish/nnn.vim'
    " Interface
    Plug 'airblade/vim-gitgutter'
    Plug 'unblevable/quick-scope'
    " Commands
    Plug 'justinmk/vim-sneak'
    Plug 'tpope/vim-vinegar'
    Plug 'tpope/vim-repeat'
    Plug 'tpope/vim-commentary'
    Plug 'godlygeek/tabular'
    Plug 'wellle/targets.vim'
    Plug 'arithran/vim-delete-hidden-buffers'
    Plug 'igemnace/vim-makery'
    " Code Display
    Plug 'mhinz/vim-startify'
    " Plug 'morhetz/gruvbox'
    Plug 'robertmeta/nofrils'
    Plug 'chriskempson/base16-vim'
    Plug 'ap/vim-css-color'

    @@ -183,24 +172,9 @@ nmap <leader>gw :Gwrite<CR>
    nmap <leader>ge :Gedit<CR>
    " Function keys {{{2
    noremap <F3> :ALEFix<CR>
    noremap <F5> :source $MYVIMRC<CR>
    nnoremap <F10> :e $MYVIMRC<CR>
    " UltiSnips {{{2
    let g:UltiSnipsExpandTrigger="<TAB>"
    let g:UltiSnipsJumpForwardTrigger="<TAB>"

    " Git Gutter
    let g:gitgutter_map_keys = 0
    " COC {{{2
    nmap <silent> <leader>rg <Plug>(coc-definition)
    nmap <silent> <leader>rr <Plug>(coc-references)
    nmap <silent> <leader>ri <Plug>(coc-implementation)
    nmap <silent> <leader>rd <Plug>(coc-diagnostic-info)
    nmap <silent> <leader>rn <Plug>(coc-diagnostic-next)
    nmap <silent> <leader>rp <Plug>(coc-diagnostic-prev)
    " FZF {{{2
    nmap <leader>fb :Buffers<cr>
    nmap <leader>ff :Files<cr>
    @@ -219,54 +193,9 @@ let g:user_emmet_settings = {
    \ },
    \ }
    let g:user_emmet_leader_key='<C-i>'
    " Ale {{{2
    let g:ale_completion_enabled = 0
    let g:ale_fix_on_save = 1
    augroup CloseLoclistWindowGroup
    autocmd!
    autocmd QuitPre * if empty(&buftype) | lclose | endif
    augroup END
    let g:ale_linters = {
    \ 'javascript': ['flow', 'eslint'],
    \ 'pug': ['puglint']
    \}
    let g:ale_fixers = {
    \ 'javascript': ['eslint'],
    \ 'perl': ['perl'],
    \ 'php': ['php_cs_fixer'],
    \ 'json': ['jq'],
    \ 'css': ['prettier'],
    \ 'html': ['prettier'],
    \ 'dart': ['dartfmt'],
    \ 'typescript': ['prettier'],
    \}
    let g:ale_sign_error = ''
    let g:ale_sign_warning = ''
    " Startify {{{2
    let g:startify_change_to_vcs_root = 1
    let g:startify_change_to_dir = 0

    let g:startify_lists = [
    \ { 'type': 'dir', 'header': [' MRU '. getcwd()] },
    \ { 'type': 'files', 'header': [' MRU'] },
    \ { 'type': 'sessions', 'header': [' Sessions'] },
    \ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
    \ { 'type': 'commands', 'header': [' Commands'] },
    \ ]

    let g:ascii = [
    \ ' ____ _ _ ',
    \ '/ ___|| | ___ _ __| | _____ __',
    \ '\___ \| |/ / | | |/ _` |/ _ \ \ / /',
    \ ' ___) | <| |_| | (_| | __/\ V / ',
    \ '|____/|_|\_\\__, |\__,_|\___| \_/ ',
    \ ' |___/ ',
    \ ''
    \]
    let g:startify_custom_header =
    \ map(g:ascii + startify#fortune#boxed(), '" ".v:val')


    "
    " NNN {{{2
    nnoremap - :NnnPicker '%:p:h'<CR>
    " Colors {{{1
    " Custom highlight {{{2
    hi jsClassDefinition gui=bold
    @@ -282,5 +211,6 @@ augroup END
    " Colorscheme {{{2
    colorscheme base16-eighties

    set errorformat+=%f:\ line\ %l\\,\ col\ %c\\,\ %m,%-G%.%#
    " {{{0
    " vim:fdm=marker:fdl=1
    " vim:fdm=marker:fdl=1
  2. skydevht renamed this gist May 8, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. skydevht revised this gist May 8, 2020. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions javascript.vim
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    set foldmethod=syntax
    set foldnestmax=10
    set nofoldenable
    set foldlevel=2

    setlocal makeprg=yarn\ --silent\ eslint\ --format\ compact\ --fix
    setlocal formatprg=yarn\ --silent\ prettier\ --stdin-filepath\ %

    setlocal autoread
    augroup JS
    autocmd! * <buffer>
    autocmd BufWritePost <buffer> silent make <afile> | checktime | silent redraw!
    augroup END
  4. skydevht revised this gist May 6, 2020. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions init.vim
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,7 @@ Plug 'mattn/emmet-vim'
    Plug 'tpope/vim-surround'
    Plug 'w0rp/ale'
    Plug 'fatih/vim-go', { 'tag': 'v1.21', 'do': ':GoUpdateBinaries', 'frozen': 1 }
    Plug 'ledger/vim-ledger'
    " Integration
    Plug 'tpope/vim-dispatch'
    Plug 'tpope/vim-projectionist'
    @@ -23,6 +24,7 @@ Plug 'unblevable/quick-scope'
    " Commands
    Plug 'justinmk/vim-sneak'
    Plug 'tpope/vim-vinegar'
    Plug 'tpope/vim-repeat'
    Plug 'tpope/vim-commentary'
    Plug 'godlygeek/tabular'
    Plug 'wellle/targets.vim'
    @@ -216,10 +218,10 @@ let g:user_emmet_settings = {
    \ 'extends' : 'jsx',
    \ },
    \ }
    let g:user_emmet_leader_key='<C-i>'
    " Ale {{{2
    let g:ale_completion_enabled = 0
    let g:ale_fix_on_save = 1
    let g:ale_open_list = 'on_save'
    augroup CloseLoclistWindowGroup
    autocmd!
    autocmd QuitPre * if empty(&buftype) | lclose | endif
    @@ -233,7 +235,6 @@ let g:ale_fixers = {
    \ 'perl': ['perl'],
    \ 'php': ['php_cs_fixer'],
    \ 'json': ['jq'],
    \ 'scss': ['prettier'],
    \ 'css': ['prettier'],
    \ 'html': ['prettier'],
    \ 'dart': ['dartfmt'],
    @@ -282,4 +283,4 @@ augroup END
    colorscheme base16-eighties

    " {{{0
    " vim:fdm=marker:fdl=1
    " vim:fdm=marker:fdl=1
  5. skydevht revised this gist Dec 2, 2019. 1 changed file with 18 additions and 11 deletions.
    29 changes: 18 additions & 11 deletions init.vim
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,7 @@ Plug 'reasonml-editor/vim-reason-plus'
    Plug 'mattn/emmet-vim'
    Plug 'tpope/vim-surround'
    Plug 'w0rp/ale'
    Plug 'fatih/vim-go', { 'tag': 'v1.21', 'do': ':GoUpdateBinaries', 'frozen': 1 }
    " Integration
    Plug 'tpope/vim-dispatch'
    Plug 'tpope/vim-projectionist'
    @@ -28,7 +29,9 @@ Plug 'wellle/targets.vim'
    Plug 'arithran/vim-delete-hidden-buffers'
    " Code Display
    Plug 'mhinz/vim-startify'
    Plug 'morhetz/gruvbox'
    " Plug 'morhetz/gruvbox'
    Plug 'robertmeta/nofrils'
    Plug 'chriskempson/base16-vim'
    Plug 'ap/vim-css-color'

    call plug#end()
    @@ -94,7 +97,7 @@ set statusline+=\ [%{strlen(&fenc)?&fenc:'none'}, " file encoding
    set statusline+=%{&ff}]\ " file format
    set statusline+=%c\ " cursor column
    set statusline+=%l/%L\ " cursor line/total lines
    set statusline+=\ %{strftime(\"%H:%M\")} " time

    " Mappings {{{1
    " Leader {{{2
    let mapleader = ","
    @@ -126,6 +129,7 @@ map <C-l> <C-W>l
    noremap <leader>bq :q<cr>
    map <leader>bd :Bclose<cr>
    map <leader>ba :bufdo bd<cr>
    map <leader>bo :only<cr>
    " Tabs {{{2
    map <leader>tn :tabnew<cr>
    @@ -215,13 +219,19 @@ let g:user_emmet_settings = {
    " Ale {{{2
    let g:ale_completion_enabled = 0
    let g:ale_fix_on_save = 1
    let g:ale_open_list = 'on_save'
    augroup CloseLoclistWindowGroup
    autocmd!
    autocmd QuitPre * if empty(&buftype) | lclose | endif
    augroup END
    let g:ale_linters = {
    \ 'javascript': ['flow', 'eslint'],
    \ 'pug': ['puglint']
    \}
    let g:ale_fixers = {
    \ 'javascript': ['eslint'],
    \ 'perl': ['perl'],
    \ 'php': ['phpcbf'],
    \ 'php': ['php_cs_fixer'],
    \ 'json': ['jq'],
    \ 'scss': ['prettier'],
    \ 'css': ['prettier'],
    @@ -231,8 +241,6 @@ let g:ale_fixers = {
    \}
    let g:ale_sign_error = ''
    let g:ale_sign_warning = ''
    " AutoPairs {{{2
    let g:AutoPairsMapSpace = 0
    " Startify {{{2
    let g:startify_change_to_vcs_root = 1
    let g:startify_change_to_dir = 0
    @@ -258,10 +266,7 @@ let g:startify_custom_header =
    \ map(g:ascii + startify#fortune#boxed(), '" ".v:val')


    " Colorscheme {{{1
    let g:gruvbox_contrast_dark='soft'
    set background=dark
    colorscheme gruvbox
    " Colors {{{1
    " Custom highlight {{{2
    hi jsClassDefinition gui=bold
    hi jsFuncArgs gui=italic
    @@ -270,9 +275,11 @@ let g:javascript_plugin_flow = 1
    " Quick Scope {{{2
    augroup qs_colors
    autocmd!
    autocmd ColorScheme * highlight QuickScopePrimary guifg='#afff5f' gui=underline ctermfg=155 cterm=underline
    autocmd ColorScheme * highlight QuickScopeSecondary guifg='#5fffff' gui=underline ctermfg=81 cterm=underline
    autocmd ColorScheme * highlight QuickScopePrimary guifg='#00c200' gui=underline ctermfg=155 cterm=underline
    autocmd ColorScheme * highlight QuickScopeSecondary guifg='#00c5c7' gui=underline ctermfg=81 cterm=underline
    augroup END
    " Colorscheme {{{2
    colorscheme base16-eighties

    " {{{0
    " vim:fdm=marker:fdl=1
  6. skydevht revised this gist Sep 27, 2019. No changes.
  7. skydevht revised this gist Sep 27, 2019. 1 changed file with 21 additions and 0 deletions.
    21 changes: 21 additions & 0 deletions init.vim
    Original file line number Diff line number Diff line change
    @@ -237,6 +237,27 @@ let g:AutoPairsMapSpace = 0
    let g:startify_change_to_vcs_root = 1
    let g:startify_change_to_dir = 0

    let g:startify_lists = [
    \ { 'type': 'dir', 'header': [' MRU '. getcwd()] },
    \ { 'type': 'files', 'header': [' MRU'] },
    \ { 'type': 'sessions', 'header': [' Sessions'] },
    \ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
    \ { 'type': 'commands', 'header': [' Commands'] },
    \ ]

    let g:ascii = [
    \ ' ____ _ _ ',
    \ '/ ___|| | ___ _ __| | _____ __',
    \ '\___ \| |/ / | | |/ _` |/ _ \ \ / /',
    \ ' ___) | <| |_| | (_| | __/\ V / ',
    \ '|____/|_|\_\\__, |\__,_|\___| \_/ ',
    \ ' |___/ ',
    \ ''
    \]
    let g:startify_custom_header =
    \ map(g:ascii + startify#fortune#boxed(), '" ".v:val')


    " Colorscheme {{{1
    let g:gruvbox_contrast_dark='soft'
    set background=dark
  8. skydevht revised this gist Sep 22, 2019. 1 changed file with 75 additions and 242 deletions.
    317 changes: 75 additions & 242 deletions init.vim
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,11 @@
    " Plugins {{{1
    call plug#begin()

    " Language
    " Language
    Plug 'sheerun/vim-polyglot'
    Plug 'reasonml-editor/vim-reason-plus'
    Plug 'mattn/emmet-vim'
    Plug 'tpope/vim-surround'
    Plug 'dart-lang/dart-vim-plugin'
    Plug 'w0rp/ale'
    " Integration
    Plug 'tpope/vim-dispatch'
    @@ -15,17 +14,13 @@ Plug 'tpope/vim-fugitive'
    Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
    Plug 'junegunn/fzf.vim'
    " Completion
    Plug 'jiangmiao/auto-pairs'
    Plug 'SirVer/ultisnips'
    Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}}
    " Interface
    Plug 'itchyny/lightline.vim'
    Plug 'airblade/vim-gitgutter'
    Plug 'moll/vim-bbye'
    Plug 'unblevable/quick-scope'
    " Commands
    Plug 'justinmk/vim-sneak'
    Plug 'tpope/vim-unimpaired'
    Plug 'tpope/vim-vinegar'
    Plug 'tpope/vim-commentary'
    Plug 'godlygeek/tabular'
    @@ -34,40 +29,35 @@ Plug 'arithran/vim-delete-hidden-buffers'
    " Code Display
    Plug 'mhinz/vim-startify'
    Plug 'morhetz/gruvbox'
    Plug 'nlknguyen/papercolor-theme'
    Plug 'skydevht/palenight.vim'
    Plug 'jacoborus/tender.vim'
    Plug 'ap/vim-css-color'
    Plug 'ryanoasis/vim-devicons'

    call plug#end()

    " General Options {{{1
    scriptencoding utf-8
    " Global Configuration Options {{{2
    set encoding=utf-8
    " Global Configuration Options {{{1
    lang en_US.UTF-8
    set backspace=indent,eol,start " Make backspace work like most other programs
    set nobackup
    " Backup {{{2
    set nowritebackup
    set noswapfile
    " Visual Indicator {{{2
    set colorcolumn=81 " Set the 80 character column (+1 if textwidth is defined else 81)
    set cursorline " Highlight the current line
    set hidden " Any buffer can be hidden
    set number
    set history=1000 " Set a huge history
    set lazyredraw " Render window only after the end of a macro
    set hidden " Any buffer can be hidden
    set linespace=0 " No extra spaces between rows
    " Writing {{{2
    set lazyredraw " Render window only after the end of a macro
    set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
    set showmatch " Show current brackets
    " Scrolling {{{2
    set scrolljump=5 " Lines to scroll when cursor leaves screen
    set scrolloff=3 " Minimum lines to keep above and below cursor
    set showmatch " Show current brackets
    " Window {{{2
    set splitbelow " Puts new split windows to the bottom of the current
    set splitright " Puts new vsplit windows to the right of the current
    set winminheight=0 " Windows can be 0 line height
    set updatetime=100 " Faster refresh time
    " Fuzzy matching {{{2
    set path+=** " fuzzy matching with :find *.ext*
    set wildmenu " Show list instead of just completing
    set wildignore+=**/node_modules/** " Ignore some folders
    set wildignore+=**/.git/**
    set wildignore+=**/build/**
    @@ -77,192 +67,35 @@ set foldmethod=syntax " Fo
    " Indentation {{{2
    " Don't enable smarindent or cindent with filetype plugin indent on
    filetype plugin indent on " Indentation based on filetype
    set autoindent " Does not interfere with other indentation settings
    " Invisible characters {{{2
    set list
    set listchars=tab\ ,trail:¿,nbsp:~ " Display invisible characters

    " Mouse {{{2
    set mouse=a

    " Netrw {{{2
    let g:netrw_banner=0 " Disable banner
    let g:netrw_altv = 1 " Open split to the right
    let g:netrw_winsize = 20
    let g:netrw_list_hide=netrw_gitignore#Hide()
    let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+'

    " Omni Completiton {{{2
    autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
    autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
    autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
    autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
    autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
    autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags

    " Search {{{2
    set hlsearch " highlight the search result
    set ignorecase " Case insensitive search
    set incsearch " Find as I type during the search
    set smartcase " Case sensitive only if search contains uppercase letter.

    " Tabulation and spaces {{{2
    set expandtab " Show spaces instead of tabs
    set shiftwidth=0 " columns per <<
    set softtabstop=4 " spaces per tab
    set tabstop=4 " columns per tabs

    " Vim directories {{{2
    set nobackup
    set noswapfile


    set softtabstop=2 " spaces per tab
    set tabstop=2 " columns per tabs
    " Wrapping {{{2
    set nowrap

    " Colors {{{2
    if (has("nvim"))
    "For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
    let $NVIM_TUI_ENABLE_TRUE_COLOR=1
    endif

    "For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
    "Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
    " < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
    if (has("termguicolors"))
    set termguicolors
    endif

    " Plugin Configuration {{{1
    " LightLine {{{2
    let g:lightline = {
    \ 'colorscheme': 'gruvbox',
    \ 'active': {
    \ 'left': [['mode', 'paste'], ['fugitive', 'filename']],
    \ 'right': [['lineinfo'], ['percent'], ['fileformat', 'fileencoding', 'filetype'], ['linter_warnings', 'linter_errors', 'linter_ok']]
    \ },
    \ 'component_function': {
    \ 'fugitive': 'LightlineFugitive',
    \ 'filename': 'LightlineFilename',
    \ 'filetype': 'MyFiletype',
    \ 'fileformat': 'MyFileformat'
    \ },
    \ 'component_expand': {
    \ 'linter_warnings': 'LightlineLinterWarnings',
    \ 'linter_errors': 'LightlineLinterErrors',
    \ 'linter_ok': 'LightlineLinterOK'
    \ }
    \ }

    function! LightlineModified()
    return &ft =~ 'help\|vimfiler' ? '' : &modified ? '+' : &modifiable ? '' : '-'
    endfunction
    function! LightlineReadonly()
    return &ft !~? 'help\|vimfiler' && &readonly ? 'RO' : ''
    endfunction
    function! LightlineFilename()
    return ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') .
    \ (&ft == 'vimfiler' ? vimfiler#get_status_string() :
    \ &ft == 'vimshell' ? vimshell#get_status_string() :
    \ '' != expand('%:t') ? expand('%:t') : '[No Name]') .
    \ ('' != LightlineModified() ? ' ' . LightlineModified() : '')
    endfunction
    function! LightlineFugitive()
    if &ft !~? 'vimfiler' && exists('*fugitive#head')
    return fugitive#head()
    endif
    return ''
    endfunction
    function! MyFiletype()
    return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype . ' ' . WebDevIconsGetFileTypeSymbol() : 'no ft') : ''
    endfunction
    function! MyFileformat()
    return winwidth(0) > 70 ? (&fileformat . ' ' . WebDevIconsGetFileFormatSymbol()) : ''
    endfunction
    function! LightlineLinterWarnings() abort
    let l:counts = ale#statusline#Count(bufnr(''))
    let l:all_errors = l:counts.error + l:counts.style_error
    let l:all_non_errors = l:counts.total - l:all_errors
    return l:counts.total == 0 ? '' : printf('%d ◆', all_non_errors)
    endfunction

    function! LightlineLinterErrors() abort
    let l:counts = ale#statusline#Count(bufnr(''))
    let l:all_errors = l:counts.error + l:counts.style_error
    let l:all_non_errors = l:counts.total - l:all_errors
    return l:counts.total == 0 ? '' : printf('%d ✗', all_errors)
    endfunction

    function! LightlineLinterOK() abort
    let l:counts = ale#statusline#Count(bufnr(''))
    let l:all_errors = l:counts.error + l:counts.style_error
    let l:all_non_errors = l:counts.total - l:all_errors
    return l:counts.total == 0 ? '' : ''
    endfunction

    autocmd User ALELint call s:MaybeUpdateLightline()

    " Update and show lightline but only if it's visible (e.g., not in Goyo)
    function! s:MaybeUpdateLightline()
    if exists('#lightline')
    call lightline#update()
    end
    endfunction

    " FZF {{{2
    let $FZF_DEFAULT_COMMAND = 'ag -g ""'

    " Emmet {{{2
    let g:user_emmet_settings = {
    \ 'javascript.jsx' : {
    \ 'extends' : 'jsx',
    \ },
    \ }

    " Ale {{{2
    let g:ale_completion_enabled = 0
    let g:ale_php_phpcbf_executable = '/home/hash/.config/composer/vendor/bin/phpcbf'
    let g:ale_php_phpcs_executable = '/home/hash/.config/composer/vendor/bin/phpcs'
    let g:ale_php_phpcs_standard = 'PSR2'
    let g:ale_php_phpcbf_standard = g:ale_php_phpcs_standard
    let g:ale_linters = {
    \ 'php': ['phpcs'],
    \ 'dart': ['dartanalyzer'],
    \ 'javascript': ['flow', 'eslint'],
    \ 'typescript': ['tsserver'],
    \}
    let g:ale_fixers = {
    \ 'javascript': ['eslint'],
    \ 'perl': ['perl'],
    \ 'php': ['phpcbf'],
    \ 'json': ['jq'],
    \ 'scss': ['prettier'],
    \ 'css': ['prettier'],
    \ 'html': ['prettier'],
    \ 'dart': ['dartfmt'],
    \ 'typescript': ['prettier'],
    \}
    let g:ale_sign_error = ''
    let g:ale_sign_warning = ''
    " call Base16hi("ALEWarningSign", g:base16_gui0A, "", "", "")
    " call Base16hi("ALEErrorSign", g:base16_gui08, "", "", "")
    let g:ale_fix_on_save = 1

    " AutoPairs {{{2
    let g:AutoPairsMapSpace = 0

    " Startify {{{3
    let g:startify_change_to_vcs_root = 1
    let g:startify_change_to_dir = 0

    autocmd BufNewFile,BufRead *.tern-project set filetype=json
    "autocmd BufNewFile,BufRead *.js set filetype=javascript.jsx
    autocmd Filetype javascript setlocal ts=2 sts=2 sw=2
    autocmd Filetype typescript setlocal ts=2 sts=2 sw=2
    autocmd Filetype pug setlocal ts=2 sts=2 sw=2
    autocmd Filetype vue setlocal ts=2 sts=2 sw=2

    " Mappings {{{1
    set termguicolors
    " StatusLine {{{2
    set statusline=%t " tail of the filename
    set statusline+=\ %h " help file flag
    set statusline+=%m " modified flag
    set statusline+=%r " read only flag
    set statusline+=%y " filetype
    set statusline+=%= " left/right separator
    set statusline+=\ [%{strlen(&fenc)?&fenc:'none'}, " file encoding
    set statusline+=%{&ff}]\ " file format
    set statusline+=%c\ " cursor column
    set statusline+=%l/%L\ " cursor line/total lines
    set statusline+=\ %{strftime(\"%H:%M\")} " time
    " Mappings {{{1
    " Leader {{{2
    let mapleader = ","
    let g:mapleader = ","
    @@ -281,16 +114,6 @@ map <c-space> ?
    " Disable highlight when <leader><cr> is pressed
    map <silent> <leader><cr> :noh<cr>
    " Terminal {{{2
    if has('nvim')
    nnoremap <leader>` :te<CR>
    " tnoremap <ESC> <c-\><c-n>
    tnoremap <C-j> <c-\><c-n><C-W>j
    tnoremap <C-k> <c-\><c-n><C-W>k
    tnoremap <C-h> <c-\><c-n><C-W>h
    tnoremap <C-l> <c-\><c-n><C-W>l
    endif

    " Windows {{{2
    noremap <leader>h <C-w>s
    noremap <leader>v <C-w>v
    @@ -321,20 +144,9 @@ map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
    map <leader>cd :cd %:p:h<cr>:pwd<cr>
    " Remap VIM 0 to first non-blank character
    map 0 ^
    " Move a line of text using ALT+[jk] or Command+[jk] on mac
    nmap <M-j> mz:m+<cr>`z
    nmap <M-k> mz:m-2<cr>`z
    vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
    vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
    noremap 0 ^
    noremap ^ 0
    if has("mac") || has("macunix")
    nmap <D-j> <M-j>
    nmap <D-k> <M-k>
    vmap <D-j> <M-j>
    vmap <D-k> <M-k>
    endif

    " Pressing ,ss will toggle and untoggle spell checking
    map <leader>ss :setlocal spell!<cr>
    @@ -351,16 +163,6 @@ noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
    " Toggle paste mode on and off
    map <leader>pp :setlocal paste!<cr>
    "" No arrow {{{2
    noremap <Up> <NOP>
    noremap <Down> <NOP>
    noremap <Left> <NOP>
    noremap <Right> <NOP>
    inoremap <Up> <NOP>
    inoremap <Down> <NOP>
    inoremap <Left> <NOP>
    inoremap <Right> <NOP>
    " Git {{{2
    nmap <leader>gs :Gstatus<CR>
    nmap <leader>ga :Git add -A<CR>
    @@ -376,12 +178,12 @@ nmap <leader>ge :Gedit<CR>
    " Function keys {{{2
    noremap <F3> :ALEFix<CR>
    noremap <F5> :source $HOME/.config/nvim/init.vim<CR>
    noremap <F5> :source $MYVIMRC<CR>
    nnoremap <F10> :e $MYVIMRC<CR>
    " UltiSnips {{{2
    let g:UltiSnipsExpandTrigger="<TAB>"
    let g:UltiSnipsJumpForwardTrigger="TAB"
    let g:UltiSnipsJumpForwardTrigger="<TAB>"

    " Git Gutter
    let g:gitgutter_map_keys = 0
    @@ -400,25 +202,56 @@ nnoremap <leader>fg :Ag<space>
    nnoremap <F12> :syntax sync fromstart<cr>
    " Quick Scope {{{2
    augroup qs_colors
    autocmd!
    autocmd ColorScheme * highlight QuickScopePrimary guifg='#afff5f' gui=underline ctermfg=155 cterm=underline
    autocmd ColorScheme * highlight QuickScopeSecondary guifg='#5fffff' gui=underline ctermfg=81 cterm=underline
    augroup END

    " Plugin Configuration {{{1
    " FZF {{{2
    let $FZF_DEFAULT_COMMAND = 'ag -g ""'
    " Emmet {{{2
    let g:user_emmet_settings = {
    \ 'javascript.jsx' : {
    \ 'extends' : 'jsx',
    \ },
    \ }
    " Ale {{{2
    let g:ale_completion_enabled = 0
    let g:ale_fix_on_save = 1
    let g:ale_linters = {
    \ 'javascript': ['flow', 'eslint'],
    \}
    let g:ale_fixers = {
    \ 'javascript': ['eslint'],
    \ 'perl': ['perl'],
    \ 'php': ['phpcbf'],
    \ 'json': ['jq'],
    \ 'scss': ['prettier'],
    \ 'css': ['prettier'],
    \ 'html': ['prettier'],
    \ 'dart': ['dartfmt'],
    \ 'typescript': ['prettier'],
    \}
    let g:ale_sign_error = ''
    let g:ale_sign_warning = ''
    " AutoPairs {{{2
    let g:AutoPairsMapSpace = 0
    " Startify {{{2
    let g:startify_change_to_vcs_root = 1
    let g:startify_change_to_dir = 0

    " Colorscheme {{{1
    " Italics for my favorite color scheme
    let g:palenight_terminal_italics=1
    let g:material_terminal_italics=1
    let g:gruvbox_contrast_dark='soft'
    set background=dark
    colorscheme gruvbox
    " Custom highlight
    " Custom highlight {{{2
    hi jsClassDefinition gui=bold
    hi jsFuncArgs gui=italic
    " Syntax options {{{2
    let g:javascript_plugin_flow = 1
    " hi Normal guibg=NONE ctermbg=NONE
    " hi NonText guibg=NONE ctermbg=NONE
    " Quick Scope {{{2
    augroup qs_colors
    autocmd!
    autocmd ColorScheme * highlight QuickScopePrimary guifg='#afff5f' gui=underline ctermfg=155 cterm=underline
    autocmd ColorScheme * highlight QuickScopeSecondary guifg='#5fffff' gui=underline ctermfg=81 cterm=underline
    augroup END

    " vim:fdm=marker:fdl=0
    " {{{0
    " vim:fdm=marker:fdl=1
  9. skydevht created this gist Sep 20, 2019.
    424 changes: 424 additions & 0 deletions init.vim
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,424 @@
    " Plugins {{{1
    call plug#begin()

    " Language
    Plug 'sheerun/vim-polyglot'
    Plug 'reasonml-editor/vim-reason-plus'
    Plug 'mattn/emmet-vim'
    Plug 'tpope/vim-surround'
    Plug 'dart-lang/dart-vim-plugin'
    Plug 'w0rp/ale'
    " Integration
    Plug 'tpope/vim-dispatch'
    Plug 'tpope/vim-projectionist'
    Plug 'tpope/vim-fugitive'
    Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
    Plug 'junegunn/fzf.vim'
    " Completion
    Plug 'jiangmiao/auto-pairs'
    Plug 'SirVer/ultisnips'
    Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}}
    " Interface
    Plug 'itchyny/lightline.vim'
    Plug 'airblade/vim-gitgutter'
    Plug 'moll/vim-bbye'
    Plug 'unblevable/quick-scope'
    " Commands
    Plug 'justinmk/vim-sneak'
    Plug 'tpope/vim-unimpaired'
    Plug 'tpope/vim-vinegar'
    Plug 'tpope/vim-commentary'
    Plug 'godlygeek/tabular'
    Plug 'wellle/targets.vim'
    Plug 'arithran/vim-delete-hidden-buffers'
    " Code Display
    Plug 'mhinz/vim-startify'
    Plug 'morhetz/gruvbox'
    Plug 'nlknguyen/papercolor-theme'
    Plug 'skydevht/palenight.vim'
    Plug 'jacoborus/tender.vim'
    Plug 'ap/vim-css-color'
    Plug 'ryanoasis/vim-devicons'

    call plug#end()

    " General Options {{{1
    scriptencoding utf-8
    " Global Configuration Options {{{2
    set encoding=utf-8
    lang en_US.UTF-8
    set backspace=indent,eol,start " Make backspace work like most other programs
    set nobackup
    set nowritebackup
    set colorcolumn=81 " Set the 80 character column (+1 if textwidth is defined else 81)
    set cursorline " Highlight the current line
    set hidden " Any buffer can be hidden
    set number
    set history=1000 " Set a huge history
    set lazyredraw " Render window only after the end of a macro
    set linespace=0 " No extra spaces between rows
    set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
    set scrolljump=5 " Lines to scroll when cursor leaves screen
    set scrolloff=3 " Minimum lines to keep above and below cursor
    set showmatch " Show current brackets
    set splitbelow " Puts new split windows to the bottom of the current
    set splitright " Puts new vsplit windows to the right of the current
    set winminheight=0 " Windows can be 0 line height
    set updatetime=100 " Faster refresh time
    " Fuzzy matching {{{2
    set path+=** " fuzzy matching with :find *.ext*
    set wildmenu " Show list instead of just completing
    set wildignore+=**/node_modules/** " Ignore some folders
    set wildignore+=**/.git/**
    set wildignore+=**/build/**
    set wildignore+=**/dist/**
    " Folding {{{2
    set foldmethod=syntax " Fold are defined by syntax highlighting
    " Indentation {{{2
    " Don't enable smarindent or cindent with filetype plugin indent on
    filetype plugin indent on " Indentation based on filetype
    set autoindent " Does not interfere with other indentation settings
    " Invisible characters {{{2
    set list
    set listchars=tab\ ,trail:¿,nbsp:~ " Display invisible characters

    " Mouse {{{2
    set mouse=a

    " Netrw {{{2
    let g:netrw_banner=0 " Disable banner
    let g:netrw_altv = 1 " Open split to the right
    let g:netrw_winsize = 20
    let g:netrw_list_hide=netrw_gitignore#Hide()
    let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+'

    " Omni Completiton {{{2
    autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
    autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
    autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
    autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
    autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
    autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags

    " Search {{{2
    set hlsearch " highlight the search result
    set ignorecase " Case insensitive search
    set incsearch " Find as I type during the search
    set smartcase " Case sensitive only if search contains uppercase letter.

    " Tabulation and spaces {{{2
    set expandtab " Show spaces instead of tabs
    set shiftwidth=0 " columns per <<
    set softtabstop=4 " spaces per tab
    set tabstop=4 " columns per tabs

    " Vim directories {{{2
    set nobackup
    set noswapfile


    " Wrapping {{{2
    set nowrap

    " Colors {{{2
    if (has("nvim"))
    "For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
    let $NVIM_TUI_ENABLE_TRUE_COLOR=1
    endif

    "For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
    "Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
    " < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
    if (has("termguicolors"))
    set termguicolors
    endif

    " Plugin Configuration {{{1
    " LightLine {{{2
    let g:lightline = {
    \ 'colorscheme': 'gruvbox',
    \ 'active': {
    \ 'left': [['mode', 'paste'], ['fugitive', 'filename']],
    \ 'right': [['lineinfo'], ['percent'], ['fileformat', 'fileencoding', 'filetype'], ['linter_warnings', 'linter_errors', 'linter_ok']]
    \ },
    \ 'component_function': {
    \ 'fugitive': 'LightlineFugitive',
    \ 'filename': 'LightlineFilename',
    \ 'filetype': 'MyFiletype',
    \ 'fileformat': 'MyFileformat'
    \ },
    \ 'component_expand': {
    \ 'linter_warnings': 'LightlineLinterWarnings',
    \ 'linter_errors': 'LightlineLinterErrors',
    \ 'linter_ok': 'LightlineLinterOK'
    \ }
    \ }

    function! LightlineModified()
    return &ft =~ 'help\|vimfiler' ? '' : &modified ? '+' : &modifiable ? '' : '-'
    endfunction
    function! LightlineReadonly()
    return &ft !~? 'help\|vimfiler' && &readonly ? 'RO' : ''
    endfunction
    function! LightlineFilename()
    return ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') .
    \ (&ft == 'vimfiler' ? vimfiler#get_status_string() :
    \ &ft == 'vimshell' ? vimshell#get_status_string() :
    \ '' != expand('%:t') ? expand('%:t') : '[No Name]') .
    \ ('' != LightlineModified() ? ' ' . LightlineModified() : '')
    endfunction
    function! LightlineFugitive()
    if &ft !~? 'vimfiler' && exists('*fugitive#head')
    return fugitive#head()
    endif
    return ''
    endfunction
    function! MyFiletype()
    return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype . ' ' . WebDevIconsGetFileTypeSymbol() : 'no ft') : ''
    endfunction
    function! MyFileformat()
    return winwidth(0) > 70 ? (&fileformat . ' ' . WebDevIconsGetFileFormatSymbol()) : ''
    endfunction
    function! LightlineLinterWarnings() abort
    let l:counts = ale#statusline#Count(bufnr(''))
    let l:all_errors = l:counts.error + l:counts.style_error
    let l:all_non_errors = l:counts.total - l:all_errors
    return l:counts.total == 0 ? '' : printf('%d ◆', all_non_errors)
    endfunction

    function! LightlineLinterErrors() abort
    let l:counts = ale#statusline#Count(bufnr(''))
    let l:all_errors = l:counts.error + l:counts.style_error
    let l:all_non_errors = l:counts.total - l:all_errors
    return l:counts.total == 0 ? '' : printf('%d ✗', all_errors)
    endfunction

    function! LightlineLinterOK() abort
    let l:counts = ale#statusline#Count(bufnr(''))
    let l:all_errors = l:counts.error + l:counts.style_error
    let l:all_non_errors = l:counts.total - l:all_errors
    return l:counts.total == 0 ? '' : ''
    endfunction

    autocmd User ALELint call s:MaybeUpdateLightline()

    " Update and show lightline but only if it's visible (e.g., not in Goyo)
    function! s:MaybeUpdateLightline()
    if exists('#lightline')
    call lightline#update()
    end
    endfunction

    " FZF {{{2
    let $FZF_DEFAULT_COMMAND = 'ag -g ""'

    " Emmet {{{2
    let g:user_emmet_settings = {
    \ 'javascript.jsx' : {
    \ 'extends' : 'jsx',
    \ },
    \ }

    " Ale {{{2
    let g:ale_completion_enabled = 0
    let g:ale_php_phpcbf_executable = '/home/hash/.config/composer/vendor/bin/phpcbf'
    let g:ale_php_phpcs_executable = '/home/hash/.config/composer/vendor/bin/phpcs'
    let g:ale_php_phpcs_standard = 'PSR2'
    let g:ale_php_phpcbf_standard = g:ale_php_phpcs_standard
    let g:ale_linters = {
    \ 'php': ['phpcs'],
    \ 'dart': ['dartanalyzer'],
    \ 'javascript': ['flow', 'eslint'],
    \ 'typescript': ['tsserver'],
    \}
    let g:ale_fixers = {
    \ 'javascript': ['eslint'],
    \ 'perl': ['perl'],
    \ 'php': ['phpcbf'],
    \ 'json': ['jq'],
    \ 'scss': ['prettier'],
    \ 'css': ['prettier'],
    \ 'html': ['prettier'],
    \ 'dart': ['dartfmt'],
    \ 'typescript': ['prettier'],
    \}
    let g:ale_sign_error = ''
    let g:ale_sign_warning = ''
    " call Base16hi("ALEWarningSign", g:base16_gui0A, "", "", "")
    " call Base16hi("ALEErrorSign", g:base16_gui08, "", "", "")
    let g:ale_fix_on_save = 1

    " AutoPairs {{{2
    let g:AutoPairsMapSpace = 0

    " Startify {{{3
    let g:startify_change_to_vcs_root = 1
    let g:startify_change_to_dir = 0

    autocmd BufNewFile,BufRead *.tern-project set filetype=json
    "autocmd BufNewFile,BufRead *.js set filetype=javascript.jsx
    autocmd Filetype javascript setlocal ts=2 sts=2 sw=2
    autocmd Filetype typescript setlocal ts=2 sts=2 sw=2
    autocmd Filetype pug setlocal ts=2 sts=2 sw=2
    autocmd Filetype vue setlocal ts=2 sts=2 sw=2

    " Mappings {{{1
    " Leader {{{2
    let mapleader = ","
    let g:mapleader = ","

    " Fast saving {{{2
    nmap <leader>w :w!<cr>
    " Visual mode pressing * or # searches for the current selection
    " Super useful! From an idea by Michael Naumann
    vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR>
    vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
    " Search {{{2
    map <space> /
    map <c-space> ?
    " Disable highlight when <leader><cr> is pressed
    map <silent> <leader><cr> :noh<cr>
    " Terminal {{{2
    if has('nvim')
    nnoremap <leader>` :te<CR>
    " tnoremap <ESC> <c-\><c-n>
    tnoremap <C-j> <c-\><c-n><C-W>j
    tnoremap <C-k> <c-\><c-n><C-W>k
    tnoremap <C-h> <c-\><c-n><C-W>h
    tnoremap <C-l> <c-\><c-n><C-W>l
    endif

    " Windows {{{2
    noremap <leader>h <C-w>s
    noremap <leader>v <C-w>v
    map <C-j> <C-W>j
    map <C-k> <C-W>k
    map <C-h> <C-W>h
    map <C-l> <C-W>l
    " Buffers {{{2
    noremap <leader>bq :q<cr>
    map <leader>bd :Bclose<cr>
    map <leader>ba :bufdo bd<cr>
    " Tabs {{{2
    map <leader>tn :tabnew<cr>
    map <leader>to :tabonly<cr>
    noremap <S-l> gt
    noremap <S-h> gT
    map <leader>tc :tabclose<cr>
    map <leader>tm :tabmove
    map <leader>t<leader> :tabnext
    let g:lasttab = 1
    nmap <Leader>tl :exe "tabn ".g:lasttab<CR>
    au TabLeave * let g:lasttab = tabpagenr()
    map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
    " Switch CWD to the directory of the open buffer
    map <leader>cd :cd %:p:h<cr>:pwd<cr>
    " Remap VIM 0 to first non-blank character
    map 0 ^
    " Move a line of text using ALT+[jk] or Command+[jk] on mac
    nmap <M-j> mz:m+<cr>`z
    nmap <M-k> mz:m-2<cr>`z
    vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
    vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
    if has("mac") || has("macunix")
    nmap <D-j> <M-j>
    nmap <D-k> <M-k>
    vmap <D-j> <M-j>
    vmap <D-k> <M-k>
    endif

    " Pressing ,ss will toggle and untoggle spell checking
    map <leader>ss :setlocal spell!<cr>
    " Shortcuts using <leader>
    map <leader>sn ]s
    map <leader>sp [s
    map <leader>sa zg
    map <leader>s? z=
    " Remove the Windows ^M - when the encodings gets messed up
    noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
    " Toggle paste mode on and off
    map <leader>pp :setlocal paste!<cr>
    "" No arrow {{{2
    noremap <Up> <NOP>
    noremap <Down> <NOP>
    noremap <Left> <NOP>
    noremap <Right> <NOP>
    inoremap <Up> <NOP>
    inoremap <Down> <NOP>
    inoremap <Left> <NOP>
    inoremap <Right> <NOP>
    " Git {{{2
    nmap <leader>gs :Gstatus<CR>
    nmap <leader>ga :Git add -A<CR>
    nmap <leader>gb :Gblame<CR>
    nmap <leader>gc :Gcommit<CR>
    nmap <leader>gd :Gdiff<CR>
    nmap <leader>gl :Glog<CR>
    nmap <leader>gp :Gpush<CR>
    nmap <leader>gpl :Gpull<CR>
    nmap <leader>gr :Gread<CR>
    nmap <leader>gw :Gwrite<CR>
    nmap <leader>ge :Gedit<CR>
    " Function keys {{{2
    noremap <F3> :ALEFix<CR>
    noremap <F5> :source $HOME/.config/nvim/init.vim<CR>
    nnoremap <F10> :e $MYVIMRC<CR>
    " UltiSnips {{{2
    let g:UltiSnipsExpandTrigger="<TAB>"
    let g:UltiSnipsJumpForwardTrigger="TAB"

    " Git Gutter
    let g:gitgutter_map_keys = 0
    " COC {{{2
    nmap <silent> <leader>rg <Plug>(coc-definition)
    nmap <silent> <leader>rr <Plug>(coc-references)
    nmap <silent> <leader>ri <Plug>(coc-implementation)
    nmap <silent> <leader>rd <Plug>(coc-diagnostic-info)
    nmap <silent> <leader>rn <Plug>(coc-diagnostic-next)
    nmap <silent> <leader>rp <Plug>(coc-diagnostic-prev)
    " FZF {{{2
    nmap <leader>fb :Buffers<cr>
    nmap <leader>ff :Files<cr>
    nnoremap <leader>fg :Ag<space>
    nnoremap <F12> :syntax sync fromstart<cr>
    " Quick Scope {{{2
    augroup qs_colors
    autocmd!
    autocmd ColorScheme * highlight QuickScopePrimary guifg='#afff5f' gui=underline ctermfg=155 cterm=underline
    autocmd ColorScheme * highlight QuickScopeSecondary guifg='#5fffff' gui=underline ctermfg=81 cterm=underline
    augroup END

    " Colorscheme {{{1
    " Italics for my favorite color scheme
    let g:palenight_terminal_italics=1
    let g:material_terminal_italics=1
    let g:gruvbox_contrast_dark='soft'
    set background=dark
    colorscheme gruvbox
    " Custom highlight
    hi jsClassDefinition gui=bold
    hi jsFuncArgs gui=italic
    let g:javascript_plugin_flow = 1
    " hi Normal guibg=NONE ctermbg=NONE
    " hi NonText guibg=NONE ctermbg=NONE

    " vim:fdm=marker:fdl=0