-- lsp config local lsp = require('lspconfig') local util = require('lspconfig.util') local u = require('utils') local nnoremap = require('astronauta.keymap').nnoremap -- https://github.com/kosayoda/nvim-lightbulb require('nvim-lightbulb').update_lightbulb { sign = { enabled = true, priority = 10, }, float = { enabled = true, text = '󱉵', win_opts = {}, }, } local my_attach = function(client) -- attach completion require 'completion'.on_attach(client) -- lsp mappings nnoremap { 'K', function() vim.lsp.buf.hover() end } nnoremap { '', function() vim.lsp.buf.definition() end } nnoremap { 'grr', function() vim.lsp.buf.rename() end } nnoremap { '', function() vim.lsp.buf.signature_help() end } nnoremap { ']d', function() vim.lsp.diagnostic.goto_next() end } nnoremap { '[d', function() vim.lsp.diagnostic.goto_prev() end } -- 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{ on_attach = my_attach; cmd = { 'lua-language-server' }; settings = { Lua = { runtime = { version = 'LuaJIT', }, diagnostics = { globals = {'vim'}, }, workspace = { library = { [vim.fn.expand('$VIMRUNTIME/lua')] = true, [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true, } } } }, } lsp.rust_analyzer.setup{ on_attach = my_attach, cmd = { 'env', 'CARGO_TARGET_DIR=/tmp', 'rust-analyzer' }, }