added none-ls (null-ls)

main
Mathias Rothenhaeusler 2025-07-25 16:04:48 +02:00
parent cf8bac705a
commit aacdd5e376
4 changed files with 69 additions and 2 deletions

View File

@ -401,3 +401,4 @@ require('custom.mason')
require('custom.bufferline')
require('custom.kulala')
require('custom.rainbow')
require('custom.none-ls')

View File

@ -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, -- youre using `phpcbf` anyway
},
},
},
})
lspconfig["slint_lsp"].setup({

View File

@ -0,0 +1,11 @@
local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.formatting.phpcbf.with({
command = "phpcbf", -- or full path if not in PATH
extra_args = { "--standard=PSR12" },
}),
},
on_attach = on_attach,
})

View File

@ -145,7 +145,9 @@ return {
end
persisted.setup(opts)
end,
}
},
'nvimtools/none-ls.nvim',
-- {
-- "folke/persistence.nvim",
-- event = "BufReadPre", -- this will only start session saving when an actual file was opened