From 842718578444c50d4bcd4c46230f29c35b7c5102 Mon Sep 17 00:00:00 2001 From: Nulo Date: Thu, 18 Nov 2021 12:24:01 -0300 Subject: [PATCH] nvim: formatter.nvim --- .config/nvim/init.vim | 25 +++++++++++++++++++ .../nvim/pack/plugins/start/formatter.nvim | 1 + .gitmodules | 3 +++ 3 files changed, 29 insertions(+) create mode 160000 .config/nvim/pack/plugins/start/formatter.nvim diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 2bff1c4..52bb08b 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -50,8 +50,33 @@ for _, lsp in ipairs(servers) do on_attach = on_attach, } end + +local prettier = { + function() + return { + exe = "prettier", + args = {"--stdin-filepath", vim.fn.fnameescape(vim.api.nvim_buf_get_name(0))}, + stdin = true + } + end +} +require('formatter').setup({ + filetype = { + javascript = prettier, + typescript = prettier, + html = prettier, + css = prettier, + scss = prettier, + sass = prettier, + } +}) EOF +augroup FormatAutogroup + autocmd! + autocmd BufWritePost *.js,*.ts,*.html,*.css,*.scss,*.sass FormatWrite +augroup END + let g:fzf_layout = { 'down': '40%' } noremap f :Files diff --git a/.config/nvim/pack/plugins/start/formatter.nvim b/.config/nvim/pack/plugins/start/formatter.nvim new file mode 160000 index 0000000..0cdce2d --- /dev/null +++ b/.config/nvim/pack/plugins/start/formatter.nvim @@ -0,0 +1 @@ +Subproject commit 0cdce2da8762ee01ee7d8df047b6e569d58c1ba3 diff --git a/.gitmodules b/.gitmodules index 67f80d7..68c30af 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,3 +22,6 @@ [submodule ".config/nvim/pack/plugins/start/fzf"] path = .config/nvim/pack/plugins/start/fzf url = https://github.com/junegunn/fzf +[submodule ".config/nvim/pack/plugins/start/formatter.nvim"] + path = .config/nvim/pack/plugins/start/formatter.nvim + url = https://github.com/mhartington/formatter.nvim