local lsp_attach = require "pi.lsp.attach" local lsp_flags = require "pi.lsp.flags" return function(ops) local capabilities = require("blink.cmp").get_lsp_capabilities(vim.lsp.protocol.make_client_capabilities()) local config = { on_attach = function(client, bufnr) -- Call the default attach function lsp_attach(client, bufnr) -- Disable LSP formatting if asmfmt is available (prefer null-ls formatting) if vim.fn.executable("asmfmt") == 1 then client.server_capabilities.documentFormattingProvider = false client.server_capabilities.documentRangeFormattingProvider = false end end, flags = lsp_flags, filetypes = { "asm", "s", "S" }, capabilities = capabilities, root_dir = function(fname) local patterns = { "Makefile", "makefile", "GNUmakefile", ".git" } for _, pattern in ipairs(patterns) do local found = vim.fs.find(pattern, { path = fname, upward = true, })[1] if found then return vim.fs.dirname(found) end end return vim.fn.getcwd() end, } if vim.fn.executable "asm-lsp" == 1 then config.cmd = { "asm-lsp" } end return vim.tbl_extend("force", config, ops) end