local lspconfig = require("lspconfig") function on_attach(client, bufnr) local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end local opts = { noremap = true, silent = true } buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) buf_set_keymap('n', 'gd', 'Telescope lsp_definitions', opts) buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) buf_set_keymap('n', 'gr', 'Telescope lsp_references', opts) buf_set_keymap('n', 'sa', 'Telescope lsp_code_actions', opts) buf_set_keymap('n', 'se', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) buf_set_keymap('n', 'sE', 'Telescope lsp_document_diagnostics', opts) buf_set_keymap('n', 'swe', 'Telescope lsp_workspace_diagnostics', opts) buf_set_keymap('n', 'sl', 'lua vim.lsp.diagnostic.set_loclist()', opts) buf_set_keymap('n', 'sr', 'lua vim.lsp.buf.rename()', opts) buf_set_keymap('n', 'ss', 'Telescope lsp_document_symbols', opts) buf_set_keymap('n', 'sS', 'Telescope lsp_workspace_symbols', opts) buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) -- Capability specific -- print(vim.inspect(client.resolved_capabilities)) if client.resolved_capabilities.document_formatting then buf_set_keymap("n", "sf", "lua vim.lsp.buf.formatting()", opts) end if client.resolved_capabilities.document_range_formatting then buf_set_keymap("v", "sf", "lua vim.lsp.buf.range_formatting()", opts) end -- Rust specific buf_set_keymap("n", "sh", "RustToggleInlayHints", opts) require("lsp_signature").on_attach({ hint_prefix = "param: " }) end local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true capabilities.textDocument.completion.completionItem.resolveSupport = { properties = { 'documentation', 'detail', 'additionalTextEdits', } } require("rust-tools").setup { server = { cmd = { vim.g.rust_analyzer_path }, settings = { ["rust-analyzer"] = { checkOnSave = { command = "clippy", }, experimental = { procAttrMacros = true, }, }, }, on_attach = on_attach, } } require("nlua.lsp.nvim").setup(require('lspconfig'), { cmd = { string.format("%s/bin/lua-language-server", vim.g.sumneko_lua_base_path), "-E", string.format("%s/extras/main.lua", vim.g.sumneko_lua_base_path), }, on_attach = on_attach, })