32 lines
897 B
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local lspconfig = require("lspconfig")
local capabilities = require("cmp_nvim_lsp").default_capabilities()
local on_attach = function(_, bufnr)
local map = function(mode, lhs, rhs)
vim.keymap.set(mode, lhs, rhs, { buffer = bufnr })
end
map("n", "gd", vim.lsp.buf.definition)
map("n", "K", vim.lsp.buf.hover)
end
local servers = {
"phpactor", -- PHP
"pyright", -- Python
"gopls", -- Go
"html", -- HTML
"cssls", -- CSS
-- "ts_ls", -- TypeScript目前暫時不需要先註解掉
}
-- 載入所有的對應的 LSP server 設定
--
-- 相關設定請看
-- <https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md>
for _, name in ipairs(servers) do
local ok, config = pcall(require, "lsp.servers." .. name)
if not ok then config = {} end
config.capabilities = capabilities
config.on_attach = on_attach
lspconfig[name].setup(config)
end