aboutsummaryrefslogtreecommitdiff
path: root/neovim/.config/nvim/ftplugin/markdown.lua
blob: e162dc8fca69783a1376aebc7d40ef89ea3432b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
--- Personal lua config files for NeoVim.
--  Last Changed: 2019-01-27
--  Author: Federico Igne <git@federicoigne.com>
--  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 <buffer> ;mg :w !gnuplot -e "set terminal dumb ansirgb size $(tput cols) $(expr $(tput lines) - 4)" -<cr>
--xnoremap <buffer> ;mG :w !gnuplot -persist -<cr>
--xnoremap <expr> <buffer> ;mp ":GnuPlot " . expand("%:h") . "/resources/"
--
--command! -range -nargs=+ GnuPlot <line1>,<line2>call GnuPlot(<f-args>)
--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 . "\"' -\<cr>"
--    " Move to the end of the gnuplot code snippet
--    call getpos("'>")->setpos('.')
--    " Add reference to the image
--    silent exec "normal! jo\<cr>![<++++>](" . a:1 . ")<++>\<esc>?<++++>\<cr>gnd"
--    startinsert
--endfunction
--
--- Table of content
--nnoremap <buffer> ;t :g/\v^##?#? /#<cr>:noh \|