Skip to content

Instantly share code, notes, and snippets.

@ryanoasis
Created March 2, 2016 20:42
Show Gist options
  • Select an option

  • Save ryanoasis/53a8d4c96f7acddaf93d to your computer and use it in GitHub Desktop.

Select an option

Save ryanoasis/53a8d4c96f7acddaf93d to your computer and use it in GitHub Desktop.
Experiment to test vim-devicon's custom ctrlp open function changes (solve E16)
" setup
function! s:strip(input)
return substitute(a:input, '^\s*\(.\{-}\)\s*$', '\1', '')
endfunction
" current way:
function! Original115()
let line = ' ~/www/some/big/long/jenky/path/something.something/whatever_it_is/bigUgly/path/too/long/something.vim'
let line = substitute(line, "[-]", "", "")
let line = s:strip(line)
endfun
" alternate way:
function! Alternate115()
let line = ' ~/www/some/big/long/jenky/path/something.something/whatever_it_is/bigUgly/path/too/long/something.vim'
let glyphCandidate = char2nr(strpart(line, 0, 3))
let glyphASCIIRangeStart = 57344
let glyphASCIIRangeEnd = 63743
if glyphCandidate >= glyphASCIIRangeStart && glyphCandidate <= glyphASCIIRangeEnd
let line = strpart(line, 3)
endif
let line = s:strip(line)
endfun
" alternate way cached variables:
let s:glyphASCIIRangeStart = 57344
let s:glyphASCIIRangeEnd = 63743
function! AlternateCached115()
let line = ' ~/www/some/big/long/jenky/path/something.something/whatever_it_is/bigUgly/path/too/long/something.vim'
let glyphCandidate = char2nr(strpart(line, 0, 3))
if glyphCandidate >= s:glyphASCIIRangeStart && glyphCandidate <= s:glyphASCIIRangeEnd
let line = strpart(line, 3)
endif
let line = s:strip(line)
endfun
" }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment