From ea8e5124827054154feaa37ec903f4b584a12c0e Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Mon, 1 Aug 2022 15:01:51 +0200 Subject: [PATCH] Add LSP configurations for solargraph and sumneko --- vim/lua/on_lsp_attach.lua | 27 +++++++++++++++++++++++++++ vim/lua/solargraph.lua | 4 ++++ vim/lua/sumneko.lua | 4 ++++ 3 files changed, 35 insertions(+) create mode 100644 vim/lua/on_lsp_attach.lua create mode 100644 vim/lua/solargraph.lua create mode 100644 vim/lua/sumneko.lua diff --git a/vim/lua/on_lsp_attach.lua b/vim/lua/on_lsp_attach.lua new file mode 100644 index 0000000..7137f91 --- /dev/null +++ b/vim/lua/on_lsp_attach.lua @@ -0,0 +1,27 @@ +local opts = { noremap=true, silent=true } + +return function(client, bufnr) + -- Enable completion triggered by + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local bufopts = { noremap=true, silent=true, buffer=bufnr } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) + + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) + vim.keymap.set('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, bufopts) + + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) + vim.keymap.set('n', 'r', vim.lsp.buf.rename, bufopts) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) + vim.keymap.set('n', 'f', vim.lsp.buf.formatting, bufopts) +end diff --git a/vim/lua/solargraph.lua b/vim/lua/solargraph.lua new file mode 100644 index 0000000..a3e202a --- /dev/null +++ b/vim/lua/solargraph.lua @@ -0,0 +1,4 @@ +local lsp_flags = require('lspconfig').solargraph.setup{ + on_attach = require 'on_lsp_attach', +} +vim.api.nvim_command("LspStart") diff --git a/vim/lua/sumneko.lua b/vim/lua/sumneko.lua new file mode 100644 index 0000000..dfd2ed3 --- /dev/null +++ b/vim/lua/sumneko.lua @@ -0,0 +1,4 @@ +local lsp_flags = require('lspconfig').sumneko_lua.setup{ + on_attach = require 'on_lsp_attach', +} +vim.api.nvim_command("LspStart")