1
Fork 0

Huge progress on korora-based tempest generation

This commit is contained in:
Matei Adriel 2023-12-25 14:14:33 +01:00
parent 63d980ddf9
commit 42cd073278
No known key found for this signature in database
8 changed files with 1678 additions and 1462 deletions
home/features/neovim/config/lua/my

View file

@ -1,11 +1,14 @@
local M = {}
function M.setup()
vim.opt.runtimepath:append(vim.g.nix_extra_runtime)
local tempest = require("my.tempest")
local nix = require("nix")
-- Import my other files
require("my.options").setup()
tempest.configureMany(nix.pre)
require("my.keymaps").setup()
require("my.lazy").setup()
require("my.abbreviations").setup()
tempest.configureMany(nix.post)
end
return M

View file

@ -55,92 +55,11 @@ end
-- }}}
function M.setup()
-- {{{ Free up q and Q
M.move("q", "yq", { desc = "Record macro" })
M.move("Q", "yQ")
-- }}}
-- {{{ Easier access to <C-^>
M.move("<C-^>", "<Leader>a", { desc = "[A]lternate file" })
-- }}}
-- {{{ Quit all buffers
M.nmap("Q", ":wqa<cr>", "Save all files and [q]uit")
-- }}}
-- {{{ Replace word in file
M.nmap("<leader>rw", ":%s/<C-r><C-w>/", "[R]eplace [w]ord in file")
-- }}}
-- {{{ Toggle settings
M.nmap(
"<leader>sw",
require("my.helpers.wrapMovement").toggle,
"toggle word [w]rap"
)
-- }}}
-- {{{ Text objects
M.delimitedTextobject("q", '"', "[q]uotes")
M.delimitedTextobject("a", "'", "[a]postrophes")
M.delimitedTextobject("r", "[", "squa[r]e brackets")
-- }}}
-- {{{Diagnostic keymaps
M.nmap("[d", vim.diagnostic.goto_prev, "Goto previous [d]iagnostic")
M.nmap("]d", vim.diagnostic.goto_next, "Goto next [d]iagnostic")
M.move("J", "qj")
M.nmap("J", vim.diagnostic.open_float, "Open current diagnostic")
M.nmap("<leader>D", vim.diagnostic.setloclist, "[D]iagnostic loclist")
-- }}}
-- {{{ Chords (save, clipboard)
-- Different chords get mapped to f keys by a custom script of mine.
-- In the future, I might get this on my keyboard firmware.
vim.keymap.set({ "i", "v" }, "<f10>", "<Esc>", { desc = "Exit insert mode" }) -- Exit inset mode using *jk*
vim.keymap.set({ "n", "v" }, "<f11>", '"+', { desc = "Use global clipboard" }) -- Use global clipboard with *cp*
M.nmap("<f12>", "<cmd>silent write<cr>", "Save current file", true) -- Save using *ji*
-- }}}
-- {{{ Shift-Enter for not continuing the current comment
-- This does not preserve intendation. Not sure what a better solution would look like.
vim.keymap.set("i", "<S-CR>", function()
vim.paste({ "", "" }, -1)
end, { desc = "Insert newline without continuing the current comment" })
-- }}}
-- {{{ Allow quiting basic buffers with "qq"
vim.api.nvim_create_autocmd("FileType", {
pattern = { "help" },
group = vim.api.nvim_create_augroup("BasicBufferQuitting", {}),
callback = function(event)
vim.keymap.set(
"n",
"qq",
"<cmd>close<cr>",
{ buffer = event.buf, silent = true, desc = "[q]uit current buffer" }
)
end,
})
-- }}}
-- {{{ Winblend
vim.api.nvim_create_autocmd("FileType", {
pattern = { "*" },
group = vim.api.nvim_create_augroup("WinblendSettings", {}),
callback = function()
vim.opt.winblend = 0
end,
})
-- }}}
-- {{{ Manage cmdheight
vim.api.nvim_create_autocmd("CmdlineEnter", {
group = vim.api.nvim_create_augroup("SetCmdheightCmdlineEnter", {}),
callback = function()
if not vim.g.inside_venn then
vim.opt.cmdheight = 1
end
end,
})
vim.api.nvim_create_autocmd("CmdlineLeave", {
group = vim.api.nvim_create_augroup("SetCmdheightCmdlineLeave", {}),
callback = function()
if not vim.g.inside_venn then
vim.opt.cmdheight = 0
end
end,
})
-- }}}
end
return M

View file

@ -7,8 +7,8 @@ end
function M.setup()
require("lazy").setup({
importFrom("my.plugins"),
importFrom("nix.plugins"),
importFrom("my.plugins.themes"),
unpack(require("nix").lazy),
}, {
defaults = { lazy = true },
install = {

View file

@ -119,17 +119,26 @@ end
function M.configure(opts, context)
if type(opts) == "function" then
return M.configure(opts(context), context)
opts = opts(context)
end
if type(opts.mk_context) == "function" then
context = opts.mk_context(context)
if type(opts) ~= "table" then
-- TODO: throw
return
end
if type(opts.mkContext) == "function" then
context = opts.mkContext(context)
end
if type(opts.vim) == "table" then
recursive_assign(opts.vim, vim)
end
if type(opts.keys) == "function" then
opts.keys = opts.keys(context)
end
if type(opts.keys) == "table" then
local keys = opts.keys
@ -143,6 +152,10 @@ function M.configure(opts, context)
end
end
if type(opts.autocmds) == "function" then
opts.autocmds = opts.autocmds(context)
end
if type(opts.autocmds) == "table" then
local autocmds = opts.autocmds
@ -180,8 +193,10 @@ function M.configure(opts, context)
end
end
M.lazy = function(lazy, opts, spec)
return M.configure(spec, { lazy = lazy, opts = opts })
function M.configureMany(specs, context)
for _, spec in ipairs(specs) do
M.configure(spec, context)
end
end
-- }}}
-- {{{ Neovim env handling
@ -230,29 +245,46 @@ end
-- {{{ Fixup lazy spec generated by nix
function M.prepareLazySpec(spec)
for _, module in ipairs(spec) do
if spec.tempest ~= nil then
spec.config = function(lazy, opts)
M.configure(spec.tempest, { lazy = lazy, opts = opts })
if module.package ~= nil then
module[1] = module.package
module.package = nil
end
local configType = type(module.config)
if configType == "function" or configType == "table" then
local previousConfig = module.config
module.config = function(lazy, opts)
M.configure(previousConfig, { lazy = lazy, opts = opts })
end
end
if spec.dependencies ~= nil then
spec.dependencies = spec.dependencies.lua
end
if spec.keys ~= nil then
local keys = spec.keys
if spec.keys.mapping ~= nil then
keys = { keys }
if module.keys ~= nil then
if type(module.keys) == "string" or module.keys.mapping ~= nil then
module.keys = { module.keys }
end
for _, key in ipairs(keys) do
key[1] = key.mapping
if key.mode ~= nil then
key.mode = H.string_chars(key.mode)
for _, key in ipairs(module.keys) do
if type(key) ~= "string" then
key[1] = key.mapping
key.mapping = nil
if key.mode ~= nil then
key.mode = H.string_chars(key.mode)
end
if key.action ~= nil then
key[2] = key.action
key.action = nil
end
end
end
end
if type(module.cond) == "table" then
local final = true
for _, cond in ipairs(module.cond) do
final = final and cond
end
module.cond = final
end
end
end
-- }}}