---------------------
----- variables -----
---------------------

vim.g.mapleader        = " "

vim.opt.expandtab      = true
vim.opt.smartindent    = true
vim.opt.shiftwidth     = 4
vim.opt.tabstop        = 4
vim.opt.cino           = "(s"
vim.g.python_indent    = { open_paren = "shiftwidth()" }

vim.opt.list           = true
vim.opt.listchars      = {
    tab   = "> ",
    trail = "-",
    nbsp  = "+",
}

vim.opt.number         = true
vim.opt.relativenumber = true
vim.opt.laststatus     = 3

vim.opt.ignorecase     = true
vim.opt.smartcase      = true

vim.opt.guicursor      = ""
vim.opt.mousemodel     = extend

vim.opt.path           = vim.o.path .. ",**"
vim.opt.suffixes       = vim.o.suffixes .. ",.pyc,.hi"

vim.opt.foldmethod     = "indent"
vim.opt.foldlevel      = 99

vim.opt.grepprg        = "grep -rn"

vim.opt.scrolloff      = 2
vim.opt.colorcolumn    = "80"

vim.g.netrw_banner     = 0
vim.g.netrw_list_hide  = "\\.o$,\\.d$,\\.gc..$"

vim.opt.lazyredraw     = true

vim.opt.complete       = vim.o.complete .. ",i"

--------------------
----- packages -----
--------------------

vim.loader.enable()

vim.cmd("packadd plenary")

require"theme"

require"pack-lspconfig"
require"pack-telescope"
require"pack-treesitter"

-----------------------
----- keybindings -----
-----------------------

-- remove trailing whitespaces
vim.keymap.set("n", "<Leader>f", "<cmd>%s/\\s\\+$//e<CR>")
vim.keymap.set("n", "n", "nzz")
vim.keymap.set("n", "N", "Nzz")

------------------------
----- autocommands -----
------------------------

vim.api.nvim_create_autocmd({ "BufWinEnter" }, { callback = function()
    vim.opt_local.listchars = vim.o.listchars ..
        ",leadmultispace:│" .. string.rep(" ", vim.o.shiftwidth - 1)
end })
