mirror of
https://github.com/neovim/neovim.git
synced 2026-01-04 02:17:09 +10:00
tutor: reorganize
This commit is contained in:
@@ -15,14 +15,25 @@ function! tutor#SetupVim()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Loads metadata file, if available
|
||||
function! tutor#LoadMetadata()
|
||||
let b:tutor_metadata = json_decode(join(readfile(expand('%').'.json'), "\n"))
|
||||
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
|
||||
@@ -35,14 +46,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'
|
||||
@@ -85,12 +88,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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user