aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/alpha/php/lsp.lua26
-rw-r--r--lua/alpha/php/servers.lua17
-rw-r--r--lua/alpha/snips/ft/yaml.lua193
3 files changed, 178 insertions, 58 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
diff --git a/lua/alpha/php/servers.lua b/lua/alpha/php/servers.lua
index 78c99a8..caab4a8 100644
--- a/lua/alpha/php/servers.lua
+++ b/lua/alpha/php/servers.lua
@@ -1,5 +1,10 @@
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]
@@ -23,6 +28,18 @@ function phpactor.findclass(buffer, fqn, callback)
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
+);
+
+local client = vim.lsp.get_client_by_id(client_id)
+P(client)
+-- use client.request or request_sync
+-- look for the direct of the symbol
return {
phpactor = phpactor,
}
diff --git a/lua/alpha/snips/ft/yaml.lua b/lua/alpha/snips/ft/yaml.lua
index 27704f9..796512e 100644
--- a/lua/alpha/snips/ft/yaml.lua
+++ b/lua/alpha/snips/ft/yaml.lua
@@ -10,107 +10,208 @@ local fmt = require("luasnip.extras.fmt").fmt
local rep = require("luasnip.extras").rep
local M = {
- str = fmt([[{}:
+ str = fmt(
+ [[{}:
type: string
-{}]], {
+{}]] ,
+ {
i(1, ""),
i(2, ""),
- }),
- bool = fmt([[{}:
+ }
+ ),
+ bool = fmt(
+ [[{}:
type: boolean
-{}]], {
+{}]] ,
+ {
i(1, ""),
i(2, ""),
- }),
- float = fmt([[{}:
+ }
+ ),
+ float = fmt(
+ [[{}:
type: number
format: float
-{}]], {
+{}]] ,
+ {
i(1, ""),
- i(2, "")
- }),
- int = fmt([[{}:
+ i(2, ""),
+ }
+ ),
+ int = fmt(
+ [[{}:
type: integer
-{}]], {
+{}]] ,
+ {
i(1, ""),
- i(2, "")
- }),
- id = fmt([[{}:
+ i(2, ""),
+ }
+ ),
+ id = fmt(
+ [[{}:
type: integer
format: int64
-{}]], {
+{}]] ,
+ {
i(1, ""),
- i(2, "")
- }),
- class = fmt([[{}:
+ i(2, ""),
+ }
+ ),
+ class = fmt(
+ [[{}:
$ref: '#/components/schemas/{}'
-{}]], {
+{}]] ,
+ {
i(1, ""),
i(2, ""),
- i(3, "")
- }),
- date = fmt([[{}:
+ i(3, ""),
+ }
+ ),
+ date = fmt(
+ [[{}:
type: string
format: date-time
-{}]], {
+{}]] ,
+ {
i(1, ""),
- i(2, "")
- }),
- arr = fmt([[{}:
+ i(2, ""),
+ }
+ ),
+ arr = fmt(
+ [[{}:
type: array
items:
{}
-{}]], {
+{}]] ,
+ {
i(1, ""),
i(2, ""),
- i(3, "")
- }),
- ref = fmt([[$ref: '#/components/schemas/{}']], {i(1, "")}),
- obj = fmt([[type: object
+ i(3, ""),
+ }
+ ),
+ ref = fmt([[$ref: '#/components/schemas/{}']], { i(1, "") }),
+ obj = fmt(
+ [[type: object
properties:
- {}]], i(1, "")),
- aint = fmt([[{}:
+ {}]] ,
+ i(1, "")
+ ),
+ aint = fmt(
+ [[{}:
type: array
items:
type: int
format: int64
-{}]], {
+{}]] ,
+ {
i(1, ""),
i(2, ""),
- }),
- astr = fmt([[{}:
+ }
+ ),
+ astr = fmt(
+ [[{}:
type: array
items:
type: string
-{}]], {
+{}]] ,
+ {
i(1, ""),
i(2, ""),
- }),
+ }
+ ),
- mut = fmt([[{}:
+ mut = fmt(
+ [[{}:
type: "{}"
resolve: '@=mutation("App\\GraphQL\\Mutation\\{}::{}", {}, info)'
args:
{}
-]], {
+]] ,
+ {
i(1, ""),
i(2, ""),
i(3, ""),
rep(1),
i(5, ""),
i(6, ""),
- }),
+ }
+ ),
- input = fmt([[{}:
+ input = fmt(
+ [[{}:
type: input-object
config:
fields:
{}
-]], {
+]] ,
+ {
i(1, ""),
i(2, ""),
- }),
- f = fmt([[{}: {{ type: "{}" }}]], {i(1, ""), i(2, "")}),
+ }
+ ),
+ f = fmt([[{}: {{ type: "{}" }}]], { i(1, ""), i(2, "") }),
+
+ api = fmt(
+ [[openapi: 3.0.2
+info:
+ title: {}
+ contact:
+ name: eva-team-be
+ version: {}
+x-bundle-apis: true
+tags:
+ - name: {}
+ description: {}
+]] ,
+ { i(1, "my app"), i(2, "1.0.0"), i(3, "tag"), i(4, "tag description") }
+ ),
+ paths = fmt([[paths:
+ {}
+]],
+ {i(0, "")}
+ ),
+ param = fmt([[parameters:
+ - name: {}
+ description: {}
+ in: path
+ required: true
+ schema:
+ type: integer
+ format: int64
+]],
+ {i(1, ""), i(2, "")}
+ ),
+ get = fmt([[get:
+ operationId: {}
+ description: {}
+ tags: [ {} ]
+ responses:
+ 200:
+ description: Response
+ content:
+ application/json:
+ schema:
+ {}
+ ]], {i(1, "GetOperation"), i(2, "description"), i(3, "tag"), i(4, "")}),
+
+ put = fmt([[put:
+ operationId: {}
+ tags: [ {} ]
+ description: {}
+ requestBody:
+ content:
+ application/json:
+ schema:
+ {}
+ required: true
+ responses:
+ 200:
+ description: {}
+ content:
+ application/json:
+ schema:
+ {}
+ ]], {i(1, "PutOperation"), i(2, "tag"), i(3, "description"), i(4, ""), i(5, "description"), i(6, "")})
}
return M