Adding in prettier formatting for javascript
This commit is contained in:
@@ -75,6 +75,7 @@ require('lazy').setup({
|
|||||||
'junegunn/vim-easy-align',
|
'junegunn/vim-easy-align',
|
||||||
'jpalardy/vim-slime',
|
'jpalardy/vim-slime',
|
||||||
'github/copilot.vim',
|
'github/copilot.vim',
|
||||||
|
'mhartington/formatter.nvim',
|
||||||
|
|
||||||
-- Detect tabstop and shiftwidth automatically
|
-- Detect tabstop and shiftwidth automatically
|
||||||
-- 'tpope/vim-sleuth',
|
-- 'tpope/vim-sleuth',
|
||||||
@@ -428,6 +429,22 @@ require('telescope').setup {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require('formatter').setup {
|
||||||
|
logging = true,
|
||||||
|
log_level = vim.log.levels.WARN,
|
||||||
|
filetype = {
|
||||||
|
javascript = {
|
||||||
|
function()
|
||||||
|
return {
|
||||||
|
exe = 'prettier',
|
||||||
|
args = { '--stdin-filepath', vim.api.nvim_buf_get_name(0) },
|
||||||
|
stdin = true,
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
-- Enable telescope fzf native, if installed
|
-- Enable telescope fzf native, if installed
|
||||||
pcall(require('telescope').load_extension, 'fzf')
|
pcall(require('telescope').load_extension, 'fzf')
|
||||||
|
|
||||||
@@ -678,11 +695,13 @@ local servers = {
|
|||||||
-- diagnostics = { disable = { 'missing-fields' } },
|
-- diagnostics = { disable = { 'missing-fields' } },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
eslint = {},
|
||||||
}
|
}
|
||||||
vim.api.nvim_set_var("lsp_formatters",
|
vim.api.nvim_set_var("lsp_formatters",
|
||||||
{
|
{
|
||||||
"luaformatter",
|
"luaformatter",
|
||||||
"prettier",
|
"prettier",
|
||||||
|
"prettierd",
|
||||||
"cmakelang",
|
"cmakelang",
|
||||||
"beautysh",
|
"beautysh",
|
||||||
"clang-format",
|
"clang-format",
|
||||||
@@ -846,5 +865,14 @@ vim.api.nvim_create_autocmd("FileType", {
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local augroup = vim.api.nvim_create_augroup
|
||||||
|
local autocmd = vim.api.nvim_create_autocmd
|
||||||
|
augroup("__formatter__", { clear = true })
|
||||||
|
autocmd("BufWritePost", {
|
||||||
|
group = "__formatter__",
|
||||||
|
command = ":FormatWrite",
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
-- The line beneath this is called `modeline`. See `:help modeline`
|
-- The line beneath this is called `modeline`. See `:help modeline`
|
||||||
-- vim: ts=2 sts=2 sw=2 et
|
-- vim: ts=2 sts=2 sw=2 et
|
||||||
|
|||||||
Reference in New Issue
Block a user