2023-10-10 00:25:38 +00:00
|
|
|
local lsp = require('lsp-zero')
|
|
|
|
|
|
|
|
lsp.preset('recommended')
|
|
|
|
|
|
|
|
require('mason').setup({})
|
|
|
|
require('mason-lspconfig').setup({
|
|
|
|
ensure_installed = {
|
|
|
|
'tsserver',
|
|
|
|
'eslint',
|
|
|
|
'rust_analyzer',
|
|
|
|
'clangd',
|
|
|
|
'html',
|
|
|
|
'cssls',
|
|
|
|
'pyright',
|
|
|
|
'vimls',
|
|
|
|
'yamlls',
|
|
|
|
'jdtls',
|
|
|
|
'bashls',
|
|
|
|
'lua_ls'
|
|
|
|
},
|
|
|
|
handlers = {
|
|
|
|
lsp.default_setup,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
local cmp = require('cmp')
|
|
|
|
|
|
|
|
local cmp_select = {behavior = cmp.SelectBehavior.Select}
|
|
|
|
local cmp_mappings = cmp.mapping.preset.insert({
|
|
|
|
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
|
|
|
|
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
|
|
|
|
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
|
|
|
["<C-Space>"] = cmp.mapping.complete(),
|
|
|
|
})
|
|
|
|
|
|
|
|
cmp_mappings['<Tab>'] = nil
|
|
|
|
cmp_mappings['<S-Tab>'] = nil
|
|
|
|
|
|
|
|
cmp.setup({
|
|
|
|
mapping = cmp_mappings
|
|
|
|
})
|
|
|
|
|
|
|
|
lsp.set_preferences({
|
|
|
|
suggest_lsp_servers = false,
|
|
|
|
sign_icons = {
|
|
|
|
error = 'E',
|
|
|
|
warn = 'W',
|
|
|
|
hint = 'H',
|
|
|
|
info = 'I'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
lsp.on_attach(function(client, bufnr)
|
|
|
|
local opts = {buffer = bufnr, remap = false}
|
|
|
|
local keymap = vim.keymap.set
|
|
|
|
|
|
|
|
keymap("n", "gd", function() vim.lsp.buf.definition() end, opts)
|
|
|
|
keymap("n", "K", function() vim.lsp.buf.hover() end, opts)
|
|
|
|
keymap("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
|
|
|
|
keymap("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
|
|
|
|
keymap("n", "[d", function() vim.diagnostic.goto_next() end, opts)
|
|
|
|
keymap("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
|
|
|
|
keymap("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
|
|
|
|
keymap("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
|
|
|
|
keymap("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
|
|
|
|
keymap("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
|
|
|
|
end)
|
|
|
|
|
|
|
|
lsp.setup()
|
|
|
|
|
|
|
|
vim.diagnostic.config({
|
|
|
|
virtual_text = true
|
|
|
|
})
|
2023-10-10 04:15:27 +00:00
|
|
|
|
|
|
|
require("neodev").setup()
|
|
|
|
require("nvim-surround").setup()
|