nvim/lua/plugins/null-ls.lua

72 lines
2.3 KiB
Lua
Raw Normal View History

2022-12-31 17:43:31 +01:00
local M = {
'jose-elias-alvarez/null-ls.nvim',
2023-01-01 20:12:55 +01:00
dependencies = {
'LostNeophyte/null-ls-embedded',
},
ft = 'markdown',
2022-12-31 17:43:31 +01:00
}
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',
2023-01-13 22:10:17 +01:00
'{BasedOnStyle: LLVM, IndentWidth: 8, UseTab: Always, BreakBeforeBraces: Linux, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false}',
-- '{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 }',
2022-12-31 17:43:31 +01:00
},
},
formatting.clang_format.with {
2023-01-22 16:45:43 +01:00
filetypes = { 'cpp', 'java' },
2022-12-31 17:43:31 +01:00
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
2023-01-01 20:12:55 +01:00
require('null-ls-embedded').nls_source,
2022-12-31 17:43:31 +01:00
},
}
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