Added more editor features to support Golang, sql and git

This commit is contained in:
2026-01-19 19:31:11 -07:00
parent a9b956e141
commit 3b41bd1552
16 changed files with 184 additions and 46 deletions

View File

@@ -114,3 +114,29 @@ autocmd("DirChanged", {
end
end,
})
-- Golang AutoOpen PProf
autocmd("BufRead", {
pattern = { "cpu.out", "mem.out", "trace.out" },
callback = function(args)
local name = vim.fn.fnamemodify(args.file, ":t")
vim.notify(
"Generated " .. name .. ". Use: `go tool pprof -http=:0 " .. name .. "` or `go tool trace " .. name .. "`",
vim.log.levels.INFO)
end,
})
-- SQL files
autocmd("FileType", {
pattern = { "sql", "mysql", "plsql" },
callback = function()
local cmp = require("cmp")
cmp.setup.buffer({
sources = {
{ name = "vim-dadbod" },
{ name = "nvim_lsp" },
{ name = "buffer" },
},
})
end,
})

View File

@@ -83,11 +83,17 @@ map("n", "<leader>tc", "<cmd>Coverage<cr>", { desc = "Show coverage" })
-- Go benchmark
map("n", "<leader>gb", function()
vim.cmd("!go test -bench . ./...")
vim.cmd("!go test -bench=. -benchmem ./...")
end, { desc = "Go benchmarks" })
map("n", "<leader>gp", function()
vim.cmd("!go test -cpuprofile cpu.out && go tool pprof cpu.out")
map("n", "<leader>gpc", function()
vim.cmd("!go test -run=^$ -bench=. -cpuprofile cpu.out ./...")
end, { desc = "Go CPU profile" })
map("n", "<leadger>gpm", function()
vim.cmd("!go test -run=^$ -bench=. -memprofile mem.out ./...")
end, { desc = "Go memory profile" })
map("n", "<leader>gpt", function()
vim.cmd("!go test -run=^$ -bench. -trace trace.out ./...")
end, { desc = "Go trace profile" })
-- Overseer
map("n", "<leader>or", "<cmd>OverseerRun<cr>", { desc = "Run task" })
@@ -102,3 +108,6 @@ map("n", "<leader>sc", vim.lsp.buf.outgoing_calls, { desc = "Outgoing calls" })
map("n", "<leader>xx", "<cmd>Trouble diagnostics toggle<cr>")
map("n", "<leader>xw", "<cmd>Trouble workspace_diagnostics<cr>")
map("n", "<leader>xt", "<cmd>Trouble todo<cr>")
-- Git Support
map("n", "<leader>gg", "<cmd>Neogit<cr>", { desc = "Neogit"})

View File

@@ -1,8 +0,0 @@
return {
name = "go test",
builder = function()
return {
cmd = { "go", "test", "./..." },
}
end,
}

View File

@@ -0,0 +1,15 @@
return {
name = "go: benchmarks",
desc = "Run Go benchmarks with memory stats",
builder = function()
return {
cmd = { "go", "test" },
args = { "-bench=.", "-benchmem", "./..." },
components = {
"default",
"on_output_quickfix",
{ "on_complete_notify", statuses = { "SUCCESS", "FAILURE" } },
},
}
end,
}

View File

@@ -0,0 +1,20 @@
return {
name = "go: cpu profile",
desc = "Generate CPU profile (cpu.out)",
builder = function()
return {
cmd = { "go", "test" },
args = {
"-run=^$",
"-bench=.",
"-cpuprofile=cpu.out",
"./...",
},
components = {
"default",
"on_output_quickfix",
{ "on_complete_notify", statuses = { "SUCCESS" } },
},
}
end,
}

View File

@@ -0,0 +1,20 @@
return {
name = "go: mem profile",
desc = "Generate heap profile (mem.out)",
builder = function()
return {
cmd = { "go", "test" },
args = {
"-run=^$",
"-bench=.",
"-memprofile=mem.out",
"./...",
},
components = {
"default",
"on_output_quickfix",
{ "on_complete_notify", statuses = { "SUCCESS" } },
},
}
end,
}

View File

@@ -0,0 +1,10 @@
return {
name = "go test",
desc = "Run all tests",
builder = function()
return {
cmd = { "go", "test" },
args = { "./..." },
}
end,
}

View File

@@ -0,0 +1,20 @@
return {
name = "go: trace",
desc = "Generate execution trace (trace.out)",
builder = function()
return {
cmd = { "go", "test" },
args = {
"-run=^$",
"-bench=.",
"-trace=trace.out",
"./...",
},
components = {
"default",
"on_output_quickfix",
{ "on_complete_notify", statuses = { "SUCCESS" } },
},
}
end,
}

View File

@@ -74,6 +74,7 @@ return {
optional = true,
dependencies = {
"kristijanhusak/vim-dadbod-completion",
"nvim-cmp",
},
opts = function(_, opts)
opts.sources = opts.sources or {}

View File

@@ -46,9 +46,9 @@ return {
["markdown.mdx"] = { "prettier" },
-- SQL
sql = { "sql_formatter" },
mysql = { "sql_formatter" },
plsql = { "sql_formatter" },
sql = { "sql_formatter", "sqlfluff", "pg_format" },
mysql = { "sql_formatter", "sqlfluff" },
plsql = { "sql_formatter", "sqlfluff", "pg_format" },
-- Makefile (no formatter - they require tabs)
-- make = {},

15
lua/plugins/git.lua Normal file
View File

@@ -0,0 +1,15 @@
return {
{
"NeogitOrg/neogit",
dependencies = {
"nvim-lua/plenary.nvim",
"sindrets/diffview.nvim",
},
cmd = "Neogit",
opts = {
integrations = {
diffview = true,
},
},
},
}

View File

@@ -1,10 +0,0 @@
return {
{
"davecheney/profile",
ft = "go",
},
{
"rbong/vim-flog",
cmd = { "Flog" },
},
}

View File

@@ -1,6 +0,0 @@
return {
{
"nvim-neotest/neotest-python",
dependencies = { "nvim-neotest/neotest" },
},
}

View File

@@ -5,15 +5,28 @@ return {
"nvim-neotest/nvim-nio",
"nvim-lua/plenary.nvim",
"antoinemadec/FixCursorHold.nvim",
-- Adapters
"nvim-neotest/neotest-go",
"nvim-neotest/neotest-python",
},
opts = {
adapters = {
require("neotest-go"),
require("neotest-python")({
dap = { justMyCode = false },
}),
},
},
config = function()
require("neotest").setup({
adapters = {
require("neotest-go")({
experimental = {
test_table = true,
},
args = { "-count=1", "-race" },
}),
require("neotest-python")({
dap = { justMyCode = false },
args = { "--disable-warnings", "-q" },
}),
},
})
end,
},
}

View File

@@ -2,7 +2,7 @@ return {
{
"stevearc/overseer.nvim",
opts = {
templates = { "builtin", "user.go", "user.npm" }
templates = { "builtin", "user" }
},
},
}