diff --git a/core/mappings.vim b/core/mappings.vim index 92c3f7d..1e0ac31 100644 --- a/core/mappings.vim +++ b/core/mappings.vim @@ -215,8 +215,17 @@ vnoremap iu :call URLTextObj() onoremap iu :call URLTextObj() function! s:URLTextObj() abort - " Note that we use https://github.com/itchyny/vim-highlighturl to get the URL pattern. - let url_pattern = highlighturl#default_pattern() + if match(&runtimepath, 'vim-highlighturl') != -1 + " Note that we use https://github.com/itchyny/vim-highlighturl to get the URL pattern. + let url_pattern = highlighturl#default_pattern() + else + let url_pattern = expand('') + " Since expand('') also works for normal words, we need to check if + " this is really URL using heuristics, e.g., URL length. + if len(url_pattern) <= 10 + return + endif + endif " Note that the index starts at 0, end_idx is index of the character left of " the pattern. let [url, start_idx, end_idx] = matchstrpos(getline('.'), url_pattern)