1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
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
|