Add basic lsp support

This commit is contained in:
Folkert Kevelam 2025-06-08 22:13:28 +02:00
parent 48e3068d7c
commit 5d803ecb80

View File

@ -41,6 +41,8 @@ vim.cmd('syntax on')
require('packer').startup(function(use)
use('tpope/vim-surround')
use('neovim/nvim-lspconfig')
use('folke/tokyonight.nvim')
use('euclidianAce/BetterLua.vim')
use{
@ -115,3 +117,60 @@ require'nvim-treesitter.configs'.setup {
additional_vim_regex_highlighting = true
}
}
vim.lsp.enable('lua_ls')
vim.lsp.config('lua_ls', {
on_init = function(client)
if client.workspace_folders then
local path = client.workspace_folders[1].name
if
path ~= vim.fn.srtdpath('config')
and (vim.uv.fs_state(path .. '/.luarc.json') or vim.uv.fs_state(path .. '/.luarc.jsonc'))
then
return
end
end
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
runtime = {
version = 'LuaJIT',
path = {
'lua/?.lua',
'lua/?/init.lua',
},
},
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME
}
}
})
end,
settings = {
Lua = {}
}
})
vim.lsp.enable('ada_ls')
vim.lsp.config('ada_ls', {
on_attach = function(client, bufnr)
vim.lsp.completion.enable(true, client.id, bufnr, {
autotrigger = true,
convert = function(item)
return { abbr = item.label:gsub("%b()", "") }
end,
})
vim.keymap.set("i", "<C-space>", vim.lsp.completion.get, {desc = "trigger autocompletion"})
end,
settings = {
ada = {
projectFile = "project.gpr";
}
}
})
vim.opt.completeopt = { "menuone", "noselect", "popup" }