173 lines
5.8 KiB
Lua
173 lines
5.8 KiB
Lua
-- options ---------------------------------------------------------------------
|
|
-- colorscheme
|
|
vim.cmd.colorscheme("basic")
|
|
|
|
-- leader
|
|
vim.g.mapleader = " "
|
|
vim.g.maplocalleader = " "
|
|
vim.keymap.set({ "n", "v" }, "<space>", "<nop>", { silent = true })
|
|
|
|
-- general
|
|
vim.opt.undofile = true
|
|
vim.opt.backup = false
|
|
vim.opt.writebackup = false
|
|
vim.opt.mouse = {}
|
|
vim.opt.title = true
|
|
|
|
-- appearance
|
|
vim.opt.shortmess:append({ I = true })
|
|
vim.opt.number = true
|
|
vim.opt.relativenumber = true
|
|
vim.opt.signcolumn = "number"
|
|
vim.opt.textwidth = 80
|
|
vim.opt.colorcolumn = "+1"
|
|
|
|
-- tabline, winbar, statusline
|
|
vim.opt.showtabline = 2
|
|
vim.opt.winbar = "%f%( %h%m%r%y %)"
|
|
vim.opt.laststatus = 3
|
|
function _G.statusline()
|
|
local col = vim.api.nvim_win_get_cursor(0)[2] + 1
|
|
local char = vim.api.nvim_get_current_line():sub(col, col):gsub("%%", "%%%1")
|
|
local wc = vim.fn.wordcount()
|
|
return table.concat({
|
|
vim.fn.pathshorten(vim.fn.getcwd()), " %f",
|
|
"%( %h%m%r%y%)",
|
|
"%=",
|
|
"<", char, "> %b ",
|
|
wc.visual_chars or wc.cursor_chars, "/", wc.chars, " ",
|
|
wc.visual_words or wc.cursor_words, "/", wc.words
|
|
})
|
|
end
|
|
vim.opt.statusline = "%!v:lua.statusline()"
|
|
|
|
-- behaviour
|
|
vim.opt.ignorecase = true
|
|
vim.opt.infercase = true
|
|
vim.opt.smartcase = true
|
|
vim.opt.smartindent = true
|
|
vim.opt.clipboard = "unnamedplus"
|
|
vim.opt.whichwrap = {
|
|
["b"] = true,
|
|
["s"] = true,
|
|
["h"] = true,
|
|
["l"] = true,
|
|
["<"] = true,
|
|
[">"] = true,
|
|
["~"] = true,
|
|
["["] = true,
|
|
["]"] = true
|
|
}
|
|
vim.opt.wildoptions = { "fuzzy" }
|
|
vim.opt.wildignorecase = true
|
|
|
|
-- langmap
|
|
vim.opt.langmap = { "č\\;", "Č:", "š[", "Š{", "đ]", "Đ}", "ž#", "Ž~" }
|
|
|
|
-- path
|
|
vim.opt.path = ".,,**"
|
|
-- local root = vim.fs.find({ ".git" }, { upward = true })[1]
|
|
|
|
-- completion
|
|
vim.opt.completeopt = {
|
|
"menuone",
|
|
"preview",
|
|
"noinsert",
|
|
"noselect"
|
|
}
|
|
|
|
-- keymaps ---------------------------------------------------------------------
|
|
-- clear hlsearch
|
|
vim.keymap.set( "n", "<esc>", function()
|
|
vim.cmd.nohlsearch()
|
|
end, { desc = "Stop the highlighting for the 'hlsearch' option" })
|
|
|
|
-- move cursor with alt in c-mode
|
|
vim.keymap.set("c", "<m-h>", "<left>", { desc = "Left" })
|
|
vim.keymap.set("c", "<m-l>", "<right>", { desc = "Right" })
|
|
|
|
-- move cursor with alt in i-mode
|
|
vim.keymap.set("i", "<m-h>", "<left>", { desc = "Left" })
|
|
vim.keymap.set("i", "<m-j>", "<down>", { desc = "Down" })
|
|
vim.keymap.set("i", "<m-k>", "<up>", { desc = "Up" })
|
|
vim.keymap.set("i", "<m-l>", "<right>", { desc = "Right" })
|
|
|
|
-- move cursor with alt in t-mode
|
|
vim.keymap.set("t", "<m-h>", "<left>", { desc = "Left" })
|
|
vim.keymap.set("t", "<m-j>", "<down>", { desc = "Down" })
|
|
vim.keymap.set("t", "<m-k>", "<up>", { desc = "Up" })
|
|
vim.keymap.set("t", "<m-l>", "<right>", { desc = "Right" })
|
|
|
|
-- navigate windows
|
|
vim.keymap.set("n", "<c-h>", "<c-w>h", { desc = "Navigate window left"})
|
|
vim.keymap.set("n", "<c-j>", "<c-w>j", { desc = "Navigate window down"})
|
|
vim.keymap.set("n", "<c-k>", "<c-w>k", { desc = "Navigate window up"})
|
|
vim.keymap.set("n", "<c-l>", "<c-w>l", { desc = "Navigate window right"})
|
|
vim.keymap.set("i", "<c-h>", "<c-\\><c-n><c-w>h", { desc = "Navigate window left"})
|
|
vim.keymap.set("i", "<c-j>", "<c-\\><c-n><c-w>j", { desc = "Navigate window down"})
|
|
vim.keymap.set("i", "<c-k>", "<c-\\><c-n><c-w>k", { desc = "Navigate window up"})
|
|
vim.keymap.set("i", "<c-l>", "<c-\\><c-n><c-w>l", { desc = "Navigate window right"})
|
|
vim.keymap.set("t", "<c-h>", "<c-\\><c-n><c-w>h", { desc = "Navigate window left"})
|
|
vim.keymap.set("t", "<c-j>", "<c-\\><c-n><c-w>j", { desc = "Navigate window down"})
|
|
vim.keymap.set("t", "<c-k>", "<c-\\><c-n><c-w>k", { desc = "Navigate window up"})
|
|
vim.keymap.set("t", "<c-l>", "<c-\\><c-n><c-w>l", { desc = "Navigate window right"})
|
|
|
|
-- cmdline history navigation
|
|
vim.keymap.set("c", "<c-p>", "<up>")
|
|
vim.keymap.set("c", "<c-n>", "<down>")
|
|
|
|
-- menus
|
|
vim.keymap.set("n", "<leader>f", ":find ")
|
|
vim.keymap.set("n", "<leader>b", ":buffer ")
|
|
vim.keymap.set("n", "<leader>h", ":help ")
|
|
|
|
-- scratch ---------------------------------------------------------------------
|
|
local scratch_buffer = vim.api.nvim_create_buf(true, true)
|
|
vim.keymap.set("n", "<leader>s", function()
|
|
vim.api.nvim_win_set_buf(0, scratch_buffer)
|
|
vim.keymap.set("n", "<leader>e", function()
|
|
if vim.bo.filetype == "lua" then
|
|
loadstring(table.concat(vim.api.nvim_buf_get_lines(0, 0, -1, true)))()
|
|
end
|
|
end, { desc = "Evaluate buffer" })
|
|
end, { desc = "Open scratch buffer" })
|
|
|
|
-- buffers ---------------------------------------------------------------------
|
|
vim.keymap.set("n", "]b", "<cmd>bnext<cr>")
|
|
vim.keymap.set("n", "[b", "<cmd>bprev<cr>")
|
|
|
|
-- vimgrep ---------------------------------------------------------------------
|
|
vim.keymap.set("n", "<leader>g", ":vimgrep / **/*<c-left><c-left>/")
|
|
|
|
local vimgrep_group = vim.api.nvim_create_augroup("Vimgrep", {})
|
|
vim.api.nvim_create_autocmd("QuickfixCmdPost", {
|
|
group = vimgrep_group,
|
|
pattern = "vimgrep",
|
|
desc = "",
|
|
command = "copen"
|
|
})
|
|
|
|
-- quickfix --------------------------------------------------------------------
|
|
vim.keymap.set("n", "co", "<cmd>copen<cr>", { desc = "Open quickfix window" })
|
|
vim.keymap.set("n", "cc", "<cmd>cclose<cr>", { desc = "Close quickfix window" })
|
|
vim.keymap.set("n", "]q", "<cmd>cnext<cr>zz", { desc = "Next quickfix item" })
|
|
vim.keymap.set("n", "[q", "<cmd>cprev<cr>zz", { desc = "Previous quickfix item" })
|
|
|
|
-- netrw -----------------------------------------------------------------------
|
|
vim.g.netrw_use_errorwindow = 0
|
|
vim.g.netrw_banner = 0
|
|
vim.g.netrw_bufsettings = "noma nomod nowrap ro nobl"
|
|
vim.g.netrw_fastbrowse = 0
|
|
|
|
vim.keymap.set("n", "<leader>.", "<cmd>e .<cr>")
|
|
|
|
local netrw_group = vim.api.nvim_create_augroup("Netrw", {})
|
|
vim.api.nvim_create_autocmd("Filetype", {
|
|
group = netrw_group,
|
|
pattern = "netrw",
|
|
desc = "",
|
|
callback = function()
|
|
vim.keymap.set("n", "<esc>", "<cmd>Rexplore<cr>", { buffer = true })
|
|
end
|
|
})
|