summaryrefslogtreecommitdiff
path: root/init.lua
blob: c1b75e974f74cdae50ceb7fac4197a65f948c981 (plain)
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
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,
})