-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split neovim config into individual files
- Loading branch information
Showing
18 changed files
with
321 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
local augroup = vim.api.nvim_create_augroup | ||
local autocmd = vim.api.nvim_create_autocmd | ||
local cmd = vim.cmd | ||
local func = vim.fn | ||
local api = vim.api | ||
|
||
-- Jump to the last visited position in the file. | ||
augroup("jumpLastPosition", {clear = true}) | ||
autocmd({"BufReadPost"}, { | ||
group = "jumpLastPosition", | ||
callback = | ||
function() | ||
local ft = vim.opt_local.filetype:get() | ||
-- don"t apply to git messages | ||
if (ft:match("commit") or ft:match("rebase")) then | ||
return | ||
end | ||
-- get position of last saved edit | ||
local markpos = api.nvim_buf_get_mark(0, '"') | ||
local line = markpos[1] | ||
local col = markpos[2] | ||
-- if in range, go there | ||
if (line > 1) and (line <= api.nvim_buf_line_count(0)) then | ||
api.nvim_win_set_cursor(0, {line,col}) | ||
end | ||
end | ||
}) | ||
|
||
-- Load templates based on file extensions. | ||
augroup("templates", {clear = true}) | ||
autocmd("BufNewFile", { | ||
group = "templates", | ||
command = [[silent! execute '0r ~/.config/nvim/templates/template.'.expand("<afile>:e")]] | ||
}) | ||
autocmd("BufNewFile", { | ||
group = "templates", | ||
pattern = "makefile", | ||
command = "silent! 0r ~/.config/nvim/templates/template.makefile" | ||
}) | ||
|
||
-- Delete trailing whitespace before saving. | ||
augroup("deleteTrailingSpace", {clear = true}) | ||
autocmd("BufWritePre", { | ||
group = "deleteTrailingSpace", | ||
callback = | ||
function() | ||
local view = func.winsaveview() | ||
cmd([[silent! %s/\s\+$//g]]) | ||
func.winrestview(view) | ||
end, | ||
desc = "Delete trailing whitespace before saving" | ||
}) | ||
|
||
-- Highlight yanked text for a short time. | ||
augroup("highlightOnYank", {clear = true}) | ||
autocmd("TextYankPost", { | ||
group = "highlightOnYank", | ||
command = [[silent! lua vim.highlight.on_yank({higroup = "IncSearch", timeout = 100})]] | ||
}) | ||
|
||
-- Track daily thesis progress. | ||
augroup("thesisProgress", {clear = true}) | ||
local progressScript = "~/Documents/CourseWork/Cambridge/MPhilThesis/paper/progress.sh" | ||
autocmd("BufWritePost", { | ||
group = "thesisProgress", | ||
pattern = "*/MPhilThesis/paper/**.tex", | ||
callback = | ||
function () | ||
local progress = func.system(progressScript) | ||
cmd("redraw") | ||
print(progress) | ||
end | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- Bootstrap lazy.nvim if it's not installed. | ||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" | ||
if not vim.loop.fs_stat(lazypath) then | ||
vim.fn.system { | ||
"git", | ||
"clone", | ||
"--filter=blob:none", | ||
"https://github.com/folke/lazy.nvim.git", | ||
"--branch=stable", | ||
lazypath | ||
} | ||
end | ||
vim.opt.runtimepath:prepend(lazypath) | ||
|
||
-- Set up all plugins in the lua/plugins directory | ||
require("lazy").setup("plugins") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
local map = vim.keymap.set | ||
local mapOpts = {silent = true} | ||
|
||
-- Normal-mode mappings: | ||
map("n", "<Leader>s", ":setlocal spell!<CR>", mapOpts) | ||
map("n", "<Esc><Esc>", ':noh<CR>:let @/="ldsfl2393rj0mash02enp3irdsfc"<CR>', mapOpts) | ||
map("n", "daa", "ggdG", mapOpts) | ||
map("n", "zt", "zt2<C-Y>", mapOpts) | ||
map("n", "zb", "zb2<C-E>", mapOpts) | ||
-- Fold around a code-block. | ||
map("n", "<Leader>p", "gwap", mapOpts) | ||
map("n", "K", ":Man<CR>", mapOpts) | ||
map("n", "gb", "gT", mapOpts) | ||
map("n", "<C-t>", ":Texplore<CR>", mapOpts) | ||
map("n", "[b", ":bprevious<CR>", mapOpts) | ||
map("n", "]b", ":bnext<CR>", mapOpts) | ||
-- Commonly mistyped quit. | ||
map("n", "q:", ":q<CR>") | ||
|
||
-- Insert-mode mappings | ||
map("i", ",,", "<Esc>", mapOpts) |
Oops, something went wrong.