Open pronobis opened 9 years ago
You can disable smartparent's autocompletion of >
, look at sp-local-pair
.
Wouldn't that disable autocompletion of > also for the opening tag? Is there a way to only do it for the closing tag?
Btw. it's company-nxml that completes the closing tag, so maybe one could also disable adding the closing bracket there.
Hm. Can you please once again explain what keys exactly you type? The problem might also be in the code that checks skipping closed pairs in SP, but I'm not sure yet.
Ok, so assume that:
<
and sp completes to <|>
, then you type the tag name and get <tag|>
. Everything good so far.<
again and SP completes to <|>
. Now typing /
will make company (it seems) complete the closing tag to </tag>|>
.So, in fact, in this case, it would be enough if company completed /tag
instead of /tag>
and thinking about it more it does not really look like an SP bug.
Hmm, although after some more testing, it seems that company-nxml only proposes /tag
as the completion. Positioning the cursor in the closing tag brackets <tag><|>
and typing manually:
company-complete
will nicely result in <tag></tag>
. But when I just type <tag></|
then we get the problem again. Not sure what is adding the additional >
.
Ok, it seems that I'm getting closer to the problem. It's the nxml-mode autocomplete function (https://www.gnu.org/software/emacs/manual/html_node/nxml-mode/Inserting-end_002dtags.html) that adds /tag> not company. When setting nxml-slash-auto-complete-flag
to nil
, I don't get the autocompletion of the ending tags and in principle the problem goes away. Still, it would be nice to get the nxml autocompletion of ending tags work with smartparens.
Basically, to reproduce:
1) Create a new xml file test.xml
2) Switch to nxml-mode
3) Enable auto-completion of end tags (setq nxml-slash-auto-complete-flag t)
3) Type <tag>
4) Type </
Observe that you get </tag>>
A workaround is to set (setq nxml-slash-auto-complete-flag nil)
. In this case, you must do an additional keystroke for each closing tag. Namely, at step 5 above, type the slash, and at new step 6, do completion-at-point
which is commonly bound to C-M-i
aka M-tab
.
Easier solution might be to add a hook to smartparens that deletes the closing >
when you enter /
right after <
(sp-local-pair 'nxml-mode "<" ">" :post-handlers '(("[d1]" "/")))
When closing the tags in nxml-mode, smartparens will conflict with the nxml tag completion and result in double closing >> for a tag. Example:
then
then