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 " formatter.nvim
packadd! formatter.nvim " https://github.com/mhartington/formatter.nvim.git packadd! formatter.nvim " https://github.com/mhartington/formatter.nvim.git
lua <<EOF lua <<EOF
-- return prettier configuration. If a frontend/ path exists in project root,
-- assume node_modules will be found there.
local prettier = function() 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 { return {
exe = "prettier", exe = base_path .. "/node_modules/.bin/prettier",
args = {"--stdin-filepath", vim.api.nvim_buf_get_name(0), '--single-quote'}, args = {"--stdin-filepath", vim.api.nvim_buf_get_name(0), '--single-quote'},
stdin = true stdin = true
} }
end end
require('formatter').setup({ require('formatter').setup({
filetype = { filetype = {
javascript = { prettier }, javascript = { prettier },