Skip to content

Instantly share code, notes, and snippets.

@codeur4
Last active September 29, 2015 16:08
Show Gist options
  • Save codeur4/fba59ef300fe15fb8e34 to your computer and use it in GitHub Desktop.
Save codeur4/fba59ef300fe15fb8e34 to your computer and use it in GitHub Desktop.
"scriptencoding utf-8
" behave mswin
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'itchyny/lightline.vim'
""Plugin 'kana/vim-tabpagecd'
" Plugin 'https://github.com/kien/ctrlp.vim'
"" Plugin 'mileszs/ack.vim'
"" Plugin 'scrooloose/nerdTree'
Plugin 'Shougo/vimproc.vim', {'build': {'windows': 'make -f make_mingw64.mak'}}
Plugin 'Shougo/unite.vim'
Plugin 'Shougo/neomru.vim'
Plugin 'Shougo/vimfiler.vim'
Plugin 'rking/ag.vim'
Plugin 'Shougo/neocomplete.vim'
Plugin 'Shougo/neosnippet'
Plugin 'Shougo/neosnippet-snippets'
" Plugin 'ggreer/the_silver_searcher'
" Plugin 'fholgado/minibufexpl.vim'
Plugin 'terryma/vim-smooth-scroll'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin o
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this l
" "===============================================================================
" => Parametrage Plugins
" "===============================================================================
set wildignore+=*/vendor/**
set wildignore+=*/node_modules/**
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe,*.bat
""" let g:ackprg = "C:/Users/herve/.vim/bundle/ack.vim -s -H --nocolor --nogroup --column"
let g:lightline = {
\ 'colorscheme': 'landscape',
\ 'mode_map': { 'c': 'NORMAL' },
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ]
\ },
\ 'component_function': {
\ 'modified': 'LightLineModified',
\ 'readonly': 'LightLineReadonly',
\ 'fugitive': 'LightLineFugitive',
\ 'filename': 'LightLineFilename',
\ 'fileformat': 'LightLineFileformat',
\ 'filetype': 'LightLineFiletype',
\ 'fileencoding': 'LightLineFileencoding',
\ 'mode': 'LightLineMode',
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
function! LightLineModified()
return &ft =~ 'help\|vimfiler\|gundo' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! LightLineReadonly()
return &ft !~? 'help\|vimfiler\|gundo' && &readonly ? '⭤' : ''
endfunction
function! LightLineFilename()
return ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
\ (&ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ &ft == 'vimshell' ? vimshell#get_status_string() :
\ '' != expand('%:t') ? expand('%:t') : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
endfunction
function! LightLineFugitive()
if &ft !~? 'vimfiler\|gundo' && exists("*fugitive#head")
let _ = fugitive#head()
return strlen(_) ? '⭠ '._ : ''
endif
return ''
endfunction
function! LightLineFileformat()
return winwidth(0) > 70 ? &fileformat : ''
endfunction
function! LightLineFiletype()
return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : ''
endfunction
function! LightLineFileencoding()
return winwidth(0) > 70 ? (strlen(&fenc) ? &fenc : &enc) : ''
endfunction
function! LightLineMode()
return winwidth(0) > 60 ? lightline#mode() : ''
endfunction
" Like Textmate icons.
let g:vimfiler_tree_leaf_icon = ' '
let g:vimfiler_tree_opened_icon = '▾'
let g:vimfiler_tree_closed_icon = '▸'
let g:vimfiler_file_icon = '-'
let g:vimfiler_marked_file_icon = '*'
let g:unite_enable_start_insert = 1
let g:unite_data_directory = 'C:\Users\herve\workspace'
let g:unite_source_history_yank_enable = 1
let g:unite_ignore_source_files = ['function.vim', 'command.vim']
call unite#filters#matcher_default#use(['matcher_fuzzy'])
call unite#filters#sorter_default#use(['sorter_rank'])
call unite#custom#source('grep,line', 'matchers', 'matcher_fuzzy')
call unite#custom_source('file,file_rec,file_rec/async,grep',
\ 'ignore_pattern', join([
\ '\.svn',
\ '\.bat',
\ '\.bundle/',
\ 'node_modules/',
\ '\.sublime-*',
\ 'vendor/',
\ ], '\|'))
"Use ag in unite grep source.
"if executable('ag')
" let g:unite_source_grep_max_candidates = 200
" let g:unite_source_grep_command = 'ag'
" let g:unite_source_grep_default_opts =
" \ '-i --vimgrep --hidden --ignore ' .
" \ '''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'' --ignore ''node_module'''
" let g:unite_source_grep_recursive_opt = ''
"endif
" The Silver Searcher
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
let g:ag_working_path_mode = 'r'
" let g:ag_scm_dirs = "C:\Users\herve\workspace\nw-todo"
"let g:miniBufExplUseSingleClick = 1
"let g:miniBufExplBuffersNeeded = 1
"let g:miniBufExplShowBufNumbers = 0
"let g:miniBufExplCycleArround = 1
"let g:miniBufExplForceSyntaxEnable = 1
"let g:vimfiler_as_default_explorer = 1
let g:neocomplete#enable_at_startup = 1
" Plugin key-mappings.
"inoremap <expr><C-g> neocomplete#undo_completion()
"inoremap <expr><C-l> neocomplete#complete_common_string()
" Recommended key-mappings.
" <CR>: close popup and save indent.
"inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
"function! s:my_cr_function()
" return "\<C-y>\<CR>"
" For no inserting <CR> key.
"return pumvisible() ? "\<C-y>" : "\<CR>"
"endfunction
" <TAB>: completion.
"inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
"inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
"inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
" Close popup by <Space>.
"inoremap <expr><Space> pumvisible() ? "\<C-y>" : "\<Space>"
" AutoComplPop like behavior.
"let g:neocomplete#enable_auto_select = 1
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" Plugin key-mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
"imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<TAB>" : "\<Plug>(neosnippet_expand_or_jump)"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
" "===============================================================================
" => Mes variables
" "===============================================================================
" With a map leader it's possible to do extra key combinations
let mapleader = ","
let g:mapleader = ","
let g:isBigScreen = 1
" "===============================================================================
" => Mon mapping
" "===============================================================================
map <F1> :source ~/.vim/session1.vim<CR>
map <F2> :source ~/.vim/session2.vim<CR>
map <F3> :call BigScreen()<CR>
:nnoremap <silent> <F12> :!start cmd /c ""C:\Tools\nwjs\nw.exe" "C:\Users\herve\workspace\nw-todo"" & pause<CR>
:nnoremap <silent> <F11> :!start "C:\Users\herve\workspace\nw-todo\run.bat" <CR>
:nnoremap <silent> <F6> :!start cmd /c "%:p:r:s,$,.exe," & pause<CR>
nnoremap <Leader>r :source $MYVIMRC<CR>
vmap g :<C-U>!""C:\Program Files (x86)\Mozilla Firefox\firefox" "http://www.google.fr/search?hl=fr^&q=<cword>^&btnG=Recherche+Google^&meta="" ^&gt;& /dev/null<CR><CR>
" U: Redos since 'u' undos
nnoremap U :redo<cr>
" Q: Closes the window
nnoremap Q :q<cr>
" W: Save
nnoremap W :w<cr>
" +/-: Increment number
nnoremap + <c-a>
nnoremap - <c-x>
" H: Go to beginning of line.
noremap H ^
" L: Go to end of line
noremap L g_
" Scroll smoothly
noremap <silent> <c-u> :call smooth_scroll#up(&scroll, 5, 3)<CR>
noremap <silent> <c-d> :call smooth_scroll#down(&scroll, 5, 3)<CR>
noremap <silent> <c-b> :call smooth_scroll#up(&scroll*2, 5, 5)<CR>
noremap <silent> <c-f> :call smooth_scroll#down(&scroll*2, 5, 5)<CR>
" strip all trailing whitespace in the current file
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
" reselect the text that was just pasted
nnoremap <leader>v V`]
" open up my ~/.vimrc file in a vertically split window
nnoremap <leader>ev <C-w><C-v><C-l>:e $MYVIMRC<cr>
" Quicker Escaping
inoremap jj <ESC>
" open a new vertical split and switch over to it
nnoremap <leader>w <C-w>v<C-w>l
" Unite uses Vim's current directory only
nnoremap <leader>cd :cd %:p:h<CR>:pwd<CR>
" Clear highlight.
nnoremap <ESC><ESC> :nohlsearch<CR>:match<CR>
" Visual mode keymappings: "{{{
" <TAB>: indent.
xnoremap <TAB> >>
nnoremap <TAB> >>
" <S-TAB>: unindent.
xnoremap <S-TAB> <<
nnoremap <S-TAB> <<
" Indent
nnoremap > <<
nnoremap < >>
xnoremap > <gv
xnoremap < >gv
"}}}
" Move to top/center/bottom.
noremap <expr> zz (winline() == (winheight(0)+1)/ 2) ?
\ 'zt' : (winline() == 1)? 'zb' : 'zz'
" Unite
" nmap § [unite]
" nnoremap [unite] <nop>
" File searching using <space>f
" nnoremap <silent> [unite]f :<C-u>Unite -no-split -buffer-name=files -profile-name=buffer -auto-preview file_rec<cr>
nnoremap <c-p> :Unite file file_rec<CR>
nnoremap <leader>fh :<C-u>UniteWithProjectDir -no-split file_rec/async<CR>
nnoremap <leader>fg :<C-u>UniteWithProjectDir -no-split file_rec<CR>
nnoremap <leader>ff :<C-u>UniteWithProjectDir -no-split file file_rec<CR>
nnoremap <leader>fb :<C-u>Unite -buffer-name=files -no-split -hide-source-names buffer<CR>
nnoremap <leader>fu :UniteWithProjectDir -buffer-name=files -no-split -start-insert file_rec<cr>
nnoremap <leader>; :Unite -no-split line<CR>
nnoremap <leader>fv :VimFiler<CR>
nnoremap <Leader>gd :<C-u>Unite -no-split -silent -buffer-name=ag vimgrep<CR>
nnoremap <Leader>gp :<C-u>UniteWithProjectDir -no-split -silent -buffer-name=ag grep:.<CR>
" bind K to grep word under cursor
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
" MiniBuffExplorer
"noremap <Leader>t :MBEToggle<cr>
"noremap <C-TAB> :MBEbn<CR>
"noremap <C-S-TAB> :MBEbp<CR>
"===============================================================================
" => Mes autocmd
"===============================================================================
if has("autocmd")
" autocmd BufWritePost .vimrc,_vimrc source $MYVIMRC
" autocmd BufEnter * lcd %:p:h "change to directory of current file automatically
" Always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside
" an event handler (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
endif
"===============================================================================
" => General
"===============================================================================
set nu
au GUIEnter * simalt ~n " pour ouvrir en grand
" set guifont=Source\ Code\ Pro:h10
if has('mouse')
set mouse=a
endif
set encoding=utf-8
set scrolloff=3
set autoindent
" set showmode
" set showcmd
set hidden
set wildmenu
set wildmode=list:longest
" set visualbell
set cursorline
set ttyfast
" set ruler
set backspace=indent,eol,start
set laststatus=2
set relativenumber
" set undofile
set nobackup
" Automatically read a file that has changed on disk
set autoread
" au FocusLost * :wa http://stevelosh.com/blog/2010/09/coming-home-to-vim/
":set guioptions-=r "remove right-hand scroll bar
":set guioptions-=L "remove left-hand scroll bar
"===============================================================================
" => Colors and Fonts
"===============================================================================
syntax on
set guifont=Consolas_for_Powerline_FixedD:h10
" set guifont=Droid_Sans_Mono_Slashed_for_Pow:h10
" set guifont=Fira_Mono_for_Powerline:h10
" let g:Powerline_symbols="fancy"
" set guifont=Inconsolata\ for\ Powerline:h11
" set guifont=Liberation\ Mono:h10
" set guifont=Input\ Mono:h12
colorscheme blackboard
"===============================================================================
" => Text, tab and indent related
"===============================================================================
" Use spaces instead of tabs
set expandtab
" Be smart when using tabs ;)
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
" Linebreak on 500 characters
set lbr
set tw=500
set ai "Auto indent
set si "Smart indent
set textwidth=0
set wrapmargin=0
set nowrap
" ignorecase smartcase case-sensitive search intelligently
set ignorecase
set smartcase
" applies substitutions globally on lines
set gdefault
" incsearce showmatce hlsearce work together to highlight search results
set incsearch
set showmatch
set hlsearch
nmap <leader>l :set list!<CR>
set listchars=tab:▸\ ,eol:¬
highlight NonText guifg=#4a4a59
highlight SpecialKey guifg=#4a4a59
" Various characters are 'wider' than normal fixed width characters, but the
" default setting of ambiwidth (single) squeezes them into 'normal' width, which
" sucks. Setting it to double makes it awesome.
"set ambiwidth=double
"===============================================================================
" => Moving around, tabs, windows and buffers
"===============================================================================
" Smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
"===============================================================================
" => Editing mappings
"===============================================================================
" Remap VIM 0 to first non-blank character
map 0 ^
" Move a line of text using ALT+[jk] or Comamnd+[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
"===============================================================================
" => Mes fonctions
"===============================================================================
function! BigScreen()
if g:isBigScreen
execute "normal \<C-W>\<bar>\<C-W>_"
let g:isBigScreen = 0
else
execute "normal\<C-W>="
let g:isBigScreen = 1
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment