chore(nvim): re-add Get_project_node_modules_path

This commit is contained in:
Rob Watson 2023-11-06 07:36:10 +01:00
parent 97f4f9d636
commit 5443f5f067
2 changed files with 14 additions and 1 deletions

View File

@ -1,6 +1,6 @@
local prettier = function()
return {
exe = vim.fn.getcwd() .. "/node_modules/.bin/prettier",
exe = Get_project_node_modules_path() .. "/.bin/prettier",
args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote" },
stdin = true,
}

View File

@ -1,3 +1,16 @@
-- Return the node_modules path for this project. If the project root contains a
-- frontend/ directory, assume node_modules lives there.
function Get_project_node_modules_path()
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 base_path .. "/node_modules"
end
-- Return the project's go module path from go.mod, or an empty string if the file cannot be read.
function Get_project_go_module_path()
local root_path = vim.fn.getcwd()