1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
require("config.lazy")
require("config.terminal")
vim.g.have_nerd_font = true
vim.g.loaded_node_provider = 0
vim.g.loaded_perl_provider = 0
vim.g.loaded_python3_provider = 0
vim.g.loaded_ruby_provider = 0
-- Set the terminal window title to the filename being edited.
-- This helps with using ROFI to find the vim window.
vim.o.title = true
vim.o.writebackup = false
vim.o.undofile = true
vim.o.undodir = vim.fn.expand("~/.local/share/nvim-v2/undodir")
vim.o.colorcolumn = "125"
vim.o.showmode = false
vim.o.showtabline = 2
vim.wo.signcolumn = "yes"
vim.wo.cursorline = true
vim.wo.cursorcolumn = false
vim.keymap.set("n", "<Leader>uc", "<CMD>set cursorcolumn!<CR>", { desc = "Toggle cursor column" })
vim.opt.number = true
vim.opt.relativenumber = true
vim.o.expandtab = true
-- Automatic toggling between line number modes
-- Source: https://jeffkreeftmeijer.com/vim-number/
vim.cmd [[
augroup NumberToggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu && mode() != "i" | set rnu | endif
autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set nornu | endif
augroup END
]]
vim.opt.splitright = true
vim.opt.splitbelow = true
vim.opt.scrolloff = 4
vim.opt.list = true
vim.opt.listchars = { tab = "▸ ", trail = "·", precedes = "←", extends = "→" }
vim.opt.hlsearch = true
vim.opt.smartcase = true
vim.opt.smartindent = true
vim.opt.shiftwidth = 2
vim.keymap.set("n", "<ESC>", "<CMD>nohlsearch<CR>")
-- When I forgot that vim is o insert mode.
vim.keymap.set("i", "jj", "<ESC>")
if vim.fn.has("termguicolors") then
vim.o.termguicolors = true
end
-- External Clipboard
vim.keymap.set("v", "<Leader>y", '"+y', { desc = "Copy to system clipboard register" })
vim.keymap.set("n", "<Leader>p", '"+p', { desc = "Paste from system clipboard register" })
vim.keymap.set("n", "<Leader>q", "<CMD>bprevious | bdelete #<CR>", { desc = "Close current buffer" })
vim.keymap.set("n", "<A-p>", "<CMD>bprevious<CR>", { desc = "Previous buffer" })
vim.keymap.set("n", "<A-n>", "<CMD>bnext<CR>", { desc = "Next buffer" })
vim.keymap.set("n", "<C-s>", "<CMD>silent! update | redraw<CR>", { desc = "Save" })
vim.keymap.set({ "i", "x" }, "<C-s>", "<ESC><CMD>silent! update | redraw<CR>", { desc = "Save and go to Normal mode" })
vim.keymap.set("n", "<Leader>-", "<CMD>Oil<CR>", { desc = "Open Oil" })
vim.api.nvim_create_autocmd("TextYankPost", { desc = "Highlight when yanking text",
group = vim.api.nvim_create_augroup("highlight-yank", { clear = true }),
callback = function()
vim.highlight.on_yank()
end,
})
vim.api.nvim_create_user_command("CopyPath", function()
local path = vim.fn.expand("%:p")
vim.fn.setreg("+", path)
vim.notify("Copied '" .. path .. "' to the clipboard.")
end, { desc = "Copy current buffer file path to the clipboard." })
vim.keymap.set("n", "<C-c>", "<CMD>CopyPath<CR>")
|