mirror of https://github.com/gabehf/nvim-conf.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.0 KiB
63 lines
2.0 KiB
local map = vim.keymap.set
|
|
local conf = require("nvconfig").ui.lsp
|
|
|
|
local on_attach = function(client, bufnr)
|
|
local function opts(desc)
|
|
return { buffer = bufnr, desc = desc }
|
|
end
|
|
|
|
map("n", "gD", vim.lsp.buf.declaration, opts "Lsp Go to declaration")
|
|
map("n", "gd", vim.lsp.buf.definition, opts "Lsp Go to definition")
|
|
map("n", "K", vim.lsp.buf.hover, opts "Lsp hover information")
|
|
map("n", "gi", vim.lsp.buf.implementation, opts "Lsp Go to implementation")
|
|
map("n", "<leader>sh", vim.lsp.buf.signature_help, opts "Lsp Show signature help")
|
|
map("n", "<leader>wa", vim.lsp.buf.add_workspace_folder, opts "Lsp Add workspace folder")
|
|
map("n", "<leader>wr", vim.lsp.buf.remove_workspace_folder, opts "Lsp Remove workspace folder")
|
|
|
|
map("n", "<leader>wl", function()
|
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
|
end, opts "Lsp List workspace folders")
|
|
|
|
map("n", "<leader>D", vim.lsp.buf.type_definition, opts "Lsp Go to type definition")
|
|
|
|
map("n", "<leader>ra", function()
|
|
require "nvchad.lsp.renamer"()
|
|
end, opts "Lsp NvRenamer")
|
|
|
|
map({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts "Lsp Code action")
|
|
map("n", "gr", "<cmd>Telescope lsp_references<CR>", opts "[G]et [R]eferences")
|
|
|
|
-- setup signature popup
|
|
if conf.signature and client.server_capabilities.signatureHelpProvider then
|
|
require("nvchad.lsp.signature").setup(client, bufnr)
|
|
end
|
|
end
|
|
local on_init = require("nvchad.configs.lspconfig").on_init
|
|
local capabilities = require("nvchad.configs.lspconfig").capabilities
|
|
|
|
local lspconfig = require "lspconfig"
|
|
local servers = { "html", "cssls", "gopls", "tsserver" }
|
|
|
|
-- lsps with default config
|
|
for _, lsp in ipairs(servers) do
|
|
lspconfig[lsp].setup {
|
|
on_attach = on_attach,
|
|
on_init = on_init,
|
|
capabilities = capabilities,
|
|
}
|
|
end
|
|
|
|
-- rust
|
|
lspconfig.rust_analyzer.setup {
|
|
settings = {
|
|
["rust-analyzer"] = {},
|
|
},
|
|
}
|
|
|
|
-- typescript
|
|
-- lspconfig.tsserver.setup {
|
|
-- on_attach = on_attach,
|
|
-- on_init = on_init,
|
|
-- capabilities = capabilities,
|
|
-- }
|