72 lines
2.3 KiB
Lua
72 lines
2.3 KiB
Lua
local M = {
|
|
'jose-elias-alvarez/null-ls.nvim',
|
|
dependencies = {
|
|
'LostNeophyte/null-ls-embedded',
|
|
},
|
|
ft = 'markdown',
|
|
}
|
|
|
|
function M.config()
|
|
local null_ls = require 'null-ls'
|
|
|
|
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting
|
|
local formatting = null_ls.builtins.formatting
|
|
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
|
|
local diagnostics = null_ls.builtins.diagnostics
|
|
|
|
null_ls.setup {
|
|
debug = false,
|
|
sources = {
|
|
formatting.prettier.with { extra_args = { '--no-semi', '--single-quote', '--jsx-single-quote' } },
|
|
formatting.black.with { extra_args = { '--fast' } },
|
|
formatting.stylua.with { extra_args = { '--quote-style=AutoPreferSingle', '--call-parentheses=None' } },
|
|
formatting.clang_format.with {
|
|
filetypes = { 'c' },
|
|
extra_args = {
|
|
'--style',
|
|
'{BasedOnStyle: LLVM, IndentWidth: 8, UseTab: Always, BreakBeforeBraces: Linux, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, AlwaysBreakAfterReturnType: AllDefinitions}',
|
|
-- '{AccessModifierOffset : -2, AllowShortIfStatementsOnASingleLine : Never, AlignConsecutiveMacros : true, AllowShortLoopsOnASingleLine : false, AlwaysBreakTemplateDeclarations : true, Standard : c++20, NamespaceIndentation : All, IndentWidth : 4, TabWidth : 4, BreakBeforeBraces : Linux, AllowShortFunctionsOnASingleLine : Empty, AllowShortBlocksOnASingleLine : Never, FixNamespaceComments : true, PointerAlignment : Right, ColumnLimit : 120, ContinuationIndentWidth : 2, UseTab : Always }',
|
|
},
|
|
},
|
|
formatting.clang_format.with {
|
|
filetypes = { 'cpp' },
|
|
extra_args = {
|
|
'--style',
|
|
'google',
|
|
},
|
|
},
|
|
formatting.beautysh,
|
|
formatting.goimports,
|
|
formatting.gofumpt,
|
|
formatting.sql_formatter,
|
|
diagnostics.golangci_lint.with {
|
|
extra_args = {
|
|
'-E',
|
|
'revive',
|
|
'-E',
|
|
'errcheck',
|
|
'-E',
|
|
'gosec',
|
|
'-E',
|
|
'nilerr',
|
|
'-E',
|
|
'nlreturn',
|
|
},
|
|
},
|
|
formatting.asmfmt.with {
|
|
filetypes = { 'asm', 's' },
|
|
},
|
|
-- diagnostics.flake8
|
|
require('null-ls-embedded').nls_source,
|
|
},
|
|
}
|
|
end
|
|
|
|
function M.has_formatter(ft)
|
|
local sources = require 'null-ls.sources'
|
|
local available = sources.get_available(ft, 'NULL_LS_FORMATTING')
|
|
return #available > 0
|
|
end
|
|
|
|
return M
|