Skip to content

Instantly share code, notes, and snippets.

@fmoralesc
Created September 2, 2015 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmoralesc/34862a268895dfb47f00 to your computer and use it in GitHub Desktop.
Save fmoralesc/34862a268895dfb47f00 to your computer and use it in GitHub Desktop.
" Base {{{1
"
if has("nvim")
if !exists('$TMUX')
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
endif
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1
set shell=fish
endif
let $PATH=$HOME."/bin/:" .$HOME. "/.cabal/bin/:". $HOME. "/.gem/ruby/1.9.1/bin/:" .$PATH
set backupdir-=.
set backupdir+=~/.backup
set undofile
set undodir=~/.vim/undo
set suffixes+=*.pdf
" Plugins: {{{1
" Filetypes: {{{2
plug vim-pandoc/vim-pandoc
plug vim-pandoc/vim-pandoc-after
plug vim-pandoc/vim-pandoc-syntax
plug vim-bibliographer
plug dag/vim-fish
plug klen/python-mode
plug fatih/vim-go
plug vimoutliner/vimoutliner
plug vim-latex/vim-latex
" Utilities: {{{2
plug tpope/vim-flagship
plug chrisbra/NrrwRgn
plug ctrlpvim/ctrlp.vim
plug fisadev/vim-ctrlp-cmdpalette
plug fmoralesc/vim-extended-autochdir
plug fmoralesc/vim-pad
plug justinmk/vim-gtfo
plug kana/vim-smartword
plug ludovicchabant/vim-gutentags
plug ntpeters/vim-better-whitespace
plug scrooloose/nerdcommenter
plug tpope/vim-eunuch
plug tpope/vim-fugitive
plug tpope/vim-repeat
plug tpope/vim-unimpaired
plug tpope/vim-vinegar
plug Shougo/deoplete.nvim
plug unblevable/quick-scope
" Only show quick-scope highlights after f/F/t/T is pressed
function! Quick_scope_selective(movement)
let needs_disabling = 0
if !g:qs_enable
QuickScopeToggle
redraw
let needs_disabling = 1
endif
"let letter = nr2char(getchar())
if needs_disabling
QuickScopeToggle
endif
"return a:movement . letter
return a:movement
endfunction
let g:qs_enable = 0
for i in [ 'f', 'F', 't', 'T' ]
execute 'noremap <expr> <silent>' . i . " Quick_scope_selective('". i . "')"
endfor
plug justinmk/vim-sneak
plug simnalamburt/vim-mundo
plug junegunn/vim-easy-align
plug benekastah/neomake
" Colorschemes: {{{2
plug tomasr/molokai
plug molokayo
"}}}2
" Options: {{{2
" CtrlP: {{{3
let g:ctrlp_clear_cache_on_exit = 0
let g:ctrlp_follow_symlinks = 2
let g:ctrlp_mruf_max = 1000
"let g:ctrlp_match_func = {'match': 'matcher#cmatch'}
if !has('nvim')
nnoremap <C-f1> :silent! :<C-u>CtrlPMRUFiles<CR>
nnoremap <C-ñ> :silent :<C-u>CtrlPLine<cr>
else
nnoremap <F25> :silent! :<C-u>CtrlPMRUFiles<cr>
endif
nnoremap <C-p> :silent :<C-u>CtrlP<CR>
nnoremap <C-c> :silent! :<C-u>CtrlPCmdPalette<cr>
" vim-sneak: {{{3
let g:sneak#streak = 1
" vim-pad: {{{3
let g:pad#dir = "/home/felipe/documents/Notas"
let g:pad#default_format = "pandoc"
let g:pad#window_height = 8
let g:pad#search_backend = "ag"
noremap <F13> :Pad ls<cr>
" vim-pandoc: {{{3
let g:pandoc#formatting#mode = "hA"
let g:pandoc#formatting#smart_autoformat_on_cursormoved = 1
let g:pandoc#folding#level = 2
"let g:pandoc#folding#mode = "relative"
let g:pandoc#after#modules#enabled = ["nrrwrgn", "tablemode", "vimcompletesme"]
let g:pandoc#completion#bib#mode = 'citeproc'
let g:pandoc#syntax#newlines = 0
" NrrRgn: {{{3
noremap <leader>nn :NR<CR>
" python-mode: {{{3
let g:pymode_lint_checkers = ['pyflakes']
"}}}1
" UI: {{{1
" Theme: {{{2
filetype plugin indent on
syntax on
set co=130 lines=40
if !exists('g:colors_name')
let g:molokayo#focus_variant = 1
colorscheme molokayo
endif
set title
"}}}2
" Folding {{{2
function! NeatFoldText() "
let line = ' ' . substitute(getline(v:foldstart), '^\s*"\?\s*\|\s*"\?\s*{{' . '{\d*\s*', '', 'g') . ' '
let lines_count = v:foldend - v:foldstart + 1
let lines_count_text = '/' . printf("%10s", lines_count . ' lines') . ' /'
let foldchar = matchstr(&fillchars, 'fold:\zs.')
let foldtextstart = strpart('+' . repeat(foldchar, v:foldlevel*2) . line, 0, (winwidth(0)*2)/3)
let foldtextend = lines_count_text . repeat(foldchar, 8)
let foldtextlength = strlen(substitute(foldtextstart . foldtextend, '.', 'x', 'g')) + &foldcolumn
return foldtextstart . repeat(foldchar, winwidth(0)-foldtextlength) . foldtextend
endfunction
set foldtext=NeatFoldText()
" }}}2
" Tabline: {{{2
set showtabline=2
set guioptions-=e
let g:tabprefix = ''
" Statusline: {{{2
"
function! StatusDir()
if &buftype != "nofile"
let d = expand("%:p:~:h")
if d != fnamemodify(getcwd(), ":~")
return expand("%:p:.:h").'/'
else
return ''
endif
else
return ''
endif
endfunction
function! OtherBuffers()
let buffers_txt = ""
redir => buffers_txt
silent ls
redir END
let lines = []
for line in split(buffers_txt, "\n")
let bufnr = split(line)[0]
if bufnr != bufnr("%")
call add(lines, split(line)[0])
endif
endfor
return lines
endfunction
function! StatusOtherBuffers()
return join(map(OtherBuffers(), '"·".v:val'), ' ')
endfunction
function! PWD()
return fnamemodify(getcwd(), ":~")
endfunction
set laststatus=2
set statusline=%#SLDelim#@:%#SLSpecial#%{PWD()}
set statusline+=%#SLDelim#:%#SLNumber#%n%#SLDelim#: "buffer number
set statusline+=%#SLDirectory#%{expand('%:h')!=''?StatusDir():''} "file path, if buffer is a file
set statusline+=%#SLIdentifier#%{expand('%:h')!=''?expand('%:t'):'[unnamed]'}%#Boolean#%m%r "buffer name and modifiers
set statusline+=%#SLDelim#%{fugitive#head()!=''?'@':''}%#SLVCS#%{fugitive#head()}
" disable the retarded vim-fugitive flag
au VimEnter * au! fugitive_statusline
set statusline+=\ %#SLCharacter#%{StatusOtherBuffers()} "list of other buffers
set statusline+=\ %=\%#SLConstant#%{&fenc}%#SLDelim#:%#SLType#%{&ft}%#SlDelim#:%#SLFunction#%{&fo}%#SLDelim#:%#SLSpellBad#%{&spell?&spl:''}
set statusline+=%#SLNumber#\ %l,%c
set wrapscan
set wildmenu
set wildmode=full
" Scroll {{{2
set scrolloff=1
noremap <expr> H 'H' . eval('&scrolloff') . '<C-u>'
noremap <expr> L 'L' . eval('&scrolloff') . 'j'
" }}}1
" Completion: {{{1
set completeopt=menuone
set complete+=s,kspell
" Indent: {{{1
set softtabstop=4
set shiftwidth=4
" Search: {{{1
set ignorecase
set smartcase
" Misc: {{{1
set shortmess+=I "no startup message
set keymodel=startsel,stopsel
" Commands: {{{1
"
command! ToggleMenu
\ if strridx(&guioptions,"m") == -1 |
\ set guioptions+=m |
\ else |
\ set guioptions-=m |
\ endif
command! SynName echo synIDattr(synID(line("."), col("."), 1), "name")
command! SynStack echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
command! SynTrans echo synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), "name")
command! FileTree leftabove 30vsplit . | map <buffer> <CR> <nop>
" Mappings: {{{1
"
let g:mapleader=" "
let g:maplocalleader=","
" Plugins: {{{2
" smartword-movements {{{3
map <leader>w <Plug>(smartword-w)
map <leader>b <Plug>(smartword-b)
map <leader>e <Plug>(smartword-e)
map <leader>ge <Plug>(smartword-ge)
" change current dir {{{2
noremap <leader>cd :cd %:h<CR>
noremap <leader>ld :lcd %:h<CR>
" movement {{{2
noremap <up> gk
noremap <down> gj
noremap <leader>j 5j
noremap <leader>k 5k
" buffer mappings {{{2
noremap <C-b>d :bdelete<CR>
noremap <C-b>w :bwipe<CR>
noremap <C-b>! :bwipe!<cr>
" reformat a paragraph {{{2
nmap <leader>q gqip
" spelling {{{2
"" Suggest spellings
inoremap <C-s> <esc>i<C-X>s
nnoremap <C-s> e<esc>i<C-x>s
"" Goto next misspelling
nnoremap <C-z> <esc>]se
inoremap <C-z> <esc>]se
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment