Create utils.lua file and add ToggleBackground command

This commit is contained in:
2021-11-15 09:24:12 +03:00
parent a3feac504b
commit f8419ac36c
2 changed files with 13 additions and 0 deletions

View File

@@ -36,3 +36,5 @@ require("colorizer").setup()
-- Automatically formatting buffer on save -- Automatically formatting buffer on save
vim.api.nvim_command("autocmd BufWritePre * lua vim.lsp.buf.formatting_sync()") vim.api.nvim_command("autocmd BufWritePre * lua vim.lsp.buf.formatting_sync()")
vim.cmd('command! ToggleBackground lua require("utils").toggleBackground()')

11
config/nvim/lua/utils.lua Normal file
View File

@@ -0,0 +1,11 @@
local M = {}
M.toggleBackground = function ()
if vim.opt.background:get() == "dark" then
vim.opt.background = "light"
else
vim.opt.background = "dark"
end
end
return M