summaryrefslogtreecommitdiff
path: root/nvim/ftplugin/php.lua
blob: 33276d52c67f7d171300cbf47b2e72888a585f15 (plain)
1
2
3
4
5
6
7
8
9
10
11
local copy_indent_macro = "<Esc>0\"_D" -- clear current line
    .. "?.<CR>" -- find first non-empty line above
    .. "^\"yy0" -- copy indentation to y register
    .. "<C-o>" -- return to original line
    .. "\"yp" -- paste y register
    .. "<cmd>noh<CR>" -- clear highlight
    .. "A" -- enter insert mode

vim.keymap.set({ "n" }, "o", "o" .. copy_indent_macro, { buffer = 0 })
vim.keymap.set({ "n" }, "O", "O" .. copy_indent_macro, { buffer = 0 })
vim.keymap.set({ "i" }, "<CR>", "<CR>" .. copy_indent_macro, { buffer = 0 })