updates
This commit is contained in:
7 files changed
+66
-24
No files matched your search
+25
-2
@@ -1,5 +1,5 @@
|
||||
local function augroup(name)
|
||||
return vim.api.nvim_create_augroup('nvim2k_' .. name, { clear = true })
|
||||
return vim.api.nvim_create_augroup('nvim' .. name, { clear = true })
|
||||
end
|
||||
|
||||
-- Strip trailing spaces before write
|
||||
@@ -119,8 +119,31 @@ enable_autoformat()
|
||||
|
||||
vim.api.nvim_create_user_command('WriteNoFormat', function()
|
||||
-- Temporarily disable the autoformat autocmd
|
||||
vim.api.nvim_del_augroup_by_name('nvim2k_autoformat')
|
||||
vim.api.nvim_del_augroup_by_name('nvim_autoformat')
|
||||
vim.cmd('write')
|
||||
-- Re-enable the autoformat autocmd
|
||||
enable_autoformat()
|
||||
end, {})
|
||||
|
||||
-- Toggle between relative/absolute line numbers
|
||||
local numbertoggle = augroup('numbertoggle')
|
||||
vim.api.nvim_create_autocmd({ 'BufEnter', 'FocusGained', 'InsertLeave', 'CmdlineLeave', 'WinEnter' }, {
|
||||
pattern = '*',
|
||||
group = numbertoggle,
|
||||
callback = function()
|
||||
if vim.o.nu and vim.api.nvim_get_mode().mode ~= 'i' then
|
||||
vim.opt.relativenumber = true
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ 'BufLeave', 'FocusLost', 'InsertEnter', 'CmdlineEnter', 'WinLeave' }, {
|
||||
pattern = '*',
|
||||
group = numbertoggle,
|
||||
callback = function()
|
||||
if vim.o.nu then
|
||||
vim.opt.relativenumber = false
|
||||
vim.cmd.redraw()
|
||||
end
|
||||
end,
|
||||
})
|
||||
Reference in new issue
Block a user