Comments (6)
Understood. I don't have much experience with <script>
, but here is a new attempt:
diff --git a/ftplugin/ruby.vim b/ftplugin/ruby.vim
index 8145728..ae915b5 100644
--- a/ftplugin/ruby.vim
+++ b/ftplugin/ruby.vim
@@ -157,8 +157,8 @@ function! s:map(mode, flags, map) abort
endfunction
cmap <buffer><script><expr> <Plug><ctag> substitute(RubyCursorTag(),'^$',"\022\027",'')
-cmap <buffer><script><expr> <Plug><cfile> substitute(RubyCursorFile(),'^$',"\022\006",'')
-let b:undo_ftplugin .= "| sil! cunmap <buffer> <Plug><ctag>| sil! cunmap <buffer> <Plug><cfile>"
+cmap <buffer><script><expr> <SID><cfile> substitute(RubyCursorFile(),'^$',"\022\006",'')
+let b:undo_ftplugin .= "| sil! cunmap <buffer> <Plug><ctag>| sil! cunmap <buffer> <SID><cfile>"
if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps")
nmap <buffer><script> <SID>: :<C-U>
@@ -206,7 +206,7 @@ if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps")
\."| sil! exe 'xunmap <buffer> iM' | sil! exe 'xunmap <buffer> aM'"
endif
- call s:map('c', '', '<C-R><C-F> <Plug><cfile>')
+ call s:map('c', '', '<C-R><C-F> <SID><cfile>')
cmap <buffer><script><expr> <SID>tagzv &foldopen =~# 'tag' ? '<Bar>norm! zv' : ''
call s:map('n', '<silent>', '<C-]> <SID>:exe v:count1."tag <Plug><ctag>"<SID>tagzv<CR>')
@@ -219,10 +219,10 @@ if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps")
call s:map('n', '<silent>', '<C-W>} <SID>:exe v:count1."ptag <Plug><ctag>"<CR>')
call s:map('n', '<silent>', '<C-W>g} <SID>:exe "ptjump <Plug><ctag>"<CR>')
- call s:map('n', '<silent>', 'gf <SID>c:find <Plug><cfile><CR>')
- call s:map('n', '<silent>', '<C-W>f <SID>c:sfind <Plug><cfile><CR>')
- call s:map('n', '<silent>', '<C-W><C-F> <SID>c:sfind <Plug><cfile><CR>')
- call s:map('n', '<silent>', '<C-W>gf <SID>c:tabfind <Plug><cfile><CR>')
+ call s:map('n', '<script><silent>', 'gf <SID>c:find <SID><cfile><CR>')
+ call s:map('n', '<script><silent>', '<C-W>f <SID>c:sfind <SID><cfile><CR>')
+ call s:map('n', '<script><silent>', '<C-W><C-F> <SID>c:sfind <SID><cfile><CR>')
+ call s:map('n', '<script><silent>', '<C-W>gf <SID>c:tabfind <SID><cfile><CR>')
endif
let &cpo = s:cpo_save
It adds <script>
to make gf
and friends less recursive, and replaces all <Plug><cfile>
with <SID><cfile>
.
I tested the patch on my machine, and can confirm it correctly fixes the gf
behavior.
from vim-ruby.
But I can suggest trying to enter the command-line with instead of a colon.
I forgot that this plugin could be used alone, and not necessarily as part of the Vim runtime files. In that case, <Cmd>
might be too recent for an old Vim (it was introduced in patch 8.2.1978).
I guess another solution would be to introduce an intermediate non-recursive mapping. Being non-recursive would disallow any expansion of abbreviations.
from vim-ruby.
But I can suggest trying to enter the command-line with instead of a colon.
I forgot that this plugin could be used alone, and not necessarily as part of the Vim runtime files. In that case,
<Cmd>
might be too recent for an old Vim (it was introduced in patch 8.2.1978).
Correct.
I guess another solution would be to introduce an intermediate non-recursive mapping. Being non-recursive would disallow any expansion of abbreviations.
Correct again. You could cmap <buffer> <SID><cfile> <Plug><cfile>
, then use <script>
maps to call that rather than the <Plug><cfile>
directly.
from vim-ruby.
You could
cmap <buffer> <SID><cfile> <Plug><cfile>
, then use<script>
maps to call that rather than the<Plug><cfile>
directly.
All right, so here is an attempt at a better fix using your suggested mapping:
diff --git a/runtime/ftplugin/ruby.vim b/runtime/ftplugin/ruby.vim
index 4a476fd8c..6e11b569a 100644
--- a/runtime/ftplugin/ruby.vim
+++ b/runtime/ftplugin/ruby.vim
@@ -159,6 +159,10 @@ endfunction
cmap <buffer><script><expr> <Plug><ctag> substitute(RubyCursorTag(),'^$',"\022\027",'')
cmap <buffer><script><expr> <Plug><cfile> substitute(RubyCursorFile(),'^$',"\022\006",'')
+cmap <buffer> <SID><cfile> <Plug><cfile>
+cnoremap <buffer> <SID>find find<Space>
+cnoremap <buffer> <SID>sfind sfind<Space>
+cnoremap <buffer> <SID>tabfind tabfind<Space>
let b:undo_ftplugin .= "| sil! cunmap <buffer> <Plug><ctag>| sil! cunmap <buffer> <Plug><cfile>"
if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps")
@@ -220,10 +224,10 @@ if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps")
call s:map('n', '<silent>', '<C-W>} <SID>:exe v:count1."ptag <Plug><ctag>"<CR>')
call s:map('n', '<silent>', '<C-W>g} <SID>:exe "ptjump <Plug><ctag>"<CR>')
- call s:map('n', '<silent>', 'gf <SID>c:find <Plug><cfile><CR>')
- call s:map('n', '<silent>', '<C-W>f <SID>c:sfind <Plug><cfile><CR>')
- call s:map('n', '<silent>', '<C-W><C-F> <SID>c:sfind <Plug><cfile><CR>')
- call s:map('n', '<silent>', '<C-W>gf <SID>c:tabfind <Plug><cfile><CR>')
+ call s:map('n', '<silent>', 'gf <SID>c:<SID>find<SID><cfile><CR>')
+ call s:map('n', '<silent>', '<C-W>f <SID>c:<SID>sfind<SID><cfile><CR>')
+ call s:map('n', '<silent>', '<C-W><C-F> <SID>c:<SID>sfind<SID><cfile><CR>')
+ call s:map('n', '<silent>', '<C-W>gf <SID>c:<SID>tabfind<SID><cfile><CR>')
endif
let &cpo = s:cpo_save
It does fix the issue on my machine, but maybe it can be simplified further.
from vim-ruby.
Sorry, the previous patch was obtained from the Vim runtime files. New patch obtained from the vim-ruby
plugin:
diff --git a/ftplugin/ruby.vim b/ftplugin/ruby.vim
index 8145728..a6a3a29 100644
--- a/ftplugin/ruby.vim
+++ b/ftplugin/ruby.vim
@@ -158,6 +158,10 @@ endfunction
cmap <buffer><script><expr> <Plug><ctag> substitute(RubyCursorTag(),'^$',"\022\027",'')
cmap <buffer><script><expr> <Plug><cfile> substitute(RubyCursorFile(),'^$',"\022\006",'')
+cmap <buffer> <SID><cfile> <Plug><cfile>
+cnoremap <buffer> <SID>find find<Space>
+cnoremap <buffer> <SID>sfind sfind<Space>
+cnoremap <buffer> <SID>tabfind tabfind<Space>
let b:undo_ftplugin .= "| sil! cunmap <buffer> <Plug><ctag>| sil! cunmap <buffer> <Plug><cfile>"
if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps")
@@ -219,10 +223,10 @@ if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps")
call s:map('n', '<silent>', '<C-W>} <SID>:exe v:count1."ptag <Plug><ctag>"<CR>')
call s:map('n', '<silent>', '<C-W>g} <SID>:exe "ptjump <Plug><ctag>"<CR>')
- call s:map('n', '<silent>', 'gf <SID>c:find <Plug><cfile><CR>')
- call s:map('n', '<silent>', '<C-W>f <SID>c:sfind <Plug><cfile><CR>')
- call s:map('n', '<silent>', '<C-W><C-F> <SID>c:sfind <Plug><cfile><CR>')
- call s:map('n', '<silent>', '<C-W>gf <SID>c:tabfind <Plug><cfile><CR>')
+ call s:map('n', '<silent>', 'gf <SID>c:<SID>find<SID><cfile><CR>')
+ call s:map('n', '<silent>', '<C-W>f <SID>c:<SID>sfind<SID><cfile><CR>')
+ call s:map('n', '<silent>', '<C-W><C-F> <SID>c:<SID>sfind<SID><cfile><CR>')
+ call s:map('n', '<silent>', '<C-W>gf <SID>c:<SID>tabfind<SID><cfile><CR>')
endif
let &cpo = s:cpo_save
from vim-ruby.
The goal is to use <script>
, which will prevent abbreviations from expanding and eliminate the need for per-command SID maps. Something like this:
call s:map('n', '<script><silent>', 'gf <SID>c:find <SID><cfile><CR>')
from vim-ruby.
Related Issues (20)
- tags turn off HOT 2
- eruby filetype plugin leaks memory HOT 4
- Incorrectly indenting next line after an endless method HOT 4
- Incorrect highlighting of quoted symbols
- Vim-ruby is changing path variable HOT 8
- Folding with single line method definitions HOT 1
- Issue with ctags (ctrl + ] )
- Visual selection not working with treesitter on Neovim HOT 3
- Incorrect indentation for `case/in` statements
- Release for Ruby 3 and Vim 9 HOT 4
- Complex string incorrectly highlights as quoted symbol HOT 2
- End-less methods aren't recognized when they are class methods HOT 3
- Incorrect auto indentation with string interpolation HOT 5
- ruby 1.9 style hash does not highlight { in matchparen.vim HOT 1
- with cursorline enabled, eruby tends to lose highlighting (no 'syntax sync') HOT 2
- [Neovim/Vim] Replaying macro broken HOT 2
- Vim 9.1 HOT 4
- Nice
- Vim 9.1 again... HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-ruby.