From 6d39ae8ac1686de03fec6935be980a2525ab64c2 Mon Sep 17 00:00:00 2001 From: "flyingscorpio@clevo" Date: Tue, 2 Aug 2022 14:12:52 +0200 Subject: [PATCH] Add lua language server for LSP --- roles/neovim/files/lua/autocommands.lua | 2 +- roles/neovim/files/lua/lsp/lua.lua | 23 +++++++++++++++++++++++ roles/neovim/files/lua/plugin_options.lua | 3 +++ roles/neovim/tasks/main.yml | 2 ++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 roles/neovim/files/lua/lsp/lua.lua diff --git a/roles/neovim/files/lua/autocommands.lua b/roles/neovim/files/lua/autocommands.lua index 3b388db..aaafa69 100644 --- a/roles/neovim/files/lua/autocommands.lua +++ b/roles/neovim/files/lua/autocommands.lua @@ -65,7 +65,7 @@ vim.api.nvim_create_autocmd("FileType", { group = group }) vim.api.nvim_create_autocmd("FileType", { - pattern = "vhdl", + pattern = { "lua", "vhdl" }, command = "setlocal shiftwidth=2 tabstop=2 softtabstop=2", group = group }) diff --git a/roles/neovim/files/lua/lsp/lua.lua b/roles/neovim/files/lua/lsp/lua.lua new file mode 100644 index 0000000..80835a4 --- /dev/null +++ b/roles/neovim/files/lua/lsp/lua.lua @@ -0,0 +1,23 @@ +-- LSP Server for Lua +require'lspconfig'.sumneko_lua.setup { + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = {'vim'}, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), + }, + -- Do not send telemetry data containing a randomized but unique identifier + telemetry = { + enable = false, + }, + }, + }, +} diff --git a/roles/neovim/files/lua/plugin_options.lua b/roles/neovim/files/lua/plugin_options.lua index bb09fce..5dc29f7 100644 --- a/roles/neovim/files/lua/plugin_options.lua +++ b/roles/neovim/files/lua/plugin_options.lua @@ -1,3 +1,6 @@ +-- LSP Servers +require('lsp.lua') + -- NERDTree vim.g.NERDTreeIgnore = { '^__pycache__$', '\\.pyc', '\\~$' } vim.keymap.set('n', 'ne', 'NERDTree', { remap = true }) diff --git a/roles/neovim/tasks/main.yml b/roles/neovim/tasks/main.yml index 2fec7fe..0d97863 100644 --- a/roles/neovim/tasks/main.yml +++ b/roles/neovim/tasks/main.yml @@ -16,6 +16,7 @@ - cmake - clang - npm + - lua-language-server when: ansible_facts['distribution'] == 'Archlinux' @@ -36,6 +37,7 @@ - cmake - clang - npm + - lua-language-server when: ansible_facts['distribution'] == 'Debian'