-local vsplit = require("snippets.vsplit")
-
--- startup init
-vim.api.nvim_create_autocmd( "VimEnter", {
- desc = "run explore & create vsplit",
- callback = function()
- if vim.bo.filetype ~= "gitcommit" then
- -- start netrw
- vim.cmd.Explore()
- -- split window on startup
- vsplit.split()
- end
- end
-})
-
--- force new window to the left pane
-vim.api.nvim_create_autocmd( "FileType", {
- desc = "force new window to the left pane",
- group = vim.api.nvim_create_augroup('enforce-single-vsplit', { clear = true }),
- pattern = { "man", "help", "qf" },
- callback = function()
- vim.schedule(function()
- local new_win = vim.api.nvim_get_current_win()
- local new_buf = vim.api.nvim_get_current_buf()
- if not ((new_win == vsplit.left_id) or (new_win == vsplit.right_id)) then
- -- logging
- vim.notify("new_win:" ..new_win .." new_buf:" ..new_buf .." vsplit.left_id:" ..vsplit.left_id)
- -- move new buffer to left pane
- vim.api.nvim_win_set_buf(vsplit.left_id, new_buf)
- -- close new window
- vim.api.nvim_win_close(new_win, false)
- -- switch focus
- if vim.bo.filetype == "qf" then
- vim.api.nvim_set_current_win(vsplit.right_id)
- end
- end
- end)
- end
-})
-
-- remove trailing whitespace on save
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
pattern = { "*" },
vim.keymap.set("n", "<space>#", "Vgc", { desc = "select line and toggle comment", remap = true })
vim.keymap.set("v", "<space>#", "gc", { desc = "toggle comment of selected line", remap = true })
--- window management
-local vsplit = require("snippets.vsplit")
-vim.keymap.set("n", "<space>s", vsplit.split, { desc = "split vertically and move to new window" })
-
-- move highlighted lines
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
M.right_id = vim.api.nvim_open_win(0, true, win_config)
end
+-- startup init
+vim.api.nvim_create_autocmd( "VimEnter", {
+ desc = "run explore & create vsplit",
+ callback = function()
+ if vim.bo.filetype ~= "gitcommit" then
+ -- start netrw
+ vim.cmd.Explore()
+ -- split window on startup
+ M.split()
+ end
+ end
+})
+
+-- force new window to the left pane
+vim.api.nvim_create_autocmd( "FileType", {
+ desc = "force new window to the left pane",
+ group = vim.api.nvim_create_augroup('enforce-single-vsplit', { clear = true }),
+ pattern = { "man", "help", "qf" },
+ callback = function()
+ vim.schedule(function()
+ local new_win = vim.api.nvim_get_current_win()
+ local new_buf = vim.api.nvim_get_current_buf()
+ if not ((new_win == M.left_id) or (new_win == M.right_id)) then
+ -- move new buffer to left pane
+ vim.api.nvim_win_set_buf(M.left_id, new_buf)
+ -- close new window
+ vim.api.nvim_win_close(new_win, false)
+ -- switch focus
+ if vim.bo.filetype == "qf" then
+ vim.api.nvim_set_current_win(M.right_id)
+ end
+ end
+ end)
+ end
+})
+
+-- keymaps
+vim.keymap.set("n", "<space>s", M.split, { desc = "split vertically and move to new window" })
+
return M