From 769fcf82ef1fd22cdf0c82d5cc45e7f109b8d19c Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Sat, 18 Nov 2023 22:31:15 +0200 Subject: [PATCH] Fix lua_ls setup, add some documentation --- home/.config/nvim/lua/.luarc.json | 4 --- home/.config/nvim/lua/lsp_utils.lua | 8 +++-- home/.config/nvim/lua/plugins/mason.lua | 40 ++++++++----------------- home/.config/nvim/lua/settings.lua | 1 - 4 files changed, 18 insertions(+), 35 deletions(-) delete mode 100644 home/.config/nvim/lua/.luarc.json diff --git a/home/.config/nvim/lua/.luarc.json b/home/.config/nvim/lua/.luarc.json deleted file mode 100644 index 03c8166..0000000 --- a/home/.config/nvim/lua/.luarc.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", - "workspace.checkThirdParty": false -} diff --git a/home/.config/nvim/lua/lsp_utils.lua b/home/.config/nvim/lua/lsp_utils.lua index 614ac5a..f8e4680 100644 --- a/home/.config/nvim/lua/lsp_utils.lua +++ b/home/.config/nvim/lua/lsp_utils.lua @@ -2,7 +2,7 @@ -- reusable functions local m = {} --- Map LSP specific keybinds. +-- Maps LSP specific keybinds. -- This makes them only available when LSP is running function m.map_keys() local telescope_builtin = require("telescope.builtin") @@ -41,7 +41,8 @@ function m.map_keys() }) end - +-- Maps keys and does other needed actions +-- when client attatches function m.on_attach(client, bufnr) -- Attach navic if document symbols are available if client.server_capabilities.documentSymbolProvider then @@ -52,8 +53,9 @@ function m.on_attach(client, bufnr) m.map_keys() end +-- Combine built-in LSP and cmp cabaibilities +-- and additional capabilities from other plugins function m.get_capabilities() - -- Combine built-in LSP and cmp cabaibilities local capabilities = vim.tbl_deep_extend( "force", vim.lsp.protocol.make_client_capabilities(), diff --git a/home/.config/nvim/lua/plugins/mason.lua b/home/.config/nvim/lua/plugins/mason.lua index af5dcc4..a10d855 100644 --- a/home/.config/nvim/lua/plugins/mason.lua +++ b/home/.config/nvim/lua/plugins/mason.lua @@ -1,17 +1,29 @@ -- Package manager for LSP servers, DAP adapters etc. +-- It also handles starting all of my LSP servers return { "williamboman/mason.nvim", dependencies = { "neovim/nvim-lspconfig", "williamboman/mason-lspconfig.nvim", "WhoIsSethDaniel/mason-tool-installer.nvim", + -- Extended functionality for jdtls "mfussenegger/nvim-jdtls", + -- Neovim setup for init.lua and plugin development with full signature help, docs and completion for the nvim lua API. + { + "folke/neodev.nvim", + opts = { + override = function(root_dir, library) + library.enabled = true + library.plugins = true + end, + }, + }, }, config = function() require("mason").setup() local mason_lsp = require("mason-lspconfig") - local lsp_utils = require('lsp_utils') + local lsp_utils = require("lsp_utils") local capabilities = lsp_utils.get_capabilities() mason_lsp.setup() @@ -24,32 +36,6 @@ return { }) end, - -- Override lua_ls settings - ["lua_ls"] = function() - require("lspconfig").lua_ls.setup({ - on_attach = lsp_utils.on_attach, - capabilities = capabilities, - 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 }, - }, - }, - }) - end, - -- Don't set up jdtls, it is set up by nvim-jdtls ["jdtls"] = function() end, }) diff --git a/home/.config/nvim/lua/settings.lua b/home/.config/nvim/lua/settings.lua index a58a827..2157830 100644 --- a/home/.config/nvim/lua/settings.lua +++ b/home/.config/nvim/lua/settings.lua @@ -25,7 +25,6 @@ o.diffopt = "filler,internal,algorithm:histogram,indent-heuristic" -- Allow switching buffers with unsaved changes o.hidden = true - o.guicursor = table.concat({ "i:ver1", -- Vertical bar cursor in insert mode "a:blinkon1", -- Blinking cursor in all modes