Giter VIP home page Giter VIP logo

vim-submode's People

Contributors

ivanbrennan avatar kana avatar lfdm avatar thinca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-submode's Issues

Setup and teardown functions

Feature proposal mentioned in #13

To build really powerful submodes it would be nice to be able to register setup and teardown functions that get called on_entering and on_leaving. I know that especially the setup part can be achieved with a workaround (defining a rhs command in the enter_with function), but that's a little hacky, as I am pretty sure you didn't intend this feature to work this way. I assume it would be enough to implement two dictionaries where the submode's name is the key and the value is an array of funcrefs to be called in the respective parts.
Possible use cases would be to activate/deactivate different highlightings or opening/closing a split window that holds additional information you could use during your submode's activity etc etc.

The leave key occured E15.

:call submode#enter_with('test', 'n', 'e', 'gt', '1 ? "gt" : "gT"')
gt<Esc>
E15: Invalid expression: 
E15: Invalid expression: 

submode#enter_with{option}eを含む場合
g:submode_keyseqs_to_leaveで設定されるleave keyも<expr>で設定されてしまい
該当のleave key押下時にE15が発生します

Doesn't work in Neovim?

Doesn't seem to work with neovim, not sure why.

$ nvim
Error detected while processing /Users/michal/.vim/init.vim:
line   73:
E117: Unknown function: submode#enter_with
line   74:
E117: Unknown function: submode#leave_with
line   77:
E117: Unknown function: submode#map
line   78:
E117: Unknown function: submode#map
line   79:

Tried installing both with "Plug" and "Plugin", both went fine.

Error on executing rhs mapping leaves submode

Given this submode definition:

call submode#enter_with('move', 'n', '', '<leader>m')
call submode#map('move', 'n', '', 'j', '<c-f>')
call submode#map('move', 'n', '', 'k', '<c-b>')

When I press j continuously in the submode until I reach the end of the file - submode exits when it is not possible to execute <c-f> anymore.

I would expect to stay in the submode no matter the error until I press the leave_with-key.

Could you look into this?
Thank you.

undocumented limitation: length of mappings on LHS

I don't know exactly what the problem is, but when I call submode#enter_with, I can use "xxx" as the LHS of the mapping but not "xxxx" or any longer mapping. The limitation doesn't really bother me, but the error message is simply "line 16: invalid argument" with no indication of which script/function had an error, so it took me a while to figure out what was happening.

Mappings stop working once I hit the end/beginning of the file

Config is

let g:submode_always_show_submode = 1
call submode#enter_with('nav', 'n', '', '<C-up>')
call submode#map('nav', 'n', '', 'e', '6j')
call submode#map('nav', 'n', '', 'o', '6k')
call submode#map('nav', 'n', '', 'n', 'B')
call submode#map('nav', 'n', '', 'i', 'W')

I can enter the submode successfully and navigate. Once the cursor hits the end or beginning of the file (or rather: tries to move past it), the mappings stop working, but I'm still inside the submode.

Prevent redraw when leaving submode?

Hi, I have the following mappings:

call submode#enter_with( 'WinCycle'    , 'n', '', '<C-W><C-W>'  , '<C-W><C-W>'   )
call submode#map       ( 'WinCycle'    , 'n', '', '<C-W>'       , '<C-W><C-W>'   )

and it always redraws the screen when leaving the submode which is very distracting.
Is there a way to prevent it from doing that?

Also, are you planning on adding support for v:count?

Thanks. Love this plugin 👍

Still alive?

Hey @kana, is this project still alive? I think it's really cool and never really got the publicity it deserves. I use it with great effect (in addition with the vim-easy-submode helpers to define submodes more easily)

Enter with mapping `<C-w><M-Left>` failed

## versions

vim version: NVIM v0.3.1
term: iTerm.app
platform: darwin

Config

call submode#enter_with('tab/window', 'n', '', '<C-w>h', '<C-w>h')
call submode#enter_with('tab/window', 'n', '', '<C-w>j', '<C-w>j')
call submode#enter_with('tab/window', 'n', '', '<C-w>k', '<C-w>k')
call submode#enter_with('tab/window', 'n', '', '<C-w>l', '<C-w>l')
call submode#leave_with('tab/window', 'n', '', '<Esc>')
call submode#map('tab/window', 'n', '', 'h', '<C-w>h')
call submode#map('tab/window', 'n', '', 'j', '<C-w>j')
call submode#map('tab/window', 'n', '', 'k', '<C-w>k')
call submode#map('tab/window', 'n', '', 'l', '<C-w>l')

call submode#enter_with('tab/window', 'n', '', '<C-w><M-Left>', ':call TmuxResize("h",5)<CR>')
call submode#enter_with('tab/window', 'n', '', '<C-w><M-Down>', ':call TmuxResize("j",5)<CR>')
call submode#enter_with('tab/window', 'n', '', '<C-w><M-Up>', ':call TmuxResize("k",5)<CR>')
call submode#enter_with('tab/window', 'n', '', '<C-w><M-Right>', ':call TmuxResize("l",5)<CR>')
" call submode#leave_with('tab/window', 'n', '', '<Esc>')
call submode#map('tab/window', 'n', '', '<M-Left>', ':call TmuxResize("h",5)<CR>')
call submode#map('tab/window', 'n', '', '<M-Down>', ':call TmuxResize("j",5)<CR>')
call submode#map('tab/window', 'n', '', '<M-Up>', ':call TmuxResize("k",5)<CR>')
call submode#map('tab/window', 'n', '', '<M-Right>', ':call TmuxResize("l",5)<CR>')

Errors

Error detected while processing function submode#enter_with[3]..<SNR>18_define_entering_mapping:
line   16:
E474: Invalid argument
E474: Invalid argument
E474: Invalid argument
E474: Invalid argument
Press ENTER or type command to continue

It seems only the submode#enter_with related to <C-w><M-*> failed. If I disable this part, the corresponding mapping still works as a submode.

Feature discussion

I recently started to build a little plugin that is basically a wrapper around your awesome submode functionality. While working on it, I made a couple of observations, that probably could be implemented as additional features of your plugin:

  • Temporarily go to insert mode

This has been talked about in #1 already (btw, hi again @suy) and is relatively easy to implement. I'd say this makes only sense when you invoke it from a normal mode submode anyway, so I didn't try it for any other modes. I implemented a submode#temporary_insert_mode function, meant to be the rhs of a mapping as in submode#map('submode', 'n, '', 'i', ':call submode#temporary_insert_mode()<cr>'
The function leaves the current submode, enters insert mode and defines an augroup that holds an aucmd triggered by the InsertLeave event which reenters the submode that has just been left. This reenter function clears the aforementioned augroup again, so that we aren't left with any deadweight afterwards

  • Quickly reenter the last submode

My plugin resolves around the idea of having a submode <prefix> key which allows to enter several different submodes with one additional key.

The temporary insert mode didn't satisfy me, becaue sometimes jumping around in a submode left me close to where I wanted to go but not precisely (the use case is equivalent to what @suy described in #1, jumping around with [c for example). So it would be great to be able to leave the submode regularily, but enter it faster afterwards - I had in mind to be able to reenter the last submode with <prefix><prefix>. A reference to the last submode would be all that is needed for it and implementing this would also clean up any code needed to build a temporary insert mode.

  • Distinct setup and teardown functions

To build really powerful submodes it would be nice to be able to register setup and teardown functions that get called on_entering and on_leaving. I know that especially the setup part can be achieved with a workaround (defining a rhs command in the enter_with function), but that's a little hacky, as I am pretty sure you didn't intend this feature to work this way. I assume it would be enough to implement two dictionaries where the submode's name is the key and the value is an array of funcrefs to be called in the respective parts.
Possible use cases would be to activate/deactivate different highlightings or opening/closing a split window that holds additional information you could use during your submode's activity and many more.

  • Counts
    Already mentioned in #11, but I haven't been able to solve this yet.

I can workaround most of these things in my plugin, however it would be much cleaner if such things would be directly build inside of vim-submode - and other's could benefit from it too.

Would love to hear your opinion on this!

Option: do not leave submode when pressing key that is not mapped

Hi there. I'd like to see an option to not leave the submode when a key that is not mapped in that submode is pressed. The key should then be processed as normal.

Would it be hard to implement such a thing? Or is this already possible to do this?

I defined a submode for moving around lines with single key presses, but I'd like to keep using vim's native ability to move around the cursor while in this submode.

entering submode with <C-N> causes strange behaviour

I would like to create a "Completion submode" using the following call:
call submode#enter_with('Completion', 'i', '', '', '')

but it causes strange behaviour... The word I am trying to use completion on suddenly vanishes and only if I press again the word comes back and the completion menu appears.

Reuse existing mappings

Hello - I have a mapping like so:

nmap <C-W>u :set winfixwidth!<CR>

Or similarly, tradewinds creates <C-W>gh (and gj/gk/gl) mappings for moving windows. I'd like to alter vim-submode to recurse into these mappings - is this wise, and if so, what would be the best way to go about it?

Code displaying in submode line.

I'm attempting to create a debugging submode for debugging scripts that ties in with VimDebug (http://vim.sourceforge.net/scripts/script.php?script_id=663). I've defined the first command in my .vimrc like so:

call submode#enter_with('Debug', 'n', '', 'D')

It seems to work, only when I hit 'D' from normal mode this is what I see on my status line:

-- Submode: Debug --                                                                   fix:Debug) 

Which I think is coming from submode.vim line 378? It doesn't matter what width my screen is, the same text is displayed on the right. If I change the definition to:

call submode#enter_with('DDDebug', 'n', '', 'D')

I get:

-- Submode: DDDebug --                                                                 x:DDDebug)

Which seems to indicate some sort of unintended echo problem.

Quicker way to reenter last submode

Feature proposal mentioned in #13

I think a way to quickly reenter the last submode you just came from would make sense. All that might be needed is a reference to the last submode we where in. Could also be a useful feature to help with implementing even further things like #14

Internal characters are displayed in 'showcmd' area

My config is as follows:

set nocompatible
set noshowmode
set noshowcmd
set encoding=utf-8
let g:submode_keep_leaving_key=1
call submode#enter_with('cmd', 'n', '', '<Space>j', ':echo "j"<CR>')

When I press <Space>j<Space>j<Space>j<Space>j<Space>j repeatedly, ÂÂÂÂÂ and @=@=@=@=@= are displayed alternately in 'showcmd' area.

These characters are not displayed when showmode or showcmd is enabled.

Adding counts?

Do you think it would be possible to add a count to submode mappings? I think this would be a very valuable addition - and probably not hard to do (don't make the submode leave when a number key is pressed and use v:count1 in the mappings itself?)

I am currently writing a very simplistic plugin that uses submodes to map more complex movement commands on the home row for easier access. Would be hndy to have the possibility to trigger them with counts as well.

Public interface to enter and leave submodes

Two public utility functions/commands could help in scripting submodes. I think there is currently no real way to do this from outside the submode plugin and even inside of it you have to fake it a bit.

map repeat macro command @@ malfunction

I tried to map @@ to repeat with @ only:

call submode#enter_with('repeat_ex_cmd', 'n', '', '@@', '@@')
call submode#leave_with('repeat_ex_cmd', 'n', '', '')
call submode#map('repeat_ex_cmd', 'n', '', '@', '@@')

It would enter submode and works find as long as I stay in submode. But when I exit submode and try to use @@ again. I would get something like this inserted at the beginning of my buffer: ubmode-enter:repeat_ex_cmd). And I would be put into insert mode.

Temporary insert mode

Feature proposal mentioned in #13

This has been talked about in #1 already (btw, hi again @suy) and is relatively easy to implement. I'd say this makes only sense when you invoke it from a normal mode submode anyway, so I didn't try it for any other modes. I implemented a submode#temporary_insert_mode function, meant to be the rhs of a mapping as in submode#map('submode', 'n, '', 'i', ':call submode#temporary_insert_mode()<cr>'
The function leaves the current submode, enters insert mode and defines an augroup that holds an aucmd triggered by the InsertLeave event which reenters the submode that has just been left. The reenter function clears the aforementioned augroup again, so that we aren't left with any deadweight afterwards.

How to exit the submode within the rhs mapping??

Hi,

I really like this vim plugin, I think this will be the most favorite vim plugin on my list :)

one thing I can't figure out is that I want to exit the submode in the rhs mapping(without typing explicity), I think it should be possible, maybe I just don't know how to achieve that.

call submode#map('ctrl_window', 'n', '', 'v', ':vs<CR><Esc>')
call submode#map('ctrl_window', 'n', '', 's', ':sp<CR><Esc>')

In the above mapping, assume I'm already in the ctrl_window submode, when I type v, I hope that it will create a vertical split and exit to normal mode. that's why I put in the rhs. But it doesn't seem to be working like this, why???

Feature: only exit a submode explicitly

Hello.

First, I want to congratulate you for vim-submode and your many other great plugins. I like them a lot! And I've just started trying them.

I've been using vim-submode with great pleasure to navigate the changelist and resize windows, but I've found a case in which it would be great if submodes could only be exited explicitly, so you could operate vim normally, and still have available the shortcuts that one has defined for the submode.

The case is: you are in vimdiff mode, and want to navigate the changes, so you create a submode to avoid having to type the tedious ]c]c]c. But in the middle you want to diffget and diffput, so you map something to do it. But now you realize there is a typo in a line, so you have to exit the mode, fix it, and enter it again to continue inspecting. Is not a big deal at all, but it could be even better if you could exit the submode only after or any other key the user has defined.

I don't know if it's possible or easy to do, but if it serves as an inspiration, there is a plugin named vim-space that does something similar: after some "hook" like ]c, g+ or g; it maps and to provide a sort of "generic next/previous". You operate Vim normally, but you still have those shortcuts available.

I like vim-submode a lot more, though, since is much more powerful and configurable, but I would love if it could have this feature too.

Thank you very much, and seriously, congratulations for your plugins, because some (like this) blew my mind when I first saw them.

How to use submode enter for mappings?

Hi,
I have a mapping as follows:

nnoremap <l :execute 'let &lines = &lines - 1<CR>

Is it possible to create a submode for this such that typing <l once enters the submode and all subsequent < will trigger <l?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.