feat: add templating for laptop dotfiles
This commit is contained in:
parent
caf6e25e43
commit
bdf7e407cb
21 changed files with 437 additions and 52 deletions
|
|
@ -16,31 +16,54 @@ end
|
|||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
-- Make sure to setup `mapleader` and `maplocalleader` before
|
||||
-- loading lazy.nvim so that mappings are correct.
|
||||
-- loading setting manual mappings or loading lazy.nvim
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = "\\"
|
||||
|
||||
-- no highlights after search
|
||||
vim.opt.hlsearch = false
|
||||
vim.opt.ignorecase = true -- ignore casing in searches...
|
||||
vim.opt.smartcase = true -- ...unless I provide both caps and lowercase
|
||||
|
||||
-- allow arrow keys and h/l to move to the next/prev line when at the edge
|
||||
vim.opt.whichwrap:append("<,>,h,l")
|
||||
|
||||
-- display non-printing character
|
||||
vim.opt.listchars = 'tab:┆-,trail:~,extends:>,precedes:<,nbsp:•'
|
||||
vim.opt.list = true
|
||||
|
||||
-- highlight line with cursor
|
||||
vim.opt.cursorline = true
|
||||
|
||||
-- spaces, not tab
|
||||
vim.opt.expandtab = true
|
||||
vim.opt.tabstop = 2
|
||||
vim.opt.shiftwidth = 2
|
||||
vim.opt.softtabstop = 2
|
||||
|
||||
-- all my code is in git anyways, and these files are cluttery
|
||||
vim.opt.backup = false
|
||||
vim.opt.writebackup = false
|
||||
vim.opt.swapfile = false
|
||||
|
||||
-- new splits open to the right or below the current window
|
||||
vim.opt.splitbelow = true
|
||||
vim.opt.splitright = true
|
||||
|
||||
function tblmerge(x, y) for k,v in pairs(y) do x[k] = v end return x end
|
||||
function tblmerge(x, y)
|
||||
for k, v in pairs(y) do x[k] = v end
|
||||
return x
|
||||
end
|
||||
|
||||
local function map(mode, lhs, rhs, opts) vim.api.nvim_set_keymap(mode, lhs, rhs, tblmerge({ noremap = true, silent = true}, opts or {})) end
|
||||
local function map(mode, lhs, rhs, opts)
|
||||
vim.api.nvim_set_keymap(mode, lhs, rhs,
|
||||
tblmerge({ noremap = true, silent = true }, opts or {}))
|
||||
end
|
||||
function nmap(l, r, opt) map('n', l, r, opt) end
|
||||
function imap(l, r, opt) map('i', l, r, opt) end
|
||||
function vmap(l, r, opt) map('v', l, r, opt) end
|
||||
|
||||
function imap(l, r, opt) map('i', l, r, opt) end
|
||||
|
||||
function vmap(l, r, opt) map('v', l, r, opt) end
|
||||
|
||||
-- Treat long lines as broken lines so you can move in them
|
||||
nmap('j', 'gj')
|
||||
|
|
@ -50,11 +73,43 @@ nmap('k', 'gk')
|
|||
vmap('<', '<gv')
|
||||
vmap('>', '>gv')
|
||||
|
||||
-- handy save
|
||||
nmap("<Leader>w", ":w<CR>")
|
||||
|
||||
-- handy escape
|
||||
imap('jk', '<Esc>')
|
||||
|
||||
-- tab handling
|
||||
nmap("<Leader>tn", ":tabnew<CR>")
|
||||
nmap('<Tab>', '<C-W>w')
|
||||
nmap('<S-Tab>', '<C-W>W')
|
||||
nmap('<Leader>te', ':tabedit <c-r>=expand("%:p:h")<cr>/<cr>')
|
||||
|
||||
-- Kill trailing whitespace
|
||||
function Whitespace()
|
||||
local save = vim.fn.winsaveview()
|
||||
vim.cmd [[keeppatterns %s/\s\+$//e]]
|
||||
vim.cmd [[keeppatterns %s/\r$//e]]
|
||||
vim.fn.winrestview(save)
|
||||
end
|
||||
|
||||
nmap('<leader>kw', ':lua Whitespace()<cr>')
|
||||
|
||||
-- C-; inserts current date in ISO8601 format, à la Excel
|
||||
-- Requires configuring the terminal to send the correct sequence; ref
|
||||
-- http://www.leonerd.org.uk/hacks/fixterms/. The correct sequence, in general, is `CSI
|
||||
-- codepoint;modifier u`, where CSI is 'Esc-[', _codepoint_ is the decimal unicode
|
||||
-- value (here, 59), and _modifier_ is chosen from
|
||||
-- None Shift Alt A+S Ctrl C+S C+A C+A+
|
||||
-- 1 2 3 4 5 6 7 8
|
||||
-- For alacritty, e.g., the keybinding to configure i
|
||||
-- - { key: Semicolon, mods: Control, chars: "\x1b[59;5u" }
|
||||
imap('<C-;>', '<C-R>=strftime("%F")<CR>')
|
||||
|
||||
-- this fnamemodify invocations turns the absolute path from expand('%') into a path
|
||||
-- relative to nvim's launch directory
|
||||
nmap('<leader>l', ':let @+=fnamemodify(expand("%"), ":~:.") . ":" . line(".")<CR>')
|
||||
|
||||
-- Setup lazy.nvim
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
|
|
@ -63,3 +118,7 @@ require("lazy").setup({
|
|||
install = { colorscheme = { "habamax" } },
|
||||
checker = { enabled = false },
|
||||
})
|
||||
|
||||
-- set cursorline highlight to an underline. Has to happen after lazy setup, since
|
||||
-- loading the colorscheme will overwrite any custom highlights.
|
||||
vim.api.nvim_set_hl(0, 'CursorLine', { underline = true })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue