init wrapper-module config

This commit is contained in:
Daniel Winkler 2026-01-30 14:22:39 +11:00
commit 91755583fd
46 changed files with 4277 additions and 0 deletions

6
ftplugin/julia.lua Normal file
View file

@ -0,0 +1,6 @@
vim.b.slime_cell_delimiter = vim.b.slime_cell_delimiter or "# %%"
local ts_lib = Config.treesitter_helpers
local global_nodes_julia = { 'source_file', 'module_definition' }
ts_lib.setup_keybindings(global_nodes_julia)

32
ftplugin/markdown.lua Normal file
View file

@ -0,0 +1,32 @@
-- Add the key mappings only for Markdown files in a zk notebook.
if require("zk.util").notebook_root(vim.fn.expand('%:p')) ~= nil then
local map = vim.keymap.set
-- Open the link under the caret.
map("n", "<CR>", "<Cmd>lua vim.lsp.buf.definition()<CR>", { noremap = true, silent = false, buffer = true })
-- Create a new note after asking for its title.
-- This overrides the global `<leader>zn` mapping to create the note in the same directory as the current buffer.
map("n", "<leader>zhn", "<Cmd>ZkNew { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }<CR>",
{ noremap = true, silent = false, buffer = true, desc = "Note (here)" })
-- Create a new note in the same directory as the current buffer, using the current selection for title.
map("v", "<leader>zhnt", ":'<,'>ZkNewFromTitleSelection { dir = vim.fn.expand('%:p:h') }<CR>",
{ noremap = true, silent = false, buffer = true, desc = "Note from selection (title)" })
-- Create a new note in the same directory as the current buffer, using the current selection for note content and asking for its title.
map("v", "<leader>zhnc",
":'<,'>ZkNewFromContentSelection { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }<CR>",
{ noremap = true, silent = false, buffer = true, desc = "Note from selection (content)" })
-- Open notes linking to the current buffer.
map("n", "<leader>zb", "<Cmd>ZkBacklinks<CR>", { noremap = true, silent = false, buffer = true, desc = "Backlinks" })
-- Alternative for backlinks using pure LSP and showing the source context.
--map('n', '<leader>zb', '<Cmd>lua vim.lsp.buf.references()<CR>', opts)
-- Open notes linked by the current buffer.
map("n", "<leader>zL", "<Cmd>ZkLinks<CR>", { noremap = true, silent = false, buffer = true, desc = "Links" })
map("n", "<leader>zi", "<Cmd>ZkInsertLink<CR>", { noremap = true, silent = false, buffer = true, desc = "Insert link" })
-- Preview a linked note.
-- Open the code actions for a visual selection.
map("v", "<leader>za", ":'<,'>lua vim.lsp.buf.range_code_action()<CR>",
{ noremap = true, silent = false, buffer = true, desc = "Code actions" })
end

20
ftplugin/python.lua Normal file
View file

@ -0,0 +1,20 @@
vim.g.slime_python_ipython = 1
vim.b.slime_cell_delimiter = vim.b.slime_cell_delimiter or "# %%"
local ts_lib = Config.treesitter_helpers
local global_nodes_python = { 'module' }
ts_lib.setup_keybindings(global_nodes_python)
local conform_format_group =
vim.api.nvim_create_augroup("PythonConformFormat_" .. vim.api.nvim_get_current_buf(), { clear = true })
vim.api.nvim_create_autocmd("BufWritePre", {
group = conform_format_group,
buffer = 0,
callback = function()
require("conform").format({
timeout_ms = 1000,
lsp_format = "prefer",
})
end,
})

56
ftplugin/r.lua Normal file
View file

@ -0,0 +1,56 @@
vim.b.slime_cell_delimiter = vim.b.slime_cell_delimiter or "## ----"
local assign_action = function()
if vim.bo.filetype ~= "r" then
return
end
local ok, r_edit = pcall(require, "r.edit")
if not ok then
return
end
if MiniTrailspace and MiniTrailspace.trim then
MiniTrailspace.trim()
end
r_edit.assign()
end
vim.api.nvim_buf_create_user_command(0, "RAssign", assign_action, { desc = "Trim trailing space and insert <-" })
-- Settings
vim.bo.comments = [[:#',:####,:###,:##,:#]]
-- Keymaps
-- Note: These use <Plug> mappings provided by R.nvim
vim.keymap.set("n", "<Enter>", "<Plug>RDSendLine", { buffer = true })
vim.keymap.set("v", "<Enter>", "<Plug>RSendSelection", { buffer = true })
-- Assignment operator (--)
vim.keymap.set("i", "--", "<Cmd>lua MiniTrailspace.trim()<CR><Plug>RInsertAssign", { buffer = true, noremap = true })
-- Pipe operator (;;)
vim.keymap.set("i", ";;", "<Cmd>lua MiniTrailspace.trim()<CR><Plug>RInsertPipe<CR>", { buffer = true, noremap = true })
-- MiniClue / WhichKey hints
local r_clues = {
{ mode = "n", keys = "<localleader>a", desc = "+batch" },
{ mode = "n", keys = "<localleader>b", desc = "+between/debug" },
{ mode = "n", keys = "<localleader>c", desc = "+substitute" },
{ mode = "n", keys = "<localleader>f", desc = "+functions" },
{ mode = "n", keys = "<localleader>i", desc = "+install" },
{ mode = "n", keys = "<localleader>k", desc = "+knit" },
{ mode = "n", keys = "<localleader>p", desc = "+paragraph" },
{ mode = "n", keys = "<localleader>r", desc = "+regular" },
{ mode = "n", keys = "<localleader>s", desc = "+selection" },
{ mode = "n", keys = "<localleader>t", desc = "+dput" },
{ mode = "n", keys = "<localleader>u", desc = "+undebug" },
}
vim.b.miniclue_config = {
clues = {
r_clues,
},
triggers = {
{ mode = "n", keys = "<localleader>", desc = "+R" },
},
}

11
ftplugin/sql.lua Normal file
View file

@ -0,0 +1,11 @@
vim.g.omni_sql_default_compl_type = "syntax"
local ts_lib = Config.treesitter_helpers
local global_nodes_sql = { 'program', 'cte' }
ts_lib.setup_keybindings(global_nodes_sql)
-- SQL specific keybindings
vim.keymap.set({ 'n' }, '<localleader>;', function()
vim.api.nvim_call_function('slime#send', { ";\n" })
end,
{ noremap = true, silent = true, desc = "SQL statment return", buffer = true })