update php support in nvim
This commit is contained in:
parent
e2e7946c6e
commit
5d48f27304
6 changed files with 96 additions and 21 deletions
|
|
@ -2,39 +2,58 @@ return {
|
|||
"stevearc/conform.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = {
|
||||
-- log_level = vim.log.levels.DEBUG,
|
||||
|
||||
-- See aviable formatters in: https://github.com/stevearc/conform.nvim#formatters
|
||||
-- Formatters can be installed by mason
|
||||
formatters_by_ft = {
|
||||
-- Conform will run multiple formatters sequentially
|
||||
-- Use a sub-list to run only the first available formatter
|
||||
-- Use a stop_after_first = true to run only the first available formatter
|
||||
-- Use the "_" filetype to run formatters on filetypes that don't
|
||||
-- have other formatters configured.
|
||||
["_"] = { "trim_whitespace" },
|
||||
["_"] = { "trim_whitespace", "injected" },
|
||||
blade = { "blade-formatter" },
|
||||
css = { { "prettierd", "prettier" } },
|
||||
go = { { "gofumpt", "goimports_reviser", "golines" } },
|
||||
html = { "prettierd" },
|
||||
javascript = { { "prettierd", "prettier" } },
|
||||
javascriptreact = { { "prettierd", "prettier" } },
|
||||
json = { { "prettierd", "prettier" } },
|
||||
jsonc = { { "prettierd", "prettier" } },
|
||||
css = { "prettierd", "prettier" },
|
||||
go = { "gofumpt", "goimports_reviser", "golines" },
|
||||
html = { "djlint", "prettierd", stop_after_first = true },
|
||||
javascript = { "prettierd", "prettier", stop_after_first = true },
|
||||
javascriptreact = { "prettierd", "prettier", stop_after_first = true },
|
||||
json = { "prettierd", "prettier", stop_after_first = true },
|
||||
jsonc = { "prettierd", "prettier", stop_after_first = true },
|
||||
lua = { "stylua" },
|
||||
markdown = { "markdownlint" },
|
||||
nim = { "nimpretty" },
|
||||
php = { "pint" },
|
||||
python = { "blue" },
|
||||
scss = { { "prettierd", "prettier" } },
|
||||
scss = { "prettierd", "prettier", stop_after_first = true },
|
||||
sh = { "shfmt" },
|
||||
typescript = { { "prettierd", "prettier" } },
|
||||
typescriptreact = { { "prettierd", "prettier" } },
|
||||
typescript = { "prettierd", "prettier", stop_after_first = true },
|
||||
typescriptreact = { "prettierd", "prettier", stop_after_first = true },
|
||||
xml = { "lemminx" },
|
||||
zsh = { "shfmt" }
|
||||
},
|
||||
formatters = {
|
||||
djlint = {
|
||||
prepend_args = {
|
||||
"--format-css",
|
||||
"--indent-css",
|
||||
"2",
|
||||
"--format-js",
|
||||
"--indent-js",
|
||||
"2",
|
||||
"--indent",
|
||||
"2",
|
||||
"--preserve-blank-lines",
|
||||
"--quiet"
|
||||
}
|
||||
}
|
||||
},
|
||||
format_on_save = function(bufnr)
|
||||
-- Disable with a global or buffer-local variable
|
||||
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
||||
return
|
||||
end
|
||||
|
||||
return { timeout_ms = 2000, lsp_fallback = true }
|
||||
end,
|
||||
},
|
||||
|
|
@ -45,15 +64,17 @@ return {
|
|||
-- to make this global, change b to g
|
||||
if vim.b.disable_autoformat == nil then
|
||||
vim.b.disable_autoformat = true
|
||||
print("Autoformat set to: " .. tostring(not vim.b.disable_autoformat))
|
||||
return
|
||||
end
|
||||
|
||||
vim.b.disable_autoformat = not vim.b.disable_autoformat
|
||||
print("Autoformat set to: " .. tostring(not vim.b.disable_autoformat))
|
||||
end
|
||||
|
||||
MAP("n", "<leader>uf", toggleAutoFormat, "Toggle auto format")
|
||||
|
||||
vim.api.nvim_create_user_command("Format", function(args)
|
||||
vim.api.nvim_create_user_command("Fmt", function(args)
|
||||
local range = nil
|
||||
if args.count ~= -1 then
|
||||
local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1]
|
||||
|
|
@ -62,7 +83,38 @@ return {
|
|||
["end"] = { args.line2, end_line:len() },
|
||||
}
|
||||
end
|
||||
require("conform").format({ async = true, lsp_format = "fallback", range = range })
|
||||
end, { range = true })
|
||||
|
||||
local function callback(err, did_edit)
|
||||
if not did_edit then
|
||||
vim.notify("The file was not formatted:\n" .. tostring(err), vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
if args.bang then
|
||||
vim.cmd("w")
|
||||
end
|
||||
end
|
||||
|
||||
require("conform").format(
|
||||
{
|
||||
async = true,
|
||||
lsp_format = "fallback",
|
||||
range = range,
|
||||
formatters = args.fargs
|
||||
},
|
||||
callback
|
||||
)
|
||||
end, {
|
||||
range = true,
|
||||
bang = true,
|
||||
force = true,
|
||||
desc = "Format the document",
|
||||
nargs = '*',
|
||||
-- complete = function()
|
||||
-- local formatters = require('conform').formatters_by_ft
|
||||
--
|
||||
-- return vim.tbl_keys(formatters)
|
||||
-- end
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,10 @@ return {
|
|||
auto_enable = true,
|
||||
lsp = true,
|
||||
},
|
||||
keys = {
|
||||
{ "<leader>uc", "<CMD>CccPick<CR>", desc = "Open Color picker" },
|
||||
{ "<leader>uC", "<CMD>CccHighlighterToggle<CR>", desc = "Toggle Color highlight" },
|
||||
},
|
||||
},
|
||||
-- Dotfiles management
|
||||
{
|
||||
|
|
|
|||
|
|
@ -56,7 +56,26 @@ return {
|
|||
bashls = {},
|
||||
cssls = {},
|
||||
dockerls = {},
|
||||
emmet_ls = {},
|
||||
emmet_ls = {
|
||||
filetypes = {
|
||||
"astro",
|
||||
"css",
|
||||
"eruby",
|
||||
"html",
|
||||
"htmldjango",
|
||||
"javascriptreact",
|
||||
"less",
|
||||
"pug",
|
||||
"sass",
|
||||
"scss",
|
||||
"svelte",
|
||||
"typescriptreact",
|
||||
"vue",
|
||||
"htmlangular",
|
||||
"php",
|
||||
"blade"
|
||||
},
|
||||
},
|
||||
html = {},
|
||||
marksman = {},
|
||||
pyright = {},
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ return {
|
|||
event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" },
|
||||
dependencies = {
|
||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||
"windwp/nvim-ts-autotag",
|
||||
"JoosepAlviste/nvim-ts-context-commentstring",
|
||||
"nvim-treesitter/nvim-treesitter-context",
|
||||
{ "windwp/nvim-ts-autotag", opts = {} },
|
||||
},
|
||||
build = ":TSUpdate",
|
||||
config = function()
|
||||
|
|
@ -82,7 +82,7 @@ return {
|
|||
},
|
||||
},
|
||||
},
|
||||
autotag = { enable = true },
|
||||
-- autotag = { enable = true },
|
||||
})
|
||||
|
||||
require('ts_context_commentstring').setup {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
||||
"comment-box.nvim": { "branch": "main", "commit": "06bb771690bc9df0763d14769b779062d8f12bc5" },
|
||||
"conform.nvim": { "branch": "master", "commit": "cd75be867f2331b22905f47d28c0c270a69466aa" },
|
||||
"conform.nvim": { "branch": "master", "commit": "0ebe875d9c306f5fc829db38492ffff2a70d8e9d" },
|
||||
"debugprint.nvim": { "branch": "main", "commit": "8f2a335fb0e6ebf0291a3551e0198363437e3a38" },
|
||||
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
|
||||
"dressing.nvim": { "branch": "master", "commit": "6741f1062d3dc6e4755367a7e9b347b553623f04" },
|
||||
|
|
@ -73,4 +73,4 @@
|
|||
"vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" },
|
||||
"vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" },
|
||||
"zen-mode.nvim": { "branch": "main", "commit": "2694c5a2bc4dc26c7a9e74b9e2b812920c90a830" }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue