fix(nvim): use project-local binary
This commit is contained in:
parent
48e8c3a5be
commit
de3c475760
14
nvimrc
14
nvimrc
|
@ -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 },
|
||||
|
|
Loading…
Reference in New Issue