diff --git a/FAQ.md b/FAQ.md new file mode 100644 index 0000000..7d31bf4 --- /dev/null +++ b/FAQ.md @@ -0,0 +1,22 @@ +# FAQ + +## "project root not found" + +If the project root is not found it can't save the jump points. You can fix this by defining more project roots like + +```lua + opts = { + open_callback = require("marlin.callbacks").use_split, + patterns = { ".git", ".svn", "Makefile", "Cargo.toml", "." }, + }, +``` + +Or disabling the message with (But jump points won't be saved) + +```lua + opts = { + suppress = { + missing_root = false + } + } +``` diff --git a/README.md b/README.md index 3b73a24..355bab3 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,9 @@ local default = { datafile = vim.fn.stdpath("data") .. "/marlin.json", -- location of data file open_callback = callbacks.change_buffer -- default way to open buffer sorter = sorter.by_buffer -- sort by bufferid + suppress = { + missing_root = false -- don't give warning on project root not found + } } ``` @@ -126,6 +129,10 @@ When I first saw harpoon I was immediately hooked but I missed a few key feature Like anyone else missing a feature I created a patch but it seems that many other did the same. +### Issues/Feature request + +[FAQ](FAQ.md) might have what you are looking, but pull request are also welcome. + ### Credits Credit goes to [ThePrimeagen](https://github.com/ThePrimeagen/harpoon/) for the idea. diff --git a/doc/marlin.txt b/doc/marlin.txt index 475dcc3..9d8d0ba 100644 --- a/doc/marlin.txt +++ b/doc/marlin.txt @@ -72,6 +72,9 @@ Default config datafile = vim.fn.stdpath("data") .. "/marlin.json", open_callback = callbacks.change_buffer, sorter = sorter.by_buffer, + suppress = { + missing_root = false + } } < diff --git a/lua/marlin/datafile.lua b/lua/marlin/datafile.lua index b4442c5..c91bc4c 100644 --- a/lua/marlin/datafile.lua +++ b/lua/marlin/datafile.lua @@ -12,8 +12,14 @@ M.read_config = function(datafile) return {} end -M.save_data = function(datafile, project, localdata) - local data = M.read_config(datafile) +M.save_data = function(opts, project, localdata) + if project == nil then + if not opts.suppress.missing_root then + vim.notify("project root not found") + end + return + end + local data = M.read_config(opts.datafile) data[project] = localdata -- If we have no more files we remove the project @@ -22,9 +28,9 @@ M.save_data = function(datafile, project, localdata) end local content = vim.fn.json_encode(data) - local fd = io.open(datafile, "w") + local fd = io.open(opts.datafile, "w") if not fd then - vim.notify("Unable to open " .. datafile .. " for write") + vim.notify("Unable to open " .. opts.datafile .. " for write") return end diff --git a/lua/marlin/init.lua b/lua/marlin/init.lua index 3cbfe37..18d4594 100644 --- a/lua/marlin/init.lua +++ b/lua/marlin/init.lua @@ -64,6 +64,9 @@ local default = { datafile = vim.fn.stdpath("data") .. "/marlin.json", open_callback = callbacks.change_buffer, sorter = sorter.by_buffer, + suppress = { + missing_root = false, + }, } --minidoc_afterlines_end @@ -74,7 +77,7 @@ end local save = function(m) vim.schedule(function() - datafile.save_data(m.opts.datafile, m.project_path, m.project_files) + datafile.save_data(m.opts, m.project_path, m.project_files) end) end