128 lines
3.2 KiB
Lua
128 lines
3.2 KiB
Lua
-- Config shortcuts
|
|
local o = vim.o
|
|
local opt = vim.opt
|
|
local keymap = vim.keymap
|
|
|
|
|
|
------------------
|
|
-- GENERAL OPTIONS
|
|
------------------
|
|
|
|
-- Line numbers
|
|
o.number = true
|
|
o.relativenumber = true
|
|
|
|
-- Highlight the cursor line
|
|
o.cursorline = true
|
|
|
|
-- Amount of screen lines that should be visible above/below the cursor
|
|
o.scrolloff = 8
|
|
|
|
-- Show tabs and trailing spaces
|
|
o.list = true
|
|
|
|
-- Wrap lines at word boundaries
|
|
o.linebreak = true
|
|
|
|
-- Case insensitive search (except when explicitly using uppercase letters)
|
|
o.ignorecase = true
|
|
o.smartcase = true
|
|
|
|
-- Indentation settings
|
|
o.smartindent = true
|
|
o.expandtab = true
|
|
o.shiftwidth = 4
|
|
o.softtabstop = -1
|
|
|
|
-- Don't auto-insert comment leader when entering insert mode with o/O
|
|
vim.api.nvim_create_autocmd('FileType', {
|
|
command = 'set formatoptions-=o',
|
|
})
|
|
|
|
|
|
-------------
|
|
-- FILE TYPES
|
|
-------------
|
|
|
|
vim.filetype.add {
|
|
extension = {
|
|
gitconfig = 'gitconfig',
|
|
},
|
|
}
|
|
|
|
-- HTML formatting
|
|
vim.g.html_indent_autotags = 'html,body'
|
|
vim.g.html_indent_inctags = 'p'
|
|
|
|
|
|
-----------
|
|
-- MAPPINGS
|
|
-----------
|
|
|
|
-- For keys that are safe to be mapped, see: https://vim.fandom.com/wiki/Unused_keys
|
|
|
|
-- Exit insert mode with jk
|
|
keymap.set('i', 'jk', '<Esc>')
|
|
|
|
-- Quick exit with Ctrl-q
|
|
keymap.set('n', '<C-q>', ':q<CR>')
|
|
|
|
-- Quick save all open buffers with Ctrl-s
|
|
keymap.set('n', '<C-s>', ':wall<CR>')
|
|
keymap.set('i', '<C-s>', '<C-o>:wall<CR>')
|
|
|
|
-- Simple copy and paste to/from system clipboard with Ctrl-c in visual mode
|
|
-- and Ctrl-v in insert mode
|
|
keymap.set('v', '<C-c>', '"+y')
|
|
keymap.set('i', '<C-v>', '<C-\\><C-o>"+P')
|
|
|
|
-- Navigate between windows with Alt and hjkl
|
|
keymap.set('n', '<A-h>', '<C-w>h')
|
|
keymap.set('n', '<A-j>', '<C-w>j')
|
|
keymap.set('n', '<A-k>', '<C-w>k')
|
|
keymap.set('n', '<A-l>', '<C-w>l')
|
|
|
|
-- Resize windows with Alt and arrow keys
|
|
keymap.set('n', '<A-Up>', '<C-w>2-')
|
|
keymap.set('n', '<A-Down>', '<C-w>2+')
|
|
keymap.set('n', '<A-Left>', '<C-w>4<')
|
|
keymap.set('n', '<A-Right>', '<C-w>4>')
|
|
|
|
-- Shortcuts for jumping to start of line (H) or end of line (L)
|
|
keymap.set({'n', 'x'}, 'H', '^')
|
|
keymap.set({'n', 'x'}, 'L', '$')
|
|
|
|
-- Use comma (,) as a "modifier prefix" for alternative functions of regular
|
|
-- commands (e.g. yank to system clipboard) or for random shortcuts.
|
|
-- TODO: Comma or semicolon or single quote?
|
|
keymap.set({'n', 'x'}, ',', '<Nop>')
|
|
|
|
-- Prefix yank/delete/change/paste commands with "," to use system clipboard
|
|
keymap.set({'n', 'x'}, ',y', '"+y')
|
|
keymap.set({'n', 'x'}, ',Y', '"+y$')
|
|
keymap.set({'n', 'x'}, ',d', '"+d')
|
|
keymap.set({'n', 'x'}, ',D', '"+D')
|
|
keymap.set({'n', 'x'}, ',c', '"+c')
|
|
keymap.set({'n', 'x'}, ',C', '"+C')
|
|
keymap.set({'n', 'x'}, ',p', '"+p')
|
|
keymap.set({'n', 'x'}, ',P', '"+P')
|
|
|
|
-- Insert empty line(s) below or above current line without moving the cursor
|
|
keymap.set('n', ',o', function()
|
|
local line = vim.api.nvim_win_get_cursor(0)[1]
|
|
local repeated = vim.fn['repeat']({''}, vim.v.count1)
|
|
vim.api.nvim_buf_set_lines(0, line, line, true, repeated)
|
|
end)
|
|
keymap.set('n', ',O', function()
|
|
local line = vim.api.nvim_win_get_cursor(0)[1] - 1
|
|
local repeated = vim.fn['repeat']({''}, vim.v.count1)
|
|
vim.api.nvim_buf_set_lines(0, line, line, true, repeated)
|
|
end)
|
|
|
|
|
|
----------
|
|
-- PLUGINS
|
|
----------
|
|
|
|
require('init.theme')
|
|
require('init.plugins')
|