summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua85
1 files changed, 85 insertions, 0 deletions
diff --git a/init.lua b/init.lua
new file mode 100644
index 0000000..c1b75e9
--- /dev/null
+++ b/init.lua
@@ -0,0 +1,85 @@
+vim.opt.softtabstop = 4
+vim.opt.shiftwidth = 4
+vim.opt.expandtab = false
+
+vim.opt.number = true
+vim.opt.relativenumber = true
+
+vim.opt.swapfile = false
+vim.opt.backup = false
+vim.opt.undofile = true
+
+vim.opt.hlsearch = false
+vim.opt.incsearch = true
+
+vim.opt.termguicolors = true
+vim.opt.cursorline = true
+vim.opt.scrolloff = 8
+vim.opt.updatetime = 50
+vim.opt.clipboard = "unnamedplus"
+vim.opt.linebreak = false
+vim.cmd[[let &showbreak = "> "]]
+
+if vim.fn.executable('rg') > 0 then
+ vim.opt.grepprg = 'rg --vimgrep'
+end
+
+vim.cmd[[colorscheme solarized8_high]]
+
+function SafeCListNav(navdir)
+ -- dir:
+ -- 1 is cnext (forwards)
+ -- -1 is cprev (backwards)
+ local dircmd = ''
+ if navdir == 1 then
+ dircmd = 'cnext'
+ elseif navdir == -1 then
+ dircmd = 'cprev'
+ end
+ local status, result = pcall(vim.cmd, dircmd)
+
+ if status == false then
+ return nil
+ end
+end
+
+-- @section: key remaps
+vim.keymap.set('n', "<space><space>x", "<cmd>source %<CR>")
+vim.keymap.set('n', "<space>vs", "<cmd>vsplit<CR>")
+vim.keymap.set('n', "<space>hs", "<cmd>split<CR>")
+vim.keymap.set('n', "<space>pv", ":Ex <CR>")
+vim.keymap.set('i', "<C-l>", "<Del>")
+
+-- @block: c-list navigation
+vim.keymap.set("n", "<A-n>", function() SafeCListNav(1) end)
+vim.keymap.set("n", "<A-p>", function() SafeCListNav(-1) end)
+vim.keymap.set("n", "<A-w>", vim.cmd.cw)
+
+--[[
+ @block: tab navigation
+ @info helpful builtin tab shortcuts
+ gt: Next tab
+ gT: Previous tab
+ ngt: Go to tab #n
+--]]
+vim.keymap.set("n", "<A-w><A-c>", ":tabnew ")
+vim.keymap.set("n", "<A-m>", ":tabnext ")
+vim.keymap.set("n", "<A-[>", ":tabprev<CR>")
+vim.keymap.set("n", "<A-]>", ":tabnext<CR>")
+
+
+-- @func: autoload_on_filechange
+vim.opt.autoread = true
+vim.api.nvim_create_autocmd("CursorHold", {
+ desc = "Command to reload the file when changes",
+ command = "silent! checktime",
+ group = vim.api.nvim_create_augroup("FileChangeGroup", { clear = true }),
+})
+
+vim.api.nvim_create_autocmd("TextYankPost", {
+ desc = "Command to highlight selection upon yanking",
+ group = vim.api.nvim_create_augroup("VimYankGroup", { clear = true }),
+ callback = function()
+ vim.highlight.on_yank()
+ end,
+})