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

Opening links with targets #281

Closed
andreadev-it opened this issue May 6, 2022 · 10 comments
Closed

Opening links with targets #281

andreadev-it opened this issue May 6, 2022 · 10 comments
Labels
bug Something isn't working Windows Windows OS issue

Comments

@andreadev-it
Copy link

I'm not an expert on org mode, but from some searches I've made it looks like you can create a link to a specific part of a page with a syntax similar to this one:

[[file:./projects.org::10][Get to line 10 of file "projects.org"]]
[[file:./todo.org::Keyword][Move to file "todo.org" and do a search for "Keyword"]] 

I've tried both this syntax using this plugin, but it doesn't seem to work. The only thing I could do was pointing to a specific file, which works correctly.
Is this supported?

@kristijanhusak
Copy link
Member

Those cases are not supported, but you can create link to headline by title, or by CUSTOM_ID.

# projects.org

* My first headline
  :PROPERTIES:
  :CUSTOM_ID: my_id
  :END:
* My second headline
By headline title
[[file:./projects.org::*My second headline]]
By custom id:
[[file:./projects.org::#my_id]]

@andreadev-it
Copy link
Author

Hi kristijan,
Thank you for the explanation! It would be perfect for my use-case, but even that doesn't seem to work on my pc...
This is what I wrote in my todo.org file:

[[file:~/Dropbox/org/progetti.org::#amazon_fb][Project link]]

[[file:~/Dropbox/org/progetti.org::**Migrations][Work website migrations]]

And this is what I have in my "progetti.org" file:

** Amazon-fallback
   :PROPERTIES:
   :CUSTOM_ID: amazon_fb
   :END:

** Migrations
   :PROPERTIES:
   :CUSTOM_ID: migrations
   :END:

Still, when using the shortcut it doesn't work. If I remove the "targets" it works fine.

@kristijanhusak
Copy link
Member

Did you give it a try with minimal configuration?
Please provide information about your system and configuration. You can follow bug template for this.

@andreadev-it
Copy link
Author

Just tried with a minimal config, keeping just treesitter and org. I've only set the leader key and the "conceallevel" and "concealcursor" options as intended by this plugin.
Still not working.
However, I checked the same situation on my ubuntu laptop (running debian) and there it's working, so it's probably a windows-related issue.

OS: Windows 10
Terminal emulator: Windows Terminal (Windows App)

nvim --version:

NVIM v0.7.0
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compiled by runneradmin@fv-az320-113

Features: -acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM\sysinit.vim"
         fallback $VIM : "C:/Program Files/nvim/share/nvim"

@kristijanhusak kristijanhusak added bug Something isn't working Windows Windows OS issue labels May 7, 2022
@andreadev-it
Copy link
Author

I've troubleshooted the problem and found out the "solution".
The problem is the way paths are handled by windows vs linux. Windows uses "\" while linux uses "/".
If I set the file path the way I did it, it will work in linux but not in windows, while if I exchange all slashes with backslashes, the file will work on windows, but not in linux.

The problem becomes clear here:

file_match = file_match and vim.fn.fnamemodify(file_match, ':p') or file_match

After this line, the returned file path has mixed backslashes and forward slashes on windows.

One way that a user can solve it, is to set the following option in init.lua on the windows machine:

vim.opt.shellslash = true

This way, expanding using the fnamemodify function will always return forward slashes.

Fixing this in the plugin seems trivial, but I'm not exactly sure what would be the best way to do it.

Hope that I was of some help :)

@kristijanhusak
Copy link
Member

Thanks for figuring it out!

Fixing this in the plugin seems trivial, but I'm not exactly sure what would be the best way to do it.

I agree, but maybe not everyone wants this behavior.
I would just update readme troubleshoot section with this information so people know how to fix it.

@andreadev-it
Copy link
Author

Yes, indeed it seems like a good idea.
I was thinking about a function that would return properly formatted paths, but I'm not sure that's even possible, to be honest. Adding it to the troubleshooting section will be very helpful for sure!

@kristijanhusak
Copy link
Member

@andreadev-it
Copy link
Author

I'm sorry to open this again. I just wanted to give a warning: after setting the "shellslash" option, Packer.nvim stopped working correctly. I currently opened an Issue on their github repo to address this, but up until then, if someone is using packer, it's probably better not to set that variable.

@andreadev-it
Copy link
Author

I've fixed the issue on packer.nvim and created a pullrequest, for anyone who might have this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Windows Windows OS issue
Projects
None yet
Development

No branches or pull requests

2 participants