-- ┌                                               ┐
-- │            Low-level (HDL and ASM)            │
-- └                                               ┘
local lsp = vim.lsp

local capabilities = require("lsp-options").capabilities
local on_attach = require("lsp-options").on_attach

-- ┌                                               ┐
-- │                      ASM                      │
-- └                                               ┘
lsp.config("asm_lsp", {
    on_attach = on_attach,
    capabilities = capabilities,
})

-- ┌                                               ┐
-- │                    Verilog                    │
-- └                                               ┘
local lspconfutil = require("lspconfig/util")
local root_pattern = lspconfutil.root_pattern("veridian.yml", ".git", ".xpr")
local verilog_root_dir = function()
    local filename = lspconfutil.path.join(vim.loop.cwd(), fname)
    return root_pattern(filename) or lspconfutil.path.dirname(filename)
end
lsp.config("veridian", {
    capabilities = capabilities,
    on_attach = on_attach,
    root_dir = verilog_root_dir,
})

lsp.config("verible", {
    -- cmd = { 'verible-verilog-ls', '--rules_config=/home/janis/.config/nvim/util/verible-conf.json' },
    cmd = { "verible-verilog-ls", "--rules=-no-trailing-spaces", "" },
    capabilities = capabilities,
    on_attach = on_attach,
    root_dir = verilog_root_dir,
})


-- ── Enable configs ───────────────────────────────────────────────
local enable = vim.lsp.enable
enable("veridian")
enable("verible")
enable("asm_lsp")
