From 2f056a870178e777eb317bc09661d5169d6314e6 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 19 Feb 2021 16:51:36 +0100 Subject: [PATCH] nvim: Update lsp lua configuration Uses arch aur-packaged installation of sumneko_lua, and invokes it for any lua file. Takes care of some additional configuration to enable easier programming for neovim itself. --- bootstrap/packages.txt | 2 + nvim/.config/nvim/lua/nvim-lspconfig/init.lua | 39 +++++++++++++------ nvim/.config/nvim/plugins.vim | 1 - 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/bootstrap/packages.txt b/bootstrap/packages.txt index adc7f27..3268d01 100644 --- a/bootstrap/packages.txt +++ b/bootstrap/packages.txt @@ -54,6 +54,8 @@ linux-lts-headers littler logrotate lscolors-git +lua-format +lua-language-server lvm2 lynx maim diff --git a/nvim/.config/nvim/lua/nvim-lspconfig/init.lua b/nvim/.config/nvim/lua/nvim-lspconfig/init.lua index 0b3e386..dd94705 100644 --- a/nvim/.config/nvim/lua/nvim-lspconfig/init.lua +++ b/nvim/.config/nvim/lua/nvim-lspconfig/init.lua @@ -30,14 +30,31 @@ require'lspconfig'.bashls.setup {on_attach = on_attach} require'lspconfig'.gopls.setup {on_attach = on_attach} require'lspconfig'.texlab.setup {on_attach = on_attach} --- To get builtin LSP running, do something like: --- NOTE: This replaces the calls where you would have before done `require('nvim_lsp').sumneko_lua.setup()` -require('nlua.lsp.nvim').setup(require('lspconfig'), { - on_attach = on_attach, - - -- Include globals you want to tell the LSP are real :) - globals = { - -- Colorbuddy - "Color", "c", "Group", "g", "s" - } -}) +-- requires the lua-language-server package to be installed +-- The arch package defaults to the following directory +local sumneko_root_path = "/usr/share/lua-language-server" +require'lspconfig'.sumneko_lua.setup { + cmd = { "lua-language-server", "-E", sumneko_root_path .. "/main.lua"}; + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + -- Setup your lua path + path = vim.split(package.path, ';'), + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = {'vim'}, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = { + [vim.fn.expand('$VIMRUNTIME/lua')] = true, + [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true, + }, + }, + }, + }, + on_attach = on_attach, +} diff --git a/nvim/.config/nvim/plugins.vim b/nvim/.config/nvim/plugins.vim index 7537ece..cf4bf87 100644 --- a/nvim/.config/nvim/plugins.vim +++ b/nvim/.config/nvim/plugins.vim @@ -70,7 +70,6 @@ Plug 'reedes/vim-textobj-sentence' Plug 'junegunn/goyo.vim', { 'for': ['pandoc', 'markdown', 'txt'], 'on': 'Goyo' } " provide distraction free writing Plug 'junegunn/limelight.vim', { 'for': ['pandoc', 'markdown', 'txt'], 'on': 'Goyo' } " provide even distraction free-er writing (lowlight paragraphs) " Language Integration -Plug 'tjdevries/nlua.nvim' " lua lsp integration Plug 'euclidianAce/BetterLua.vim' " better syntax highlighting for lua Plug 'sheerun/vim-polyglot' " syntax plugins for almost every language Plug 'stephpy/vim-yaml'