aboutsummaryrefslogtreecommitdiffstats
path: root/lua/pi/php/servers.lua
diff options
context:
space:
mode:
authorElvis Claros Castro <elvis@claros.ar>2024-07-12 11:18:14 -0300
committerElvis Claros Castro <elvis@claros.ar>2024-07-12 11:18:14 -0300
commitea0f4bf8ffade657b1d45152dbc183d4679e75c4 (patch)
treecc1fb023bc308e019ddce33a4b0aed39f56805dc /lua/pi/php/servers.lua
parent1fd0af14d592d612c2aaab7717c04c8806ba3daa (diff)
downloadnvim-conf-ea0f4bf8ffade657b1d45152dbc183d4679e75c4.tar.gz
nvim-conf-ea0f4bf8ffade657b1d45152dbc183d4679e75c4.zip
Feat: PI
Diffstat (limited to 'lua/pi/php/servers.lua')
-rw-r--r--lua/pi/php/servers.lua38
1 files changed, 38 insertions, 0 deletions
diff --git a/lua/pi/php/servers.lua b/lua/pi/php/servers.lua
new file mode 100644
index 0000000..9450152
--- /dev/null
+++ b/lua/pi/php/servers.lua
@@ -0,0 +1,38 @@
+local phpactor = {}
+
+-- TODO possible improvement look how it works underline
+-- use the client directly to call, no need for the buffer
+-- to find a class.
+-- vim.lsp.start() should return the client
+
+function phpactor.findclass(buffer, fqn, callback)
+ local class_parts = vim.split(fqn, "\\")
+ local class = class_parts[#class_parts]
+
+ vim.lsp.buf_request(buffer, "workspace/symbol", { query = class }, function(err, server_result, _, _)
+ if err then
+ callback(nil, "Error when finding workspace symbols: " .. err.message)
+
+ return
+ end
+
+ local locations = vim.lsp.util.symbols_to_items(server_result or {}, buffer) or {}
+ if vim.tbl_isempty(locations) then
+ vim.api.nvim_err_writeln("Empty response looking for class: " .. fqn)
+ return
+ end
+ end)
+end
+
+-- getting the config I can re use the client
+-- the next thing is to make the request with the client
+local config = require("lspconfig").phpactor
+config.root_dir = vim.fn.getcwd()
+local client_id = vim.lsp.start(config)
+
+vim.lsp.get_client_by_id(client_id)
+-- use client.request or request_sync
+-- look for the direct of the symbol
+return {
+ phpactor = phpactor,
+}