mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-29 04:00:05 +02:00
enc: add formattrer & linter for php config
This commit is contained in:
parent
b28f354786
commit
13e2e75069
5 changed files with 63 additions and 3 deletions
|
@ -156,7 +156,7 @@ pcode.active_javascript_config = {
|
|||
jest_command = "npm test -- ",
|
||||
jest_config = "jest.config.mjs",
|
||||
}
|
||||
pcode.active_php_config = false
|
||||
pcode.active_php_config = true
|
||||
pcode.active_golang_config = false
|
||||
pcode.active_python_config = false
|
||||
pcode.active_cpp_config = true
|
||||
|
|
|
@ -106,6 +106,45 @@ if pcode.active_php_config then
|
|||
{ "<Leader>TS", function() require("neotest").run.stop() end, desc = "Stop" },
|
||||
},
|
||||
},
|
||||
{
|
||||
"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.php = { "php-cs-fixer" }
|
||||
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 = 500,
|
||||
})
|
||||
end, { desc = "Format file or range (in visual mode)" })
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-lint",
|
||||
events = { "BufWritePost", "BufReadPost", "InsertLeave" },
|
||||
opts = {
|
||||
linters_by_ft = {
|
||||
php = { "phpcs" },
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("lint").linters_by_ft = opts.linters_by_ft
|
||||
end,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -51,8 +51,6 @@ if pcode.active_php_config then
|
|||
table.insert(pcode.treesitter_ensure_installed, ts)
|
||||
end
|
||||
table.insert(pcode.mason_ensure_installed, "intelephense")
|
||||
table.insert(pcode.null_ls_ensure_installed, "phpcbf")
|
||||
table.insert(pcode.null_ls_ensure_installed, "phpcs")
|
||||
end
|
||||
-- run if golang config true
|
||||
if pcode.active_golang_config then
|
||||
|
|
|
@ -128,6 +128,24 @@ return {
|
|||
local supported_linters = linter.linter_list_registered(buf_ft)
|
||||
vim.list_extend(buf_client_names, supported_linters)
|
||||
|
||||
-- add nvim-lint
|
||||
local lint_s, lint = pcall(require, "lint")
|
||||
if lint_s then
|
||||
for ft_k, ft_v in pairs(lint.linters_by_ft) do
|
||||
if type(ft_v) == "table" then
|
||||
for _, lntr in ipairs(ft_v) do
|
||||
if buf_ft == ft_k then
|
||||
table.insert(buf_client_names, lntr)
|
||||
end
|
||||
end
|
||||
elseif type(ft_v) == "string" then
|
||||
if buf_ft == ft_k then
|
||||
table.insert(buf_client_names, ft_v)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- decomple
|
||||
-- local unique_client_names = vim.fn.uniq(buf_client_names)
|
||||
local unique_client_names = unique_list(buf_client_names)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue