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",
|
"stevearc/conform.nvim",
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
opts = {
|
opts = {
|
||||||
|
-- log_level = vim.log.levels.DEBUG,
|
||||||
|
|
||||||
-- See aviable formatters in: https://github.com/stevearc/conform.nvim#formatters
|
-- See aviable formatters in: https://github.com/stevearc/conform.nvim#formatters
|
||||||
-- Formatters can be installed by mason
|
-- Formatters can be installed by mason
|
||||||
formatters_by_ft = {
|
formatters_by_ft = {
|
||||||
-- Conform will run multiple formatters sequentially
|
-- 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
|
-- Use the "_" filetype to run formatters on filetypes that don't
|
||||||
-- have other formatters configured.
|
-- have other formatters configured.
|
||||||
["_"] = { "trim_whitespace" },
|
["_"] = { "trim_whitespace", "injected" },
|
||||||
blade = { "blade-formatter" },
|
blade = { "blade-formatter" },
|
||||||
css = { { "prettierd", "prettier" } },
|
css = { "prettierd", "prettier" },
|
||||||
go = { { "gofumpt", "goimports_reviser", "golines" } },
|
go = { "gofumpt", "goimports_reviser", "golines" },
|
||||||
html = { "prettierd" },
|
html = { "djlint", "prettierd", stop_after_first = true },
|
||||||
javascript = { { "prettierd", "prettier" } },
|
javascript = { "prettierd", "prettier", stop_after_first = true },
|
||||||
javascriptreact = { { "prettierd", "prettier" } },
|
javascriptreact = { "prettierd", "prettier", stop_after_first = true },
|
||||||
json = { { "prettierd", "prettier" } },
|
json = { "prettierd", "prettier", stop_after_first = true },
|
||||||
jsonc = { { "prettierd", "prettier" } },
|
jsonc = { "prettierd", "prettier", stop_after_first = true },
|
||||||
lua = { "stylua" },
|
lua = { "stylua" },
|
||||||
markdown = { "markdownlint" },
|
markdown = { "markdownlint" },
|
||||||
nim = { "nimpretty" },
|
nim = { "nimpretty" },
|
||||||
php = { "pint" },
|
php = { "pint" },
|
||||||
python = { "blue" },
|
python = { "blue" },
|
||||||
scss = { { "prettierd", "prettier" } },
|
scss = { "prettierd", "prettier", stop_after_first = true },
|
||||||
sh = { "shfmt" },
|
sh = { "shfmt" },
|
||||||
typescript = { { "prettierd", "prettier" } },
|
typescript = { "prettierd", "prettier", stop_after_first = true },
|
||||||
typescriptreact = { { "prettierd", "prettier" } },
|
typescriptreact = { "prettierd", "prettier", stop_after_first = true },
|
||||||
xml = { "lemminx" },
|
xml = { "lemminx" },
|
||||||
zsh = { "shfmt" }
|
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)
|
format_on_save = function(bufnr)
|
||||||
-- Disable with a global or buffer-local variable
|
-- Disable with a global or buffer-local variable
|
||||||
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
return { timeout_ms = 2000, lsp_fallback = true }
|
return { timeout_ms = 2000, lsp_fallback = true }
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
@ -45,15 +64,17 @@ return {
|
||||||
-- to make this global, change b to g
|
-- to make this global, change b to g
|
||||||
if vim.b.disable_autoformat == nil then
|
if vim.b.disable_autoformat == nil then
|
||||||
vim.b.disable_autoformat = true
|
vim.b.disable_autoformat = true
|
||||||
|
print("Autoformat set to: " .. tostring(not vim.b.disable_autoformat))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.b.disable_autoformat = not vim.b.disable_autoformat
|
vim.b.disable_autoformat = not vim.b.disable_autoformat
|
||||||
|
print("Autoformat set to: " .. tostring(not vim.b.disable_autoformat))
|
||||||
end
|
end
|
||||||
|
|
||||||
MAP("n", "<leader>uf", toggleAutoFormat, "Toggle auto format")
|
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
|
local range = nil
|
||||||
if args.count ~= -1 then
|
if args.count ~= -1 then
|
||||||
local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1]
|
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"] = { args.line2, end_line:len() },
|
||||||
}
|
}
|
||||||
end
|
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,
|
end,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,10 @@ return {
|
||||||
auto_enable = true,
|
auto_enable = true,
|
||||||
lsp = true,
|
lsp = true,
|
||||||
},
|
},
|
||||||
|
keys = {
|
||||||
|
{ "<leader>uc", "<CMD>CccPick<CR>", desc = "Open Color picker" },
|
||||||
|
{ "<leader>uC", "<CMD>CccHighlighterToggle<CR>", desc = "Toggle Color highlight" },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
-- Dotfiles management
|
-- Dotfiles management
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,26 @@ return {
|
||||||
bashls = {},
|
bashls = {},
|
||||||
cssls = {},
|
cssls = {},
|
||||||
dockerls = {},
|
dockerls = {},
|
||||||
emmet_ls = {},
|
emmet_ls = {
|
||||||
|
filetypes = {
|
||||||
|
"astro",
|
||||||
|
"css",
|
||||||
|
"eruby",
|
||||||
|
"html",
|
||||||
|
"htmldjango",
|
||||||
|
"javascriptreact",
|
||||||
|
"less",
|
||||||
|
"pug",
|
||||||
|
"sass",
|
||||||
|
"scss",
|
||||||
|
"svelte",
|
||||||
|
"typescriptreact",
|
||||||
|
"vue",
|
||||||
|
"htmlangular",
|
||||||
|
"php",
|
||||||
|
"blade"
|
||||||
|
},
|
||||||
|
},
|
||||||
html = {},
|
html = {},
|
||||||
marksman = {},
|
marksman = {},
|
||||||
pyright = {},
|
pyright = {},
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@ return {
|
||||||
event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" },
|
event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" },
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||||
"windwp/nvim-ts-autotag",
|
|
||||||
"JoosepAlviste/nvim-ts-context-commentstring",
|
"JoosepAlviste/nvim-ts-context-commentstring",
|
||||||
"nvim-treesitter/nvim-treesitter-context",
|
"nvim-treesitter/nvim-treesitter-context",
|
||||||
|
{ "windwp/nvim-ts-autotag", opts = {} },
|
||||||
},
|
},
|
||||||
build = ":TSUpdate",
|
build = ":TSUpdate",
|
||||||
config = function()
|
config = function()
|
||||||
|
|
@ -82,7 +82,7 @@ return {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
autotag = { enable = true },
|
-- autotag = { enable = true },
|
||||||
})
|
})
|
||||||
|
|
||||||
require('ts_context_commentstring').setup {
|
require('ts_context_commentstring').setup {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||||
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
||||||
"comment-box.nvim": { "branch": "main", "commit": "06bb771690bc9df0763d14769b779062d8f12bc5" },
|
"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" },
|
"debugprint.nvim": { "branch": "main", "commit": "8f2a335fb0e6ebf0291a3551e0198363437e3a38" },
|
||||||
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
|
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
|
||||||
"dressing.nvim": { "branch": "master", "commit": "6741f1062d3dc6e4755367a7e9b347b553623f04" },
|
"dressing.nvim": { "branch": "master", "commit": "6741f1062d3dc6e4755367a7e9b347b553623f04" },
|
||||||
|
|
@ -73,4 +73,4 @@
|
||||||
"vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" },
|
"vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" },
|
||||||
"vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" },
|
"vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" },
|
||||||
"zen-mode.nvim": { "branch": "main", "commit": "2694c5a2bc4dc26c7a9e74b9e2b812920c90a830" }
|
"zen-mode.nvim": { "branch": "main", "commit": "2694c5a2bc4dc26c7a9e74b9e2b812920c90a830" }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ unbind '"' # Split horizontally
|
||||||
|
|
||||||
bind s split-window -h -c "#{pane_current_path}"
|
bind s split-window -h -c "#{pane_current_path}"
|
||||||
bind v split-window -v -c "#{pane_current_path}"
|
bind v split-window -v -c "#{pane_current_path}"
|
||||||
bind D kill-pane
|
bind D respawn-pane -k
|
||||||
|
|
||||||
bind -r m resize-pane -Z # maximize pane
|
bind -r m resize-pane -Z # maximize pane
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue