feat: move all LSP config to lsp.lua
This commit is contained in:
parent
5e93f497de
commit
1c1f869b16
2 changed files with 60 additions and 52 deletions
|
@ -1,52 +0,0 @@
|
|||
return {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
config = function()
|
||||
require("mason").setup()
|
||||
end,
|
||||
},
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
config = function()
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = { "lua_ls", "tsserver", "html" },
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
config = function()
|
||||
local lspconfig = require("lspconfig")
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
lspconfig.lua_ls.setup({
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
||||
lspconfig.tsserver.setup({
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "Go to definition" })
|
||||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { desc = "Go to implementation" })
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, { desc = "Show signature" })
|
||||
vim.keymap.set("n", "<Leader>f", vim.lsp.buf.format, { desc = "Format buffer" })
|
||||
vim.keymap.set("n", "<Leader>ca", vim.lsp.buf.code_action, { desc = "View code actions" })
|
||||
end,
|
||||
},
|
||||
{
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
config = function()
|
||||
local mason_tool_installer = require("mason-tool-installer")
|
||||
|
||||
mason_tool_installer.setup({
|
||||
ensure_installed = {
|
||||
"djlint",
|
||||
"prettierd",
|
||||
"eslint_d",
|
||||
},
|
||||
automatic_installation = true,
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
60
lua/plugins/lsp.lua
Normal file
60
lua/plugins/lsp.lua
Normal file
|
@ -0,0 +1,60 @@
|
|||
return {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
opts = {},
|
||||
},
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"lua_ls",
|
||||
"tsserver",
|
||||
"html",
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"djlint",
|
||||
"eslint_d",
|
||||
"prettierd",
|
||||
"stylua",
|
||||
},
|
||||
automatic_installation = true,
|
||||
}
|
||||
},
|
||||
-- lspconfig should be the last step.
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
event = "VeryLazy",
|
||||
dependencies = {
|
||||
"mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
},
|
||||
opts = {
|
||||
servers = {
|
||||
tsserver = {},
|
||||
lua_ls = {}
|
||||
}
|
||||
},
|
||||
config = function(_, opts)
|
||||
local lspconfig = require("lspconfig")
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
local servers = opts.servers
|
||||
|
||||
for server, server_opts in pairs(servers) do
|
||||
local sopts = vim.tbl_deep_extend("force", server_opts, capabilities)
|
||||
lspconfig[server].setup(sopts)
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "Go to definition" })
|
||||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { desc = "Go to implementation" })
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, { desc = "Show signature" })
|
||||
vim.keymap.set("n", "<Leader>f", vim.lsp.buf.format, { desc = "Format buffer" })
|
||||
vim.keymap.set("n", "<Leader>ca", vim.lsp.buf.code_action, { desc = "View code actions" })
|
||||
end,
|
||||
},
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue