Added more editor features to support Golang, sql and git
This commit is contained in:
@@ -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,
|
||||
})
|
||||
|
||||
@@ -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"})
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
return {
|
||||
name = "go test",
|
||||
builder = function()
|
||||
return {
|
||||
cmd = { "go", "test", "./..." },
|
||||
}
|
||||
end,
|
||||
}
|
||||
15
lua/overseer/template/user/go_bench.lua
Normal file
15
lua/overseer/template/user/go_bench.lua
Normal 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,
|
||||
}
|
||||
20
lua/overseer/template/user/go_cpu_profile.lua
Normal file
20
lua/overseer/template/user/go_cpu_profile.lua
Normal 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,
|
||||
}
|
||||
20
lua/overseer/template/user/go_mem_profile.lua
Normal file
20
lua/overseer/template/user/go_mem_profile.lua
Normal 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,
|
||||
}
|
||||
10
lua/overseer/template/user/go_test.lua
Normal file
10
lua/overseer/template/user/go_test.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
return {
|
||||
name = "go test",
|
||||
desc = "Run all tests",
|
||||
builder = function()
|
||||
return {
|
||||
cmd = { "go", "test" },
|
||||
args = { "./..." },
|
||||
}
|
||||
end,
|
||||
}
|
||||
20
lua/overseer/template/user/go_trace.lua
Normal file
20
lua/overseer/template/user/go_trace.lua
Normal 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,
|
||||
}
|
||||
@@ -74,6 +74,7 @@ return {
|
||||
optional = true,
|
||||
dependencies = {
|
||||
"kristijanhusak/vim-dadbod-completion",
|
||||
"nvim-cmp",
|
||||
},
|
||||
opts = function(_, opts)
|
||||
opts.sources = opts.sources or {}
|
||||
|
||||
@@ -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
15
lua/plugins/git.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
return {
|
||||
{
|
||||
"NeogitOrg/neogit",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"sindrets/diffview.nvim",
|
||||
},
|
||||
cmd = "Neogit",
|
||||
opts = {
|
||||
integrations = {
|
||||
diffview = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
return {
|
||||
{
|
||||
"davecheney/profile",
|
||||
ft = "go",
|
||||
},
|
||||
{
|
||||
"rbong/vim-flog",
|
||||
cmd = { "Flog" },
|
||||
},
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
return {
|
||||
{
|
||||
"nvim-neotest/neotest-python",
|
||||
dependencies = { "nvim-neotest/neotest" },
|
||||
},
|
||||
}
|
||||
@@ -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,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ return {
|
||||
{
|
||||
"stevearc/overseer.nvim",
|
||||
opts = {
|
||||
templates = { "builtin", "user.go", "user.npm" }
|
||||
templates = { "builtin", "user" }
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user