--- Personal lua config files for NeoVim. -- Last Changed: 2019-01-27 -- Author: Federico Igne -- License: This file is placed in the public domain. local map = require 'dyamon.util.map' local cp = require 'dyamon.util.checkpoint' local bopt = vim.bo local wopt = vim.wo --- {{{1 Options -- @section options -- Set default compiler to generate a PDF (via Pandoc) bopt.makeprg = "pandoc %:p -t latex -o %:p:r.pdf" -- Set soft wrapping bopt.textwidth = 0 -- disable hard wrapping wopt.wrap = true wopt.linebreak = true -- soft wrapping on 'breakat' -- Conceal some visual markup wopt.conceallevel = 2 --- {{{1 Custom vim-surround options -- @section vim-surround vim.b['surround_'..string.byte('b')] = "**\r**" vim.b['surround_'..string.byte('c')] = "```{.\r #<+id+><++>}\n<++>\n```\n" vim.b['surround_'..string.byte('s')] = "~~\r~~" vim.b['surround_'..string.byte('i')] = "![\r](<+img+>)" vim.b['surround_'..string.byte('l')] = "[\r](<+link+>)" --- {{{1 Mappings -- @section mappings -- Images and links cp.surround(";i", "i", 0) cp.surround(";ln", "l", 0) -- Bold face, italic constant-width and strikeout faces cp.surround(";fi", "*", 0) cp.surround(";fb", "b", 0) cp.surround(";fc", "`", 0) cp.surround(";fs", "s", 0) -- Additional parenthesis cp.surround("$$", "$", 0) -- Code block --map.un.b.i(nil, "``") -- Disable global `` keymap cp.surround("```", "c", 0) --- GnuPlot --xnoremap ;mg :w !gnuplot -e "set terminal dumb ansirgb size $(tput cols) $(expr $(tput lines) - 4)" - --xnoremap ;mG :w !gnuplot -persist - --xnoremap ;mp ":GnuPlot " . expand("%:h") . "/resources/" -- --command! -range -nargs=+ GnuPlot ,call GnuPlot() --function! GnuPlot( ... ) range -- " Generate image -- exec "normal! :" . a:firstline . "," . a:lastline . "w !gnuplot -e 'set terminal png size " . a:2 . "," . a:3 . "' -e 'set output \"" . a:1 . "\"' -\" -- " Move to the end of the gnuplot code snippet -- call getpos("'>")->setpos('.') -- " Add reference to the image -- silent exec "normal! jo\![<++++>](" . a:1 . ")<++>\?<++++>\gnd" -- startinsert --endfunction -- --- Table of content --nnoremap ;t :g/\v^##?#? /#:noh \|