diff options
| author | Ariel D'Alessandro <ariel.dalessandro@auto1.com> | 2022-10-17 09:28:34 +0200 |
|---|---|---|
| committer | Ariel D'Alessandro <ariel.dalessandro@auto1.com> | 2022-10-17 09:29:32 +0200 |
| commit | 0971768bdd5a06916dc2a74296fb76bd5b211540 (patch) | |
| tree | 5e657d528d8c467151c46dd11475acbbff386b43 /lua/alpha/php/lsp.lua | |
| parent | 7e62950549047548c2744b634d5947da67647881 (diff) | |
| download | nvim-conf-0971768bdd5a06916dc2a74296fb76bd5b211540.tar.gz nvim-conf-0971768bdd5a06916dc2a74296fb76bd5b211540.zip | |
feat: add yaml snippets, use phpactor for internal php lsp action
Diffstat (limited to 'lua/alpha/php/lsp.lua')
| -rw-r--r-- | lua/alpha/php/lsp.lua | 26 |
1 files changed, 14 insertions, 12 deletions
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 |