Files
nvim/lua/lspconfiguration.lua
nichkara 7b3f516848
Some checks failed
Test Neovim config on push / build (ubuntu-20.04) (push) Failing after 42s
VHDL LSP integration update
2025-10-22 20:38:43 +02:00

67 lines
1.6 KiB
Lua

-- Mason setup
require("mason").setup(require("mason").setup({
ui = {
icons = {
package_installed = "",
package_pending = "󰔟",
package_uninstalled = "",
},
},
}))
require("mason-lspconfig").setup({
ensure_installed = {
"lua_ls",
},
})
vim.lsp.enable("verible")
vim.lsp.config("verible", { cmd = { "verible-verilog-ls", "--rules_config_search" } })
vim.lsp.enable("clangd")
vim.lsp.config("clangd", {
cmd = { "clangd" },
root_markers = { ".clangd" },
filetypes = { "c", "cpp" },
})
-- @name file_exists
-- @param (name
-- @short Check if a file does exists (i. e. an ada project file)
local function file_exists(name)
local f = io.open(name, "r")
return f ~= nil and io.close(f)
end
-- @name get_config_file
-- @param
-- @short Get the configuration file.
local function get_config_file()
local filename = vim.api.nvim_buf_get_name(0)
local basedirectory = filename:gsub("/[^%/]-$", "")
local currentdirectory = filename:match("[^%/]-$")
if file_exists(basedirectory .. currentdirectory .. ".gpr") then
return basedirectory .. currentdirectory .. ".gpr"
else
basedirectory = basedirectory:gsub("/[^%/]-$", "")
currentdirectory = filename:match("[^%/]-$")
if file_exists(basedirectory .. currentdirectory .. ".gpr") then
return basedirectory .. currentdirectory .. ".gpr"
else
return "default.gpr"
end
end
end
vim.lsp.enable("als")
vim.lsp.config("als", { projectFile = get_config_file() })
vim.lsp.enable("vhdl_ls")
vim.lsp.config("vhdl_ls", {
cmd = { "vhdl_ls" },
filetypes = { "vhdl" },
root_markers = { "vhdl_ls.toml", ".git" },
settings = {},
})