run :Format

This commit is contained in:
Fabrice Mouhartem 2023-12-25 14:29:10 +01:00
parent 66137fdea3
commit 37f15e1b16
6 changed files with 69 additions and 60 deletions

View File

@ -8,38 +8,38 @@
if vim.fn.maparg("gbc") ~= "" then
vim.keymap.del("n", "gbc")
vim.keymap.set('n', 'gBc', function()
return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_blockwise_current)'
or '<Plug>(comment_toggle_blockwise_count)'
end, { expr = true, desc = 'Comment toggle current block' })
return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_blockwise_current)'
or '<Plug>(comment_toggle_blockwise_count)'
end, { expr = true, desc = 'Comment toggle current block' })
end
-- [[ vimtex ]]
-- Some BÉPO mappings for vimtex
local texgroup = vim.api.nvim_create_augroup("latex", { clear = true })
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
pattern = {"*.tex", "*.bib", "*.cls", "*.tikz", },
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
pattern = { "*.tex", "*.bib", "*.cls", "*.tikz", },
group = texgroup,
callback = function()
local vimtex_remaps = {
-- c <-> t
{ mode = "n", source = "csd", target = "tsd", command = "<Plug>(vimtex-delim-change-math)"},
{ mode = "n", source = "csc", target = "lsc", command = "<Plug>(vimtex-cmd-change)"},
{ mode = "n", source = "cse", target = "lse", command = "<Plug>(vimtex-env-change)"},
{ mode = "n", source = "cs$", target = "ls$", command = "<Plug>(vimtex-env-change-math))"},
{ mode = "n", source = "csd", target = "tsd", command = "<Plug>(vimtex-delim-change-math)" },
{ mode = "n", source = "csc", target = "lsc", command = "<Plug>(vimtex-cmd-change)" },
{ mode = "n", source = "cse", target = "lse", command = "<Plug>(vimtex-env-change)" },
{ mode = "n", source = "cs$", target = "ls$", command = "<Plug>(vimtex-env-change-math))" },
-- t <-> j
{ mode = {"x", "n"}, source = "tsD", target = "jsD", command = "<Plug>(vimtex-delim-toggle-modifier-reverse)"},
{ mode = {"x", "n"}, source = "tsd", target = "jsd", command = "<Plug>(vimtex-delim-toggle-modifier)"},
{ mode = {"x", "n"}, source = "tsf", target = "jsf", command = "<Plug>(vimtex-cmd-toggle-frac)"},
{ mode = "n", source = "tsc", target = "jsc", command = "<Plug>(vimtex-cmd-toggle-star)"},
{ mode = "n", source = "ts$", target = "js$", command = "<Plug>(vimtex-env-toggle-math)"},
{ mode = "n", source = "tse", target = "jse", command = "<Plug>(vimtex-env-toggle-star)"},
{ mode = { "x", "n" }, source = "tsD", target = "jsD", command = "<Plug>(vimtex-delim-toggle-modifier-reverse)" },
{ mode = { "x", "n" }, source = "tsd", target = "jsd", command = "<Plug>(vimtex-delim-toggle-modifier)" },
{ mode = { "x", "n" }, source = "tsf", target = "jsf", command = "<Plug>(vimtex-cmd-toggle-frac)" },
{ mode = "n", source = "tsc", target = "jsc", command = "<Plug>(vimtex-cmd-toggle-star)" },
{ mode = "n", source = "ts$", target = "js$", command = "<Plug>(vimtex-env-toggle-math)" },
{ mode = "n", source = "tse", target = "jse", command = "<Plug>(vimtex-env-toggle-star)" },
}
for _,remap in pairs(vimtex_remaps) do
for _, remap in pairs(vimtex_remaps) do
if vim.fn.maparg(remap.source) ~= "" then
vim.keymap.del(remap.mode, remap.source, { buffer = true })
vim.keymap.set(remap.mode, remap.target, remap.command, { silent = true, noremap = true, buffer = true})
vim.keymap.set(remap.mode, remap.target, remap.command, { silent = true, noremap = true, buffer = true })
end
end
end,

View File

@ -8,38 +8,40 @@ local keyunmap = function(mode, binding)
end
-- Recognize .md as pandoc
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
pattern = {"*.md", },
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
pattern = { "*.md", },
group = markdown,
callback = function()
callback = function()
vim.o.filetype = 'pandoc'
require('luasnip').filetype_extend("pandoc", {"markdown"})
require('luasnip').filetype_extend("pandoc", { "markdown" })
vim.o.spell = true
vim.o.spelllang = 'en'
vim.o.formatoptions = "qj"
-- email commands: my/msy to paste the html inside the clipboard
vim.keymap.set('', '<LocalLeader>msy', ':w !pandoc -f markdown+emoji -t html5 -s | wl-copy<CR><CR>', { noremap = true, silent = true })
vim.keymap.set('', '<LocalLeader>my', ':w !pandoc -f markdown+emoji --wrap=none -t html5 | wl-copy<CR><CR>', { noremap = true, silent = true })
vim.keymap.set('', '<LocalLeader>msy', ':w !pandoc -f markdown+emoji -t html5 -s | wl-copy<CR><CR>',
{ noremap = true, silent = true })
vim.keymap.set('', '<LocalLeader>my', ':w !pandoc -f markdown+emoji --wrap=none -t html5 | wl-copy<CR><CR>',
{ noremap = true, silent = true })
end
})
-- French markdown files
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
pattern = {"*-fr.md", },
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
pattern = { "*-fr.md", },
group = markdown,
callback = function()
callback = function()
vim.o.spelllang = 'fr'
end
})
-- Spell shortcuts
vim.api.nvim_create_autocmd({"OptionSet"}, {
vim.api.nvim_create_autocmd({ "OptionSet" }, {
pattern = { "spell" },
group = markdown,
callback = function()
if vim.o.spell == true then
vim.keymap.set("n", "<Leader>i", "mz[s1z=`z", {noremap = true, silent = true})
vim.keymap.set("n", "à", "]s", {noremap = true, silent = true})
vim.keymap.set("n", "<Leader>i", "mz[s1z=`z", { noremap = true, silent = true })
vim.keymap.set("n", "à", "]s", { noremap = true, silent = true })
else
keyunmap("n", "<Leader>i")
keyunmap("n", "à")
@ -51,18 +53,19 @@ vim.api.nvim_create_autocmd({"OptionSet"}, {
local texgroup = vim.api.nvim_create_augroup("latex", { clear = true })
vim.api.nvim_create_autocmd("FileType", {
pattern = {"latex"},
pattern = { "latex" },
group = texgroup,
callback = function()
-- vimtex configuration
vim.g.vimtex_view_method = 'zathura'
vim.g.maplocalleader = ' '
vim.g.maplocalleader = ' '
-- Legacy shortcut from my vim-latexsuite days
vim.api.nvim_set_keymap("n", "<Leader>ls", ":VimtexView<CR>", {noremap = true, silent = true, desc = 'View [L]atex Document'})
vim.api.nvim_set_keymap("n", "<Leader>ls", ":VimtexView<CR>",
{ noremap = true, silent = true, desc = 'View [L]atex Document' })
vim.o.foldmethod = 'expr'
vim.o.foldexpr='vimtex#fold#level(v:lnum)'
vim.o.foldtext='vimtex#fold#text()'
vim.o.foldexpr = 'vimtex#fold#level(v:lnum)'
vim.o.foldtext = 'vimtex#fold#text()'
vim.o.spell = true
end,
})

View File

@ -43,17 +43,17 @@ vim.o.background = "light"
-- general purpose options
local set_true = { 'title', 'relativenumber', 'ruler', 'modeline',
'autoread', 'cursorline', 'cursorcolumn',
'incsearch',
'showcmd', 'showmatch', 'lazyredraw', 'linebreak', 'wrap',
'wildmenu', 'wildignorecase', 'showfulltag', }
'autoread', 'cursorline', 'cursorcolumn',
'incsearch',
'showcmd', 'showmatch', 'lazyredraw', 'linebreak', 'wrap',
'wildmenu', 'wildignorecase', 'showfulltag', }
vim.o.colorcolumn = '+1'
for _,o in ipairs(set_true) do
for _, o in ipairs(set_true) do
vim.o[o] = true
end
-- folds
vim.g.ip_skipfold=true
vim.g.ip_skipfold = true
-- window management
vim.o.tw = 80

View File

@ -211,7 +211,8 @@ require('lazy').setup({
-- Pandoc
'vim-pandoc/vim-pandoc-syntax',
-- neorg
{ 'nvim-neorg/neorg',
{
'nvim-neorg/neorg',
build = ':Neorg sync-parsers',
dependencies = { "nvim-lua/plenary.nvim" },
},

View File

@ -7,7 +7,7 @@ local map_list = {
local keymap = vim.keymap.set
for key, binding in pairs(map_list) do
keymap("n", key, binding .. "<CR>", {noremap = true, silent = true})
keymap("n", key, binding .. "<CR>", { noremap = true, silent = true })
end
-- [[ kickstart.nvim ]]
@ -25,15 +25,13 @@ keymap('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic mess
keymap('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
keymap('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
keymap("n", "<Leader>y", '"+y', {noremap = true, silent = true})
keymap("v", "<Leader>y", '"+y', {noremap = true, silent = true})
keymap("n", "<Leader>p", '"+p', {noremap = true, silent = true})
keymap("v", "<Leader>p", '"+p', {noremap = true, silent = true})
keymap({ "n", "v" }, "<Leader>y", '"+y', { noremap = true, silent = true, desc = "[Y]ank to system clipboard" })
keymap({ "n", "v" }, "<Leader>p", '"+p', { noremap = true, silent = true, desc = "[P]ast from system clipboard" })
-- z0…z9 to open folds to a certain level
for i=0,9 do
keymap('n', 'z' .. i , ':set fdl=' .. i .. '<CR>', {noremap = true, silent = false})
for i = 0, 9 do
keymap('n', 'z' .. i, ':set fdl=' .. i .. '<CR>', { noremap = true, silent = false })
end
-- in :terminal esc exits edit mode
keymap('t', '<Esc>', '<C-\\><C-n>', {noremap = true, silent = true})
keymap('t', '<Esc>', '<C-\\><C-n>', { noremap = true, silent = true })

View File

@ -1,22 +1,29 @@
--vim.api.nvim_set_keymap('', 'à', '<Nop>', { noremap = true, silent = true })
local neorgroup = vim.api.nvim_create_augroup("neorg", { clear = true })
vim.api.nvim_create_autocmd({"FileType"}, {
pattern = {"norg"},
vim.api.nvim_create_autocmd({ "FileType" }, {
pattern = { "norg" },
group = neorgroup,
callback = function()
vim.g.maplocalleader=' '
vim.o.conceallevel=2
vim.api.nvim_set_keymap("n", "<Leader>nr", ":Neorg return<CR>", {noremap = true, silent = true, desc = "[N]eorg [R]eturn"})
vim.g.maplocalleader = ' '
vim.o.conceallevel = 2
vim.api.nvim_set_keymap("n", "<Leader>nr", ":Neorg return<CR>",
{ noremap = true, silent = true, desc = "[N]eorg [R]eturn" })
end,
})
vim.api.nvim_set_keymap("n", "<Leader>ni", ":Neorg index<CR>", {noremap = true, silent = true, desc = "[N]eorg [I]ndex"})
vim.api.nvim_set_keymap("n", "<Leader>nm", ":Neorg inject-metadata<CR>", {noremap = true, silent = true, desc = "[N]eorg insert [M]etadata"})
vim.api.nvim_set_keymap("n", "<Leader>nj", ":Neorg journal toc open<CR>", {noremap = true, silent = true, desc = "[N]eorg [J]ournal"})
vim.api.nvim_set_keymap("n", "<Leader>nt", ":Neorg journal today<CR>", {noremap = true, silent = true, desc = "[N]eorg [T]oday"})
vim.api.nvim_set_keymap("n", "<Leader>ns", ":Neorg journal tomorrow<CR>", {noremap = true, silent = true, desc = "Neorg tomorrow"})
vim.api.nvim_set_keymap("n", "<Leader>ny", ":Neorg journal yesterday<CR>", {noremap = true, silent = true, desc = "[N]eorg [Y]esterday"})
vim.api.nvim_set_keymap("n", "<Leader>ni", ":Neorg index<CR>",
{ noremap = true, silent = true, desc = "[N]eorg [I]ndex" })
vim.api.nvim_set_keymap("n", "<Leader>nm", ":Neorg inject-metadata<CR>",
{ noremap = true, silent = true, desc = "[N]eorg insert [M]etadata" })
vim.api.nvim_set_keymap("n", "<Leader>nj", ":Neorg journal toc open<CR>",
{ noremap = true, silent = true, desc = "[N]eorg [J]ournal" })
vim.api.nvim_set_keymap("n", "<Leader>nt", ":Neorg journal today<CR>",
{ noremap = true, silent = true, desc = "[N]eorg [T]oday" })
vim.api.nvim_set_keymap("n", "<Leader>ns", ":Neorg journal tomorrow<CR>",
{ noremap = true, silent = true, desc = "Neorg tomorrow" })
vim.api.nvim_set_keymap("n", "<Leader>ny", ":Neorg journal yesterday<CR>",
{ noremap = true, silent = true, desc = "[N]eorg [Y]esterday" })
local neorg = require('neorg')