-
-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add base dirs (#73) #179
Conversation
* add new base_dirs key to global settings config * setup - make global settings available early so that the utils module can read it * getting project key - check base dir global setting before returning project key * merging - if the user base_dirs key is changed (eg to an empty key), overwrite the base_dirs key in the cached file
@@ -34,6 +34,11 @@ HarpoonConfig = HarpoonConfig or {} | |||
-- tbl_deep_extend does not work the way you would think | |||
local function merge_table_impl(t1, t2) | |||
for k, v in pairs(t2) do | |||
if (k == 'base_dirs') then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- if I add an or condition to include "menu"
- and assuming that menu = {} (and not simply removed entirely) in the harpoon setup call
then Selectively cache config #47 can also be fixed ... fyi @jesseleite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heyo! So if I delete my custom menu = { ... }
config (to revert to harpoon defaults in my setup method), would I still have to go and bust the cache myself somewhere? Hoping not 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yups,
- originally, if you did this to set up your menu
require("harpoon").setup({
menu = {
width = vim.api.nvim_win_get_width(0) - 4,
}
-- other settings ...
})
- later to remove your menu settings, you can do this
-- need to call setup again and pass an empty table to the menu key to clear the menu settings
require("harpoon").setup({
menu = {}
-- other settings ...
})
- unfortunately this won't work (removing the menu key entirely)
-- need to call setup again and pass an empty table to the menu key to clear the menu settings
require("harpoon").setup({
-- other settings ...
})
no need to mess about with deleting the harpoon cache
From my preliminary testing, providing menu={} clears up the menu settings without needing to mess about with the cache.
This is caused by the current deep merge implementation which doesn't merge nicely. The nicer solution would be to clean up the deep merge function. The work around is to detect if we are attempting to merge the menu key and simply overwrite the 'left' table. Haven't created a PR for this yet though ... but should be simple enough to add an or condition and PR ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, though I disagree with having to leave menu = {}
to clear some cache. What I'm suggesting in #47 is to altogether avoid caching configs that don't benefit from caching in the first place. Should people really have to provide menu = {}
in order to revert back to setup function defaults for said config? 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, agree that it's not ideal. Seems like the deep merge function would also be a good excuse to have a go at implementing unit tests ... #30 ... will get round to it if I get round to it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am very worried about merging this one. I don't want anything to break others using it. I like the fix, but it makes me much scared :) |
btw, why is the lsp changing the directory? My guess is that its not the LSP, its your setting (its a vim setting, something like autocd) |
Yups understand the concern, is there anything that can be done to reduce the risk? I suppose we'll need a test suite to really move forward with this ... when we get round to it!!! I am much sad though, was hoping to get my first open source PR merged :)) Not too sure why lsp was changing the directory, from my recollection of my debugging then:
could be an autocd-ish option hmm will have to investigate ¯_(ツ)_/¯ |
I can test this. I use scripts to manage git worktrees. Can you give me some pointers how to workaround My main problems are that I need different Accessing the shell history kinda doesnt work and calling scripts from relative position is painful. |
@tg0h If you are interested I can post an obfuscated version of the test stuff I use at work, which uses git worktrees. |
I think once this plugin for telescope can store project paths in a scratch buffer, it would solve the use case significantly (with some tweaks for custom actions): The better alternative for most use cases is to have completely different views defined with the session system that can be switched to upon opening the path to the vendored git worktree inside the base dir, all available from a project local scratch buffer. |
Add base dirs to fix #73
Current Problem:
Solution:
Note:
Improvements:
Path:new(cwd):make_relative(baseDir)
Limitations
Questions