Sketch out tempest neovim runtime
This commit is contained in:
parent
a456fe3781
commit
659fb33ca7
18 changed files with 783 additions and 390 deletions
home/features/neovim/config/lua/my
|
@ -6,10 +6,7 @@ local M = {}
|
|||
M.unicode = {
|
||||
-- {{{ Logic
|
||||
{ "frl", "∀" }, -- [f]o[r]al[l]
|
||||
|
||||
|
||||
|
||||
{ "exs", "∃" }, -- [e][x]ist[s]
|
||||
{ "exs", "∃" }, -- [e][x]ist[s]
|
||||
{ "land", "∧" }, -- [l]ogical [and]
|
||||
{ "Land", "⋀" }, -- arbitrary [l]ogical [and]
|
||||
{ "lor", "∨" }, -- [l]ogical [or]
|
||||
|
@ -23,6 +20,7 @@ M.unicode = {
|
|||
-- }}}
|
||||
-- {{{ Set theory
|
||||
{ "nolla", "∅" },
|
||||
{ "carprod", "×" }, -- cartesian product
|
||||
{ "sect", "∩" }, -- set intersection
|
||||
{ "Sect", "⋂" }, -- arbitrary set intersection
|
||||
{ "dsect", "⊓" }, -- disjoint set intersection (whatever that means lol)
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
local M = {}
|
||||
|
||||
function M.modinverse(b, m)
|
||||
local g, x, _ = M.gcd(b, m)
|
||||
if g ~= 1 then return nil end
|
||||
return x % m
|
||||
end
|
||||
|
||||
function M.gcd(a, b)
|
||||
if a == 0 then return b, 0, 1 end
|
||||
local g, x1, y1 = M.gcd(b % a, a)
|
||||
return g, y1 - (math.floor(b / a)) * x1, x1
|
||||
end
|
||||
|
||||
return M
|
|
@ -1,42 +0,0 @@
|
|||
local M = {
|
||||
"postfen/clipboard-image.nvim",
|
||||
cmd = "PasteImg",
|
||||
}
|
||||
|
||||
local function img_name()
|
||||
vim.fn.inputsave()
|
||||
local name = vim.fn.input("Name: ")
|
||||
vim.fn.inputrestore()
|
||||
|
||||
if name == nil or name == "" then
|
||||
return os.date("%y-%m-%d-%H-%M-%S")
|
||||
end
|
||||
return name
|
||||
end
|
||||
|
||||
function M.init()
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
"<leader>p",
|
||||
":PasteImg<cr>",
|
||||
{ desc = "[P]aste image from clipboard" }
|
||||
)
|
||||
end
|
||||
|
||||
function M.config()
|
||||
require("clipboard-image").setup({
|
||||
default = {
|
||||
img_name = img_name,
|
||||
},
|
||||
tex = {
|
||||
img_dir = { "%:p:h", "img" },
|
||||
affix = "\\includegraphics[width=\\textwidth]{%s}",
|
||||
},
|
||||
typst = {
|
||||
img_dir = { "%:p:h", "img" },
|
||||
affix = '#image("%s", width: 100)',
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
|
@ -117,7 +117,6 @@ function M.config()
|
|||
{ name = "cmdline" },
|
||||
}),
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
local K = require("my.keymaps")
|
||||
local M = {
|
||||
"saecki/crates.nvim",
|
||||
event = "BufReadPost Cargo.toml",
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
config = function()
|
||||
local crates = require("crates")
|
||||
|
||||
crates.setup({
|
||||
null_ls = {
|
||||
enabled = true,
|
||||
name = "crates.nvim",
|
||||
},
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("InsertEnter", {
|
||||
group = vim.api.nvim_create_augroup("CmpSourceCargo", {}),
|
||||
pattern = "Cargo.toml",
|
||||
callback = function()
|
||||
require("cmp").setup.buffer({ sources = { { name = "crates" } } })
|
||||
end,
|
||||
})
|
||||
|
||||
local function nmap(from, to, desc)
|
||||
K.nmap(from, to, desc, true, true)
|
||||
end
|
||||
|
||||
nmap("<leader>lct", crates.toggle, "[c]rates [t]oggle")
|
||||
nmap("<leader>lcr", crates.reload, "[c]rates [r]efresh")
|
||||
|
||||
nmap("<leader>lcH", crates.open_homepage, "[c]rates [H]omepage")
|
||||
nmap("<leader>lcR", crates.open_repository, "[c]rates [R]repository")
|
||||
nmap("<leader>lcD", crates.open_documentation, "[c]rates [D]ocumentation")
|
||||
nmap("<leader>lcC", crates.open_crates_io, "[c]rates [C]rates.io")
|
||||
|
||||
nmap("<leader>lcv", crates.show_versions_popup, "[c]rates [v]ersions")
|
||||
nmap("<leader>lcf", crates.show_features_popup, "[c]rates [f]eatures")
|
||||
nmap("<leader>lcd", crates.show_dependencies_popup, "[c]rates [d]eps")
|
||||
nmap("K", crates.show_popup, "crates popup")
|
||||
|
||||
local wk = require("which-key")
|
||||
|
||||
wk.register({
|
||||
["<leader>lc"] = {
|
||||
name = "[l]ocal [c]rates",
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
return M
|
|
@ -1,32 +0,0 @@
|
|||
local lspconfig = require("my.plugins.lspconfig")
|
||||
local M = {
|
||||
"mrcjkb/haskell-tools.nvim",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
},
|
||||
version = "^2",
|
||||
ft = { "haskell", "lhaskell", "cabal", "cabalproject" },
|
||||
}
|
||||
|
||||
function M.config()
|
||||
vim.g.haskell_tools = {
|
||||
hls = {
|
||||
on_attach = lspconfig.on_attach,
|
||||
settings = {
|
||||
haskell = {
|
||||
formattingProvider = "fourmolu",
|
||||
-- This seems to work better with custom preludes
|
||||
-- See this issue https://github.com/fourmolu/fourmolu/issues/357
|
||||
plugin = { fourmolu = { config = { external = true } } },
|
||||
},
|
||||
},
|
||||
},
|
||||
tools = {
|
||||
hover = {
|
||||
enable = false,
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
|
@ -30,27 +30,13 @@ local M = {
|
|||
function M.on_attach(client, bufnr)
|
||||
-- {{{ Keymap helpers
|
||||
local opts = function(desc)
|
||||
return { noremap = true, silent = true, desc = desc, buffer = bufnr }
|
||||
return { silent = true, desc = desc, buffer = bufnr }
|
||||
end
|
||||
|
||||
local nmap = function(from, to, desc)
|
||||
vim.keymap.set("n", from, to, opts(desc))
|
||||
end
|
||||
-- }}}
|
||||
-- {{{ Auto format
|
||||
local function format()
|
||||
vim.lsp.buf.format({ async = false, bufnr = bufnr })
|
||||
end
|
||||
|
||||
-- if client.supports_method("textDocument/formatting") then
|
||||
-- nmap("<leader>F", format, "[F]ormat")
|
||||
-- vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
-- group = vim.api.nvim_create_augroup("LspFormatting", { clear = false }),
|
||||
-- buffer = bufnr,
|
||||
-- callback = format,
|
||||
-- })
|
||||
-- end
|
||||
-- }}}
|
||||
-- {{{ Go to declaration / references / implementation
|
||||
nmap("gd", vim.lsp.buf.definition, "[G]o to [d]efinition")
|
||||
nmap("gi", vim.lsp.buf.implementation, "[G]o to [i]mplementation")
|
||||
|
@ -131,7 +117,7 @@ local servers = {
|
|||
Lua = {
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
format = {
|
||||
enable = true
|
||||
enable = true,
|
||||
},
|
||||
-- Do not send telemetry data containing a randomized but unique identifier
|
||||
telemetry = {
|
||||
|
@ -215,9 +201,9 @@ function lspconfig.config()
|
|||
diagnostics_icons()
|
||||
-- -- {{{ Change on-hover borders
|
||||
vim.lsp.handlers["textDocument/hover"] =
|
||||
vim.lsp.with(vim.lsp.handlers.hover, { border = "single" })
|
||||
vim.lsp.with(vim.lsp.handlers.hover, { border = "single" })
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] =
|
||||
vim.lsp.with(vim.lsp.handlers.signature_help, { border = "single" })
|
||||
vim.lsp.with(vim.lsp.handlers.signature_help, { border = "single" })
|
||||
-- -- }}}
|
||||
|
||||
local capabilities = M.capabilities()
|
||||
|
@ -230,7 +216,7 @@ function lspconfig.config()
|
|||
|
||||
require("lspconfig")[lsp].setup({
|
||||
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+
|
||||
},
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
local K = require("my.keymaps")
|
||||
local lspconfig = require("my.plugins.lspconfig")
|
||||
|
||||
local M = {
|
||||
"simrat39/rust-tools.nvim",
|
||||
config = function()
|
||||
require("rust-tools").setup({
|
||||
server = {
|
||||
on_attach = function(client, bufnr)
|
||||
K.nmap(
|
||||
"<leader>lc",
|
||||
"<cmd>RustOpenCargo<cr>",
|
||||
"Open [c]argo.toml",
|
||||
true,
|
||||
true
|
||||
)
|
||||
|
||||
lspconfig.on_attach(client, bufnr)
|
||||
end,
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
return M
|
|
@ -1,26 +0,0 @@
|
|||
local M = {
|
||||
"lervag/vimtex", -- latex support
|
||||
ft = "tex",
|
||||
enabled = false
|
||||
}
|
||||
|
||||
function M.config()
|
||||
vim.g.vimtex_view_method = "zathura"
|
||||
vim.g.Tex_DefaultTargetFormat = "pdf"
|
||||
vim.g.vimtex_compiler_latexmk = {
|
||||
options = {
|
||||
"-pdf",
|
||||
"-shell-escape",
|
||||
"-verbose",
|
||||
"-file-line-error",
|
||||
"-synctex=1",
|
||||
"-interaction=nonstopmode",
|
||||
},
|
||||
}
|
||||
|
||||
vim.g.vimtex_fold_enabled = 0
|
||||
vim.g.vimtex_imaps_enabled = 0
|
||||
vim.g.vimtex_syntax_conceal_disable = 1
|
||||
end
|
||||
|
||||
return M
|
132
home/features/neovim/config/lua/my/runtime.lua
Normal file
132
home/features/neovim/config/lua/my/runtime.lua
Normal file
|
@ -0,0 +1,132 @@
|
|||
local M = {}
|
||||
|
||||
-- {{{ General helpers
|
||||
local function string_chars(str)
|
||||
local chars = {}
|
||||
for i = 1, #str do
|
||||
table.insert(chars, str:sub(i, i))
|
||||
end
|
||||
return chars
|
||||
end
|
||||
|
||||
local function with_default(default, given)
|
||||
if given == nil then
|
||||
return default
|
||||
else
|
||||
return given
|
||||
end
|
||||
end
|
||||
-- }}}
|
||||
-- {{{ API wrappers
|
||||
-- {{{ Keymaps
|
||||
function M.set_keymap(opts, context)
|
||||
if context == nil then
|
||||
context = {}
|
||||
end
|
||||
|
||||
local buffer = nil
|
||||
|
||||
if context.bufnr ~= nil then
|
||||
buffer = context.bufnr
|
||||
end
|
||||
|
||||
vim.keymap.set(
|
||||
string_chars(with_default("n", opts.mode)),
|
||||
opts.mapping,
|
||||
opts.action,
|
||||
{
|
||||
desc = opts.desc,
|
||||
buffer = with_default(buffer, opts.buffer),
|
||||
expr = opts.expr,
|
||||
silent = with_default(true, opts.silent),
|
||||
}
|
||||
)
|
||||
end
|
||||
-- }}}
|
||||
-- {{{ Autocmds
|
||||
function M.create_autocmd(opts)
|
||||
local callback
|
||||
|
||||
if type(opts.callback) == "function" then
|
||||
callback = opts.callback
|
||||
end
|
||||
|
||||
if type(opts.callback) == "table" then
|
||||
callback = function(event)
|
||||
M.configure(opts.callback, event)
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd(opts.event, {
|
||||
group = vim.api.nvim_create_augroup(opts.group, {}),
|
||||
pattern = opts.pattern,
|
||||
callback = callback,
|
||||
})
|
||||
end
|
||||
-- }}}
|
||||
-- }}}
|
||||
-- {{{ Main config runtime
|
||||
local function recursive_assign(source, destination)
|
||||
for key, value in pairs(source) do
|
||||
if type(value) == "table" then
|
||||
destination[key] = destination[key] or {}
|
||||
recursive_assign(value, destination[key])
|
||||
else
|
||||
destination[key] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function M.configure(opts, context)
|
||||
if type(opts.vim) == "table" then
|
||||
recursive_assign(opts, vim)
|
||||
end
|
||||
|
||||
if type(opts.keys) == "table" then
|
||||
local keys = opts.keys
|
||||
|
||||
-- Detect single key passed instead of array
|
||||
if keys.mapping ~= nil then
|
||||
keys = { keys }
|
||||
end
|
||||
|
||||
for _, keymap in ipairs(keys) do
|
||||
M.set_keymap(keymap, context)
|
||||
end
|
||||
end
|
||||
|
||||
if type(opts.autocmds) == "table" then
|
||||
local autocmds = opts.autocmds
|
||||
|
||||
-- Detect single autocmd passed instead of array
|
||||
if autocmds.pattern ~= nil then
|
||||
autocmds = { autocmds }
|
||||
end
|
||||
|
||||
for _, autocmd in ipairs(autocmds) do
|
||||
M.create_autocmd(autocmd)
|
||||
end
|
||||
end
|
||||
|
||||
if type(opts.setup) == "table" then
|
||||
for key, arg in pairs(opts.setup) do
|
||||
require(key).setup(arg)
|
||||
end
|
||||
end
|
||||
|
||||
if
|
||||
type(context) == "table"
|
||||
and context.opts ~= nil
|
||||
and context.lazy ~= nil
|
||||
then
|
||||
-- This is a terrible way to do it :/
|
||||
require(context.lazy.name).setup(context.opts)
|
||||
end
|
||||
|
||||
if type(opts.callback) == "function" then
|
||||
opts.callback(context)
|
||||
end
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return M
|
Loading…
Add table
Add a link
Reference in a new issue