fix(nvim): use project-local binary

This commit is contained in:
Rob Watson 2023-09-16 22:22:29 +02:00
parent 48e8c3a5be
commit de3c475760
1 changed files with 13 additions and 1 deletions

14
nvimrc
View File

@ -491,14 +491,26 @@ packadd! vim-wordmotion " https://github.com/chaoren/vim-wordmotion.git
" formatter.nvim
packadd! formatter.nvim " https://github.com/mhartington/formatter.nvim.git
lua <<EOF
-- return prettier configuration. If a frontend/ path exists in project root,
-- assume node_modules will be found there.
local prettier = function()
local root_path = vim.fn.getcwd()
local frontend_path = root_path .. "/frontend"
local is_frontend = vim.fn.isdirectory(frontend_path) ~= 0
local base_path = root_path
if is_frontend then
base_path = frontend_path
end
return {
exe = "prettier",
exe = base_path .. "/node_modules/.bin/prettier",
args = {"--stdin-filepath", vim.api.nvim_buf_get_name(0), '--single-quote'},
stdin = true
}
end
require('formatter').setup({
filetype = {
javascript = { prettier },