Fix lua_ls setup, add some documentation

This commit is contained in:
Marko Korhonen 2023-11-18 22:31:15 +02:00
parent 168742d109
commit 769fcf82ef
Signed by: FunctionalHacker
GPG key ID: A7F78BCB859CD890
4 changed files with 18 additions and 35 deletions

View file

@ -1,4 +0,0 @@
{
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
"workspace.checkThirdParty": false
}

View file

@ -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(),

View file

@ -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,
})

View file

@ -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