@@ -12,6 +12,17 @@ end
local keymap = vim.keymap -- for conciseness
-- smart format with null-ls if aviable
local function smart_format ( )
vim.lsp . buf.format ( {
filter = function ( client )
if vim.bo . filetype == " rust " then
return client.name == " rust_analyzer "
end
return client.name == " null-ls "
end ,
} )
end
---------- border >------------------------------
local orig_floating_preview = vim.lsp . util.open_floating_preview
vim.lsp . util.open_floating_preview = function ( contents , syntax , opts , ... )
@@ -31,7 +42,8 @@ local on_attach = function(_, bufnr)
-- keymap.set("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts) keymap.set("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts) -- got to declaration
keymap.set ( " n " , " gd " , " <cmd>lua vim.lsp.buf.definition()<CR> " , opts ) -- see definition and make edits in window
keymap.set ( " n " , " gi " , " <cmd>lua vim.lsp.buf.implementation()<CR> " , opts ) -- go to implementation
keymap.set ( " n " , " <leader>l " , " <cmd>lua vim.lsp.buf.format()<CR> " , opts ) -- format code
-- keymap.set("n", "<leader>l", " <cmd>lua vim.lsp.buf.format()<CR>", opts) -- format code
keymap.set ( " n " , " <leader>l " , smart_format , opts ) -- format code
keymap.set ( " n " , " <leader>rn " , " <cmd>lua vim.lsp.buf.rename()<CR> " , opts ) -- format code
-- keymap.set("n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts) -- see available code actions
-- keymap.set("n", "<leader>ed", "<cmd>Telescope diagnostics<CR>", opts) -- jump to previous diagnostic in buffer
@@ -161,6 +173,12 @@ lspconfig["lua_ls"].setup({
filetypes = { " lua " } ,
} )
local util = require ( " lspconfig.util " )
local fallback_root_dir = function ( fname )
return util.root_pattern ( " composer.json " , " .git " ) ( fname ) or util.path . dirname ( fname )
end
lspconfig [ " phpactor " ] . setup ( {
on_attach = on_attach ,
capabilities = capabilities ,
@@ -169,12 +187,47 @@ lspconfig["phpactor"].setup({
[ " language_server_psalm.enabled " ] = false ,
} ,
filetypes = { " php " } ,
root_dir = fallback_root_dir ,
} )
lspconfig [ " intelephense " ] . setup ( {
capabilities = capabilities ,
on_attach = on_attach ,
filetypes = { " php " } ,
init_options = {
licenceKey = vim.fn . readfile ( vim.fn . expand ( " $HOME/.config/intelephense/license.txt " ) ) [ 1 ] ,
} ,
root_dir = fallback_root_dir ,
settings = {
intelephense = {
-- ✅ Enable property inference (Pro)
telemetry = { enabled = false } , -- optional, privacy
files = {
maxSize = 5000000 , -- increase if needed
associations = { " **/*.php " } ,
} ,
-- environment = {
-- includePaths = {
-- "/path/to/your/stubs", -- ⬅️ Your custom stub folder
-- },
-- },
completion = {
fullyQualifyGlobalConstantsAndFunctions = false ,
triggerParameterHints = true ,
maxItems = 100 ,
} ,
-- enables smarter inference
phpdoc = {
enabled = true ,
} ,
diagnostics = {
enable = true ,
} ,
format = {
enable = false , -- you’ re using `phpcbf` anyway
} ,
} ,
} ,
} )
lspconfig [ " slint_lsp " ] . setup ( {