looking promising
This commit is contained in:
parent
0885630404
commit
3897717e23
5 changed files with 97 additions and 1 deletions
43
home/nvim/ftplugin/markdown.vim
Normal file
43
home/nvim/ftplugin/markdown.vim
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
setlocal spell
|
||||
setlocal textwidth=0
|
||||
setlocal syntax=rmd
|
||||
setlocal breakat-=@
|
||||
|
||||
set makeprg=Rscript\ -e\ 'publishR::render(\\"%\\")'
|
||||
|
||||
" nnoremap <localleader>oh :! xdg-open %:r.html<cr>
|
||||
nnoremap <localleader>oh :! chromium-browser %:r.html<cr>
|
||||
nnoremap <localleader>op :! xdg-open %:r.pdf<cr>
|
||||
nnoremap <localleader>ow :! xdg-open %:r.docx<cr>
|
||||
|
||||
nnoremap <leader>t :TOC<cr>
|
||||
|
||||
xnoremap <silent> ic :<c-u>call InnerChunk()<cr>
|
||||
onoremap <silent> ic :<c-u>call InnerChunk()<cr>
|
||||
xnoremap <silent> ac :<c-u>call OuterChunk()<cr>
|
||||
onoremap <silent> ac :<c-u>call OuterChunk()<cr>
|
||||
|
||||
function OuterChunk()
|
||||
let chunk = FindChunk()
|
||||
execute "normal! " . chunk.start . "GV" . chunk.end . "G"
|
||||
endfunction
|
||||
|
||||
function InnerChunk()
|
||||
let chunk = FindChunk()
|
||||
execute "normal! " . chunk.start . "GjV" . chunk.end . "Gk"
|
||||
endfunction
|
||||
|
||||
function FindChunk()
|
||||
let view = winsaveview()
|
||||
normal! j
|
||||
?\v^ *```(\{.*\})=$
|
||||
let startFence = line(".")
|
||||
/\v^ *``` *
|
||||
let endFence = line(".")
|
||||
if startFence <= view.lnum && endFence >= view.lnum
|
||||
return {"start": startFence, "end": endFence}
|
||||
else
|
||||
echoerr "Not inside a chunk"
|
||||
endif
|
||||
call winrestview(view)
|
||||
endfunction
|
||||
Loading…
Add table
Add a link
Reference in a new issue