Adding php to lsp
This commit is contained in:
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
test.*
|
||||||
|
.eslintrc
|
||||||
|
.prettierrc
|
||||||
|
lazy-lock.json
|
||||||
@@ -16,3 +16,4 @@ require("config/lsp/lsp-signs")
|
|||||||
require("config/lsp/bash")
|
require("config/lsp/bash")
|
||||||
require("config/lsp/lua")
|
require("config/lsp/lua")
|
||||||
require("config/lsp/web")
|
require("config/lsp/web")
|
||||||
|
require("config/lsp/php")
|
||||||
|
|||||||
62
lua/config/lsp/php.lua
Normal file
62
lua/config/lsp/php.lua
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
local ok, mason_lspconfig, mason_tool_installer, lspconfig, conform, lint = pcall(function()
|
||||||
|
return require("mason-lspconfig"),
|
||||||
|
require("mason-tool-installer"),
|
||||||
|
require("lspconfig"),
|
||||||
|
require("conform"),
|
||||||
|
require("lint")
|
||||||
|
end)
|
||||||
|
|
||||||
|
if not ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
mason_lspconfig.setup({
|
||||||
|
ensure_installed = {
|
||||||
|
"phpactor",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
lspconfig.phpactor.setup({
|
||||||
|
capabilities = require("config/lsp/lsp-capabilities"),
|
||||||
|
on_attach = require("config/lsp/lsp-attach"),
|
||||||
|
})
|
||||||
|
|
||||||
|
mason_tool_installer.setup({
|
||||||
|
ensure_installed = {
|
||||||
|
"php-cs-fixer",
|
||||||
|
"phpcs",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
conform.setup({
|
||||||
|
formatters_by_ft = {
|
||||||
|
php = { "php-cs-fixer" },
|
||||||
|
},
|
||||||
|
format_on_save = {
|
||||||
|
async = false,
|
||||||
|
timeout_ms = 500,
|
||||||
|
lsp_fallback = true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.keymap.set({ "n", "v" }, "<leader>lf", function()
|
||||||
|
conform.format({
|
||||||
|
async = false,
|
||||||
|
timeout_ms = 500,
|
||||||
|
lsp_fallback = true,
|
||||||
|
})
|
||||||
|
end, { desc = "Format" })
|
||||||
|
|
||||||
|
lint.linters_by_ft = {
|
||||||
|
phpcs = { "phpcs" },
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
|
||||||
|
callback = function()
|
||||||
|
lint.try_lint()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>ll", function()
|
||||||
|
lint.try_lint()
|
||||||
|
end, { desc = "Lint" })
|
||||||
@@ -17,12 +17,12 @@ _RESET="\e[0m"
|
|||||||
_title() {
|
_title() {
|
||||||
printf "$_CR$_E1$_BOLD$_BLACK$1"
|
printf "$_CR$_E1$_BOLD$_BLACK$1"
|
||||||
[[ ! -z $3 ]] && printf "$_E_RIGHT"
|
[[ ! -z $3 ]] && printf "$_E_RIGHT"
|
||||||
for (( i=0; i<(( 10 - ${#2} / 2 )); i++ ))
|
for (( i=0 ; i < 10 - ${#2} / 2 ; i++ ))
|
||||||
do
|
do
|
||||||
printf " "
|
printf " "
|
||||||
done
|
done
|
||||||
printf "$2"
|
printf "$2"
|
||||||
for (( i=0; i<(( 10 - ${#2} / 2 )); i++ ))
|
for (( i=0 ; i < 10 - ${#2} / 2 ; i++ ))
|
||||||
do
|
do
|
||||||
printf " "
|
printf " "
|
||||||
done
|
done
|
||||||
@@ -32,7 +32,7 @@ _title() {
|
|||||||
|
|
||||||
# _shortcut [string:modifier] [string:key] [string:message] [bool:right]
|
# _shortcut [string:modifier] [string:key] [string:message] [bool:right]
|
||||||
_shortcut() {
|
_shortcut() {
|
||||||
_MODIFIER=$(sed "s|+|\\\e[38;5;1m+\\\e[38;5;5m|g" <<< $1)
|
_MODIFIER="$(sed "s|+|\\\e[38;5;1m+\\\e[38;5;5m|g" <<< "$1")"
|
||||||
[[ ! -z $4 ]] && printf "$_E_RIGHT"
|
[[ ! -z $4 ]] && printf "$_E_RIGHT"
|
||||||
printf "$_E2"
|
printf "$_E2"
|
||||||
printf "$_PURPLE$_MODIFIER$_RESET"
|
printf "$_PURPLE$_MODIFIER$_RESET"
|
||||||
@@ -82,4 +82,4 @@ _title "\e[48;5;204m" "Visual mode"
|
|||||||
|
|
||||||
_title "\e[48;5;214m" "not finished yet"
|
_title "\e[48;5;214m" "not finished yet"
|
||||||
|
|
||||||
read -n 1 -s
|
read -r -n 1 -s
|
||||||
|
|||||||
Reference in New Issue
Block a user