improved prettier setup
This commit is contained in:
parent
5c60042f1e
commit
c386da8ff5
@ -6,20 +6,38 @@ function M.config()
|
||||
return
|
||||
end
|
||||
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
null_ls.setup {
|
||||
sources = {
|
||||
-- https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md
|
||||
|
||||
-- sudo pacman -S prettierd
|
||||
-- null_ls.builtins.formatting.prettierd,
|
||||
null_ls.builtins.formatting.prettierd.with({
|
||||
disabled_filetypes = { "html", "markdown" },
|
||||
}),
|
||||
|
||||
-- sudo pacman -S eslint_d
|
||||
-- null_ls.builtins.diagnostics.eslint_d.with({
|
||||
-- diagnostic_config = { -- see also :help vim.diagnostic.config()
|
||||
-- virtual_text = false,
|
||||
-- }
|
||||
-- }),
|
||||
}
|
||||
null_ls.builtins.diagnostics.eslint_d.with({
|
||||
condition = function(utils)
|
||||
return utils.root_has_file({ ".eslintrc.js" })
|
||||
end,
|
||||
diagnostic_config = { -- see also :help vim.diagnostic.config()
|
||||
virtual_text = false,
|
||||
}
|
||||
}),
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ bufnr = bufnr })
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -1,14 +0,0 @@
|
||||
local M = {}
|
||||
|
||||
function M.config()
|
||||
local status_ok, prettier = pcall(require, "prettier")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
prettier.setup({
|
||||
bin = 'prettierd'
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
@ -139,7 +139,11 @@ packer.startup {
|
||||
-- use { 'simrat39'/symbols-outline.nvim', cmd = 'SymbolsOutline', setup = function ... }
|
||||
|
||||
-- null-ls LSP injector
|
||||
use { 'jose-elias-alvarez/null-ls.nvim', config = function() require'configs.null-ls'.config() end }
|
||||
use {
|
||||
'jose-elias-alvarez/null-ls.nvim',
|
||||
event = 'BufRead',
|
||||
config = function() require'configs.null-ls'.config() end
|
||||
}
|
||||
|
||||
-- highlight hovered-over text
|
||||
use {
|
||||
|
Loading…
Reference in New Issue
Block a user