view vim/vimrc @ 61:8c80aa9bd387

Re-enabled lawrencium status-line.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 08 Dec 2011 21:46:16 -0800
parents 6df571869f4a
children 34dafaf8ed9c
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

" Set some important system-dependent variables.
if has("win32") || has("win64") || has("dos32")
    let $HOMEVIM = "vimfiles"
    let $PLATFORM = "windows"
else
    let $HOMEVIM = ".vim"
    let $PLATFORM = "unix"
endif

" Disable some plugins.
let g:pathogen_disabled = []
call add(g:pathogen_disabled, 'vimroom')

" Load pathogen.
call pathogen#infect()

" 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=50
    set columns=135
endif

" }}}

" General Settings {{{

" Disable modelines.
set modelines=0

" 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

" Remember lots of commands.
set history=1000

" 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

" 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
set backupdir=~/$HOMEVIM/backup
set directory=~/$HOMEVIM/temp

" Better command-line completion, but don't show some
" stuff we don't care about.
set wildmenu
set wildignore+=.DS_Store,Thumbs.db

" Always display the tab-page line.
set showtabline=2

" Show matching braces.
set showmatch

" 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

" Default encoding
set encoding=utf-8

" Clipboard buffer.
set clipboard=unnamed

" Smoot 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

" Folds are defined by markers in the text.
set foldmethod=marker

" And now, for some system-dependent settings:
" - font to use
if $PLATFORM == "windows"
    set guifont=Consolas:h12
else
    set guifont=Monaco:h12
endif


" Syntax highlighting.
syntax on

" Change the current directory to the home directory.
if !exists('g:resourcing_vimrc')
    cd ~/
endif

" Default color scheme.
if has('gui_running')
    set background=light
else
    set background=dark
endif
colorscheme solarized

" Enable file type detection.
filetype indent plugin on

" }}}

" Plugin Settings {{{

" Navigate MiniBufExplorer with CTRL+Tab/CTRL+Shift+Tab.
let g:miniBufExplMapCTabSwitchBufs = 1

" }}}

" Mappings {{{

let mapleader=","

" Edit & source the VIMRC.
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
nnoremap <leader>sv :source $MYVIMRC<cr>

" MiniBufExplorer mappings.
nnoremap <F2> :TMiniBufExplorer<cr>

" Open NERDtree.
nnoremap <F3> :NERDTreeToggle<cr>

" Switch between FR and US keyboard layouts.
nnoremap <leader>fr :setlocal keymap=french<cr>
nnoremap <leader>us :setlocal keymap=<cr>

" Toggle spell check according to current keyboard layout.
nnoremap <leader>sp :call <SID>ToggleSpellCheck()<cr>

" Simple way to close a buffer without closing the window.
nnoremap <leader>bd :bprevious<cr>:bdelete #<cr>

" Toggle folds with <space>
nnoremap <space> za

" Create folds with <space> (in visual mode)
vnoremap <space> zf

" }}}

" Abbreviations {{{

iabbrev @@      ludovic@chabant.com
iabbrev ccopy   Copyright &copy;2011 Ludovic Chabant, all rights reserved.
iabbrev ssig    --<cr>l u d o .<cr>. 8 0 17 80

" }}}

" Status Line {{{

set statusline=%f    " Path.
set statusline+=%m   " Modified flag.
set statusline+=%r   " Readonly flag.
set statusline+=%w   " Preview window flag.

set statusline+=\    " Space.

set statusline+=%#redbar#                       " Highlight the following as a warning.
set statusline+=%{SyntasticStatuslineFlag()}    " Syntastic errors.
set statusline+=%*                              " Reset highlighting.

set statusline+=%=   " Right align.

" Mercurial information.
set statusline+=%{lawrencium#statusline('[',']')}
set statusline+=\    " Space.

" File format, encoding and type.  Ex: "(unix/utf-8/python)"
set statusline+=(
set statusline+=%{&ff}                        " Format (unix/DOS).
set statusline+=/
set statusline+=%{strlen(&fenc)?&fenc:&enc}   " Encoding (utf-8).
set statusline+=/
set statusline+=%{&ft}                        " Type (python).
set statusline+=)

" Line and column position and counts.
set statusline+=\ (line\ %l\/%L,\ col\ %03c)

" }}}

" 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

" }}}

" Temporary stuff {{{

" Enable debugging Lawrencium
let g:lawrencium_debug = 1
let g:lawrencium_trace = 1

" }}}

"let mapleader=","                                               " Use , as Leader
"let gmapleader=","
"map Y y$                                                        " Yank to the end of the line w/ Y
"map <leader>nt :tabnew<CR>                                      " New tab w/ ,nt
"map <leader>f :FufFile<CR>                                      " Find files with ,f
"nmap <leader>w :w!<cr>
"map <F3> :r !pbpaste<CR>
"map <F4> :setlocal spell spelllang=en_gb<CR>                    " Turn on spellcheck with <F4>
"map <F5> :set nospell<CR>
"set pastetoggle=<F6>
"map <F7> :set complete+=k<CR>
"map <S-F7> :set complete=-k<CR>                                 
"map <F8> :YRShow<CR>                                            " Show the YankRing w/ <F8>
"nnoremap <F3> :GundoToggle<CR>                                  " Show the undo tree w/ <F3>
"nnoremap ; :
"autocmd BufRead,BufNewfile ~/notes/* set filetype=markdown      " All files in ~/notes are Markdown
"au BufWinLeave *.html,*.css mkview	
"au BufWinEnter *.html,*.css silent loadview	
"au FileType mail set tw=65                                      " Thin width when writing mail in mutt 
"au FocusLost * :wa                                              " Saves file when vim loses focus
"if has('statusline')                                            " Status line with git repo info
"  set statusline=%<%f\ 
"  set statusline+=%w%h%m%r 
"  set statusline+=%{fugitive#statusline()}
"  set statusline+=\ [%{&ff}/%Y]  
"  set statusline+=\ [%{getcwd()}]
"  set statusline+=%=%-14.(Line:\ %l\ of\ %L\ [%p%%]\ -\ Col:\ %c%V%)
"endif

" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")

" Don't use Ex mode, use Q for formatting
"map Q gq

" This is an alternative that also works in block mode, but the deleted
" text is lost and it only works for putting the current register.
"vnoremap p "_dp

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
"if &t_Co > 2 || has("gui_running")
"  syntax on
"  set hlsearch
"endif

" Only do this part when compiled with support for autocommands.
"if has("autocmd")

  " Enable file type detection.
  " Use the default filetype settings, so that mail gets 'tw' set to 72,
  " 'cindent' is on in C files, etc.
  " Also load indent files, to automatically do language-dependent indenting.
"  filetype plugin indent on

  " Put these in an autocmd group, so that we can delete them easily.
"  augroup vimrcEx
"  au!

  " For all text files set 'textwidth' to 78 characters.
"  autocmd FileType text setlocal textwidth=78

  " When editing a file, 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

"  augroup END

"else

"  set autoindent		" always set autoindenting on

"endif " has("autocmd")

"set fileformats=dos,unix	" set fileformat to DOS by default