Mercurial > dotfiles
view vim/vimrc @ 485:25bdfc963612
Some vimrc tweaks.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 24 Sep 2020 23:11:23 -0700 |
parents | 759ccf5befb2 |
children | b452486b97c5 |
line wrap: on
line source
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " " Ludovic Chabant's ~/.vimrc " " http://ludovic.chabant.com " """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Global Setup {{{ " Use Vim settings, rather then Vi settings (much better!). " This must be first, because it changes other options as a side effect. set nocompatible " Set a variable that says we already sourced this file, for those few " settings we don't want to re-apply. if exists('g:sourced_vimrc') let g:resourcing_vimrc = 1 endif let g:sourced_vimrc = 1 " Local pre-override. let s:local_vimrc_pre = ludo#localpath('vimrc-local-pre') if filereadable(s:local_vimrc_pre) execute 'source' s:local_vimrc_pre endif " Make sure `filetype` stuff is turned off before loading Pathogen. syntax off filetype off " Disable some plugins. let g:pathogen_disabled = get(g:, 'pathogen_disabled', []) call ludo#setup_pathogen([ludo#localpath('bundle'), ludo#localpath('local')]) " Load pathogen. runtime bundle/pathogen/autoload/pathogen.vim " Add the bundle directory, and potentially add the local one if it exists. " Note that we pass absolute paths to make pathogen prepend stuff before Vim's " system files otherwise stuff like indent plugins don't work. let s:pathogen_bundles = [ludo#localpath('bundle', '{}')] if isdirectory(ludo#localpath('local')) call add(s:pathogen_bundles, ludo#localpath('local', '{}')) endif call call('pathogen#infect', s:pathogen_bundles) " Hide the toolbar in MacVim/gVIM, and set a nice window size. if has("gui_running") && !exists('g:resourcing_vimrc') set guioptions=-t set lines=999 set columns=999 if has("win32") au GUIEnter * simalt ~x endif endif function! s:HasPlugin(plugname, ...) abort let l:dirname = 'plugin/' if a:0 && a:1 let l:dirname = 'autoload/' endif return globpath(&runtimepath, l:dirname.a:plugname.'.vim') !=# '' endfunction " }}} " General Settings {{{ " Restrict modelines. set modelines=1 " Don't unload abandoned buffers. set hidden " Show line numbers. set number " Show what mode we're in, and what command we're typing. set showmode set showcmd " Keep the cursor off the top/bottom edges. set scrolloff=3 " Smart auto-indenting. set autoindent set smartindent " Use confirmation dialog. set confirm " Don't use annoying sounds. set visualbell " Remember lots of commands. set history=1000 " Try to reduce flickering. set lazyredraw " Show matching braces but not for too long. set showmatch set matchtime=2 " Show soft-broken/wrapped lines with a prefix. set showbreak=→ " Use incremental search, with highlighting, " case-insensitive unless we actually type some " mixed-case stuff. set incsearch set hlsearch set ignorecase set smartcase " Always show window status lines. set laststatus=2 " Enable using the mouse like some everyday guy. set mouse=a " Show interesting stuff at the bottom of the window. set showcmd set ruler " Make sure splitting windows is done in a way that makes sense. set splitbelow set splitright " Don't pollute the hard-drive with *~ files. Only " create them in hidden backup/temp directories while " we edit the file, and then get rid of it. set nobackup set writebackup execute('set backupdir='.ludo#localpath('backup')) execute('set directory='.ludo#localpath('temp')) " Better command-line completion, but don't show some " stuff we don't care about. set wildmenu set wildmode=list:longest set wildignore+=.DS_Store,Thumbs.db set wildignore+=*.so,*.dll,*.exe,*.lib,*.pdb set wildignore+=*.pyc,*.pyo set wildignore+=*.swp set formatoptions=croqn1j " Always display the tab-page line. set showtabline=2 " Set the file-formats. set ffs=unix,mac,dos " Tabs and indenting are 4 characters, and tabs behave like " spaces during editing. They're smart, too, and when you " press <TAB> it actually inserts a soft-tab so everything's " indented the same. set tabstop=4 set shiftwidth=4 set softtabstop=4 set smarttab set expandtab " Auto-reload files that have changed outside of Vim (which is useful " when reverting/syncing/whatever from the shell). set autoread " Default encoding set encoding=utf-8 " Clipboard buffer. set clipboard=unnamed " Smooth terminal experience. set ttyfast " Allow backspacing over anything. set backspace=indent,eol,start " Going left and right let you go to other lines. set whichwrap+=<,>,h,l " How to show invisible characters set listchars=eol:$,tab:>-,trail:-,extends:>,precedes:<,nbsp:%,conceal:. " Nice auto-complete menu. set complete=.,w,b set completeopt=longest,menuone,preview " Column indicators. set colorcolumn=72,79 " And now, for some system-dependent settings: " - font to use if !has('nvim') if ludo#platform() == "windows" set guifont=InputMono:h11,Hack:h12,Consolas:h12 else set guifont=InputMono:h11,Hack:h12,Monaco:h12 endif endif " Syntax highlighting. syntax on " Default color scheme. if has('gui_running') set background=dark else set background=dark let g:solarized_termcolors = 256 let g:solarized_termtrans = 1 endif if ludo#platform() == "windows" && &term == "win32" " Windows terminal sucks with colours, so pick an appropriate theme. colorscheme xterm16 else colorscheme solarized endif " Enable file type detection. filetype indent plugin on " }}} " Auto-Commands {{{ " Only show the highlighted cursor line in the current window. augroup CursorLine au! au WinLeave * set nocursorline au WinEnter * set cursorline augroup END " }}} " Plugin Settings {{{ " NERDTree {{{ let NERDTreeRespectWildIgnore = 1 " }}} " Ack {{{ if executable('rg') let g:ackprg = 'rg --vimgrep' elseif executable('ag') let g:ackprg = 'ag --vimgrep' endif nnoremap <Leader>a :Ack!<Space> nnoremap <Leader>f :Ack! <C-R><C-W> %:h<Tab> vnoremap <Leader>f "zy:Ack! <C-R>z %:h<Tab> " }}} " Ctrl-P {{{ " We'll set our own mappings. let g:ctrlp_map = '' " Ctrl-P should manage the working directory. let g:ctrlp_working_path_mode = 'ra' " Ctrl-P should however ignore some stuff. let g:ctrlp_custom_ignore = { \ 'dir': '\v[\/](\.git|\.hg|\.svn|venv|static|node_modules|_cache|_counter)$' \ } " Make Ctrl-P cache stuff in our temp directory. let g:ctrlp_cache_dir = ludo#localpath('cache') " Remember things. let g:ctrlp_clear_cache_on_exit = 0 " Don't include some stuff in the most recently used list. let g:ctrlp_mruf_exclude = 'hg\-editor\-\d+\.txt' " Enable some cool extensions. let g:ctrlp_extensions = [ \'tag', 'buffertag', 'quickfix', 'mixed', 'bookmarkdir', \'autoignore' \] " Use PyMatch to go faster. if (has('python3') || has('python')) if s:HasPlugin('ctrlp-py-matcher') let g:ctrlp_match_func = {'match': 'pymatcher#PyMatch'} let g:ctrlp_max_files = 0 let g:ctrlp_lazy_update = 350 elseif s:HasPlugin('cpsm', 1) let g:ctrlp_match_func = {'match': 'cpsm#CtrlPMatch'} let g:ctrlp_max_files = 0 let g:ctrlp_lazy_update = 350 endif endif " }}} " FZF {{{ " Load FZF Vim plugin from our sub-repo. let s:local_fzfplugin = ludo#localpath('../lib/fzf/plugin/fzf.vim') if filereadable(s:local_fzfplugin) execute 'source' s:local_fzfplugin else call ludo#error("Can't find FZF at: ".s:local_fzfplugin) endif " Customized keyboard shotcuts. let g:fzf_action = { \'ctrl-t': 'tab split', \'ctrl-v': 'vsplit', \'ctrl-x': 'split', \} " Make fzf remember stuff. let g:fzf_history_dir = ludo#localpath('fzf-history') " Use fd for listing files if it's available on the system. if executable('fd') let $FZF_DEFAULT_COMMAND = 'fd --type f --hidden' endif " }}} " Gutentags {{{ let g:gutentags_cache_dir = ludo#localpath('tags') let g:gutentags_ctags_extra_args = ['--options='.ludo#localpath('ctagsrc')] let g:gutentags_ctags_exclude_wildignore = 0 augroup GutentagsStatusLineRefresher autocmd! autocmd User GutentagsUpdating call lightline#update() autocmd User GutentagsUpdated call lightline#update() augroup END " }}} " Syntastic {{{ let g:syntastic_auto_loc_list = 2 let g:syntastic_check_on_open = 1 let g:syntastic_check_on_wq = 0 " flake8 includes pyflakes, pep8, and mccabe " I could maybe replace pyflakes with frosted? let g:syntastic_python_checkers = ['flake8'] ", 'pylint'] let g:syntastic_python_python_exec = 'python3' let g:syntastic_python_flake8_args='--ignore=W191,W391' " }}} " ALE {{{ let g:ale_sign_error = '✗' let g:ale_sign_warning = '⚠' " }}} " Supertab {{{ let g:SuperTabDefaultCompletionType = "context" let g:SuperTabLongestEnhanced = 1 let g:SuperTabLongestHighlight = 0 let g:SuperTabCrMapping = 1 " }}} " Lawrencium {{{ " Custom Mercurial commands highlighting in Lawrencium. let g:lawrencium_hg_commands_file_types = { \'clog': 'hggraphlog' \} " Make the annotate window better in Lawrencium. let g:lawrencium_annotate_width_offset = 1 " }}} " Gundo {{{ let g:gundo_map_move_older = '<Down>' let g:gundo_map_move_newer = '<Up>' " }}} " YankRing {{{ let g:yankring_replace_n_pkey = '<C-K>' let g:yankring_replace_p_pkey = '<C-J>' " }}} " Python-Mode {{{ let g:pymode = 0 let g:pymode_python = 'python3' let g:pymode_syntax = 0 let g:pymode_syntax_all = 0 let g:pymode_syntax_builtin_objs = 1 let g:pymode_syntax_print_as_function = 1 let g:pymode_syntax_space_errors = 1 let g:pymode_indent = 0 let g:pymode_run = 0 let g:pymode_lint = 0 let g:pymode_trim_whitespaces = 0 let g:pymode_folding = 1 let g:pymode_doc = 1 let g:pymode_doc_bind = 'K' let g:pymode_virtualenv = 0 let g:pymode_rope = 0 " }}} " Lightline {{{ let g:lightline = { \'colorscheme': 'solarized', \'active': { \ 'left': [ ['mode', 'paste'], \ ['fugitive', 'lawrencium', 'readonly', 'relativepath', 'modified'], \ ['ctrlpmark'] ], \ 'right': [ ['lineinfo'], \ ['percent'], \ ['fileformat', 'fileencoding', 'filetype'], \ ['gutentags', 'syntastic', 'ycm_errs', 'ycm_warns'] ] \ }, \'component_function': { \ 'fugitive': '_LightlineFugitive', \ 'lawrencium': '_LightlineLawrencium', \ 'ctrlpmark': '_LightlineCtrlPMark', \ }, \'component_expand': { \ 'syntastic': '_LightlineLinter', \ 'ycm_errs': '_LightlineYcmErrors', \ 'ycm_warns': '_LightlineYcmWarnings', \ 'gutentags': '_LightlineGutentags', \ }, \'component_type': { \ 'syntastic': 'error', \ 'ycm_errs': 'error', \ 'ycm_warns': 'warning', \ 'gutentags': 'warning', \ }, \} if s:HasPlugin('fugitive') function! _LightlineFugitive() return fugitive#head() endfunction else function! _LightlineFugitive() endfunction endif if s:HasPlugin('lawrencium') function! _LightlineLawrencium() return lawrencium#statusline() endfunction else function! _LightlineLawrencium() endfunction endif function! _LightlineCtrlPMark() if expand('%:t') =~ 'ControlP' && has_key(g:lightline, 'ctrlp_item') call lightline#link('iR'[g:lightline.ctrlp_regex]) return lightline#concatenate( \['WAT?', g:lightline.ctrlp_prev, \ g:lightline.ctrlp_item, \ g:lightline.ctrlp_next], \0) else return '' endif endfunction if s:HasPlugin('gutentags') function! _LightlineGutentags() return gutentags#statusline('', '', '♨') endfunction else function! _LightlineGutentags() endfunction endif if s:HasPlugin('syntastic') function! _LightlineLinter() return SyntasticStatuslineFlag() endfunction else function! _LightlineLinter() 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 ? 'OK' : printf( \ '%dW %dE', \ all_non_errors, \ all_errors \) endfunction endif if s:HasPlugin('youcompleteme') function! _LightlineYcmErrors() let l:cnt = youcompleteme#GetErrorCount() return l:cnt > 0 ? string(l:cnt) : '' endfunction function! _LightlineYcmWarnings() let l:cnt = youcompleteme#GetWarningCount() return l:cnt > 0 ? string(l:cnt) : '' endfunction else function! _LightlineYcmErrors() endfunction function! _LightlineYcmWarnings() endfunction endif " }}} " YouCompleteMe {{{ let g:ycm_always_populate_location_list = 1 " }}} " }}} " File-Specific Settings {{{ augroup VimRCFileType_markdown au! autocmd FileType text,markdown setlocal textwidth=80 autocmd FileType markdown nnoremap <buffer> <localleader>1 yypVr=:redraw<cr> autocmd FileType markdown nnoremap <buffer> <localleader>2 yypVr-:redraw<cr> autocmd FileType markdown nnoremap <buffer> <localleader>3 mzI###<space><esc>`z4l autocmd FileType markdown nnoremap <buffer> <localleader>4 mzI####<space><esc>`z5l autocmd BufRead,BufNewfile */Dropbox/Personal/SimpleNote/* set ft=markdown autocmd BufRead,BufNewFile */_content/**/*.html set ft=piecrustmarkdown augroup END augroup VimRCFileType_php au! " Who the hell changes my matchpairs? autocmd FileType php setlocal matchpairs-=<:> augroup END augroup VimRCFileType_c au! autocmd FileType c,c++,cpp setlocal foldmethod=syntax autocmd FileType c,c++,cpp setlocal colorcolumn=240 autocmd FileType c,c++,cpp setlocal synmaxcol=250 autocmd FileType c,c++,cpp nnoremap <buffer> <localleader>z :call <SID>ToggleCppFolding()<CR> augroup END augroup VimRCFileType_csharp au! autocmd BufNewFile,BufRead *.xaml setlocal filetype=xml autocmd FileType cs setlocal foldmethod=syntax autocmd FileType cs setlocal colorcolumn=240 autocmd FileType cs setlocal synmaxcol=250 augroup END augroup VimRCFileType_css au! autocmd BufNewFile,BufRead *.less setlocal filetype=less autocmd Filetype less,css setlocal foldmethod=marker autocmd Filetype less,css setlocal foldmarker={,} autocmd Filetype less,css setlocal iskeyword+=- autocmd Filetype less,css setlocal omnifunc=csscomplete#CompleteCSS augroup END augroup VimRCTrailingWhitespaces au! autocmd FileType php,ruby,python,js,css,less autocmd BufWritePre <buffer> :call <SID>StripTrailingWhitespaces() augroup END " }}} " Mappings {{{ let mapleader="," " Visual line navigation noremap <up> g<up> noremap <down> g<down> noremap <home> g<home> noremap <end> g<end> noremap <S-up> 20<up> noremap <S-down> 20<down> " Tab navigation noremap <C-Tab> :tabnext<cr> noremap <C-S-Tab> :tabprevious<cr> nnoremap <leader>t :tabnew<cr> " Window navigation nnoremap <C-up> :wincmd k<cr> nnoremap <C-down> :wincmd j<cr> nnoremap <C-left> :wincmd h<cr> nnoremap <C-right> :wincmd l<cr> " Switch buffers. nnoremap <F1> :execute ("buffer " . bufname("#"))<cr> " NERDTree. nnoremap <F2> :call <SID>ToggleNERDTree()<cr> nnoremap <C-F2> :call <SID>FindInNERDTree()<cr> nnoremap <leader>e :e %:h<cr> " Tagbar. nnoremap <F3> :TagbarToggle<cr> nnoremap <C-F3> :TagbarOpenAutoClose<cr> " Gundo. nnoremap <F4> :GundoToggle<cr> " F5 to F8 are available for context-dependent mappings. " Jump to tags by keeping things better in view. Option for jumping to a tag " in a split window where everything is folded except what you need to see. " Note that if a tag search yield multiple possible results, we will still run " some of that `zvzz` stuff, but that's OK, the main point is to not mess up " the result selection window either. " " Go back after checking out a tag. nnoremap <F9> :pop<CR> " Go check out a tag. nnoremap <F10> g<C-]>zvzz " Go check out a tag in a split window. nnoremap <S-F10> <C-W>vg<C-]>zMzvzz " Move to previous matching tag. nnoremap <C-F9> :tprevious<CR> " Move to next matching tag. nnoremap <C-F10> :tnext<CR> " Common typos. nnoremap ; : " Split windows nnoremap <leader>s :split<cr> nnoremap <leader>v :vsplit<cr> " Easier things to type nnoremap <leader>w :w<cr> nnoremap <leader>q :q<cr> nnoremap <leader>hh :Hg nnoremap <leader>hg :Hg! nnoremap <leader>hs :Hgstatus<cr> nnoremap <leader>hv :Hgvdiff<cr> " Make the hash-key not suck. inoremap # X<BS># " Toggle invisible characters nnoremap <leader>i :set list!<cr> " Clear search matches nnoremap <leader><space> :noh<cr>:call clearmatches()<cr> " Switch between FR and US keyboard layouts. nnoremap <C-l>f :setlocal keymap=french<cr> nnoremap <C-l>u :setlocal keymap=<cr> " Toggle spell check according to current keyboard layout. nnoremap <C-l>s :call <SID>ToggleSpellCheck()<cr> " Simple way to close a buffer without closing the window. nnoremap <leader>d :bprevious<cr>:bdelete #<cr> " Use sane regexes. nnoremap / /\v vnoremap / /\v " Don't lose visual selection when you indent/unindent. vnoremap > >gv vnoremap < <gv " Next/previous quickfix and location messages. " This is meant to be similar to ]c and [c for the diff navigation. nnoremap ]q :cnext<cr>zvzz nnoremap [q :cprevious<cr>zvzz nnoremap ]l :lnext<cr>zvzz nnoremap [l :lprevious<cr>zvzz " Same with change and jump lists. nnoremap ]e g,zz nnoremap [e g;zz nnoremap ]j <C-I> nnoremap [j <C-O> " Copy the current buffer's info. nnoremap <leader>cp :let @+ = expand('%:p')<cr>:echo @+<cr> nnoremap <leader>cf :let @+ = expand('%:h')<cr>:echo @+<cr> nnoremap <leader>cw :let @+ = getcwd()<cr>:echo @+<cr> " Make the diff navigation also center things. nnoremap ]c ]czvzz nnoremap [c [czvzz " Quick search and replace. function! s:VSetSearch() let temp = @@ norm! gvy let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g') let @@ = temp endfunction vnoremap * :<C-u>call <SID>VSetSearch()<CR>//<CR><c-o> vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR><c-o> " Keep search matches in the middle of the window. nnoremap n nzvzz nnoremap N Nzvzz " YCM mappings. if s:HasPlugin('youcompleteme') augroup VimRC_YouCompleteMe autocmd! autocmd FileType cpp nnoremap <Leader>jj :YcmCompleter GoToImprecise<cr>zv autocmd FileType cpp nnoremap <Leader>jd :YcmCompleter GoToDefinition<cr>zv autocmd FileType cpp nnoremap <Leader>jh :YcmCompleter GoToDeclaration<cr>zv autocmd FileType cpp nnoremap <Leader>ji :YcmCompleter GoToInclude<cr> autocmd FileType cpp nnoremap <Leader>jc :YcmCompleter GetDoc<cr> autocmd FileType cpp nnoremap <Leader>jt :YcmCompleter GetType<cr> autocmd FileType cpp nnoremap <Leader>je :YcmShowDetailedDiagnostic<cr> augroup END endif " OmniSharp mappings if s:HasPlugin('OmniSharp') augroup VimRC_OmniSharp autocmd! autocmd FileType cs setlocal omnifunc=OmniSharp#Complete autocmd BufEnter,TextChanged,InsertLeave *.cs SyntasticCheck autocmd CursorHold *.cs call OmniSharp#TypeLookupWithoutDocumentation() autocmd FileType cs nnoremap <Leader>jj :OmniSharpGotoDefinition<cr> autocmd FileType cs nnoremap <Leader>x :OmniSharpFixIssue<cr> autocmd FileType cs nnoremap <Leader>fx :OmniSharpFixUsings<cr> autocmd FileType cs nnoremap <Leader>tt :OmniSharpTypeLookup<cr> autocmd FileType cs nnoremap <Leader>dc :OmniSharpDocumentation<cr> augroup END endif " ProjectRoot mappings let g:ludo_enable_autoprojectroot = 0 let s:no_auto_projectroot_buftypes = [ \'help', 'nofile', 'quickfix'] function! s:AutoProjectRootCD() abort if g:ludo_enable_autoprojectroot try if index(s:no_auto_projectroot_buftypes, &buftype) == -1 ProjectRootCD endif catch " Silently ignore invalid buffers endtry endif endfunction augroup VimRC_ProjectRoot autocmd! autocmd BufEnter * call <SID>AutoProjectRootCD() augroup END nnoremap <leader>cd :ProjectRootCD<cr> " Ctrl-P mappings. if s:HasPlugin('ctrlp') nnoremap <silent> <C-p> :CtrlP<cr> nnoremap <silent> <C-o> :CtrlPBuffer<cr> nnoremap <silent> <C-u> :CtrlPTag<cr> nnoremap <silent> <C-y> :CtrlPBufTag<cr> nnoremap <silent> <Tab> :CtrlPMRUFiles<cr> nnoremap <silent> <F8> :CtrlPBookmarkDir<cr> endif " FZF mappings. if s:HasPlugin('fzf') if exists('*fzf#run') nnoremap <silent> <C-p> :Files<cr> nnoremap <silent> <C-o> :Buffers<cr> nnoremap <Tab> :History<cr> " Replace the default `Tags` command, which requires Perl, with " something I can use, based on Python. command! -bang -nargs=* Tags call ludo#run_fzf_tags(<q-args>, <bang>0) nnoremap <silent> <C-u> :Tags<cr> else call ludo#error( \"FZF is installed and enabled, but the Vim plugin ". \"isn't loaded... add it to your `vimrc-local-pre`.") endif endif " LeaderF mappings. if s:HasPlugin('leaderf') let g:Lf_ShortcutF = '<C-p>' let g:Lf_ShortcutB = '<C-o>' nnoremap <silent> <C-p> :LeaderfFile<cr> nnoremap <silent> <C-o> :LeaderfBuffer<cr> nnoremap <silent> <C-u> :LeaderfTag<cr> nnoremap <silent> <C-y> :LeaderfBufTagAll<cr> nnoremap <silent> <Tab> :LeaderfMru<cr> nnoremap <silent> <Leader>fl :LeaderfLine<cr> nnoremap <silent> <Leader>fc :LeaderfColorscheme<cr> nnoremap <silent> <Leader>fh :LeaderfHelp<cr> let g:Lf_StlSeparator = { 'left': '', 'right': '' } endif " Vimcrosoft mappings. if s:HasPlugin('vimcrosoft') nnoremap <F7> :VimcrosoftBuildActiveProject<cr> nnoremap <F8> :VimcrosoftBuildSln<cr> endif " }}} " Folding {{{ " Start with one level of open. set foldlevel=1 " Don't fold too much. set foldnestmax=2 " Folds are defined by markers in the text. set foldmethod=marker"{{{"}}} " Toggle folds with <space>. nnoremap <space> za " Create folds with <space> (in visual mode). vnoremap <space> zf " See http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text " Don't screw up folds when inserting text that might affect them, until " leaving insert mode. Foldmethod is local to the window. Protect against " screwing up folding when switching between windows. autocmd InsertEnter * if !exists('w:last_fdm') | let w:last_fdm=&foldmethod | setlocal foldmethod=manual | endif autocmd InsertLeave,WinLeave * if exists('w:last_fdm') | let &l:foldmethod=w:last_fdm | unlet w:last_fdm | endif " }}} " Abbreviations {{{ iabbrev @@ ludovic@chabant.com iabbrev ccopy Copyright ©2011 Ludovic Chabant, all rights reserved. iabbrev ssig --<cr>l u d o .<cr>. 8 0 17 80 " }}} " Functions {{{ function! s:ToggleSpellCheck() abort if &spell ==? 'nospell' if &keymap ==? 'french' setlocal spell spelllang=fr_fr else setlocal spell spelllang=en_us,en_ca endif else setlocal spell nospell endif endfunction function! s:StripTrailingWhitespaces() abort let l = line(".") let c = col(".") %s/\s\+$//e call cursor(l, c) endfunction function! s:ToggleNERDTree() abort NERDTreeToggle endfunction function! s:FindInNERDTree() abort ProjectRootExe NERDTreeFind normal zz endfunction function! s:ToggleCppFolding() abort if (&foldmethod == "syntax") setlocal foldmethod=manual setlocal nofoldenable else setlocal foldmethod=syntax setlocal foldenable endif endfunction " }}} " Local override {{{ let s:local_vimrc = ludo#localpath('vimrc-local') if filereadable(s:local_vimrc) execute 'source' s:local_vimrc endif " }}}