45 lines
1.7 KiB
Lua
45 lines
1.7 KiB
Lua
local status_ok, mason = pcall(require, "mason")
|
|
if not status_ok then
|
|
return
|
|
end
|
|
|
|
local status_ok, mason_lspconfig = pcall(require, "mason-lspconfig")
|
|
if not status_ok then
|
|
return
|
|
end
|
|
|
|
local status_ok, lspconfig = pcall(require, "lspconfig")
|
|
if not status_ok then
|
|
return
|
|
end
|
|
|
|
mason.setup()
|
|
mason_lspconfig.setup()
|
|
|
|
local opts = { noremap = true, silent = true }
|
|
|
|
vim.api.nvim_set_keymap("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
|
vim.api.nvim_set_keymap("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
|
vim.api.nvim_set_keymap("n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
|
vim.api.nvim_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
|
vim.api.nvim_set_keymap("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
|
vim.api.nvim_set_keymap("n", "grr", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
|
vim.api.nvim_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
|
vim.api.nvim_set_keymap("n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
|
|
-- vim.api.nvim_buf_set_keymap("n", "<leader>f", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
|
|
vim.api.nvim_set_keymap("n", "[d", '<cmd>lua vim.diagnostic.goto_prev({ border = "rounded" })<CR>', opts)
|
|
vim.api.nvim_set_keymap(
|
|
"n",
|
|
"gl",
|
|
'<cmd>lua vim.diagnostic.open_float({ border = "rounded" })<CR>',
|
|
opts
|
|
)
|
|
vim.api.nvim_set_keymap("n", "]d", '<cmd>lua vim.diagnostic.goto_next({ border = "rounded" })<CR>', opts)
|
|
vim.api.nvim_set_keymap("n", "<leader>q", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
|
|
|
|
vim.cmd([[ command! Format execute 'lua vim.lsp.buf.format{async=true}' ]])
|
|
|
|
require("user.lsp.mason_lsp_config")
|
|
|
|
require("user.lsp.handlers").setup()
|