From 627dd26d4ab92cb46924101e2a27048b1c68c766 Mon Sep 17 00:00:00 2001 From: Julien Moutinho Date: Tue, 29 Jul 2014 21:51:27 +0200 Subject: [PATCH] Ajout : vim/ --- vim/.vimrc | 250 ++++++++++++++++++ .../neocomplcache/filters/sorter_bytes.vim | 54 ++++ 2 files changed, 304 insertions(+) create mode 100644 vim/.vimrc create mode 100644 vim/autoload/neocomplcache/filters/sorter_bytes.vim diff --git a/vim/.vimrc b/vim/.vimrc new file mode 100644 index 0000000..f9ec41a --- /dev/null +++ b/vim/.vimrc @@ -0,0 +1,250 @@ +function! GetFoldExprFromIndent() + " Calcule l'indentation en fonction des tabulations + " et espaces au début des lignes + let line = getline(v:lnum) + let tabs = strlen(matchstr(line,"^\t*")) + let spaces = strlen(matchstr(line,"^[ \t]*")) - tabs + return tabs + ((spaces + 3) / 4) + endfunction +hi FoldColumn ctermfg=black ctermbg=none cterm=bold +hi Folded ctermfg=black ctermbg=none cterm=bold +hi LineNr ctermfg=black ctermbg=none cterm=bold +hi Pmenu cterm=none ctermfg=white ctermbg=blue guibg=blue +hi PmenuSel cterm=bold ctermfg=white ctermbg=red guibg=red +hi Search ctermbg=yellow +hi SpecialKey ctermfg=black cterm=bold +hi StatusLine term=bold,reverse ctermfg=grey ctermbg=blue cterm=none +hi StatusLineNC term=reverse ctermfg=blue ctermbg=none cterm=underline +hi Visual guibg=yellow +nmap * :set hls:let @/="\\<\\>"/ +nmap µ :set hls:let @/=""/ +nnoremap i +nnoremap k +nnoremap j +nnoremap l +xnoremap i +xnoremap k +xnoremap j +xnoremap l +nnoremap K J +nnoremap J w +nnoremap L +set autochdir +set cmdheight=1 +set completeopt=longest,menu +set directory=$HOME/var/cache/vim/swap +set encoding=utf-8 +set foldcolumn=0 +set foldenable +set foldexpr=GetFoldExprFromIndent() +set foldmethod=expr +set foldminlines=0 +set history=2048 +set hlsearch +set incsearch +set laststatus=2 +set lazyredraw +set list +set path=.,/usr/include,/usr/local/include,, +set scroll=0 +set scrolloff=0 +set sidescroll=0 +set sidescrolloff=0 +set swapfile +set matchpairs+=<:> +set maxmempattern=2000 +set nocompatible +set noerrorbells +set noignorecase +set loadplugins +set nowrap +set nowrapscan +set number +set ruler +set runtimepath=$HOME/.vim,$VIMRUNTIME,$VIM +set sessionoptions=curdir,folds +set shiftwidth=2 +set showcmd +set smartindent +set statusline=%F%=\ %m%R\ %l:%c\ x%02B\ %Y\ %{&encoding} +set tabstop=2 +set ttyfast +set undolevels=512 +set updatetime=4096 +set verbose=0 +set viewdir=$HOME/var/lib/vim/view +set viminfo+=n$HOME/var/cache/vim/info +set novisualbell +set visualbell t_vb= +set whichwrap+=<,>,[,] +set wildignore=*.a,*.d,*.o,*.so,*~,*.cmo,*.cmi,*.cmx,*.cmxs,*.cma,*.cmxa,*.byte,*.native +set wildmenu +set wildmode=longest,list,full +syntax on +if (&term == "linux") + set foldtext=substitute(getline(v\:foldstart),'\\t','\|_','g').'\ \ ('.(v\:foldend-v\:foldstart+1).')\ ' + set fillchars=fold:_ + set list listchars=nbsp:+,tab:\|_,trail:_,extends:>,precedes:< + else + set foldtext=substitute(getline(v\:foldstart),'\\t','⎢·','g').'\ \ ('.(v\:foldend-v\:foldstart+1).')\ ' + set fillchars=fold:· + set list listchars=nbsp:¬,tab:⎢·,trail:·,extends:>,precedes:< + endif +if (v:version >= 700) + hi TabLine term=bold,reverse ctermfg=white ctermbg=blue cterm=none + hi TabLineFill term=bold,reverse ctermfg=none ctermbg=blue cterm=none + hi TabLineSel term=reverse ctermfg=white ctermbg=none cterm=bold + inoremap :tabpreviousi + inoremap :tabnew + inoremap :tabnexti + nnoremap :tabprevious + nnoremap :tabprevious + nnoremap :tabnew + nnoremap :tabnext + nnoremap :tabprevious + nnoremap td :tabclose + nnoremap ti :tabfirst + nnoremap tj :tabprev + nnoremap tk :tablast + nnoremap tl :tabnext + nnoremap tm :tabm + nnoremap tn :tabnew + nnoremap tt :tabedit + set tabpagemax=1000 + set sessionoptions+=tabpages + endif +if (v:version >= 740) + set undodir=$HOME/var/cache/vim/undo/ + set undofile + endif +""" +""" filetypes +""" +autocmd BufNewFile,BufRead *.hledger,*.ledger,*.journal setfiletype hledger +autocmd Filetype hledger set iskeyword+=.,38,39,40,41,44,45,58 +""" +""" plugins +""" +runtime plugin/gundo.vim +runtime plugin/gzip.vim +runtime macros/justify.vim +let b:match_words = '«:»,“:”' +runtime plugin/matchit.vim +let g:netrw_liststyle = 3 +"let g:netrw_cursorline = 0 +let s:netrw_usercul = 0 +runtime plugin/netrwPlugin.vim + +" EasyAlign + vmap (EasyAlign) + nmap a (EasyAlign) + let g:easy_align_ignore_groups = ['Comment', 'String', 'hledgerComment', 'hledgerTransaction'] + +" neocomplcache + " Disable automatic completion popup + let g:neocomplcache_disable_auto_complete = 1 + " Disable AutoComplPop. + let g:acp_enableAtStartup = 0 + " Use neocomplcache. + let g:neocomplcache_enable_at_startup = 1 + " Use smartcase. + let g:neocomplcache_enable_smart_case = 1 + " Set minimum syntax keyword length. + let g:neocomplcache_min_syntax_length = 2 + let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*' + + " Define dictionary. + let g:neocomplcache_dictionary_filetype_lists = { + \ 'default' : '', + \ 'vimshell' : $HOME.'/.vimshell_hist', + \ 'scheme' : $HOME.'/.gosh_completions' + \ } + + " Define keyword. + if !exists('g:neocomplcache_keyword_patterns') + let g:neocomplcache_keyword_patterns = {} + endif + let g:neocomplcache_keyword_patterns['default'] = '\h\w*' + + " Plugin key-mappings. + inoremap neocomplcache#undo_completion() + inoremap neocomplcache#complete_common_string() + + " Complete with . + "inoremap pumvisible() ? "\" : check_back_space() ? "\" : "\\" + inoremap pumvisible() ? neocomplcache#complete_common_string() : check_back_space() ? "\" : "\\" + + function! s:check_back_space() + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~ '\s' + endfunction + + " Choose candidate with . + inoremap neocomplcache#smart_close_popup() . “\” + + " Recommended key-mappings. + " : close popup and save indent. + inoremap =my_cr_function() + function! s:my_cr_function() + return neocomplcache#smart_close_popup() . "\" + " For no inserting key. + "return pumvisible() ? neocomplcache#close_popup() : "\" + endfunction + " : completion. + "inoremap pumvisible() ? neocomplcache#complete_common_string() : "\" + "inoremap neocomplcache#complete_common_string() + " , : close popup and delete backword char. + inoremap neocomplcache#smart_close_popup()."\" + inoremap neocomplcache#smart_close_popup()."\" + inoremap neocomplcache#close_popup() + inoremap neocomplcache#cancel_popup() + " Close popup by . + inoremap pumvisible() ? neocomplcache#close_popup() : "\" + + " Sort choices by bytes + call neocomplcache#custom_source('_', 'sorters', ['sorter_bytes']) + + " For cursor moving in insert mode(Not recommended) + "inoremap neocomplcache#close_popup() . "\" + "inoremap neocomplcache#close_popup() . "\" + "inoremap neocomplcache#close_popup() . "\" + "inoremap neocomplcache#close_popup() . "\" + " Or set this. + "let g:neocomplcache_enable_cursor_hold_i = 1 + " Or set this. + "let g:neocomplcache_enable_insert_char_pre = 1 + + " AutoComplPop like behavior. + "let g:neocomplcache_enable_auto_select = 1 + + " Enable heavy features. + " Use camel case completion. + "let g:neocomplcache_enable_camel_case_completion = 1 + " Use underbar completion. + let g:neocomplcache_enable_underbar_completion = 1 + + " Shell like behavior(not recommended). + "set completeopt+=longest + "let g:neocomplcache_enable_auto_select = 1 + "let g:neocomplcache_disable_auto_complete = 1 + "inoremap pumvisible() ? "\" : "\\" + + " 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 + + " Enable heavy omni completion. + if !exists('g:neocomplcache_omni_patterns') + let g:neocomplcache_omni_patterns = {} + endif + let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::' + let g:neocomplcache_omni_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)' + let g:neocomplcache_omni_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::' + + " For perlomni.vim setting. + " https://github.com/c9s/perlomni.vim + let g:neocomplcache_omni_patterns.perl = '\h\w*->\h\w*\|\h\w*::' + runtime plugin/neocomplcache.vim diff --git a/vim/autoload/neocomplcache/filters/sorter_bytes.vim b/vim/autoload/neocomplcache/filters/sorter_bytes.vim new file mode 100644 index 0000000..2ea4c47 --- /dev/null +++ b/vim/autoload/neocomplcache/filters/sorter_bytes.vim @@ -0,0 +1,54 @@ +"============================================================================= +" FILE: sorter_bytes.vim +" AUTHOR: Julien Moutinho +" Last Modified: 24 July 2014 +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +function! neocomplcache#filters#sorter_bytes#define() "{{{ + return s:sorter + endfunction"}}} + +let s:sorter = { + \ 'name' : 'sorter_bytes', + \ 'description' : 'sort by matched bytes order', + \} + +function! s:sorter.filter(context) "{{{ + return sort(a:context.candidates, 's:compare') + endfunction"}}} + +function! s:compare(i1, i2) + let diff = a:i1.word ==# a:i2.word + if !diff + let diff = (a:i1.word > a:i2.word) ? 1 : -1 + endif + return diff + endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker -- 2.20.1