Feat: code formating with null-ls

This commit is contained in:
Bertrand Benjamin 2022-02-14 11:36:10 +01:00
parent 171ed7447e
commit 7e85124b10
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,21 @@
local null_ls_status_ok, null_ls = pcall(require, "null-ls")
if not null_ls_status_ok then
return
end
-- 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" } },
diagnostics.flake8,
},
}
local map = vim.api.nvim_set_keymap
map('n', '<leader>f', '<cmd>lua vim.lsp.buf.formatting_sync()<cr>', {})

View File

@ -78,6 +78,12 @@ return packer.startup(function(use)
use {'hrsh7th/cmp-nvim-lsp', after = 'nvim-cmp'} use {'hrsh7th/cmp-nvim-lsp', after = 'nvim-cmp'}
-- use {'f3fora/cmp-spell', after = 'nvim-cmp'} -- use {'f3fora/cmp-spell', after = 'nvim-cmp'}
-- for formatters and linters
use {
"jose-elias-alvarez/null-ls.nvim",
config = [[require('config.null-ls')]]
}
use 'nvim-lua/popup.nvim' use 'nvim-lua/popup.nvim'
use { use {