
---@type vim.lsp.Config
local config = {
    cmd = {
        "arduino-language-server",
    },
    filetypes = {
        "arduino",
    },
    root_dir = function (bufnr, on_dir)
        local fname = vim.api.nvim_buf_get_name(bufnr)
        --vim.notify(vim.fs.find({ vim.fn.fnamemodify(fname, ':t:r') }, { type = "directory", upward = true })[1])
        on_dir(vim.fs.find({ vim.fn.fnamemodify(fname, ':t:r') }, { type = "directory", upward = true })[1])
    end,
    capabilities = {
        textDocument = {
            ---@diagnostic disable-next-line: assign-type-mismatch
            semanticTokens = vim.NIL,
        },
        workspace = {
            ---@diagnostic disable-next-line: assign-type-mismatch
            semanticTokens = vim.NIL,
        },
    },
}

vim.lsp.config['arduino_language_server'] = config
vim.lsp.enable('arduino_language_server')

