refactor: simplify
This commit is contained in:
+16
-16
@@ -1,5 +1,21 @@
|
||||
local M = {}
|
||||
|
||||
--- Interactive picker for selecting and running tasks defined in a Justfile.
|
||||
function M.pick_just_task()
|
||||
local obj = vim.system({ "just", "--summary" }, { text = true }):wait()
|
||||
if obj.code ~= 0 or not obj.stdout or obj.stdout == "" then
|
||||
return vim.notify("No recipes or justfile found", vim.log.levels.WARN)
|
||||
end
|
||||
|
||||
require("mini.pick").start({
|
||||
source = {
|
||||
items = vim.split(vim.trim(obj.stdout), "%s+"),
|
||||
name = " Just Tasks",
|
||||
choose = function(choice) run_task("just " .. choice) end,
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
local function run_task(cmd)
|
||||
vim.notify(" Running: " .. cmd)
|
||||
|
||||
@@ -20,20 +36,4 @@ local function run_task(cmd)
|
||||
end)
|
||||
end
|
||||
|
||||
--- Interactive picker for selecting and running tasks defined in a Justfile.
|
||||
function M.pick_just_task()
|
||||
local obj = vim.system({ "just", "--summary" }, { text = true }):wait()
|
||||
if obj.code ~= 0 or not obj.stdout or obj.stdout == "" then
|
||||
return vim.notify("No recipes or justfile found", vim.log.levels.WARN)
|
||||
end
|
||||
|
||||
require("mini.pick").start({
|
||||
source = {
|
||||
items = vim.split(vim.trim(obj.stdout), "%s+"),
|
||||
name = " Just Tasks",
|
||||
choose = function(choice) run_task("just " .. choice) end,
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
+6
-8
@@ -3,21 +3,19 @@ local M = {}
|
||||
--- Opens a TUI application in a simple centered floating window.
|
||||
function M.open_terminal_app(cmd)
|
||||
local buf = vim.api.nvim_create_buf(false, true)
|
||||
local w, h = math.floor(vim.o.columns * 0.95), math.floor(vim.o.lines * 0.95)
|
||||
|
||||
-- Open a centered floating window (80% screen width/height)
|
||||
local win = vim.api.nvim_open_win(buf, true, {
|
||||
relative = "editor",
|
||||
width = math.floor(vim.o.columns * 0.95),
|
||||
height = math.floor(vim.o.lines * 0.95),
|
||||
row = math.floor(vim.o.lines * 0.025),
|
||||
col = math.floor(vim.o.columns * 0.025),
|
||||
width = w,
|
||||
height = h,
|
||||
row = math.floor((vim.o.lines - h) / 2),
|
||||
col = math.floor((vim.o.columns - w) / 2),
|
||||
border = "rounded",
|
||||
})
|
||||
|
||||
vim.fn.termopen(cmd, {
|
||||
on_exit = function()
|
||||
pcall(vim.api.nvim_win_close, win, true)
|
||||
end,
|
||||
on_exit = function() pcall(vim.api.nvim_win_close, win, true) end,
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
@@ -38,9 +38,6 @@ vim.o.tabstop = 2 -- Show tab as this number of spaces
|
||||
vim.o.virtualedit = 'block' -- Allow going past end of line in blockwise mode
|
||||
vim.opt.autoread = true -- Do not prompt to reread files on update
|
||||
|
||||
-- Pattern for a start of numbered list (used in `gw`).
|
||||
vim.o.formatlistpat = [[^\s*[0-9\-\+\*]\+[\.\)]*\s\+]]
|
||||
|
||||
-- Built-in completion
|
||||
vim.o.complete = '.,w,b,kspell' -- Use less sources
|
||||
vim.o.completeopt = 'menuone,noselect,fuzzy,nosort' -- Use custom behavior
|
||||
@@ -71,16 +68,4 @@ Config.later(function()
|
||||
},
|
||||
update_in_insert = false,
|
||||
})
|
||||
|
||||
local dap_signs = {
|
||||
DapBreakpoint = { text = '', texthl = 'DapBreakpoint', linehl = '', numhl = '' },
|
||||
DapBreakpointCondition = { text = '', texthl = 'DapBreakpointCondition', linehl = '', numhl = '' },
|
||||
DapLogPoint = { text = '', texthl = 'DapLogPoint', linehl = '', numhl = '' },
|
||||
DapStopped = { text = '', texthl = 'DapStopped', linehl = 'DapStoppedLine', numhl = '' },
|
||||
DapBreakpointRejected = { text = '', texthl = 'DapBreakpointRejected', linehl = '', numhl = '' },
|
||||
}
|
||||
|
||||
for name, sign in pairs(dap_signs) do
|
||||
vim.fn.sign_define(name, sign)
|
||||
end
|
||||
end)
|
||||
|
||||
+11
-25
@@ -14,32 +14,18 @@ Config.leader_group_clues = {
|
||||
}
|
||||
|
||||
-- Helpers =====================================================================
|
||||
local function lazy_wrap(name, action)
|
||||
return function()
|
||||
if Config["setup_" .. name] then Config["setup_" .. name]() end
|
||||
action()
|
||||
end
|
||||
local function map(mode, lhs, rhs, desc, plugin)
|
||||
local final_rhs = plugin and function()
|
||||
if Config["setup_" .. plugin] then Config["setup_" .. plugin]() end
|
||||
rhs()
|
||||
end or rhs
|
||||
vim.keymap.set(mode, lhs, final_rhs, { desc = desc })
|
||||
end
|
||||
|
||||
local nmap = function(lhs, rhs, desc, plugin)
|
||||
local final_rhs = plugin and lazy_wrap(plugin, rhs) or rhs
|
||||
vim.keymap.set("n", lhs, final_rhs, { desc = desc })
|
||||
end
|
||||
|
||||
local tmap = function(lhs, rhs, desc, plugin)
|
||||
local final_rhs = plugin and lazy_wrap(plugin, rhs) or rhs
|
||||
vim.keymap.set("t", lhs, final_rhs, { desc = desc })
|
||||
end
|
||||
|
||||
local nmap_leader = function(suffix, rhs, desc, plugin)
|
||||
local final_rhs = plugin and lazy_wrap(plugin, rhs) or rhs
|
||||
vim.keymap.set("n", "<Leader>" .. suffix, final_rhs, { desc = desc })
|
||||
end
|
||||
|
||||
local xmap_leader = function(suffix, rhs, desc, plugin)
|
||||
local final_rhs = plugin and lazy_wrap(plugin, rhs) or rhs
|
||||
vim.keymap.set("x", "<Leader>" .. suffix, final_rhs, { desc = desc })
|
||||
end
|
||||
local nmap = function(lhs, rhs, desc, plugin) map("n", lhs, rhs, desc, plugin) end
|
||||
local tmap = function(lhs, rhs, desc, plugin) map("t", lhs, rhs, desc, plugin) end
|
||||
local nmap_leader = function(suffix, rhs, desc, plugin) map("n", "<Leader>" .. suffix, rhs, desc, plugin) end
|
||||
local xmap_leader = function(suffix, rhs, desc, plugin) map("x", "<Leader>" .. suffix, rhs, desc, plugin) end
|
||||
|
||||
-- Buffers =====================================================================
|
||||
nmap_leader("bd", function() pcall(vim.cmd, "bdelete") end, "Delete")
|
||||
@@ -122,7 +108,7 @@ nmap_leader("sw", function() MiniSessions.write() end, "Write current")
|
||||
-- Terminal ====================================================================
|
||||
nmap_leader("tT", function() vim.cmd("horizontal term") end, "Terminal (horizontal)")
|
||||
nmap_leader("tt", function() vim.cmd("vertical term") end, "Terminal (vertical)")
|
||||
nmap_leader("tc", function() vim.cmd("vertical term claude") end, "Terminal (vertical)")
|
||||
nmap_leader("tc", function() vim.cmd("vertical term claude") end, "Claude")
|
||||
nmap_leader("tg", function() require("terminal").open_terminal_app("lazygit") end, "LazyGit")
|
||||
nmap_leader("ts", function() require("terminal").open_terminal_app("lazysql") end, "LazySQL")
|
||||
|
||||
|
||||
+12
-5
@@ -83,12 +83,19 @@ function Config.setup_dap()
|
||||
Config.setup_dap = nil
|
||||
vim.pack.add({ "https://github.com/mfussenegger/nvim-dap" })
|
||||
|
||||
local dap = require("dap")
|
||||
dap.adapters.go = {
|
||||
type = "server",
|
||||
host = "127.0.0.1",
|
||||
port = "${port}",
|
||||
local dap_signs = {
|
||||
DapBreakpoint = { text = '', texthl = 'DapBreakpoint' },
|
||||
DapBreakpointCondition = { text = '', texthl = 'DapBreakpointCondition' },
|
||||
DapLogPoint = { text = '', texthl = 'DapLogPoint' },
|
||||
DapStopped = { text = '', texthl = 'DapStopped', linehl = 'DapStoppedLine' },
|
||||
DapBreakpointRejected = { text = '', texthl = 'DapBreakpointRejected' },
|
||||
}
|
||||
for name, sign in pairs(dap_signs) do
|
||||
vim.fn.sign_define(name, sign)
|
||||
end
|
||||
|
||||
local dap = require("dap")
|
||||
dap.adapters.go = { type = "server", host = "127.0.0.1", port = "${port}" }
|
||||
end
|
||||
|
||||
-- Kulala ======================================================================
|
||||
|
||||
Reference in New Issue
Block a user