neovim: add a snippet for using pandoc

This commit is contained in:
FollieHiyuki 2021-09-28 01:23:34 +07:00
parent 6f78887641
commit a8e3fb728b
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
4 changed files with 45 additions and 19 deletions

View File

@ -1,6 +1,23 @@
local api = vim.api local api = vim.api
local wk = require('which-key') local wk = require('which-key')
local function pandoc_convert(ofiletype)
if ofiletype == nil then
ofiletype = 'html'
end
local ifilename = vim.fn.expand('%:p')
local ofilename = vim.fn.expand('%:p:r') .. '.' .. ofiletype
local cmd
if ofiletype == 'pdf' then
cmd = string.format('pandoc %s -o %s --pdf-engine=xelatex -V "mainfont:Iosevka Etoile" -V "sansfont:Iosevka Aile" -V "monofont:Iosevka" -V "geometry:margin=1in"', ifilename, ofilename)
else
cmd = string.format('pandoc %s -o %s', ifilename, ofilename)
end
vim.fn.jobstart(cmd)
end
-- No one likes Esc -- No one likes Esc
api.nvim_set_keymap('i', 'jk', [[<Esc>]], {noremap = true, silent = true}) api.nvim_set_keymap('i', 'jk', [[<Esc>]], {noremap = true, silent = true})
@ -130,7 +147,16 @@ wk.register({
D = {'<Cmd>tabclose<CR>', 'Close tab'}, D = {'<Cmd>tabclose<CR>', 'Close tab'},
J = {'<Cmd>tabprev<CR>', 'Previous tab'}, J = {'<Cmd>tabprev<CR>', 'Previous tab'},
K = {'<Cmd>tabnext<CR>', 'Next tab'}, K = {'<Cmd>tabnext<CR>', 'Next tab'},
N = {'<Cmd>tabnew<CR>', 'New tab'} N = {'<Cmd>tabnew<CR>', 'New tab'},
v = {
name = 'Convert',
m = {function() pandoc_convert('md') end, 'To Markdown'},
o = {function() pandoc_convert('org') end, 'To Org'},
p = {function() pandoc_convert('pdf') end, 'To PDF'},
r = {function() pandoc_convert('rst') end, 'To RST'},
t = {function() pandoc_convert('tex') end, 'To LaTeX'},
w = {function() pandoc_convert('html') end, 'To HTML'}
}
}, },
d = { d = {

View File

@ -170,20 +170,20 @@ function M.snippets_conf()
require('luasnip/loaders/from_vscode').load() require('luasnip/loaders/from_vscode').load()
end end
function M.coq_conf() -- function M.coq_conf()
-- To add snippets from lsp servers, change lsp.lua: -- -- To add snippets from lsp servers, change lsp.lua:
----- -- -----
-- local coq = require('coq') -- -- local coq = require('coq')
-- lspconf.<server>.setup(...) --> lspconf.<server>.setup(coq.lsp_ensure_capabilities(...)) -- -- lspconf.<server>.setup(...) --> lspconf.<server>.setup(coq.lsp_ensure_capabilities(...))
vim.g.coq_settings = { -- vim.g.coq_settings = {
auto_start = true, -- auto_start = true,
display = { -- display = {
icons = { -- icons = {
mode = 'none' -- mode = 'none'
} -- }
} -- }
} -- }
end -- end
function M.autotag_conf() function M.autotag_conf()
require('nvim-ts-autotag').setup({ require('nvim-ts-autotag').setup({

View File

@ -113,7 +113,7 @@ function M.matchup_conf()
end end
function M.hop_conf() function M.hop_conf()
require('hop').setup{keys = 'etovxqpdygfblzhckisuran'} require('hop').setup {keys = 'etovxqpdygfblzhckisuran'}
end end
function M.eft_conf() function M.eft_conf()

View File

@ -298,7 +298,7 @@ return require('packer').startup(
}}, }},
config = tools.neogit_conf config = tools.neogit_conf
} }
use { use { -- TODO: replace with code_runner.nvim
'skywind3000/asynctasks.vim', 'skywind3000/asynctasks.vim',
cmd = { cmd = {
'AsyncTask', 'AsyncTask',
@ -316,7 +316,7 @@ return require('packer').startup(
use { use {
'iamcco/markdown-preview.nvim', 'iamcco/markdown-preview.nvim',
run = 'cd app && yarn install', run = 'cd app && yarn install',
ft = {'markdown', 'pandoc.markdown', 'rmd'}, ft = {'markdown', 'rmd'},
config = tools.markdown_preview_conf config = tools.markdown_preview_conf
} }
use { use {
@ -398,6 +398,6 @@ return require('packer').startup(
-- use {'dstein64/vim-startuptime', cmd = 'StartupTime'} -- Just for benchmarking -- use {'dstein64/vim-startuptime', cmd = 'StartupTime'} -- Just for benchmarking
-- TODO: dial.nvim, rust-tools.nvim, crates.nvim, go.nvim, clojure-vim/*, -- TODO: dial.nvim, rust-tools.nvim, crates.nvim, go.nvim, clojure-vim/*,
-- vim-pandoc, nvim-bqf, nvim-comment-frame -- nvim-bqf, nvim-comment-frame, nvim-revJ.lua
end end
) )