summaryrefslogtreecommitdiffstats
path: root/.config/nvim/init.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/init.lua')
-rw-r--r--.config/nvim/init.lua44
1 files changed, 37 insertions, 7 deletions
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua
index f2f577c..e806097 100644
--- a/.config/nvim/init.lua
+++ b/.config/nvim/init.lua
@@ -23,7 +23,10 @@ vim.opt.winbar = "%#WinBarCwd#%{fnamemodify(getcwd(),':~')}%* | %#WinBarFilePath
local function show_buf_diff_orig()
local bname = vim.api.nvim_buf_get_name(0)
if not vim.uv.fs_stat(bname) then
- vim.notify("Cannot diff with original because " .. bname .. " doesn't exist", vim.log.levels.WARN)
+ vim.notify(
+ "Cannot diff with original because " .. bname .. " doesn't exist",
+ vim.log.levels.WARN
+ )
return
end
local cwin = vim.api.nvim_get_current_win()
@@ -34,7 +37,10 @@ local function show_buf_diff_orig()
vim.notify("Could not copy file: " .. err, vim.log.levels.ERROR)
return
end
- vim.cmd.split({ temp, mods = { vertical = vim.api.nvim_win_get_width(0) >= vim.o.textwidth * 2, keepalt = true } })
+ vim.cmd.split({
+ temp,
+ mods = { vertical = vim.api.nvim_win_get_width(0) >= vim.o.textwidth * 2, keepalt = true },
+ })
vim.cmd.diffthis()
vim.opt_local.bufhidden = "wipe"
vim.opt_local.buftype = "nofile"
@@ -99,7 +105,11 @@ vim.api.nvim_create_autocmd({ "FileChangedShell" }, {
-- Commands (there's more in the different plugins)
------------------------------------------------------------------------------------------------------------------------
-vim.api.nvim_create_user_command("DiffOrig", show_buf_diff_orig, { desc = "Show diff between current buffer and file" })
+vim.api.nvim_create_user_command(
+ "DiffOrig",
+ show_buf_diff_orig,
+ { desc = "Show diff between current buffer and file" }
+)
------------------------------------------------------------------------------------------------------------------------
-- Keymaps (there's more in the different plugins)
@@ -109,14 +119,24 @@ vim.api.nvim_create_user_command("DiffOrig", show_buf_diff_orig, { desc = "Show
-- Miscellaneous
vim.keymap.set("n", "<M-z>", "zA", { desc = "Toggle fold (recursively) under cursor" })
-vim.keymap.set("n", "ZR", vim.cmd.SessionRestart, { desc = "Save and load default session and restart" })
+vim.keymap.set(
+ "n",
+ "ZR",
+ vim.cmd.SessionRestart,
+ { desc = "Save and load default session and restart" }
+)
vim.keymap.set("n", "ZZ", vim.cmd.SessionExitSave, { desc = "Save to default session and exit" })
vim.keymap.set("n", "ZQ", vim.cmd.SessionExitNoSave, { desc = "Quit without saving session" })
vim.keymap.set("t", "<C-\\><C-\\>", "<C-\\><C-n>", { desc = "Exit terminal mode" })
vim.keymap.set("n", "<Leader>mm", "<Cmd>messages<CR>", { desc = "Show all messages" })
vim.keymap.set("n", "<Leader>mc", "<Cmd>messages clear<CR>", { desc = "Clear all messages" })
vim.keymap.set("n", "<Leader>lh", vim.cmd.LspHintToggle, { desc = "Toggle inlay hints (LSP)" })
-vim.keymap.set("n", "<Leader>y+", "<Cmd>let @+ = expand('%:p')<CR>", { desc = "Copy file path to clipboard" })
+vim.keymap.set(
+ "n",
+ "<Leader>y+",
+ "<Cmd>let @+ = expand('%:p')<CR>",
+ { desc = "Copy file path to clipboard" }
+)
-- These two mappings work well together to start command mode and insert from history in two keystrokes.
vim.keymap.set("n", "<C-p>", ":", { desc = "Enter command mode" })
vim.keymap.set("c", "<C-p>", "<Up>", { desc = "Insert previous history entry" })
@@ -159,9 +179,19 @@ vim.keymap.set("n", "<Leader>w|", "<C-W>|", { desc = "Set window width" })
-- Tabpages
vim.keymap.set("n", "<M-t>", "<Cmd>tabnew<CR>", { desc = "Create new tabpage" })
vim.keymap.set("n", "<C-w>t", "<Cmd>tabclose<CR>", { desc = "Delete current tabpage" })
-vim.keymap.set({ "n", "i", "t" }, "<M-p>", "<Cmd>tabnext #<CR>", { desc = "Move to last accessed tab page" })
+vim.keymap.set(
+ { "n", "i", "t" },
+ "<M-p>",
+ "<Cmd>tabnext #<CR>",
+ { desc = "Move to last accessed tab page" }
+)
vim.keymap.set({ "n", "i", "t" }, "<M-n>", "<Cmd>tabnext<CR>", { desc = "Move to next tab page" })
-vim.keymap.set({ "n", "i", "t" }, "<M-b>", "<Cmd>tabprevious<CR>", { desc = "Move to previous tab page" })
+vim.keymap.set(
+ { "n", "i", "t" },
+ "<M-b>",
+ "<Cmd>tabprevious<CR>",
+ { desc = "Move to previous tab page" }
+)
vim.keymap.set("n", "<C-w>>", "<Cmd>tabmove +1<CR>", { desc = "Move tab to next position" })
vim.keymap.set("n", "<C-w><", "<Cmd>tabmove -1<CR>", { desc = "Move tab to next position" })
-- Scrolling