Comments (4)
The path should finish on:
- No
CursorMoved
events received forg:pf_autorun_delay
CursorMoved
caused the current line to be modifiedInsertEnter
WinLeave
from pathfinder.vim.
@aryabhatta-dey I have just realised that running the pathfinder in a thread would still cause the cursor to jump around while motions are tested. Don't know why I didn't think of that before.
I've had an idea how to work around this:
- When Vim is opened, launch another instance of Vim in a subprocess (
subprocess.Popen
), with-u
set to a custom vimrc included with the plugin. - The custom vimrc loads the pathfinding code, which starts a
multiprocessing.connection.Listener
or similar to listen for pathfinding requests. - When a path needs to be calculated:
- Send the current buffer contents and window size to the subprocess. The window size can be restored using the
&lines
and&columns
options, to avoid needing to copy surrounding windows over. Remember to include space for&cmdheight
. - Send the start and target positions.
- Pathfinding runs in the background instance of Vim, while the user continues to work.
- When complete, send the finished path back to the client (the main Vim instance).
- Display the received path.
- Send the current buffer contents and window size to the subprocess. The window size can be restored using the
- Ensure that the subprocess Vim closes itself when the client Vim disconnects.
I'm going to try implementing that to see if it works.
from pathfinder.vim.
Possible implementation
This could be done by starting a background thread in Python, and sending it CursorMoved
events using an autocmd.
CursorMoved - After the cursor was moved in Normal mode. Also when the text of the cursor line has been changed, e.g., with "x", "rx" or "p". Not triggered when there is typeahead or when an operator is pending. For an example see |match-parens|.
When the thread receives no motions for a while (g:pf_autorun_delay
?), it will generate a path between the position the cursor was at before and after. x
,rx
,p
and so on, or leaving normal mode, should finish the movement regardless of the delay.
Running on a thread means Vim is not blocked, so the user can continue working while the path is processed. Once pathfinding completes, the result should be shown only if it is shorter than the recorded input. For example, you don't want gg
appearing as a suggestion if you used 2k
to get to the same place.
I suggest using a popup window either next to the cursor or in a corner of the screen to show suggestions in a notification style. If the current vim doesn't have +popupwin
, then just echo it.
This behaviour should be able to be disabled, e.g. by setting the delay option to a negative value. In that case, the current commands would still be available to use manually.
from pathfinder.vim.
#11 would only be useable with manual commands since it'd take up a lot of screen space appearing all the time.
from pathfinder.vim.
Related Issues (20)
- Function error python3#Call HOT 1
- Use neovim floating window if available
- Freezes during i_ctrl-r with vim-peekaboo
- Possibly not working on Vim 8.0 HOT 3
- Option to disable motion descriptions HOT 1
- Can I configure how long the suggestions appear? HOT 3
- PathfinderLoop does not start after installation
- kk is not always the same as 2k
- Move to anywhere on the target line in visual-line mode
- Freezes when handling large files
- Cognitive complexity HOT 1
- &wrap setting is not transferred to the server HOT 1
- Set fg/bg color of popup HOT 1
- IndexError when deleting lines at the end of a file
- 1-100% motions
- Not working with folds
- Failing to start after latest update
- "Undefined variable: g:python3_host_prog" on non-Neovim installation HOT 2
- Undefined variable: g:python3_host_prog HOT 2
- Do not show hint if its length is >= the number of keys pressed. HOT 2
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 pathfinder.vim.