Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

link-format with auto completion #26

Closed
zhengpd opened this issue Jan 19, 2022 · 13 comments
Closed

link-format with auto completion #26

zhengpd opened this issue Jan 19, 2022 · 13 comments

Comments

@zhengpd
Copy link
Contributor

zhengpd commented Jan 19, 2022

I tried to insert wiki link by typing [[, and the completion menu pops up. After selecting a file, the generated text became [[[Untitled](4vyz)]], which I would expect to be [Untitled](4vyz) or [[4vyz]]. Am I missing something or this is intended behavior? The README doesn't talk about this.

# actual text after completion:
[[[Untitled](4vyz)]]

# expected:
[Untitled](4vyz)
  • completion plugin: nvim-cmp
@zhengpd
Copy link
Contributor Author

zhengpd commented Jan 19, 2022

I updated zk config to link-format = "{{filename}}" to make it compatible with nvim-cmp & nvim-autopairs. For anyone stumble across this issue, you could take a look at https://github.com/mickael-menu/zk/issues/22.

@zhengpd zhengpd closed this as completed Jan 19, 2022
@kabouzeid
Copy link
Collaborator

Must be an issue with nvim-autopairs then. This doesn't happen with nvim-cmp and delimitmate.

@mickael-menu
Copy link
Collaborator

I merged in a PR that should fix this issue without resorting to the hack with nvim-autopairs (although it was a smart workaround @zhengpd!) https://github.com/mickael-menu/zk/pull/160

Let me know if it works for you.

@tim-hilt
Copy link

tim-hilt commented Feb 18, 2022

Hm.. The opening brackets are deleted for me, but not the closing ones, that are presumably added by my auto-pair-plugin (smart-pairs in my case). Instead they are prepended to the link?! I don't really undrestand what's happening there! To make things even weirder, it works correctly if the link is the first String in the current line. Is this the error @zhengpd described, or is the autopair-plugin at fault here?

Peek 2022-02-18 20-54

@mickael-menu
Copy link
Collaborator

I added something in the LSP server to remove extra ]] when the editor auto-pair brackets, but it's not guaranteed to work depending on the implementation of the completion plugin in the LSP client.

https://github.com/mickael-menu/zk/blob/e037befdf1e6080c1a103c5d48d47145bace514a/internal/adapter/lsp/server.go#L844-L850

I suggest disabling smart-pairs for Markdown files if you can, or maybe try nvim-autopairs and/or a different completion plugin.

@tim-hilt
Copy link

I initially installed smart-pairs because nvim-autopairs had this issue! Would be curious to know if @zhengpd still doesn’t see this issue when using nvim-autopairs. Disabling the the autopair-plug-in would be kind of a bummer but a last resort I would be ok with. Moving backwards to remove the brackets each time would be more annoying I guess.

@kabouzeid
Copy link
Collaborator

definitely works with delimitmate, which is what I use

@tim-hilt
Copy link

@kabouzeid I'm a delemitmate convert now! Works flawlessly. Grüße nach Aachen!

@tim-hilt
Copy link

Hey @kabouzeid, at this point I feel like I'm a bit annoying. But I still have a small request, if I may: Can you test what happens, if you add some links one after the other? Basically the same thing that is shown in the gif above. I still see the same behavior as in the screencast. It's working fine, when adding links in normal sentences, where there are other words in between the links.

However, I oftentimes add multiple tags at the top of a file, when I know the link-text won't appear in the actual text of the note. @mickael-menu this might be due to the nature of the fix you provided, if I'm not mistaken?

@kabouzeid
Copy link
Collaborator

hmm works for me no problem, not sure what is happening on your end. my dotfiles are public if you want to take a look

@tim-hilt
Copy link

It's really weird! Sometimes it works without any problems, sometimes it looks like the gif above. Also, it doesn't seem to be dependant on the actual autopairs-plugin, as I've tried three different plugins to date. Looks kind of like an initialization error to me. I try to find a way to reproduce it and will be taking a look at your dotfiles. I can't open-source my whole dotfiles right now, but at least I have my nvim-config in a public repo, if you're interested.

@rafi
Copy link

rafi commented Jul 5, 2022

The use-additional-text-edits setting doesn't work for me (cmp + nvim-autopairs), I ended up disabling the [ rule in markdown files:

local autopairs = require('nvim-autopairs')
local cond = require('nvim-autopairs.conds')

autopairs.get_rule('['):with_pair(cond.not_filetypes({ 'markdown' }))

@thecontinium
Copy link
Contributor

Maybe this latest commit helps ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants