feat(LSP): Add PHP parser, remap LSP keybindings

This commit is contained in:
Калистратов Максим
2026-06-01 12:52:53 +03:00
parent fd3267ca21
commit c00508b08d
8 changed files with 80 additions and 5 deletions

View File

@@ -0,0 +1,12 @@
---@type vim.lsp.Config
return {
root_markers = { "composer.json" },
---@type lspconfig.settings.intelephense
settings = {
intelephense = {
environment = {
phpVersion = "8.3.30",
},
},
},
}

View File

@@ -16,8 +16,3 @@ telescope.setup(options)
utils.nmap("<leader>ff", builtin.find_files, "Find Files")
utils.nmap("<leader>fg", builtin.live_grep, "Live Grep")
utils.nmap("<leader>fr", builtin.lsp_references, "LSP References")
utils.nmap("<leader>fi", builtin.lsp_implementations, "LSP Implementations")
utils.nmap("<leader>fs", builtin.lsp_document_symbols, "LSP Document Symbols")
utils.nmap("<leader>fS", builtin.lsp_dynamic_workspace_symbols, "LSP Workspace Symbols")

View File

@@ -0,0 +1,3 @@
local which_key = require("which-key")
which_key.setup()

View File

@@ -6,6 +6,7 @@ require("lsp")
require("completion")
require("formatting")
require("colorscheme")
require("highlighting")
local opt = vim.opt
@@ -36,6 +37,7 @@ opt.sidescrolloff = 8
opt.wrap = false
opt.colorcolumn = "120"
vim.o.background = "light"
vim.cmd("colorscheme rose-pine")
-- Splits

16
lua/highlighting.lua Normal file
View File

@@ -0,0 +1,16 @@
local manager = require("tree-sitter-manager")
---@type tree-sitter-manager.Config
local options = {
ensure_installed = {
"php",
"html",
"html_tags",
"ecma",
"typescript",
"vue",
"blade",
},
}
manager.setup(options)

View File

@@ -1,7 +1,42 @@
local utils = require("utils")
require("mason").setup({})
require("mason-lspconfig").setup({
ensure_installed = {
"lua_ls",
"stylua",
"intelephense",
},
})
local telescope = require("telescope.builtin")
vim.api.nvim_create_autocmd("LspAttach", {
desc = "LSP Keymaps",
callback = function(args)
local bufnr = args.buf
local options = { buffer = bufnr }
-- Navigation
utils.nmap("<leader>gt", telescope.lsp_type_definitions, "Go to Type Definition", options)
utils.nmap("<leader>gd", telescope.lsp_definitions, "Go to Definition", options)
utils.nmap("<leader>gD", vim.lsp.buf.declaration, "Go to Declaration", options)
utils.nmap("<leader>gi", telescope.lsp_implementations, "Go to Implementation", options)
utils.nmap("<leader>gr", telescope.lsp_references, "References", options)
utils.nmap("<leader>gs", telescope.lsp_document_symbols, "LSP Document Symbols", options)
utils.nmap("<leader>gS", telescope.lsp_dynamic_workspace_symbols, "LSP Workspace Symbols", options)
-- Info
utils.nmap("<leader>gh", vim.lsp.buf.hover, "Hover Docs", options)
utils.nmap("<leader>gH", vim.lsp.buf.signature_help, "Signature Help", options)
-- Refactor
utils.nmap("<leader>gn", vim.lsp.buf.rename, "Rename Symbol", options)
utils.nmap("<leader>ga", vim.lsp.buf.code_action, "Code Action", options)
utils.nmap("<leader>gf", vim.lsp.buf.format, "Format Buffer", options)
-- Diagnostics
utils.nmap("<leader>gl", vim.diagnostic.open_float, "Line Diagnostics", options)
utils.nmap("<leader>gk", vim.diagnostic.goto_prev, "Previous Diagnostic", options)
utils.nmap("<leader>gj", vim.diagnostic.goto_next, "Next Diagnostic", options)
utils.nmap("<leader>gq", vim.diagnostic.setloclist, "Diagnostics to Loclist", options)
end,
})

View File

@@ -11,6 +11,9 @@ vim.pack.add({
-- Automatically enable installed language servers
{ src = "https://github.com/mason-org/mason-lspconfig.nvim" },
-- Automatically install TreeSitter parsers
{ src = "https://github.com/romus204/tree-sitter-manager.nvim" },
-- All-in-one completions engine
{ src = "https://github.com/saghen/blink.lib" },
{ src = "https://github.com/saghen/blink.cmp" },
@@ -28,6 +31,7 @@ vim.pack.add({
-- Miscellaneous
{ src = "https://github.com/windwp/nvim-autopairs" },
{ src = "https://github.com/folke/which-key.nvim" },
-- WoW Addon API
{ src = "https://github.com/Tyrannican/warcraft-api.nvim" },

View File

@@ -48,9 +48,17 @@
"rev": "7d324792b7943e4aa16ad007212e6acc6f9fe335",
"src": "https://github.com/nvim-telescope/telescope.nvim"
},
"tree-sitter-manager.nvim": {
"rev": "bb66b815aff01e87b2e26be995116be8d2f91474",
"src": "https://github.com/romus204/tree-sitter-manager.nvim"
},
"warcraft-api.nvim": {
"rev": "c016bc54ed62bca5058cc3bd7553e429dd8caf37",
"src": "https://github.com/Tyrannican/warcraft-api.nvim"
},
"which-key.nvim": {
"rev": "3aab2147e74890957785941f0c1ad87d0a44c15a",
"src": "https://github.com/folke/which-key.nvim"
}
}
}