Open HaleTom opened 2 years ago
I think this problem stems from Obsidian's code mirror version being updated, and causing the api used to create the commands to now be incorrect.
If you are interesting in solving the issue, I'd most likely look at the Vimrc plugin and see how they changed things with registration of commands, and emulate the changes to this plugin.
If not, I'll see if I can get to this some time soon :)
Seems this is the crux of the changes needed: https://github.com/esm7/obsidian-vimrc-support/commit/c7253f1706d4bcc84e432f375d078911a050e806#diff-564c860307257bfac9176f554a35aa858c350a59d75c0dcd0a5d63a480805bd0R76-R159
And then just a bunch of search and replace.
Revisiting this, is it just me or do any features of this plugin currently work?
Typing :g0
I get:
Not an editor command ":g0"
Cheers for the gj
and gk
mappings - they're super useful!
When this plugin originally was released, commands worked well. However, at the moment, I don't use obsidian anymore, and I don't have enough time to fix this at the time being :(. Huyz has provided a nice reference that could be used to fixup this plugin.
I guess I can take a crack at it
I got most of it to work, but g0
and gHead
don't work because I get goLineLeftSmart is not implemented
and goLineRight is not implemented
. I'm not familiar enough with CodeMirror to know why.
@huyz Thanks for giving it a good go with some improvements! Could they be merged in?
I shouldn't say "most". I only got the [[
and ]]
to work. g0
and gHead
are busted. There's something messed up about Obsidian's CodeMirror and vim.js where versions seem mismatched: there's code that's invoking functions that don't exist in the app but do exist online in published code.
My guess is we'll have to wait for some updates to Obsidian's CodeMirror dependencies.
Anyway, what I've done doesn't help much so I can't merge that in.
The author of the vimrc-support-plugin has added a file with a tutorial on how to achieve this: https://github.com/esm7/obsidian-vimrc-support/blob/master/JsSnippets.md
You need to
FYI I got around the annoying aspect of 1 by just putting it in my .obsidian
folder and changing the exmap to /.obsidian/mdHelpers.js
.
Now if someone could also write a g0
and gHead
equivalent using JS snippets, that would be great
I'm not really concerned about getting [[
and ]]
to work. I think they're already defined to work like gg
and G
. I was able to get what I really wanted out of this plugin inside just the vimrc though.
nmap j gj
nmap k gk
vmap j gj
vmap k gk
exmap 0 goLineLeftSmart
exmap $ goLineRight
FWIW it looks like as of today, codemirror-vim now has g0
, g^
, and g$
implemented, so you can just directly remap your keys to those commands in your .obsidian.vimrc
without any exmap
s needed (for those, at least).
nnoremap 0 g^
nnoremap $ g$
nnoremap H g^
nnoremap L g$
nnoremap I g^i
nnoremap A g$a
(And goLineLeftSmart
is no longer available, it looks like, but shouldn't be needed anymore)
It seems this plugin is mostly obsolete, I don't use Obsidian anymore and haven't for a long time. If you'd like to update the README with more info/context regarding this, it would be more than welcome :)
Hey @hhhapz :) sure happy to update things here.
I also did a little more digging and was able to get your plugin's implementation of pHead
and pNext
working with CM6 (just needed to use (window as any).CodeMirrorAdapter?.Vim)
instead of CodeMirror.Vim
). I figured it could still be nice for people to simply be able to install a plugin and have those commands available, rather than needing to write their own JS snippets and store them in their vaults.
So, your repo may not be obsolete, for that use case. But you don't need to maintain it if you don't want to anymore—we could either:
pHead
/ pNext
functionality to this repo (and could also add other Obsidian-specific vim commands like moveDownSkipFold
), and keep this repo activeLet me know if you'd prefer either one, I'm happy with anything
I'm happy with anything, if you'd like to fork, that's fine with me, if you want commit access here, I'll be happy to give you that too.
Okay cool, it could be simpler to just bring the changes into here, then. Other than I'm not quite sure how the release process works with the official Obsidian plugin directory, but briefly looking into it, it looks like I can maybe just do that through GitHub. Can look more into that when I get a chance :)
Hey @hhhapz :) sure happy to update things here.
I also did a little more digging and was able to get your plugin's implementation of
pHead
andpNext
working with CM6 (just needed to use(window as any).CodeMirrorAdapter?.Vim)
instead ofCodeMirror.Vim
). I figured it could still be nice for people to simply be able to install a plugin and have those commands available, rather than needing to write their own JS snippets and store them in their vaults.So, your repo may not be obsolete, for that use case. But you don't need to maintain it if you don't want to anymore—we could either:
* Add the fixed `pHead` / `pNext` functionality to this repo (and could also add other Obsidian-specific vim commands like [`moveDownSkipFold`](https://github.com/esm7/obsidian-vimrc-support/blob/master/JsSnippets.md)), and keep this repo active * Deprecate this repo, and I could either maintain a new fork of it, or see if @esm7 wants the commands to be exposed by his [obsidian-vimrc-support](https://github.com/esm7/obsidian-vimrc-support/) plugin
Let me know if you'd prefer either one, I'm happy with anything
I'm perfectly good with adding these to obsidian-vimrc-support, if you wish. Whatever you think would be better :)
@esm7 Oh nice, yeah if you're happy to do that, I think that'd be best from a user perspective too, just needing to install a single plugin :)
Mind opening a pull request for that? It'll probably take me a couple of weeks to review, as I'll use the opportunity to also review other issues and release an updated version, but we can definitely get it done.
Sure sounds good :) I'll work on writing that up
Sorry for the delay here, got busy with some other stuff, but just put up a PR for obsidian-vimrc-support to provide these (and a couple other) motions/commands. If that looks good and gets merged, we can probably go ahead and deprecate this plugin
I've got the
.obsidian.vimrc
lines:When I type
]]
, I see:This plugin is installed and enabled through Obsidian's settings. v0.0.1
How would I go about debugging this?