31 lines
904 B
Lua
31 lines
904 B
Lua
-- Null-ls.
|
|
local status, null_ls = pcall(require, 'null-ls')
|
|
if (not status) then return end
|
|
|
|
local formatting = null_ls.builtins.formatting
|
|
local prettier_config = vim.fn.stdpath('config') .. '/lua/axp/plugins/null-ls/.prettierrc'
|
|
local clang_format_config = vim.fn.stdpath('config') .. '/lua/axp/plugins/null-ls/.clang-format'
|
|
|
|
-- Init.
|
|
null_ls.setup {
|
|
sources = {
|
|
formatting.clang_format.with({
|
|
extra_args = {
|
|
-- '--style=Google'
|
|
'--assume-filename=' .. clang_format_config
|
|
}
|
|
}),
|
|
formatting.prettier.with({
|
|
extra_args = { '--config', prettier_config }
|
|
})
|
|
},
|
|
on_attach = function (client, bufnr)
|
|
if client.supports_method('textDocument/formatting') then
|
|
-- Create a command `:Format` local to the LSP buffer
|
|
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
|
|
vim.lsp.buf.format()
|
|
end, { desc = 'Format current buffer with LSP' })
|
|
end
|
|
end
|
|
}
|