mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-07-10 01:14:30 +02:00
add: migrate go format & lint
This commit is contained in:
parent
39b6c22356
commit
33fe8d43df
5 changed files with 49 additions and 9 deletions
|
@ -157,10 +157,10 @@ pcode.active_javascript_config = {
|
|||
jest_config = "jest.config.mjs",
|
||||
}
|
||||
pcode.active_php_config = true
|
||||
pcode.active_golang_config = false
|
||||
pcode.active_golang_config = true
|
||||
pcode.active_python_config = false
|
||||
pcode.active_cpp_config = true
|
||||
pcode.active_cpp_config = false
|
||||
pcode.active_java_config = {
|
||||
active = true,
|
||||
active = false,
|
||||
project = "gradle", -- gradle or maven
|
||||
}
|
||||
|
|
|
@ -134,6 +134,45 @@ if pcode.active_golang_config then
|
|||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-lint",
|
||||
events = { "BufWritePost", "BufReadPost", "InsertLeave" },
|
||||
opts = function(_, opts)
|
||||
opts.linters_by_ft = opts.linters_by_ft or {}
|
||||
opts.linters_by_ft.go = { "golangcilint" }
|
||||
return opts
|
||||
end,
|
||||
config = function(_, opts)
|
||||
require("lint").linters_by_ft = opts.linters_by_ft
|
||||
end,
|
||||
},
|
||||
{
|
||||
"stevearc/conform.nvim",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
opts = function(_, opts)
|
||||
local psave = pcode.format_on_save or 0
|
||||
opts.formatters_by_ft = opts.formatters_by_ft or {}
|
||||
opts.formatters_by_ft.go = { "gofmt" }
|
||||
if psave == 1 then
|
||||
opts.format_on_save = {
|
||||
timeout_ms = pcode.format_timeout_ms or 500,
|
||||
lsp_fallback = true,
|
||||
}
|
||||
end
|
||||
return opts
|
||||
end,
|
||||
config = function(_, opts)
|
||||
local conform = require("conform")
|
||||
conform.setup(opts)
|
||||
vim.keymap.set({ "n", "v" }, "<leader>lF", function()
|
||||
conform.format({
|
||||
lsp_fallback = true,
|
||||
async = false,
|
||||
timeout_ms = pcode.format_timeout_ms or 500,
|
||||
})
|
||||
end, { desc = "Format file or range (in visual mode)" })
|
||||
end,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ if pcode.active_php_config then
|
|||
conform.format({
|
||||
lsp_fallback = true,
|
||||
async = false,
|
||||
timeout_ms = 500,
|
||||
timeout_ms = pcode.format_timeout_ms or 500,
|
||||
})
|
||||
end, { desc = "Format file or range (in visual mode)" })
|
||||
end,
|
||||
|
|
|
@ -59,8 +59,6 @@ if pcode.active_golang_config then
|
|||
table.insert(pcode.treesitter_ensure_installed, ts)
|
||||
end
|
||||
table.insert(pcode.mason_ensure_installed, "gopls")
|
||||
table.insert(pcode.null_ls_ensure_installed, "ast_grep")
|
||||
table.insert(pcode.null_ls_ensure_installed, "gofumpt")
|
||||
end
|
||||
-- run if python config true
|
||||
if pcode.active_python_config then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue