-->
let’s continue our configuration.
LSP stands for language server protocol
, which is started by microsoft
, so we can do code auto-complete and check errors when write our code.
I use Mason and Mason-lspconfig + Nvim-lspconfig to do this.
/mason
is auto installed within when you clone the configurations of lazy./
so create a file in plugins
fold, maybe call it lsp-config
.
talk is cheap, let me show you the code:
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", "jsonls", "vale_ls", "tailwindcss" },
})
end,
},
{
"neovim/nvim-lspconfig",
config = function(_, opts)
local lspconfig = require("lspconfig")
lspconfig.dartls.setup({
cmd = { "dart", "language-server", "--protocol=lsp" },
})
lspconfig.tsserver.setup({})
lspconfig.lua_ls.setup({})
lspconfig.tailwindcss.setup({})
lspconfig.prismals.setup({})
lspconfig.vale_ls.setup({}) -- for markdown
lspconfig.jsonls.setup({})
vim.keymap.set('n', 'K', vim.lsp.buf.hover, {})
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {})
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, {})
vim.keymap.set('n', '<leader>ce', vim.diagnostic.open_float, {})
end
},
}
the code mainly does the things below: