First version

master
Fabrice Mouhartem 8 months ago
commit b493e9a3e2

@ -0,0 +1,52 @@
--------------
-- nvim.lua --
--------------
-- Default config
vim.o.fileencoding = 'utf8'
vim.o.encoding = 'utf-8'
vim.o.ff = 'unix'
vim.o.backspace = 'indent,eol,start'
local set_true = { 'title', 'number', 'ruler', 'modeline', 'autoread',
-- search
'incsearch', 'ignorecase', 'smartcase',
'showcmd', 'showmatch', 'lazyredraw', 'linebreak', 'wrap',
'wildmenu', 'wildignorecase', 'showfulltag', }
local set_false = {'hlsearch', 'compatible', }
for _,o in ipairs(set_true) do
vim.o[o] = true
end
for _,o in ipairs(set_false) do
vim.o[o] = false
end
--- indent
vim.cmd 'filetype indent on'
local indent_options = { 'cindent', 'smartindent', 'autoindent', 'expandtab' }
for _,o in ipairs(indent_options) do vim.o[o] = true end
for _,o in ipairs({'tabstop', 'softtabstop', 'shiftwidth'}) do vim.o[o] = 2 end
vim.o.tw = 80
vim.o.scrolloff = 10
vim.cmd "set formatoptions-=t"
-- undodir: undo across files
vim.o.undodir = '/tmp/undo'
vim.o.undofile = true
vim.o.backup = false
-- Theme
vim.cmd "colorscheme peachpuff"
-- REMAP
local map_list = {
["w|"] = ":vsplit<CR>", ["w-"] = ":split<CR>", -- w| / w- pour créer des splits verticaux et horizontaux
["gi"] = ":bprevious<CR>", ["ge"] = ":bnext<CR>",
["W"] = ":w<CR>",
["<C-t>"] = ":tabnew<CR>",
}
for key, binding in pairs(map_list) do
vim.api.nvim_set_keymap('n', key, binding, { noremap = true, silent = true })
end

@ -0,0 +1,68 @@
-- colorise les nbsp
-- highlight NbSp ctermbg=lightgray guibg=lightred
--hi NbSps ctermbg=lightred guibg=lightred
--match NbSps /\%xa0\|\%u202F/
-- bépo
vim.opt.listchars:append({nbsp = "·", trail = "¤"})
vim.opt.list = true
-- ii devient Esc
vim.api.nvim_set_keymap('i', 'ii', '<Esc>', { noremap = true, silent = true })
-- Y pour copier dans le presse papier
vim.api.nvim_set_keymap('', 'Y', '"+y', {})
-- {W} -> [É]
-- ——————————
-- On remappe W sur É :
-- Pour faciliter les manipulations de fenêtres, on utilise {W} comme un Ctrl+W :
local map_list = { ['é'] = 'w', ['É'] = 'W', ['w'] = '<C-w>' }
for key,binding in pairs(map_list) do
vim.api.nvim_set_keymap('', key, binding, { noremap = true, silent = true })
end
-- Corollaire: on remplace les text objects aw, aW, iw et iW
-- pour effacer/remplacer un mot quand on nest pas au début (daé / laé).
local omap_list = { [''] = 'w', [''] = 'aW', [''] = 'iw', [''] = 'iW' }
for key,binding in pairs(omap_list) do
vim.api.nvim_set_keymap('o', key, binding, { noremap = true, silent = true })
end
-- [HJKL] <-> {CTSR}
-- ————————————————
local map_list = { ['c'] = 'h', ['r'] = 'l', ['t'] = 'j', ['s'] = 'k', ['C'] = 'H', ['R'] = 'L', ['T'] = 'J', ['S'] = 'K', -- [HJKL] -> [CTSR]
['j'] = 't', ['J'] = 'T', ['l'] = 'c', ['L'] = 'C', ['h'] = 'r', ['H'] = 'R', ['k'] = 's', ['K'] = 'S', -- [CTSR] -> [HJKL]: J = jusqu'à, L = change, h = remplace, k = substitute
['zs'] = 'zj', ['zt'] = 'zk', -- Pour les replis
[']k'] = ']s', ['[k'] = '[s' , -- correction orthographique
}
for key, binding in pairs(map_list) do
vim.api.nvim_set_keymap('', key, binding, { noremap = true, silent = true })
end
-- Désambiguation de {g}
-- —————————————————————
-- ligne écran précédente / suivante (à l'intérieur d'une phrase)
-- onglets précédent/suivant : gé/gb, premier/dernier onglet : gÉ/gB,
-- g" = première ligne de lécran
local map_list = { ['gs'] = 'gk', ['gt'] = 'gj', ['gb'] = 'gT', [''] = 'gt', ['gB'] = ':tabfirst<CR>', [''] = ':tablast<CR>', ['g"'] = 'g0', }
for key, binding in pairs(map_list) do
vim.api.nvim_set_keymap('', key, binding, { noremap = true, silent = true })
end
-- <> en direct
-- ————————————
vim.api.nvim_set_keymap('', '«', '<', { noremap = true, silent = true })
vim.api.nvim_set_keymap('', '»', '>', { noremap = true, silent = true })
-- Chiffres en accès direct
-- ————————————————————————
-- À décommenter si on souhaite les avoir
--local map_list = { ['"'] = '1', ['1'] = '"', ['«'] = '2', ['2'] = '<', ['»'] = '3', ['3'] = '>', ['('] = '4', ['4'] = '(', [')'] = '5', ['5'] = ')', ['@'] = '6', ['6'] = '@', ['+'] = '7', ['7'] = '+', ['-'] = '8', ['8'] = '-', ['/'] = '9', ['9'] = '/', ['*'] = '0', ['0'] = '*', }
--for key, binding in pairs(map_list) do
-- vim.api.nvim_set_keymap('', key, binding, { noremap = true, silent = true })
--end
-- Remaper la gestion des fenêtres
-- ———————————————————————————————
local map_list = { ['wt'] = '<C-w>j', ['ws'] = '<C-w>k', ['wc'] = '<C-w>h', ['wr'] = '<C-w>l', ['wd'] = '<C-w>c', ['wo'] = '<C-w>s', ['wp'] = '<C-w>o', ['w<SPACE>'] = ':split<CR>', ['w<CR>'] = ':vsplit<CR>', ['<A-w>'] = '<C-w><C-w>', }
for key, binding in pairs(map_list) do
vim.api.nvim_set_keymap('', key, binding, { noremap = true, silent = true })
end

@ -0,0 +1,4 @@
augroup vimrc-remember-cursor-position
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
Loading…
Cancel
Save