1
Fork 0

Move more modules from lua to nix

This commit is contained in:
Matei Adriel 2024-01-01 21:24:04 +01:00
parent 42cd073278
commit c36f93d9c9
No known key found for this signature in database
13 changed files with 1316 additions and 1332 deletions

View file

@ -1 +0,0 @@
vim.api.nvim_buf_set_option(0, "commentstring", "-- %s")

View file

@ -1 +0,0 @@
require("my.helpers.wrapMovement").enable()

View file

@ -1,9 +0,0 @@
-- Use _<leader>lg_ to fetchgit stuff
vim.keymap.set("n", "<leader>lg", function()
require("my.tempest").withSavedCursor(function()
vim.cmd(":%!update-nix-fetchgit")
end)
end, { buffer = true, desc = "Update all fetchgit calls" })
-- Idk why this isn't here by default
vim.api.nvim_buf_set_option(0, "commentstring", "# %s")

View file

@ -1,7 +1,6 @@
local A = require("my.abbreviations") local A = require("my.abbreviations")
local scrap = require("scrap") local scrap = require("scrap")
require("my.helpers.wrapMovement").enable()
require("my.abbreviations.math").setup() require("my.abbreviations.math").setup()
vim.opt.conceallevel = 0 vim.opt.conceallevel = 0

View file

@ -1,3 +1,2 @@
require("my.helpers.wrapMovement").enable()
require("my.abbreviations.math").setup() require("my.abbreviations.math").setup()
require("my.abbreviations.unicode").setup() require("my.abbreviations.unicode").setup()

View file

@ -14,6 +14,7 @@
"conform": { "branch": "master", "commit": "48bc9996ebfe90e7766f46338360f75fd6ecb174" }, "conform": { "branch": "master", "commit": "48bc9996ebfe90e7766f46338360f75fd6ecb174" },
"crates": { "branch": "main", "commit": "b8ea20fda2e1029fbbb1bae7a9eab35c84037ca0" }, "crates": { "branch": "main", "commit": "b8ea20fda2e1029fbbb1bae7a9eab35c84037ca0" },
"discord-rich-presence": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, "discord-rich-presence": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" },
"dressing": { "branch": "master", "commit": "94b0d24483d56f3777ee0c8dc51675f21709318c" },
"edit-code-block": { "branch": "main", "commit": "5e4e31012eafa113216cb5894f696682833f8e7f" }, "edit-code-block": { "branch": "main", "commit": "5e4e31012eafa113216cb5894f696682833f8e7f" },
"fidget": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" }, "fidget": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" },
"flash": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" }, "flash": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" },
@ -37,6 +38,7 @@
"mini.comment": { "branch": "main", "commit": "3d9c8009615857e982f09bc5357fc95f2a2175f3" }, "mini.comment": { "branch": "main", "commit": "3d9c8009615857e982f09bc5357fc95f2a2175f3" },
"mini.files": { "branch": "main", "commit": "173d73f5d0b2a9abbb2d6533a3770fdbbd0c4dcc" }, "mini.files": { "branch": "main", "commit": "173d73f5d0b2a9abbb2d6533a3770fdbbd0c4dcc" },
"mini.operators": { "branch": "main", "commit": "7a97e2528a4c274e9da8953d3ba22f493c360a9f" }, "mini.operators": { "branch": "main", "commit": "7a97e2528a4c274e9da8953d3ba22f493c360a9f" },
"mini.pairs": { "branch": "main", "commit": "552062017ff207e1f35f7028bfb3f27c7421d22d" },
"mini.statusline": { "branch": "main", "commit": "950d9029c7ed901b67c839e74478f784b7432665" }, "mini.statusline": { "branch": "main", "commit": "950d9029c7ed901b67c839e74478f784b7432665" },
"mini.surround": { "branch": "main", "commit": "af8129efcabe95fc08a233e9f91569829bed031f" }, "mini.surround": { "branch": "main", "commit": "af8129efcabe95fc08a233e9f91569829bed031f" },
"neoconf": { "branch": "main", "commit": "64437787dba70fce50dad7bfbb97d184c5bc340f" }, "neoconf": { "branch": "main", "commit": "64437787dba70fce50dad7bfbb97d184c5bc340f" },
@ -46,7 +48,6 @@
"nui": { "branch": "main", "commit": "c9b4de623d19a85b353ff70d2ae9c77143abe69c" }, "nui": { "branch": "main", "commit": "c9b4de623d19a85b353ff70d2ae9c77143abe69c" },
"nui.nvim": { "branch": "main", "commit": "c9b4de623d19a85b353ff70d2ae9c77143abe69c" }, "nui.nvim": { "branch": "main", "commit": "c9b4de623d19a85b353ff70d2ae9c77143abe69c" },
"null-ls": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" }, "null-ls": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" },
"nvim-autopairs": { "branch": "master", "commit": "0f04d78619cce9a5af4f355968040f7d675854a1" },
"nvim-lspconfig": { "branch": "master", "commit": "511609ae0311abfcfaed3c398429a147e895ce2c" }, "nvim-lspconfig": { "branch": "master", "commit": "511609ae0311abfcfaed3c398429a147e895ce2c" },
"nvim-tree": { "branch": "master", "commit": "7d1760f892951dd6a118dae1d7a1d8df5f029edf" }, "nvim-tree": { "branch": "master", "commit": "7d1760f892951dd6a118dae1d7a1d8df5f029edf" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "ec1c5bdb3d87ac971749fa6c7dbc2b14884f1f6a" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "ec1c5bdb3d87ac971749fa6c7dbc2b14884f1f6a" },

View file

@ -1,14 +0,0 @@
local M = {}
function M.setup()
local default_length = 0.04
-- vim.g.neovide_floating_blur_amount_x = 10.0
-- vim.g.neovide_floating_blur_amount_y = 10.0
vim.g.neovide_transparency = require("nix.theme").opacity.applications
-- vim.g.transparency = 0.6
-- vim.g.pumblend = 0
vim.g.neovide_cursor_animation_length = default_length
vim.g.neovide_cursor_animate_in_insert_mode = false
end
return M

View file

@ -1,36 +0,0 @@
local runtime = require("my.tempest")
if runtime.whitelist("neovide") then
require("my.neovide").setup()
end
return {
{
-- Better ui for inputs/selects
"stevearc/dressing.nvim",
config = true,
-- https://github.com/folke/dot/blob/master/config/nvim/lua/config/plugins/init.lua
init = function()
---@diagnostic disable-next-line: duplicate-set-field
vim.ui.select = function(...)
require("lazy").load({ plugins = { "dressing.nvim" } })
return vim.ui.select(...)
end
---@diagnostic disable-next-line: duplicate-set-field
vim.ui.input = function(...)
require("lazy").load({ plugins = { "dressing.nvim" } })
return vim.ui.input(...)
end
end,
cond = runtime.blacklist("vscode"),
enabled = false,
},
{
"windwp/nvim-autopairs",
event = "InsertEnter",
config = function()
require("nvim-autopairs").setup()
end,
},
}

View file

@ -4,7 +4,7 @@ local lspconfig = {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
event = "BufReadPre", event = "BufReadPre",
dependencies = { dependencies = {
"folke/neoconf.nvim", "neoconf",
{ {
"folke/neodev.nvim", "folke/neodev.nvim",
config = true, config = true,
@ -26,59 +26,19 @@ local M = {
}, },
} }
function M.on_attach(client, bufnr) function M.on_attach(_, _) end
function M.legacy_on_attach(_, bufnr)
-- {{{ Keymap helpers -- {{{ Keymap helpers
local opts = function(desc) local opts = function(desc)
return { silent = true, desc = desc, buffer = bufnr } return { silent = true, desc = desc, buffer = bufnr }
end end
local nmap = function(from, to, desc)
vim.keymap.set("n", from, to, opts(desc))
end
-- }}}
-- {{{ Go to declaration / references / implementation
nmap("gd", vim.lsp.buf.definition, "[G]o to [d]efinition")
nmap("<leader>gi", vim.lsp.buf.implementation, "[G]o to [i]mplementation")
nmap("<leader>gr", vim.lsp.buf.references, "[G]o to [r]eferences")
-- }}}
-- {{{ Hover
-- Note: diagnostics are already covered in keymaps.lua
if client.supports_method("textDocument/hover") then
nmap("K", vim.lsp.buf.hover, "Hover")
end
nmap("L", vim.lsp.buf.signature_help, "Signature help")
-- }}} -- }}}
-- {{{ Code actions -- {{{ Code actions
nmap("<leader>c", vim.lsp.buf.code_action, "[C]ode actions")
nmap("<leader>li", "<cmd>LspInfo<cr>", "[L]sp [i]nfo")
local expropts = opts("[R]e[n]ame") local expropts = opts("[R]e[n]ame")
expropts.expr = true expropts.expr = true
vim.keymap.set("n", "<leader>rn", function() vim.keymap.set("n", "<leader>rn", function()
return ":IncRename " .. vim.fn.expand("<cword>") return ":IncRename " .. vim.fn.expand("<cword>")
end, expropts) end, expropts)
vim.keymap.set(
"v",
"<leader>c",
":'<,'> lua vim.lsp.buf.range_code_action()",
opts("[C]ode actions")
)
-- }}}
-- {{{ Workspace stuff
nmap(
"<leader>wa",
vim.lsp.buf.add_workspace_folder,
"[W]orkspace [A]dd Folder"
)
nmap(
"<leader>wr",
vim.lsp.buf.remove_workspace_folder,
"[W]orkspace [R]emove Folder"
)
nmap("<leader>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, "[W]orkspace [L]ist Folders")
-- }}} -- }}}
end end
@ -156,7 +116,7 @@ local servers = {
-- }}} -- }}}
-- {{{ Nix -- {{{ Nix
rnix = {}, rnix = {},
nil_ls = {}, -- nil_ls = {},
nixd = {}, nixd = {},
-- }}} -- }}}
---@diagnostic disable-next-line: missing-fields ---@diagnostic disable-next-line: missing-fields
@ -184,22 +144,10 @@ M.capabilities = function()
return c return c
end end
-- }}}
-- {{{ Nice diagnostic icons
-- See https://github.com/folke/dot/blob/master/config/nvim/lua/config/plugins/lsp/diagnostics.lua
local function diagnostics_icons()
local signs = { Error = "", Warn = "", Hint = "", Info = "" }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
end
end
-- }}} -- }}}
-- {{{ Main config function -- {{{ Main config function
function lspconfig.config() function lspconfig.config()
diagnostics_icons() -- diagnostics_icons()
-- -- {{{ Change on-hover borders -- -- {{{ Change on-hover borders
vim.lsp.handlers["textDocument/hover"] = vim.lsp.handlers["textDocument/hover"] =
vim.lsp.with(vim.lsp.handlers.hover, { border = "single" }) vim.lsp.with(vim.lsp.handlers.hover, { border = "single" })
@ -210,23 +158,22 @@ function lspconfig.config()
local capabilities = M.capabilities() local capabilities = M.capabilities()
-- Setup basic language servers -- Setup basic language servers
for lsp, details in pairs(servers) do for lsp, details in pairs(servers) do
if details.on_attach == nil then
-- Default setting for on_attach
details.on_attach = M.on_attach
end
require("lspconfig")[lsp].setup({ require("lspconfig")[lsp].setup({
on_attach = details.on_attach, on_attach = details.on_attach,
settings = details.settings, -- Specific per-language settings settings = details.settings, -- Specific per-language settings
flags = {
debounce_text_changes = 150, -- This will be the default in neovim 0.7+
},
cmd = details.cmd, cmd = details.cmd,
capabilities = capabilities, capabilities = capabilities,
}) })
end end
end
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev)
local client = vim.lsp.get_client_by_id(ev.data.client_id)
M.legacy_on_attach(client, ev.buf)
end,
})
end
--}}} --}}}
return M return M

View file

@ -49,32 +49,31 @@ function M.config()
on_enter = function() on_enter = function()
vim.opt.virtualedit = "all" vim.opt.virtualedit = "all"
vim.g.inside_venn = true vim.g.inside_venn = true
vim.opt.cmdheight = 1
end, end,
on_exit = function() on_exit = function()
vim.opt.virtualedit = "" vim.opt.virtualedit = ""
vim.g.inside_venn = false
vim.opt.cmdheight = 0
end, end,
desc = "[V]enn mode", desc = "[V]enn mode",
}, },
mode = "n", mode = "n",
body = "<leader>V", body = "<leader>V",
heads = { heads = {
{ "H", "<C-v>h:VBox<cr>", { silent = true, desc = "test description" } }, { "H", "<C-v>h<esc><cmd>silent VBox<cr>", { silent = true } },
{ "J", "<C-v>j:VBox<cr>", { silent = true, desc = "test description" } }, { "J", "<C-v>j<esc><cmd>silent VBox<cr>", { silent = true } },
{ "K", "<C-v>k:VBox<cr>", { silent = true, desc = "test description" } }, { "K", "<C-v>k<esc><cmd>silent VBox<cr>", { silent = true } },
{ "L", "<C-v>l:VBox<cr>", { silent = true, desc = "test description" } }, { "L", "<C-v>l<esc><cmd>silent VBox<cr>", { silent = true } },
{ "f", "<cmd>VBox<cr>", { mode = "v" } }, { "f", "<cmd>VBox<cr>", { mode = "v" } },
{ "<Esc>", nil, { exit = true } }, { "<Esc>", nil, { exit = true } },
}, },
}) })
-- vim.keymap.set("n", "w", "<C-v>h:VBox<cr>", { silent = true })
end end
function M.init() function M.init()
require("which-key").register({ -- require("which-key").register({
["<leader>V"] = { name = "[V]enn mode" }, -- ["<leader>V"] = { name = "[V]enn mode" },
}) -- })
end end
return M return M

View file

@ -100,7 +100,7 @@ function M.create_autocmd(opts)
vim.api.nvim_create_autocmd(opts.event, { vim.api.nvim_create_autocmd(opts.event, {
group = vim.api.nvim_create_augroup(opts.group, {}), group = vim.api.nvim_create_augroup(opts.group, {}),
pattern = opts.pattern, pattern = H.with_default("*", opts.pattern),
callback = callback, callback = callback,
}) })
end end
@ -118,6 +118,7 @@ local function recursive_assign(source, destination)
end end
function M.configure(opts, context) function M.configure(opts, context)
-- {{{ Construct opts & context
if type(opts) == "function" then if type(opts) == "function" then
opts = opts(context) opts = opts(context)
end end
@ -130,11 +131,20 @@ function M.configure(opts, context)
if type(opts.mkContext) == "function" then if type(opts.mkContext) == "function" then
context = opts.mkContext(context) context = opts.mkContext(context)
end end
-- }}}
if
opts.cond == false
or type(opts.cond) == "function" and opts.cond(context) == false
then
return
end
if type(opts.vim) == "table" then if type(opts.vim) == "table" then
recursive_assign(opts.vim, vim) recursive_assign(opts.vim, vim)
end end
-- {{{ Keybinds
if type(opts.keys) == "function" then if type(opts.keys) == "function" then
opts.keys = opts.keys(context) opts.keys = opts.keys(context)
end end
@ -151,7 +161,8 @@ function M.configure(opts, context)
M.set_keymap(keymap, context) M.set_keymap(keymap, context)
end end
end end
-- }}}
-- {{{ Autocmds
if type(opts.autocmds) == "function" then if type(opts.autocmds) == "function" then
opts.autocmds = opts.autocmds(context) opts.autocmds = opts.autocmds(context)
end end
@ -160,7 +171,7 @@ function M.configure(opts, context)
local autocmds = opts.autocmds local autocmds = opts.autocmds
-- Detect single autocmd passed instead of array -- Detect single autocmd passed instead of array
if autocmds.pattern ~= nil then if autocmds.event ~= nil then
autocmds = { autocmds } autocmds = { autocmds }
end end
@ -168,7 +179,8 @@ function M.configure(opts, context)
M.create_autocmd(autocmd) M.create_autocmd(autocmd)
end end
end end
-- }}}
-- {{{ .setup calls
if type(opts.setup) == "table" then if type(opts.setup) == "table" then
for key, arg in pairs(opts.setup) do for key, arg in pairs(opts.setup) do
require(key).setup(arg) require(key).setup(arg)
@ -187,10 +199,16 @@ function M.configure(opts, context)
module.setup(context.opts) module.setup(context.opts)
end end
end end
-- }}}
-- {{{ Callbacks
if type(opts.callback) == "function" then if type(opts.callback) == "function" then
opts.callback(context) opts.callback(context)
end end
if type(opts.callback) == "table" then
M.configure(opts.callback, context)
end
-- }}}
end end
function M.configureMany(specs, context) function M.configureMany(specs, context)

View file

@ -6,11 +6,11 @@ let
inherit lib korora; inherit lib korora;
} }
{ {
languageServerModule = "my.plugins.lspconfig";
tempestModule = "my.tempest"; tempestModule = "my.tempest";
}; };
generated = nlib.generateConfig (lib.fix (self: { generated = nlib.generateConfig
(lib.fix (self: with nlib; {
# {{{ Pre-plugin config # {{{ Pre-plugin config
pre = { pre = {
# {{{ General options # {{{ General options
@ -79,18 +79,13 @@ let
"1:misc-keybinds" = { "1:misc-keybinds" = {
# {{{ Global keybinds # {{{ Global keybinds
keys = keys =
let
# {{{ Keybind helpers # {{{ Keybind helpers
nmap = mapping: action: desc: let dmap = mapping: action: desc: {
{ inherit mapping action desc; };
unmap = mapping:
{ inherit mapping; action = "<nop>"; };
dmap = mapping: action: desc: {
inherit mapping desc; inherit mapping desc;
action = nlib.lua "vim.diagnostic.${action}"; action = lua "vim.diagnostic.${action}";
}; };
# }}}
in in
# }}}
[ [
# {{{ Free up q and Q # {{{ Free up q and Q
(nmap "<c-q>" "q" "Record macro") (nmap "<c-q>" "q" "Record macro")
@ -103,19 +98,10 @@ let
# See [my slambda config](../../../hosts/nixos/common/optional/services/slambda.nix) for details. # See [my slambda config](../../../hosts/nixos/common/optional/services/slambda.nix) for details.
# #
# Exit insert mode using *jk* # Exit insert mode using *jk*
{ (keymap "iv" "<f10>" "<esc>" "Exit insert mode")
mode = "iv";
mapping = "<f10>";
action = "<esc>";
desc = "Exit insert mode";
}
# Use global clipboard using *cp* # Use global clipboard using *cp*
{ (keymap "nv" "<f11>" ''"+'' "Use global clipboard")
mode = "nv";
mapping = "<f11>";
action = ''"+'';
desc = "Use global clipboard";
}
# Save using *ji* # Save using *ji*
(nmap "<f12>" "<cmd>silent write<cr>" "Save current file") (nmap "<f12>" "<cmd>silent write<cr>" "Save current file")
# }}} # }}}
@ -123,7 +109,7 @@ let
{ {
mode = "i"; mode = "i";
mapping = "<c-cr>"; mapping = "<c-cr>";
action = nlib.thunk /* lua */ '' action = thunk /* lua */ ''
vim.paste({ "", "" }, -1) vim.paste({ "", "" }, -1)
''; '';
desc = "Insert newline without continuing the current comment"; desc = "Insert newline without continuing the current comment";
@ -141,11 +127,7 @@ let
(dmap "]d" "goto_next" "Goto next [d]iagnostic") (dmap "]d" "goto_next" "Goto next [d]iagnostic")
(dmap "J" "open_float" "Open current diagnostic") (dmap "J" "open_float" "Open current diagnostic")
(dmap "<leader>D" "setloclist" "[D]iagnostic loclist") (dmap "<leader>D" "setloclist" "[D]iagnostic loclist")
{ (nmap "qj" "J" "join lines")
mapping = "qj";
action = "J";
desc = "join lines";
}
# }}} # }}}
# {{{ Other misc keybinds # {{{ Other misc keybinds
(nmap "<Leader>a" "<C-^>" "[A]lternate file") (nmap "<Leader>a" "<C-^>" "[A]lternate file")
@ -153,22 +135,31 @@ let
(nmap "Q" ":wqa<cr>" "Save all files and [q]uit") (nmap "Q" ":wqa<cr>" "Save all files and [q]uit")
(nmap "<leader>rw" ":%s/<C-r><C-w>/" "[R]eplace [w]ord in file") (nmap "<leader>rw" ":%s/<C-r><C-w>/" "[R]eplace [w]ord in file")
(nmap "<leader>sw" (nmap "<leader>sw"
(nlib.lua ''require("my.helpers.wrapMovement").toggle'') (lua ''require("my.helpers.wrapMovement").toggle'')
"toggle word [w]rap") "toggle word [w]rap")
# }}} # }}}
]; ];
# }}} # }}}
# {{{ Autocmds
autocmds = [
# {{{ Exit certain buffers with qq # {{{ Exit certain buffers with qq
autocmds = { {
event = "FileType"; event = "FileType";
pattern = [ "help" ]; pattern = [ "help" ];
group = "BasicBufferQuitting"; group = "BasicBufferQuitting";
action.keys = { action.keys =
mapping = "qq"; nmap "qq" "<cmd>close<cr>" "[q]uit current buffer";
action = "<cmd>close<cr>"; }
desc = "[q]uit current buffer"; # }}}
}; # {{{ Enable wrap movemenets by default in certain filetypes
}; {
event = "FileType";
pattern = [ "markdown" "typst" "tex" ];
group = "EnableWrapMovement";
action = lua ''require("my.helpers.wrapMovement").enable'';
}
# }}}
];
# }}} # }}}
}; };
# }}} # }}}
@ -186,6 +177,75 @@ let
} }
]; ];
# }}} # }}}
# {{{ Lsp on-attach
"3:lsp-on-attach".autocmds = {
event = "LspAttach";
group = "UserLspConfig";
action =
let nmap = mapping: action: desc:
nlib.nmap mapping
(lua "vim.lsp.buf.${action}")
desc;
in
{
mkContext = event: {
bufnr = lua "${event}.buf";
client = lua /* lua */
"vim.lsp.get_client_by_id(${event}.data.client_id)";
};
keys = [
(nlib.nmap "<leader>li" "<cmd>LspInfo<cr>" "[L]sp [i]nfo")
(nmap "gd" "definition" "[G]o to [d]efinition")
(nmap "<leader>gi" "implementation" "[G]o to [i]mplementation")
(nmap "<leader>gr" "references" "[G]o to [r]eferences")
(nmap "L" "signature_help" "Signature help")
(nmap "<leader>c" "code_action" "[C]ode actions")
(keymap "v" "<leader>c" ":'<,'> lua vim.lsp.buf.range_code_action()" "[C]ode actions")
(nmap "<leader>wa" "add_workspace_folder" "[W]orkspace [A]dd Folder")
(nmap "<leader>wr" "remove_workspace_folder" "[W]orkspace [R]emove Folder")
(nlib.nmap "<leader>wl"
(thunk /* lua */ ''
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
'') "[W]orkspace [L]ist Folders")
];
callback = {
cond = ctx: lua ''
return ${ctx}.client.supports_method("textDocument/hover")
'';
keys = nmap "K" "hover" "Hover";
};
};
};
# }}}
# {{{ Neovide config
"4:configure-neovide" = {
cond = whitelist "neovide";
vim.g = {
neovide_transparency = lua ''require("my.helpers.theme").theme.opacity.applications'';
neovide_cursor_animation_length = 0.04;
neovide_cursor_animate_in_insert_mode = false;
};
};
# }}}
# {{{ Language specific settings
"5:language-specific-settings".autocmds = [{
event = "FileType";
group = "UserNixSettings";
pattern = "*.nix";
action = {
vim.opt.commentstring = "# %s";
keys = {
mapping = "<leader>lg";
action = thunk /* lua */ ''
D.tempest.withSavedCursor(function()
vim.cmd(":%!${lib.getExe pkgs.update-nix-fetchgit}")
end)
'';
desc = "Update all fetchgit calls";
};
};
}];
# }}}
}; };
# }}} # }}}
# {{{ Plugins # {{{ Plugins
@ -218,12 +278,10 @@ let
nvim-tree = { nvim-tree = {
package = "kyazdani42/nvim-tree.lua"; package = "kyazdani42/nvim-tree.lua";
cond = nlib.blacklist [ "vscode" "firenvim" ]; cond = blacklist [ "vscode" "firenvim" ];
config = true; config = true;
keys.mapping = "<C-n>"; keys = nmap "<C-n>" "Toggle [n]vim-tree" "<cmd>NvimTreeToggle<cr>";
keys.desc = "Toggle [n]vim-tree";
keys.action = "<cmd>NvimTreeToggle<cr>";
}; };
# }}} # }}}
# {{{ mini.statusline # {{{ mini.statusline
@ -232,16 +290,16 @@ let
name = "mini.statusline"; name = "mini.statusline";
dependencies.lua = [ self.lazy.web-devicons.package ]; dependencies.lua = [ self.lazy.web-devicons.package ];
cond = nlib.blacklist [ "vscode" "firenvim" ]; cond = blacklist [ "vscode" "firenvim" ];
lazy = false; lazy = false;
opts.content.inactive = nlib.thunk /* lua */ '' opts.content.inactive = thunk /* lua */ ''
require("mini.statusline").combine_groups({ require("mini.statusline").combine_groups({
{ hl = "MiniStatuslineFilename", strings = { vim.fn.expand("%:t") } }, { hl = "MiniStatuslineFilename", strings = { vim.fn.expand("%:t") } },
}) })
''; '';
opts.content.active = nlib.thunk /* lua */ '' opts.content.active = thunk /* lua */ ''
local st = require("mini.statusline"); local st = require("mini.statusline");
local mode, mode_hl = st.section_mode({ trunc_width = 120 }) local mode, mode_hl = st.section_mode({ trunc_width = 120 })
local git = st.section_git({ trunc_width = 75 }) local git = st.section_git({ trunc_width = 75 })
@ -264,11 +322,11 @@ let
name = "mini.files"; name = "mini.files";
dependencies.lua = [ self.lazy.web-devicons.package ]; dependencies.lua = [ self.lazy.web-devicons.package ];
cond = nlib.blacklist [ "vscode" "firenvim" ]; cond = blacklist [ "vscode" "firenvim" ];
keys = { keys = {
mapping = "<c-s-f>"; mapping = "<c-s-f>";
desc = "[S]earch [F]iles"; desc = "[S]earch [F]iles";
action = nlib.thunk /* lua */ '' action = thunk /* lua */ ''
local files = require("mini.files") local files = require("mini.files")
if not files.close() then if not files.close() then
files.open(vim.api.nvim_buf_get_name(0)) files.open(vim.api.nvim_buf_get_name(0))
@ -285,7 +343,7 @@ let
winbar = { winbar = {
package = "fgheng/winbar.nvim"; package = "fgheng/winbar.nvim";
cond = nlib.blacklist [ "vscode" "firenvim" ]; cond = blacklist [ "vscode" "firenvim" ];
event = "BufReadPost"; event = "BufReadPost";
opts.enabled = true; opts.enabled = true;
@ -299,7 +357,7 @@ let
let goto = key: index: { let goto = key: index: {
desc = "Goto harpoon file ${toString index}"; desc = "Goto harpoon file ${toString index}";
mapping = "<c-s>${key}"; mapping = "<c-s>${key}";
action = nlib.thunk action = thunk
/* lua */ ''require("harpoon.ui").nav_file(${toString index})''; /* lua */ ''require("harpoon.ui").nav_file(${toString index})'';
}; };
in in
@ -307,13 +365,13 @@ let
{ {
desc = "Add file to [h]arpoon"; desc = "Add file to [h]arpoon";
mapping = "<leader>H"; mapping = "<leader>H";
action = nlib.thunk action = thunk
/* lua */ ''require("harpoon.mark").add_file()''; /* lua */ ''require("harpoon.mark").add_file()'';
} }
{ {
desc = "Toggle harpoon quickmenu"; desc = "Toggle harpoon quickmenu";
mapping = "<c-a>"; mapping = "<c-a>";
action = nlib.thunk action = thunk
/* lua */ ''require("harpoon.ui").toggle_quick_menu()''; /* lua */ ''require("harpoon.ui").toggle_quick_menu()'';
} }
(goto "q" 1) (goto "q" 1)
@ -333,13 +391,9 @@ let
package = "TimUntersberger/neogit"; package = "TimUntersberger/neogit";
dependencies.lua = [ self.lazy.plenary.package ]; dependencies.lua = [ self.lazy.plenary.package ];
cond = nlib.blacklist [ "vscode" "firenvim" ]; cond = blacklist [ "vscode" "firenvim" ];
cmd = "Neogit"; # We sometimes spawn this directly from fish using a keybind cmd = "Neogit"; # We sometimes spawn this directly from fish using a keybind
keys = { keys = nmap "<c-g>" "<cmd>Neogit<cr>" "Open neo[g]it";
mapping = "<c-g>";
action = "<cmd>Neogit<cr>";
desc = "Open neo[g]it";
};
opts = true; # Here so the tempest runtime will call .setup opts = true; # Here so the tempest runtime will call .setup
config.autocmds = { config.autocmds = {
@ -354,7 +408,7 @@ let
telescope = { telescope = {
package = "nvim-telescope/telescope.nvim"; package = "nvim-telescope/telescope.nvim";
version = "0.1.x"; version = "0.1.x";
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
# {{{ Dependencies # {{{ Dependencies
dependencies = { dependencies = {
@ -372,22 +426,22 @@ let
# {{{ Keymaps # {{{ Keymaps
keys = keys =
let let
keymap = mapping: action: desc: { nmap = mapping: action: desc: {
inherit mapping desc; inherit mapping desc;
action = "<cmd>Telescope ${action} theme=ivy<cr>"; action = "<cmd>Telescope ${action} theme=ivy<cr>";
}; };
findFilesByExtension = mapping: extension: tag: findFilesByExtension = mapping: extension: tag:
keymap nmap
"<leader>f${mapping}" "<leader>f${mapping}"
"find_files find_command=rg,--files,--glob=**/*.${extension}" "find_files find_command=rg,--files,--glob=**/*.${extension}"
"Find ${tag} files"; "Find ${tag} files";
in in
[ [
(keymap "<c-p>" "find_files" "File finder [p]alette") (nmap "<c-p>" "find_files" "File finder [p]alette")
(keymap "<leader>d" "diagnostics" "[D]iagnostics") (nmap "<leader>d" "diagnostics" "[D]iagnostics")
(keymap "<c-f>" "live_grep" "[F]ind in project") (nmap "<c-f>" "live_grep" "[F]ind in project")
(keymap "<leader>t" "builtin" "[T]elescope pickers") (nmap "<leader>t" "builtin" "[T]elescope pickers")
# {{{ Files by extension # {{{ Files by extension
(findFilesByExtension "tx" "tex" "[t]ex") (findFilesByExtension "tx" "tex" "[t]ex")
(findFilesByExtension "ts" "ts" "[t]ypescript") (findFilesByExtension "ts" "ts" "[t]ypescript")
@ -410,7 +464,7 @@ let
}; };
# }}} # }}}
# {{{ Load fzf extension # {{{ Load fzf extension
config.callback = nlib.thunk /* lua */ '' config.callback = thunk /* lua */ ''
require("telescope").load_extension("fzf") require("telescope").load_extension("fzf")
''; '';
# }}} # }}}
@ -425,6 +479,26 @@ let
# }}} # }}}
}; };
# }}} # }}}
# {{{ dressing
dressing = {
package = "stevearc/dressing.nvim";
cond = blacklist "vscode";
event = "BufReadPre";
config = true;
init = thunk /* lua */ ''
vim.ui.select = function(...)
require("lazy").load({ plugins = { "dressing.nvim" } })
return vim.ui.select(...)
end
vim.ui.input = function(...)
require("lazy").load({ plugins = { "dressing.nvim" } })
return vim.ui.input(...)
end
'';
};
# }}}
# }}} # }}}
# {{{ visual # {{{ visual
# The line between `ui` and `visual` is a bit rought. I currenlty mostly judge # The line between `ui` and `visual` is a bit rought. I currenlty mostly judge
@ -435,7 +509,7 @@ let
main = "ibl"; main = "ibl";
config = true; config = true;
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
event = "BufReadPost"; event = "BufReadPost";
}; };
# }}} # }}}
@ -450,12 +524,7 @@ let
opts.commands.Norm.cmd = "norm"; opts.commands.Norm.cmd = "norm";
opts.commands.G.cmd = "g"; opts.commands.G.cmd = "g";
keys = { keys = keymap "v" "N" ":Norm " "Map lines in [n]ormal mode";
mode = "v";
mapping = "N";
action = ":Norm ";
desc = "Map lines in [n]ormal mode";
};
}; };
# }}} # }}}
# {{{ fidget # {{{ fidget
@ -463,7 +532,7 @@ let
package = "j-hui/fidget.nvim"; package = "j-hui/fidget.nvim";
tag = "legacy"; tag = "legacy";
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
event = "BufReadPre"; event = "BufReadPre";
config = true; config = true;
}; };
@ -475,7 +544,7 @@ let
dependencies.lua = [ "nvim-treesitter/nvim-treesitter-textobjects" ]; dependencies.lua = [ "nvim-treesitter/nvim-treesitter-textobjects" ];
dependencies.nix = [ pkgs.tree-sitter ]; dependencies.nix = [ pkgs.tree-sitter ];
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
event = "BufReadPost"; event = "BufReadPost";
#{{{ Highlighting #{{{ Highlighting
@ -533,7 +602,7 @@ let
package = "haringsrob/nvim_context_vt"; package = "haringsrob/nvim_context_vt";
dependencies.lua = [ "treesitter" ]; dependencies.lua = [ "treesitter" ];
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
event = "BufReadPost"; event = "BufReadPost";
}; };
@ -542,30 +611,31 @@ let
package = "nvim-treesitter/nvim-treesitter-context"; package = "nvim-treesitter/nvim-treesitter-context";
dependencies.lua = [ "treesitter" ]; dependencies.lua = [ "treesitter" ];
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
event = "BufReadPost"; event = "BufReadPost";
opts.enable = true; opts.enable = true;
}; };
# }}} # }}}
# }}} # }}}
# {{{ editing {{{ text navigation # {{{ editing
# {{{ text navigation
# {{{ flash # {{{ flash
flash = { flash = {
package = "folke/flash.nvim"; package = "folke/flash.nvim";
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
keys = keys =
let keybind = mode: mapping: action: desc: { let nmap = mode: mapping: action: desc: {
inherit mapping desc mode; inherit mapping desc mode;
action = nlib.thunk /* lua */ ''require("flash").${action}()''; action = thunk /* lua */ ''require("flash").${action}()'';
}; };
in in
[ [
(keybind "nxo" "s" "jump" "Flash") (nmap "nxo" "s" "jump" "Flash")
(keybind "nxo" "S" "treesitter" "Flash Treesitter") (nmap "nxo" "S" "treesitter" "Flash Treesitter")
(keybind "o" "r" "remote" "Remote Flash") (nmap "o" "r" "remote" "Remote Flash")
(keybind "ox" "R" "treesitter_search" "Treesitter Search") (nmap "ox" "R" "treesitter_search" "Treesitter Search")
(keybind "c" "<C-S>" "toggle" "Toggle Flash Search") (nmap "c" "<C-S>" "toggle" "Toggle Flash Search")
]; ];
# Disable stuff like f/t/F/T # Disable stuff like f/t/F/T
@ -576,7 +646,7 @@ let
ftft = { ftft = {
package = "gukz/ftFT.nvim"; package = "gukz/ftFT.nvim";
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
keys = [ "f" "F" "t" "T" ]; keys = [ "f" "F" "t" "T" ];
config = true; config = true;
}; };
@ -586,7 +656,7 @@ let
clipboard-image = { clipboard-image = {
package = "postfen/clipboard-image.nvim"; package = "postfen/clipboard-image.nvim";
cond = nlib.blacklist "firenvim"; cond = blacklist "firenvim";
cmd = "PasteImg"; cmd = "PasteImg";
keys = { keys = {
@ -595,7 +665,7 @@ let
desc = "[P]aste image from clipboard"; desc = "[P]aste image from clipboard";
}; };
opts.default.img_name = nlib.import ./plugins/clipboard-image.lua "img_name"; opts.default.img_name = importFrom ./plugins/clipboard-image.lua "img_name";
opts.tex = { opts.tex = {
img_dir = [ "%:p:h" "img" ]; img_dir = [ "%:p:h" "img" ];
affix = "\\includegraphics[width=\\textwidth]{%s}"; affix = "\\includegraphics[width=\\textwidth]{%s}";
@ -610,7 +680,7 @@ let
lastplace = { lastplace = {
package = "ethanholz/nvim-lastplace"; package = "ethanholz/nvim-lastplace";
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
event = "BufReadPre"; event = "BufReadPre";
opts.lastplace_ignore_buftype = [ "quickfix" "nofile" "help" ]; opts.lastplace_ignore_buftype = [ "quickfix" "nofile" "help" ];
@ -620,24 +690,23 @@ let
undotree = { undotree = {
package = "mbbill/undotree"; package = "mbbill/undotree";
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
cmd = "UndotreeToggle"; cmd = "UndotreeToggle";
keys = { keys = nmap
mapping = "<leader>u"; "<leader>u"
action = "<cmd>UndoTreeToggle<cr>"; "<cmd>UndoTreeToggle<cr>"
desc = "[U]ndo tree"; "[U]ndo tree";
};
}; };
# }}} # }}}
# {{{ ssr (structured search & replace) # {{{ ssr (structured search & replace)
ssr = { ssr = {
package = "cshuaimin/ssr.nvim"; package = "cshuaimin/ssr.nvim";
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
keys = { keys = {
mode = "nx"; mode = "nx";
mapping = "<leader>rt"; mapping = "<leader>rt";
action = nlib.thunk /* lua */ ''require("ssr").open()''; action = thunk /* lua */ ''require("ssr").open()'';
desc = "[r]eplace [t]emplate"; desc = "[r]eplace [t]emplate";
}; };
@ -650,7 +719,7 @@ let
dependencies.lua = [ "treesitter" ]; dependencies.lua = [ "treesitter" ];
main = "ecb"; main = "ecb";
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
config = true; config = true;
keys = { keys = {
mapping = "<leader>e"; mapping = "<leader>e";
@ -735,6 +804,16 @@ let
]; ];
}; };
# }}} # }}}
# {{{ mini.pairs
mini-pairs = {
package = "echasnovski/mini.pairs";
name = "mini.pairs";
config = true;
# We could specify all the generated bindings, but I don't think it's worth it
event = [ "InsertEnter" "CmdlineEnter" ];
};
# }}}
# {{{ luasnip # {{{ luasnip
# snippeting engine # snippeting engine
luasnip = luasnip =
@ -744,21 +823,21 @@ let
package = "L3MON4D3/LuaSnip"; package = "L3MON4D3/LuaSnip";
version = "v2"; version = "v2";
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
config = nlib.thunk reload; config = thunk reload;
# {{{ Keybinds # {{{ Keybinds
keys = [ keys = [
{ {
mapping = "<leader>rs"; mapping = "<leader>rs";
action = nlib.thunk reload; action = thunk reload;
desc = "[R]eload [s]nippets"; desc = "[R]eload [s]nippets";
} }
{ {
mode = "i"; mode = "i";
expr = true; expr = true;
mapping = "<tab>"; mapping = "<tab>";
action = nlib.thunk /* lua */ '' action = thunk /* lua */ ''
local luasnip = require("luasnip") local luasnip = require("luasnip")
if not luasnip.jumpable(1) then if not luasnip.jumpable(1) then
@ -776,7 +855,7 @@ let
{ {
mode = "i"; mode = "i";
mapping = "<s-tab>"; mapping = "<s-tab>";
action = nlib.thunk /* lua */ '' action = thunk /* lua */ ''
require("luasnip").jump(-1) require("luasnip").jump(-1)
''; '';
desc = "Jump to previous snippet tabstop"; desc = "Jump to previous snippet tabstop";
@ -791,7 +870,7 @@ let
conform = { conform = {
package = "stevearc/conform.nvim"; package = "stevearc/conform.nvim";
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
event = "BufReadPost"; event = "BufReadPost";
opts.format_on_save.lsp_fallback = true; opts.format_on_save.lsp_fallback = true;
@ -816,6 +895,8 @@ let
cmd = "Neoconf"; cmd = "Neoconf";
# Provide autocomplete for every language server
opts.plugins.jsonls.configure_servers_only = false;
opts.import = { opts.import = {
vscode = true; # local .vscode/settings.json vscode = true; # local .vscode/settings.json
coc = false; # global/local coc-settings.json coc = false; # global/local coc-settings.json
@ -828,13 +909,12 @@ let
package = "jose-elias-alvarez/null-ls.nvim"; package = "jose-elias-alvarez/null-ls.nvim";
dependencies.lua = [ "neovim/nvim-lspconfig" ]; dependencies.lua = [ "neovim/nvim-lspconfig" ];
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
event = "BufReadPre"; event = "BufReadPre";
opts = nlib.thunk /* lua */ '' opts = thunk /* lua */ ''
local p = require("null-ls") local p = require("null-ls")
return { return {
on_attach = require("my.plugins.lspconfig").on_attach,
sources = { sources = {
p.builtins.diagnostics.ruff p.builtins.diagnostics.ruff
} }
@ -846,11 +926,11 @@ let
gitsigns = { gitsigns = {
package = "lewis6991/gitsigns.nvim"; package = "lewis6991/gitsigns.nvim";
cond = nlib.blacklist [ "vscode" "firenvim" ]; cond = blacklist [ "vscode" "firenvim" ];
event = "BufReadPost"; event = "BufReadPost";
opts.on_attach = nlib.tempest { opts.on_attach = tempest {
mkContext = nlib.lua /* lua */ mkContext = lua /* lua */
"function(bufnr) return { bufnr = bufnr } end"; "function(bufnr) return { bufnr = bufnr } end";
keys = keys =
let let
@ -867,7 +947,7 @@ let
# {{{ exprmap helper # {{{ exprmap helper
exprmap = mapping: action: desc: { exprmap = mapping: action: desc: {
inherit mapping desc; inherit mapping desc;
action = nlib.thunk /* lua */ '' action = thunk /* lua */ ''
if vim.wo.diff then if vim.wo.diff then
return "${mapping}" return "${mapping}"
end end
@ -897,14 +977,14 @@ let
(nmap "d" "diffthis" "[s]tage hunk") (nmap "d" "diffthis" "[s]tage hunk")
{ {
mapping = prefix "D"; mapping = prefix "D";
action = nlib.thunk '' action = thunk ''
${gs}.diffthis("~") ${gs}.diffthis("~")
''; '';
desc = "[d]iff file (?)"; desc = "[d]iff file (?)";
} }
{ {
mapping = prefix "b"; mapping = prefix "b";
action = nlib.thunk '' action = thunk ''
${gs}.blame_line({ full = true }) ${gs}.blame_line({ full = true })
''; '';
desc = "[b]lame line"; desc = "[b]lame line";
@ -918,7 +998,7 @@ let
{ {
mode = "v"; mode = "v";
mapping = prefix "s"; mapping = prefix "s";
action = nlib.thunk /* lua */ '' action = thunk /* lua */ ''
${gs}.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) ${gs}.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
''; '';
desc = "stage visual hunk"; desc = "stage visual hunk";
@ -926,7 +1006,7 @@ let
{ {
mode = "v"; mode = "v";
mapping = prefix "r"; mapping = prefix "r";
action = nlib.thunk /* lua */ '' action = thunk /* lua */ ''
${gs}.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) ${gs}.reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
''; '';
desc = "reset visual hunk"; desc = "reset visual hunk";
@ -953,9 +1033,9 @@ let
self.lazy.luasnip.package self.lazy.luasnip.package
]; ];
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
event = [ "InsertEnter" "CmdlineEnter" ]; event = [ "InsertEnter" "CmdlineEnter" ];
config = nlib.import ./plugins/cmp.lua "config"; config = importFrom ./plugins/cmp.lua "config";
}; };
# }}} # }}}
# }}} # }}}
@ -966,20 +1046,17 @@ let
dependencies.lua = [ self.lazy.plenary.package ]; dependencies.lua = [ self.lazy.plenary.package ];
version = "^2"; version = "^2";
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
ft = [ "haskell" "lhaskell" "cabal" "cabalproject" ]; ft = [ "haskell" "lhaskell" "cabal" "cabalproject" ];
config.vim.g.haskell_tools = { config.vim.g.haskell_tools = {
hls = { hls.settings.haskell = {
on_attach = nlib.lua /* lua */ ''require("my.plugins.lspconfig").on_attach'';
settings.haskell = {
formattingProvider = "fourmolu"; formattingProvider = "fourmolu";
# This seems to work better with custom preludes # This seems to work better with custom preludes
# See this issue https://github.com/fourmolu/fourmolu/issues/357 # See this issue https://github.com/fourmolu/fourmolu/issues/357
plugin.fourmolu.config.external = true; plugin.fourmolu.config.external = true;
}; };
};
# I think this wasn't showing certain docs as I expected (?) # I think this wasn't showing certain docs as I expected (?)
tools.hover.enable = false; tools.hover.enable = false;
@ -992,10 +1069,10 @@ let
package = "simrat39/rust-tools.nvim"; package = "simrat39/rust-tools.nvim";
dependencies.nix = [ pkgs.rust-analyzer pkgs.rustfmt ]; dependencies.nix = [ pkgs.rust-analyzer pkgs.rustfmt ];
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
ft = "rust"; ft = "rust";
opts.server.on_attach = nlib.customLanguageServerOnAttach { opts.server.on_attach = tempestBufnr {
keys = { keys = {
mapping = "<leader>lc"; mapping = "<leader>lc";
action = "<cmd>RustOpenCargo<cr>"; action = "<cmd>RustOpenCargo<cr>";
@ -1009,7 +1086,7 @@ let
package = "saecki/crates.nvim"; package = "saecki/crates.nvim";
dependencies.lua = [ self.lazy.plenary.package ]; dependencies.lua = [ self.lazy.plenary.package ];
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
event = "BufReadPost Cargo.toml"; event = "BufReadPost Cargo.toml";
# {{{ Set up null_ls source # {{{ Set up null_ls source
@ -1025,7 +1102,7 @@ let
event = "InsertEnter"; event = "InsertEnter";
group = "CargoCmpSource"; group = "CargoCmpSource";
pattern = "Cargo.toml"; pattern = "Cargo.toml";
action = nlib.thunk /* lua */ '' action = thunk /* lua */ ''
require("cmp").setup.buffer({ sources = { { name = "crates" } } }) require("cmp").setup.buffer({ sources = { { name = "crates" } } })
''; '';
} }
@ -1036,7 +1113,7 @@ let
group = "CargoKeybinds"; group = "CargoKeybinds";
pattern = "Cargo.toml"; pattern = "Cargo.toml";
# # {{{ Register which-key info # # {{{ Register which-key info
# action.callback = nlib.contextThunk /* lua */ '' # action.callback = contextThunk /* lua */ ''
# require("which-key").register({ # require("which-key").register({
# ["<leader>lc"] = { # ["<leader>lc"] = {
# name = "[l]ocal [c]rates", # name = "[l]ocal [c]rates",
@ -1049,9 +1126,9 @@ let
action.keys = _: action.keys = _:
let let
# {{{ Keymap helpers # {{{ Keymap helpers
keymap = mapping: action: desc: { nmap = mapping: action: desc: {
inherit mapping desc; inherit mapping desc;
action = nlib.lua /* lua */ ''require("crates").${action}''; action = lua /* lua */ ''require("crates").${action}'';
}; };
keyroot = "<leader>lc"; keyroot = "<leader>lc";
@ -1059,18 +1136,18 @@ let
in in
# {{{ Keybinds # {{{ Keybinds
[ [
(keymap "${keyroot}t" "toggle" "[c]rates [t]oggle") (nmap "${keyroot}t" "toggle" "[c]rates [t]oggle")
(keymap "${keyroot}r" "reload" "[c]rates [r]efresh") (nmap "${keyroot}r" "reload" "[c]rates [r]efresh")
(keymap "${keyroot}H" "open_homepage" "[c]rate [H]omephage") (nmap "${keyroot}H" "open_homepage" "[c]rate [H]omephage")
(keymap "${keyroot}R" "open_repository" "[c]rate [R]epository") (nmap "${keyroot}R" "open_repository" "[c]rate [R]epository")
(keymap "${keyroot}D" "open_documentation" "[c]rate [D]ocumentation") (nmap "${keyroot}D" "open_documentation" "[c]rate [D]ocumentation")
(keymap "${keyroot}C" "open_crates_io" "[c]rate [C]rates.io") (nmap "${keyroot}C" "open_crates_io" "[c]rate [C]rates.io")
(keymap "${keyroot}v" "show_versions_popup" "[c]rate [v]ersions") (nmap "${keyroot}v" "show_versions_popup" "[c]rate [v]ersions")
(keymap "${keyroot}f" "show_features_popup" "[c]rate [f]eatures") (nmap "${keyroot}f" "show_features_popup" "[c]rate [f]eatures")
(keymap "${keyroot}d" "show_dependencies_popup" "[c]rate [d]eps") (nmap "${keyroot}d" "show_dependencies_popup" "[c]rate [d]eps")
(keymap "K" "show_popup" "[c]rate popup") (nmap "K" "show_popup" "[c]rate popup")
]; ];
# }}} # }}}
} }
@ -1088,7 +1165,7 @@ let
"neovim/nvim-lspconfig" "neovim/nvim-lspconfig"
]; ];
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
ft = "lean"; ft = "lean";
opts = { opts = {
@ -1097,10 +1174,8 @@ let
cmp = true; cmp = true;
}; };
lsp = { lsp.capabilites =
on_attach = nlib.lua /* lua */ ''require("my.plugins.lspconfig").on_attach''; lua /* lua */ ''require("my.plugins.lspconfig").capabilities'';
capabilites = nlib.lua /* lua */ ''require("my.plugins.lspconfig").capabilities'';
};
lsp3 = false; # We don't want the lean 3 language server! lsp3 = false; # We don't want the lean 3 language server!
mappings = true; mappings = true;
@ -1116,18 +1191,18 @@ let
"neovim/nvim-lspconfig" "neovim/nvim-lspconfig"
]; ];
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
ft = [ "idris2" "lidris2" "ipkg" ]; ft = [ "idris2" "lidris2" "ipkg" ];
opts = { opts = {
client.hover.use_split = true; client.hover.use_split = true;
serve.on_attach = nlib.customLanguageServerOnAttach { serve.on_attach = tempestBufnr {
# {{{ Keymaps # {{{ Keymaps
keys = keys =
let keymap = mapping: action: desc: { let keymap = mapping: action: desc: {
inherit desc; inherit desc;
mapping = "<leader>i${mapping}"; mapping = "<leader>i${mapping}";
action = nlib.lua /* lua */ ''require("idris2.code_action").${action}''; action = lua /* lua */ ''require("idris2.code_action").${action}'';
}; };
in in
[ [
@ -1148,7 +1223,7 @@ let
github-actions = { github-actions = {
package = "yasuhiroki/github-actions-yaml.vim"; package = "yasuhiroki/github-actions-yaml.vim";
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
ft = [ "yml" "yaml" ]; ft = [ "yml" "yaml" ];
}; };
# }}} # }}}
@ -1157,7 +1232,7 @@ let
package = "kaarmu/typst.vim"; package = "kaarmu/typst.vim";
dependencies.nix = [ pkgs.typst-lsp pkgs.typst-fmt ]; dependencies.nix = [ pkgs.typst-lsp pkgs.typst-fmt ];
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
ft = "typst"; ft = "typst";
}; };
# }}} # }}}
@ -1165,7 +1240,7 @@ let
hyprland = { hyprland = {
package = "theRealCarneiro/hyprland-vim-syntax"; package = "theRealCarneiro/hyprland-vim-syntax";
cond = nlib.blacklist "vscode"; cond = blacklist "vscode";
ft = "hypr"; ft = "hypr";
config.autocmds = { config.autocmds = {
@ -1184,7 +1259,7 @@ let
package = "wakatime/vim-wakatime"; package = "wakatime/vim-wakatime";
dependencies.nix = [ pkgs.wakatime ]; dependencies.nix = [ pkgs.wakatime ];
cond = nlib.blacklist [ "vscode" "firenvim" ]; cond = blacklist [ "vscode" "firenvim" ];
event = "BufReadPost"; event = "BufReadPost";
}; };
# }}} # }}}
@ -1193,7 +1268,7 @@ let
package = "andweeb/presence.nvim"; package = "andweeb/presence.nvim";
main = "presence"; main = "presence";
cond = nlib.blacklist [ "vscode" "firenvim" ]; cond = blacklist [ "vscode" "firenvim" ];
event = "BufReadPost"; event = "BufReadPost";
config = true; config = true;
}; };
@ -1207,7 +1282,7 @@ let
package = "ruifm/gitlinker.nvim"; package = "ruifm/gitlinker.nvim";
dependencies.lua = [ self.lazy.plenary.package ]; dependencies.lua = [ self.lazy.plenary.package ];
cond = nlib.blacklist [ "vscode" "firenvim" ]; cond = blacklist [ "vscode" "firenvim" ];
opts.mappings = mapping; opts.mappings = mapping;
keys = mapping; keys = mapping;
}; };
@ -1229,8 +1304,8 @@ let
dependencies.lua = [ self.lazy.plenary.package ]; dependencies.lua = [ self.lazy.plenary.package ];
cond = [ cond = [
(nlib.blacklist [ "vscode" "firenvim" ]) (blacklist [ "vscode" "firenvim" ])
(nlib.lua /* lua */ "vim.loop.cwd() == ${nlib.encode vault}") (lua /* lua */ "vim.loop.cwd() == ${encode vault}")
]; ];
event = "VeryLazy"; event = "VeryLazy";
@ -1290,7 +1365,6 @@ let
# Others # Others
fd # file finder fd # file finder
update-nix-fetchgit # Useful for nix stuff
# Latex setup # Latex setup
# texlive.combined.scheme-full # Latex stuff # texlive.combined.scheme-full # Latex stuff
@ -1305,15 +1379,19 @@ let
extraRuntimePaths = [ generatedConfig ]; extraRuntimePaths = [ generatedConfig ];
extraRuntimeJoinedPaths = pkgs.symlinkJoin { extraRuntimeJoinedPaths = pkgs.symlinkJoin
{
name = "nixified-neovim-lua-modules"; name = "nixified-neovim-lua-modules";
paths = extraRuntimePaths; paths = extraRuntimePaths;
}; };
extraRuntime = extraRuntime =
let snippets = config.satellite.dev.path "home/features/neovim/snippets"; let snippets = config.satellite.dev.path
"home/features/neovim/snippets";
in in
lib.concatStringsSep "," [ extraRuntimeJoinedPaths snippets ]; lib.concatStringsSep
","
[ extraRuntimeJoinedPaths snippets ];
# }}} # }}}
# {{{ Client wrapper # {{{ Client wrapper
# Wraps a neovim client, providing the dependencies # Wraps a neovim client, providing the dependencies
@ -1346,7 +1424,8 @@ let
}; };
# }}} # }}}
# {{{ Clients # {{{ Clients
neovim = wrapClient { neovim = wrapClient
{
base = base =
if config.satellite.toggles.neovim-nightly.enable if config.satellite.toggles.neovim-nightly.enable
then pkgs.neovim-nightly then pkgs.neovim-nightly
@ -1354,13 +1433,15 @@ let
name = "nvim"; name = "nvim";
}; };
neovide = wrapClient { neovide = wrapClient
{
base = pkgs.neovide; base = pkgs.neovide;
name = "neovide"; name = "neovide";
extraArgs = "--set NEOVIDE_MULTIGRID true"; extraArgs = "--set NEOVIDE_MULTIGRID true";
}; };
firenvim = wrapClient { firenvim = wrapClient
{
base = pkgs.neovim; base = pkgs.neovim;
name = "firenvim"; name = "firenvim";
binName = "nvim"; binName = "nvim";

View file

@ -110,11 +110,12 @@ let
tempestConfig = lazyType "lazy tempest config" (_: struct "tempest config" tempestConfig = lazyType "lazy tempest config" (_: struct "tempest config"
{ {
vim = types.luaValue; vim = types.luaValue;
callback = k.union [ k.function types.luaLiteral ]; callback = k.union [ types.luaLiteral types.tempestConfig ];
setup = k.attrsOf types.luaValue; setup = k.attrsOf types.luaValue;
keys = types.luaEagerOrLazy (types.oneOrMany types.tempestKey); keys = types.luaEagerOrLazy (types.oneOrMany types.tempestKey);
autocmds = types.luaEagerOrLazy (types.oneOrMany types.tempestAutocmd); autocmds = types.luaEagerOrLazy (types.oneOrMany types.tempestAutocmd);
mkContext = types.luaLiteral; mkContext = types.luaValue;
cond = types.oneOrMany types.luaLiteral;
} }
[ ]); [ ]);
# }}} # }}}
@ -136,15 +137,14 @@ let
let err = type.verify value; in let err = type.verify value; in
lib.assertMsg (err == null) err; lib.assertMsg (err == null) err;
mkLib = { tempestModule, languageServerModule }: mkLib = { tempestModule }:
assert hasType k.string tempestModule; assert hasType k.string tempestModule;
assert hasType k.string languageServerModule;
rec { rec {
inherit (e) encode; inherit (e) encode;
# {{{ Common generation helpers # {{{ Common generation helpers
lua = value: assert hasType k.string value; lua = value: assert hasType k.string value;
{ inherit value; __luaEncoderTag = "lua"; }; { inherit value; __luaEncoderTag = "lua"; };
import = path: tag: importFrom = path: tag:
assert lib.isPath path; assert lib.isPath path;
assert hasType k.string tag; assert hasType k.string tag;
lua "dofile(${encode (toString path)}).${tag}"; lua "dofile(${encode (toString path)}).${tag}";
@ -157,16 +157,18 @@ let
${context} ${context}
) )
''; '';
customLanguageServerOnAttach = given: tempestBufnr = given: context: lua ''
assert hasType types.tempestConfig given; D.tempest.configure(
lua /* lua */ '' ${encode given},
function(client, bufnr) { bufnr = ${context}}
D.tempest.configure(${encode given}, )
{ client = client; bufnr = bufnr; })
D.language_server.on_attach(client, bufnr)
end
''; '';
keymap = mode: mapping: action: desc:
{ inherit mode mapping action desc; };
nmap = mapping: action: desc:
{ inherit mapping action desc; };
unmap = mapping:
{ inherit mapping; action = "<nop>"; };
blacklist = given: blacklist = given:
assert hasType (types.oneOrMany types.neovimEnv) given; assert hasType (types.oneOrMany types.neovimEnv) given;
lua /* lua */ '' lua /* lua */ ''
@ -210,7 +212,6 @@ let
local M = {} local M = {}
local D = { local D = {
tempest = require(${encode tempestModule}), tempest = require(${encode tempestModule}),
langauge_server = require(${encode languageServerModule})
} }
-- {{{ Pre-plugin config -- {{{ Pre-plugin config