summaryrefslogtreecommitdiff
path: root/lua/lang/php.lua
blob: 019f3a94c78c20c6248101e8bcf841e8d7c2c4d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
local M = {}

M.config = function()
  -- TODO: implement config for language
  return "No config available!"
end

M.format = function()
  O.formatters.filetype["php"] = {
    function()
      return {
        exe = O.lang.php.formatter.exe,
        args = O.lang.php.formatter.args,
        stdin = not (O.lang.php.formatter.stdin ~= nil),
      }
    end,
  }

  require("formatter.config").set_defaults {
    logging = false,
    filetype = O.formatters.filetype,
  }
end

M.lint = function()
  -- TODO: implement linters (if applicable)
  return "No linters configured!"
end

M.lsp = function()
  if require("lv-utils").check_lsp_client_active "intelephense" then
    return
  end

  require("lspconfig").intelephense.setup {
    cmd = { DATA_PATH .. "/lspinstall/php/node_modules/.bin/intelephense", "--stdio" },
    on_attach = require("lsp").common_on_attach,
    handlers = {
      ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
        virtual_text = O.lang.php.diagnostics.virtual_text,
        signs = O.lang.php.diagnostics.signs,
        underline = O.lang.php.diagnostics.underline,
        update_in_insert = true,
      }),
    },
    filetypes = O.lang.php.filetypes,
    settings = {
      intelephense = {
        format = {
          braces = O.lang.php.format.braces,
        },
        environment = {
          phpVersion = O.lang.php.environment.php_version,
        },
      },
    },
  }
end

M.dap = function()
  -- TODO: implement dap
  return "No DAP configured!"
end

return M