-- lsp config local lsp = require 'lspconfig' local util = require 'lspconfig.util' local function my_attach(client) -- attach completion require 'completion'.on_attach(client) -- do lsp mappings vim.fn.nvim_buf_set_keymap(0, 'n', 'K', 'lua vim.lsp.buf.hover()', {noremap=true, silent=true}) vim.fn.nvim_buf_set_keymap(0, 'n', '', 'lua vim.lsp.buf.definition()', {noremap=true, silent=true}) vim.fn.nvim_buf_set_keymap(0, 'n', 'grr', 'lua vim.lsp.buf.rename()', {noremap=true, silent=true}) vim.fn.nvim_buf_set_keymap(0, 'i', '', 'lua vim.lsp.buf.signature_help()', {noremap=true, silent=true}) -- nnoremap gD lua vim.lsp.buf.declaration() -- nnoremap gd lua vim.lsp.buf.definition() -- nnoremap gT lua vim.lsp.buf.type_definition() -- nnoremap gI lua vim.lsp.buf.implementation() -- nnoremap gr lua vim.lsp.buf.references() -- nnoremap g0 lua vim.lsp.buf.document_symbol() -- nnoremap gW lua vim.lsp.buf.workspace_symbol() -- nnoremap ;h lua vim.lsp.buf.hover() -- nnoremap ;s lua vim.lsp.buf.signature_help() end -- lsp.ccls.setup{ -- on_attach = my_attach, -- } lsp.gopls.setup{ on_attach = my_attach, root_dir = util.root_pattern('go.mod', '.git'), -- NOTE: this is done to avoid the gopls warning about being outside gopath -- message_level = vim.lsp.protocol.MessageType.Error, } lsp.sumneko_lua.setup{ cmd = { 'lua-language-server' }; on_attach = my_attach; } lsp.rust_analyzer.setup{ cmd = { 'env', 'CARGO_TARGET_DIR=/tmp', 'rust-analyzer' }, on_attach = my_attach, }