File tree Expand file tree Collapse file tree 2 files changed +24
-13
lines changed
Expand file tree Collapse file tree 2 files changed +24
-13
lines changed Original file line number Diff line number Diff line change @@ -26,17 +26,7 @@ function OrgLinkHttp:follow(link)
2626 return false
2727 end
2828
29- if vim .ui [' open' ] then
30- vim .ui .open (url )
31- return true
32- end
33-
34- if not vim .g .loaded_netrwPlugin then
35- utils .echo_warning (' Netrw plugin must be loaded in order to open urls.' )
36- return false
37- end
38-
39- vim .fn [' netrw#BrowseX' ](url , vim .fn [' netrw#CheckIfRemote' ]())
29+ vim .ui .open (url )
4030 return true
4131end
4232
Original file line number Diff line number Diff line change 11local utils = require (' orgmode.utils' )
22local link_utils = {}
33
4+ local external_filetypes = {
5+ -- pdf is considered a valid filetype even though it cannot be correctly read
6+ ' pdf' ,
7+ }
8+
9+ --- @param filename string
10+ --- @return boolean - if editable , returns true , otherwise false
11+ local function edit_file (filename )
12+ local filetype = vim .filetype .match ({ filename = filename })
13+ if not filetype or vim .tbl_contains (external_filetypes , filetype ) then
14+ vim .ui .open (filename )
15+ return false
16+ end
17+ vim .cmd ((' edit %s' ):format (filename ))
18+ return true
19+ end
20+
421--- @param file OrgFile
522--- @return boolean
623function link_utils .goto_file (file )
7- vim . cmd (( ' edit %s ' ): format ( file .filename ) )
24+ edit_file ( file .filename )
825 return true
926end
1027
@@ -54,7 +71,11 @@ function link_utils.open_file_and_search(file_path, search_text)
5471 return true
5572 end
5673 if file_path ~= utils .current_file_path () then
57- vim .cmd ((' edit %s' ):format (file_path ))
74+ local editable = edit_file (file_path )
75+ -- Return without attempt to find text. File is not editable.
76+ if not editable then
77+ return true
78+ end
5879 end
5980
6081 if not search_text or search_text == ' ' then
You can’t perform that action at this time.
0 commit comments