home/dotfiles/vimrc
2020-11-17 14:00:39 +01:00

154 lines
3.9 KiB
VimL

" VIM Configuration - DarKou
" Cancel VI compatibility
set nocompatible
" -- Vim-plug
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'arcticicestudio/nord-vim'
Plug 'sjbach/lusty'
Plug 'kshenoy/vim-signature'
Plug 'w0rp/ale'
Plug 'ap/vim-css-color'
Plug 'mileszs/ack.vim'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'moll/vim-node'
Plug 'pangloss/vim-javascript'
Plug 'briancollins/vim-jst'
Plug '1995eaton/vim-better-javascript-completion'
Plug 'heavenshell/vim-jsdoc', {
\ 'for': ['javascript', 'javascript.jsx','typescript'],
\ 'do': 'make install'
\}
Plug 'JamshedVesuna/vim-markdown-preview'
Plug 'ternjs/tern_for_vim', {'do': 'yarn install'}
Plug 'alvan/vim-closetag'
Plug 'psykidellic/vim-jekyll'
Plug 'airblade/vim-gitgutter'
" Initialize plugin system
call plug#end()
" -- Markdown preview
let vim_markdown_preview_browser='Mozilla Firefox'
" -- Display
colorscheme nord
set title
set number
set ruler
set wrap
set scrolloff=5
syntax enable
set encoding=utf-8
set fileencoding=utf-8
set showmatch " When a bracket is inserted, briefly jump to the matching one
set cursorline " Highlight the screen line of the cursor
filetype on
filetype plugin on
filetype indent on
set omnifunc=syntaxcomplete#Complete
:highlight ExtraWhitespace ctermbg=red guibg=red
:match ExtraWhitespace /\s\+$/
:match errorMsg /\s\+$/
" -- Search
set ignorecase
set smartcase
set incsearch
set hlsearch
" -- Ack search
let g:ackprg="ack -H --nocolor --nogroup --column"
nmap <leader>j mA:Ack<space>
nmap <leader>ja mA:Ack "<C-r>=expand("<cword>")<cr>"
nmap <leader>jA mA:Ack "<C-r>=expand("<cWORD>")<cr>"
" -- Ctrlp
let g:ctrlp_map='<leader>c'
" -- Beep
set visualbell
set noerrorbells
"
set backspace=indent,eol,start
" Hide file when open other file
set hidden
" Code formating
set smartindent " Do smart autoindenting when starting a new line
set tabstop=2 " Number of spaces that a <Tab> in the file counts for
set shiftwidth=2 " Alignment with '<' and '>'
set expandtab " Use spaces instead of tab
augroup myTodo
autocmd!
autocmd Syntax * syntax match myTodo /\v\_.<(TODO|FIXME|INFO).*/hs=s+1 containedin=.*Comment
augroup END
highlight link myTodo Todo
" Auto close brackets/…
inoremap " ""<left>
inoremap ' ''<left>
inoremap ` ``<left>
inoremap ( ()<left>
inoremap [ []<left>
inoremap { {}<left>
inoremap {<CR> {<CR>}<ESC>O
inoremap {;<CR> {<CR>};<ESC>O
" -- Remove unwantedd spaces
function GlobalTrimWhiteSpace()
%s/\s*$//
''
endfunction
set list listchars=trail:.,extends:>
autocmd FileWritePre * call GlobalTrimWhiteSpace()
autocmd FileAppendPre * call GlobalTrimWhiteSpace()
autocmd FilterWritePre * call GlobalTrimWhiteSpace()
autocmd BufWritePre * call GlobalTrimWhiteSpace()
map <F2> :call GlobalTrimWhiteSpace()<CR>
map! <F2> :call GlobalTrimWhiteSpace()<CR>
" -- Plugins configurations
" ale
let b:ale_linters = ['eslint']
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'javascript': ['prettier', 'eslint'],
\ 'css': ['prettier']
\ }
let g:ale_sign_error = '❌'
let g:ale_sign_warning = '⚠️'
let g:ale_fix_on_save = 1
" vim-javascript
let g:javascript_plugin_jsdoc = 1 " Enables syntax highlighting for JSDocs
let g:javascript_plugin_flow = 1 " Enables syntax highlighting for Flow
" vim-closetag
let g:closetag_filenames = '*.html,*.xhtml,*.phtml'
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx, *.ejs'
let g:closetag_filetypes = 'html,xhtml,phtml'
let g:closetag_xhtml_filetypes = 'xhtml,jsx'
let g:closetag_emptyTags_caseSensitive = 1
let g:closetag_regions = {
\ 'typescript.tsx': 'jsxRegion,tsxRegion',
\ 'javascript.jsx': 'jsxRegion',
\ }
let g:closetag_shortcut = '>'
let g:closetag_close_shortcut = '<leader>>'