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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@ local map_list = {
local keymap = vim.keymap.set local keymap = vim.keymap.set
for key, binding in pairs(map_list) do 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 end
-- [[ kickstart.nvim ]] -- [[ 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>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
keymap('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) keymap('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
keymap("n", "<Leader>y", '"+y', {noremap = true, silent = true}) keymap({ "n", "v" }, "<Leader>y", '"+y', { noremap = true, silent = true, desc = "[Y]ank to system clipboard" })
keymap("v", "<Leader>y", '"+y', {noremap = true, silent = true}) keymap({ "n", "v" }, "<Leader>p", '"+p', { noremap = true, silent = true, desc = "[P]ast from system clipboard" })
keymap("n", "<Leader>p", '"+p', {noremap = true, silent = true})
keymap("v", "<Leader>p", '"+p', {noremap = true, silent = true})
-- z0…z9 to open folds to a certain level -- z0…z9 to open folds to a certain level
for i=0,9 do for i = 0, 9 do
keymap('n', 'z' .. i , ':set fdl=' .. i .. '<CR>', {noremap = true, silent = false}) keymap('n', 'z' .. i, ':set fdl=' .. i .. '<CR>', { noremap = true, silent = false })
end end
-- in :terminal esc exits edit mode -- 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 }) --vim.api.nvim_set_keymap('', 'à', '<Nop>', { noremap = true, silent = true })
local neorgroup = vim.api.nvim_create_augroup("neorg", { clear = true }) local neorgroup = vim.api.nvim_create_augroup("neorg", { clear = true })
vim.api.nvim_create_autocmd({"FileType"}, { vim.api.nvim_create_autocmd({ "FileType" }, {
pattern = {"norg"}, pattern = { "norg" },
group = neorgroup, group = neorgroup,
callback = function() callback = function()
vim.g.maplocalleader=' ' vim.g.maplocalleader = ' '
vim.o.conceallevel=2 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.api.nvim_set_keymap("n", "<Leader>nr", ":Neorg return<CR>",
{ noremap = true, silent = true, desc = "[N]eorg [R]eturn" })
end, 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>ni", ":Neorg index<CR>",
vim.api.nvim_set_keymap("n", "<Leader>nm", ":Neorg inject-metadata<CR>", {noremap = true, silent = true, desc = "[N]eorg insert [M]etadata"}) { noremap = true, silent = true, desc = "[N]eorg [I]ndex" })
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>nm", ":Neorg inject-metadata<CR>",
vim.api.nvim_set_keymap("n", "<Leader>nt", ":Neorg journal today<CR>", {noremap = true, silent = true, desc = "[N]eorg [T]oday"}) { noremap = true, silent = true, desc = "[N]eorg insert [M]etadata" })
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>nj", ":Neorg journal toc open<CR>",
vim.api.nvim_set_keymap("n", "<Leader>ny", ":Neorg journal yesterday<CR>", {noremap = true, silent = true, desc = "[N]eorg [Y]esterday"}) { 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') local neorg = require('neorg')