Skip to content

Commit

Permalink
tutor: reorganize
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoralesc committed Jul 15, 2017
1 parent 37af859 commit 3014a10
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions runtime/autoload/tutor.vim
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,28 @@ function! tutor#SetupVim()
endif
endfunction

" Loads metadata file, if available
function! tutor#LoadMetadata()
try
let b:tutor_metadata = json_decode(join(readfile(expand('%').'.json'), "\n"))
catch
endtry
endfunction

" Mappings: {{{1

function! tutor#SetNormalMappings()
nnoremap <silent> <buffer> <CR> :call tutor#FollowLink(0)<cr>
nnoremap <silent> <buffer> <2-LeftMouse> :call tutor#MouseDoubleClick()<cr>
nnoremap <buffer> >> :call tutor#InjectCommand()<cr>
endfunction

function! tutor#MouseDoubleClick()
if foldclosed(line('.')) > -1
normal! zo
else
if match(getline('.'), '^#\{1,} ') > -1
normal! zc
silent normal! zc
else
call tutor#FollowLink(0)
endif
Expand All @@ -35,14 +49,6 @@ function! tutor#InjectCommand()
redraw | echohl WarningMsg | echon "tutor: ran" | echohl None | echon " " | echohl Statement | echon l:cmd
endfunction

function! tutor#SetNormalMappings()
nnoremap <silent> <buffer> <CR> :call tutor#FollowLink(0)<cr>
nnoremap <silent> <buffer> <2-LeftMouse> :call tutor#MouseDoubleClick()<cr>
nnoremap <buffer> >> :call tutor#InjectCommand()<cr>
endfunction

" Hypertext: {{{1

function! tutor#FollowLink(force)
let l:stack_s = join(map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")'), '')
if l:stack_s =~# 'tutorLink'
Expand Down Expand Up @@ -85,12 +91,6 @@ function! tutor#InfoText()
return join(l:info_parts, " ")
endfunction

function! tutor#LoadMetadata()
try
let b:tutor_metadata = json_decode(join(readfile(expand('%').'.json'), "\n"))
catch
endtry
endfunction

" Marks: {{{1

Expand Down

0 comments on commit 3014a10

Please sign in to comment.