129 lines
3.4 KiB
Lua
129 lines
3.4 KiB
Lua
local opt, cmd, api = vim.opt, vim.cmd, vim.api
|
|
local fn = vim.fn
|
|
local v, g = vim.v, vim.g
|
|
|
|
-- colorscheme -----------------------------------------------------------------
|
|
|
|
cmd.colorscheme("basic")
|
|
|
|
-- statusline ------------------------------------------------------------------
|
|
|
|
function Statusline()
|
|
local wordcount = fn.wordcount()
|
|
return table.concat({
|
|
fn.pathshorten(fn.getcwd()),
|
|
" %=",
|
|
" <%b>",
|
|
" ", wordcount.visual_chars or wordcount.cursor_chars, "/", wordcount.chars,
|
|
" ", wordcount.visual_words or wordcount.cursor_words, "/", wordcount.words,
|
|
" %l/%L",
|
|
" %c"
|
|
})
|
|
end
|
|
|
|
-- options ---------------------------------------------------------------------
|
|
|
|
-- moving around, searching and patterns
|
|
opt.path = {".", "", "**"}
|
|
opt.ignorecase = true
|
|
opt.smartcase = true
|
|
|
|
-- displaying text
|
|
opt.scrolloff = 10
|
|
opt.breakindent = true
|
|
opt.showbreak = "+++ "
|
|
opt.number = true
|
|
opt.relativenumber = true
|
|
opt.colorcolumn = "+1"
|
|
|
|
-- multiple windows
|
|
opt.laststatus = 3
|
|
opt.statusline = "%!v:lua.Statusline()"
|
|
|
|
-- multiple tab pages
|
|
opt.showtabline = 2
|
|
|
|
-- terminal
|
|
opt.title = true
|
|
|
|
-- messages and info
|
|
opt.shortmess:append({ I = true })
|
|
|
|
-- selecting text
|
|
opt.clipboard = "unnamedplus"
|
|
|
|
-- editing text
|
|
opt.undofile = true
|
|
opt.textwidth = 80
|
|
opt.completeopt = { "menuone", "preview", "noselect" }
|
|
|
|
-- tabs and indenting
|
|
opt.tabstop = 4
|
|
opt.shiftwidth = 4
|
|
opt.smarttab = true
|
|
opt.softtabstop = -1
|
|
opt.expandtab = true
|
|
opt.smartindent = true
|
|
|
|
-- reading and writing files
|
|
opt.writebackup = false
|
|
opt.backup = false
|
|
|
|
-- command line editing
|
|
opt.wildmode = "longest:full,full"
|
|
opt.wildignorecase = true
|
|
|
|
-- various
|
|
opt.signcolumn = "number"
|
|
opt.winbar = "%f%( %h%m%r%y%)"
|
|
opt.wildoptions = { "fuzzy" }
|
|
|
|
|
|
-- keymaps ---------------------------------------------------------------------
|
|
|
|
local keymap_set = vim.keymap.set
|
|
|
|
keymap_set("n", "<esc>", "<cmd>nohlsearch<cr>")
|
|
keymap_set("c", "<m-h>", "<left>")
|
|
keymap_set("c", "<m-l>", "<right>")
|
|
keymap_set("n", "<leader>f", ":find ")
|
|
keymap_set("n", "<leader>b", ":buffer ")
|
|
keymap_set("n", "<leader>h", ":help ")
|
|
keymap_set("n", "<leader>g", ":vimgrep /")
|
|
keymap_set("n", "<leader>s", "<cmd>set spell!<cr>")
|
|
keymap_set("n", "<leader>m", "<cmd>make<cr>")
|
|
keymap_set("n", "<leader>d", "<cmd>bdelete<cr>")
|
|
keymap_set("n", "]b", "<cmd>bnext<cr>")
|
|
keymap_set("n", "[b", "<cmd>bprev<cr>")
|
|
keymap_set("n", "]B", "<cmd>blast<cr>")
|
|
keymap_set("n", "[B", "<cmd>bfirst<cr>")
|
|
keymap_set("n", "]t", "<cmd>tabnext<cr>")
|
|
keymap_set("n", "[t", "<cmd>tabprev<cr>")
|
|
keymap_set("n", "]T", "<cmd>tablast<cr>")
|
|
keymap_set("n", "[T", "<cmd>tabfirst<cr>")
|
|
keymap_set("n", "]q", "<cmd>cnext<cr>zz")
|
|
keymap_set("n", "[q", "<cmd>cprev<cr>zz")
|
|
keymap_set("n", "]Q", "<cmd>clast<cr>zz")
|
|
keymap_set("n", "[Q", "<cmd>cfirst<cr>zz")
|
|
keymap_set("n", "<leader>co", "<cmd>copen<cr>")
|
|
keymap_set("n", "<leader>cc", "<cmd>cclose<cr>")
|
|
keymap_set("n", "<c-h>", "<c-w>h")
|
|
keymap_set("n", "<c-j>", "<c-w>j")
|
|
keymap_set("n", "<c-k>", "<c-w>k")
|
|
keymap_set("n", "<c-l>", "<c-w>l")
|
|
keymap_set("n", "<leader>.", "<cmd>edit .<cr>")
|
|
|
|
-- buffer autocomplete ---------------------------------------------------------
|
|
|
|
local bufautocomplete_augroup = api.nvim_create_augroup("Buffer autocompletion", {}),
|
|
api.nvim_create_autocmd("InsertCharPre", {
|
|
group = bufautocomplete_augroup,
|
|
pattern = "*",
|
|
callback = function ()
|
|
if fn.pumvisible() == 0 and v.char:find("%w") then
|
|
api.nvim_input("<c-n>")
|
|
end
|
|
end,
|
|
desc = "Buffer autocomplete on InsertCharPre",
|
|
})
|