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
@ -185,21 +145,9 @@ 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)

File diff suppressed because it is too large Load diff

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; }) '';
keymap = mode: mapping: action: desc:
D.language_server.on_attach(client, bufnr) { inherit mode mapping action desc; };
end 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