Open marcopolo4k opened 1 year ago
The problem is not in MacVim, but in the script file itself as some conditions hasn't been met. This error is quite common as you Google it
This would be a useful thing to support but I think it requires MacVim to be a document-based program. It's a little more tricky than it seems because the actual files opened are being managed by Vim. We could just expose the currently edited document but that wouldn't be really supporting the full document API.
Marking this as a feature request for now. It's doable, but just not very high priority.
Just curious though @cPMarco what are you trying to do here? What do you want to accomplish by writing that script?
We could just expose the currently edited document but that wouldn't be really supporting the full document API.
I'd vote for that - I'm only interested in this one functionality.
Marking this as a feature request for now.
Makes sense.
Just curious though @cPMarco what are you trying to do here?
I often open/take quick notes with TextEdit, while Vim is used for development. I'd like to be able to toggle those quick notes into MacVim, and back out into TextEdit if I need.
I see. And you are only interested in the file path right? Can you show me what an example script would look like and how you would use the path you get from MacVim to send to TextEdit? AppleScript is always one of those things that I didn't feel like learning too much of. That would cover MacVim -> TextEdit. As for TextEdit -> MacVim, I would imagine the easiest way is just to use the mvim://
protocol.
I kind of need to think through more how to expose MacVim functionality to other apps anyway. There are kind of too many ways to do this right now and Apple seems keen on pushing more and more without supporting each one fully. For example, I was going to suggest doing this via the Shortcuts app instead, but it doesn't seem like TextEdit even supports it (correct me if I'm wrong). There are Services, Apple Script, Share, Shortcuts w/ SiriKit Intents and App Intents and Action extensions, and more, and they all have overlapping functionality. Anyway I digress.
Yes, the file path is what I need. The full script I'm using is here.
~/toggle-text-editor.apple.scpt
osascript ~/toggle-text-editor.apple.scpt e
If I had to do any setup to install Applescript in Mac osacript, I don't remember any.
Ok, I can take a look. Judging from current features down the line, I am guessing this will be investigated around r176. AppleScript support is kind of one of those things that haven't been touched in a while and I want to take a cohesive look into what kind of functionality MacVim should expose to other applications via Shortcuts, intents, and whatnot as well.
Just don't listen to that StackOverflow comment about switching to Emacs :)
Steps to reproduce
document 1
. Eg:osascript script_name
.Can’t get document 1. Invalid index. (-1719)
See more details here.
Expected behaviour
get path of document 1
should return the file path of the first document being currently displayed. I believe it's also called the 'front document'.Version of Vim and architecture
9.0.65 (173)
Environment
Operating System: Bug Sur version 11.6.8 (20G730) Terminal: Using MacVim GUI, not a terminal. It's version shows the Vim version 9.0.65 (173). It also says c2007 Bjorn Winckler. Value of $TERM: xterm-256color
How MacVim was installed
brew install macvim
Logs and stack traces
Vim configuration where issue is reproducable
No response
Issue has been tested with given configuration
Issue has been tested with no configuration
mvim --clean
(orgvim
, supplied by MacVim distribution)vim --clean
(in terminal, supplied by MacVim distribution)vim --clean
(in terminal, other suppliers, e.g. /usr/bin/vim)Other conditions