From 1996ef15613f2d4773017128bba1a719a1b63a19 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Sat, 20 Feb 2021 21:27:26 +0100 Subject: Move to lua based vimrc --- .vim/lua/plugins/_lsp.lua | 78 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .vim/lua/plugins/_lsp.lua (limited to '.vim/lua/plugins/_lsp.lua') diff --git a/.vim/lua/plugins/_lsp.lua b/.vim/lua/plugins/_lsp.lua new file mode 100644 index 0000000..9d98aca --- /dev/null +++ b/.vim/lua/plugins/_lsp.lua @@ -0,0 +1,78 @@ +-- lsp config + +local lsp = require('lspconfig') +local util = require('lspconfig.util') +local u = require('utils') + +-- 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 + u.map('n', 'K', 'lua vim.lsp.buf.hover()') + u.map(0, 'n', '', 'lua vim.lsp.buf.definition()') + u.map(0, 'n', 'grr', 'lua vim.lsp.buf.rename()') + u.map(0, 'i', '', 'lua vim.lsp.buf.signature_help()') + u.map(0, 'n', ']d', 'lua vim.lsp.diagnostic.goto_next()') + u.map(0, 'n', '[d', 'lua vim.lsp.diagnostic.goto_prev()') + + -- 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' }, +} -- cgit 1.4.1