From 0971768bdd5a06916dc2a74296fb76bd5b211540 Mon Sep 17 00:00:00 2001 From: Ariel D'Alessandro Date: Mon, 17 Oct 2022 09:28:34 +0200 Subject: feat: add yaml snippets, use phpactor for internal php lsp action --- lua/alpha/php/lsp.lua | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'lua/alpha/php/lsp.lua') diff --git a/lua/alpha/php/lsp.lua b/lua/alpha/php/lsp.lua index 8a92b0e..6845d1c 100644 --- a/lua/alpha/php/lsp.lua +++ b/lua/alpha/php/lsp.lua @@ -70,14 +70,23 @@ lsp.find = function(search, client) end if class_location == nil then - P("Did not found any class") + P("Did not found any class: " .. class) return end + local command = "edit" + local filename = class_location.filename + + if vim.api.nvim_buf_get_name(0) ~= filename or command ~= "edit" then + filename = Path:new(vim.fn.fnameescape(filename)):normalize(vim.loop.cwd()) + pcall(vim.cmd, string.format("%s %s", command, filename)) + end + + local params = vim.lsp.util.make_position_params(0) vim.lsp.buf_request( - buffer, - "workspace/symbol", - { query = method }, + 0, + "textDocument/documentSymbol", + params, function(method_err, method_server_result, _, _) if err then vim.api.nvim_err_writeln("Error when finding workspace symbols: " .. method_err.message) @@ -92,7 +101,7 @@ lsp.find = function(search, client) local method_location = nil for _, value in ipairs(method_locations) do - if value.filename == class_location.filename then + if value.text == string.format("[Method] %s", method) then method_location = value break end @@ -102,16 +111,9 @@ lsp.find = function(search, client) return end - local command = "edit" - local filename = method_location.filename local row = method_location.lnum local col = method_location.col - 1 - if vim.api.nvim_buf_get_name(0) ~= filename or command ~= "edit" then - filename = Path:new(vim.fn.fnameescape(filename)):normalize(vim.loop.cwd()) - pcall(vim.cmd, string.format("%s %s", command, filename)) - end - if row and col then local ok, err_msg = pcall(vim.api.nvim_win_set_cursor, 0, { row, col }) if not ok then -- cgit v1.2.3