Skip to content
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

[QUESTION]: cd into root when creating notes #7

Closed
idr4n opened this issue Mar 11, 2024 · 10 comments
Closed

[QUESTION]: cd into root when creating notes #7

idr4n opened this issue Mar 11, 2024 · 10 comments
Assignees
Labels
enhancement New feature or request

Comments

@idr4n
Copy link
Contributor

idr4n commented Mar 11, 2024

Description

Hi there,

When I find a note with tdo f the function find_note cd into root. I was wondering if there is a particular reason why this behavior is not added when creating notes, e.g. with tdo e or tdo t.

Particularly, I would like to automatically cd into root whenever creating notes from any other path or directory outside of root. That is, to add cd "$root" || return to functions such as new_todo and new_entry.

Let me know if you would like to consider a PR for this.

Thanks in advance!

Additional Information

No response

@idr4n idr4n added the enhancement New feature or request label Mar 11, 2024
@2KAbhishek
Copy link
Owner

Thanks for opening up the issue.

I wanted to understand what problem are you facing for this feature not being present.

Can you share some more details on that please.

@idr4n
Copy link
Contributor Author

idr4n commented Mar 12, 2024

It is not a problem as such, but if I crate a note, at which point neovim is opened (as it is my editor), then neo-tree or nvimtree for example, will not show the right directory and therefore it is difficult to locate the newly created note. Also, if I want to fuzzy find something (e.g., with Telescope) then it would not be possible or difficult. This is because, most of the time after creating a note, I want to interact with the rest of my notes dir or vault (also, I am using obsidian.nvim which will not detect the right notes directory, therefore).

@2KAbhishek
Copy link
Owner

Ahh right, I am aware of this and it was intentional since neovim uses the tdo script in non interactive mode.

I personally use a keybinding that let's me quickly change the root to the parent of the current file: https://github.com/2KAbhishek/nvim2k/blob/13cb15d51e9ccc5ffa02e08b925d4642a3221722/lua/plugins/tools/which-key.lua#L126

You can also write a lua function that can do the same but change to git root instead of file root.

@2KAbhishek
Copy link
Owner

Just pushed out a neovim command to handle git root / parent dir

You can check it out here: 2KAbhishek/nvim2k@a96091e

If this addresses your concern, feel free to close the issue as well

@idr4n
Copy link
Contributor Author

idr4n commented Mar 12, 2024

Thanks for elaborating on that. Not sure what you mean by "neovim uses the tdo script in non interactive mode" though.

I do have a similar command for changing the current directory in neovim (which I never use actually), but in my case, since whenever I interact with a note I want the notes directory to be set as the cwd, changing the cwd manually would add another step in my workflow.

At the moment I am happy by adding cd "$current_dir" || return to the functions that create notes, as it is working as expected so far for me. So I'm going to close this issue given that you preference is to not cd into the notes directory overall when creating notes.

Thanks again!

@idr4n idr4n closed this as completed Mar 12, 2024
@2KAbhishek
Copy link
Owner

I was referring to the https://github.com/2kabhishek/tdo.nvim plugin.

This executes the script non interactively.

@2KAbhishek
Copy link
Owner

Hey @idr4n I was going through the code and found a way to handle the case you mentioned without breaking compatibility with the neovim extension, I have pushed out a fix :)

@idr4n
Copy link
Contributor Author

idr4n commented Mar 20, 2024

Thank @2KAbhishek. However I was referring to the functions that create notes, such as new_note, new_todo and new_entry.

@2KAbhishek
Copy link
Owner

yes, they have been updated to cd into the root dir beofre opening neovim. check the write_file code

@idr4n
Copy link
Contributor Author

idr4n commented Mar 22, 2024

Oh yes, I missed that. Thanks a lot @2KAbhishek, it is working as desired!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants