hrsh7th/nvim-compe

Compe buffer source interferes with Ultisnips tabstops

physicophilic opened this issue · 6 comments

Checkhealth

health#compe#check
========================================================================
## compe:snippet
  - OK: snippet engine detected.

## compe:mapping
  - INFO: `compe#complete` is not mapped
  - INFO: `compe#confirm` is not mapped
  - INFO: `compe#close` is not mapped
  - INFO: `compe#scroll` is not mapped

Describe the bug

I like using buffer source in markdown. But after writing a lot, my snippet tabstops start to fail. I can't tab through them. See the example below.

Add the snippets to /.config/nvim/UltiSnips/markdown.snippets

snippet td "to the ... power" iA
^{$1}$0
endsnippet

and

snippet mk "Inline math" wA
$$1$$0
endsnippet

To Reproduce

Steps to reproduce the behavior with the minimal config:

  1. Take this minimal config
if has('vim_starting')
  set encoding=utf-8
endif
scriptencoding utf-8

if &compatible
  set nocompatible
endif
let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !isdirectory(s:plug_dir)
  execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end

execute 'set runtimepath+=' . s:plug_dir
call plug#begin(s:plug_dir)
Plug 'SirVer/ultisnips'
Plug 'hrsh7th/nvim-compe'
call plug#end()
PlugInstall | quit

" Options or settings here.

set completeopt=menuone,noinsert,noselect " better completion
let g:compe = {}
let g:compe.enabled = v:true
let g:compe.autocomplete = v:true
let g:compe.debug = v:false
let g:compe.min_length = 1
let g:compe.preselect = 'enable'
let g:compe.throttle_time = 80
let g:compe.source_timeout = 200
let g:compe.resolve_timeout = 800
let g:compe.incomplete_delay = 400
let g:compe.max_abbr_width = 100
let g:compe.max_kind_width = 100
let g:compe.max_menu_width = 100
let g:compe.documentation = v:true

let g:compe.source = {}
let g:compe.source.path = v:true
let g:compe.source.buffer = v:true
let g:compe.source.calc = v:true
let g:compe.source.nvim_lsp = v:true
let g:compe.source.nvim_lua = v:true
let g:compe.source.vsnip = v:true
let g:compe.source.ultisnips = v:true
let g:compe.source.luasnip = v:true
let g:compe.source.emoji = v:true

let g:UltiSnipsExpandTrigger = '<Tab>'
let g:UltiSnipsJumpForwardTrigger = '<Tab>'
let g:UltiSnipsJumpBackwardTrigger = '<S-Tab>'
let g:UltiSnipsSnippetsDir = $HOME.'.config/nvim/UltiSnips'
let g:UltiSnipsSnippetDirectories = [$HOME.'/.config/nvim/UltiSnips']


  1. Open a markdown buffer, and enter this content (just a sample which makes it fail for me). Sorry for adding the whole thing, cause I don't know what really triggers this.

$\circ$ Proposal of observable correspondence - CFT correlation functions $\langle \Phi(y_1) \Phi(y_2) \cdot  \cdot \cdot  \Phi(y_n)\rangle$ arise from
  dependence of supergravity action $S_G(y, r)$ on asymptotic boundary conditions, where $y$ is used for coordinates on boundary. 


 
  That makes sense, $S_G(y, r\to  \infty)$ ought to do the job.
 

 


 - Masses of particles in supergravity give (scaling) dimension of CFT operators
   as a special case (it appears).


### Introduction

Understanding gauge theory with group $SU(N)$ for large $N$ has importance in
solving confinement problem, which has led Witten to this perhaps, because
Maldacena's proposal links conformally invariant 'cousins' of $SU(N)$ (for large $N$) with super gravity - although I don't see who's a cousin of who. 

$\mathcal{N} = 4$ super Yang Mills in 4D has $SU(N)$ gauge group and is also a CFT. I don't know what's $\mathcal{N}$. But this theory is important example, cited everywhere. Let's do a map between this and IIB superstring theory to which Maldacena declares it is dual. 

| super YM  |   superstring |
|:-----------------:|:-----:|
| $g_{YM}$ | $g_{st} \sim g_{YM}^2 \cdot \phi \cdot R_s$ |
| $SU(N)$| ?|
| $M^{4}$| $AdS_5 \times S^{5}$ |

The spheres in IIB have radius $R_s = (g_{YM}^2 N)^{1/4}$ and $\phi$ is some
kind of flux on $S^{5}$. The bulk theory is supergravity if $N\to \infty$ and
$g^2_{YM} N \to \infty$ as well. First is related to degrees of freedom of QFT ($c_{eff} = N^2 -1$) and $g^2_{YM} N$ is a modified coupling constant $\lambda$.  If this is true, and $g_{st}$ is small in this case, $\phi$ better be non-trivial.


#### AdS space 

* There's a "boundary" at spatial infinity. This makes quantization difficult. What does it mean? Hawking's book's reference is given.  See later.
* Boundary of $AdS_{d+1}$ is $M_{d}$: minkowski space - almost!
* $SO(2,d)$ acts on AdS bulk as 'ordinary symmetry' group (isometries) but same
  group acts on $M_d$ as conformal group. On $M_d$, one sees 'singleton
  representations', basically seen as free field theories - what we did. Much references.


The way he puts it is interesting. 



Other things in intro:

- Minkowski space as boundary of AdS - exercise. 
- AdS description using coordinates similar to boundary coordinates. General
  behaviour of AdS a bit more - exercise.

- Holography in general. Gives examples of other kinds. AdS-CFT has 'covariance'
  - bulk theory is relativistic - under $SO(2,d)$. Others may or may not have this, and the way covariance is achieved may be different.

### Boundary behaviour  

* Euclidean $AdS_{d+1}$

What does he mean? Surely not Euclidean space $\mathbb{R}^{d+1}$,  as
that's Euclidean "Minkowski space", not Euclidean "AdS". So we try being
smarter. AdS space comes from a hypersurface of Minkowski space in 1 higher
dimension, so no surprise that Euclidean does similar. However, he makes this
claim:

- Boundary of Euclidean AdS = Minkowski = boundary of true AdS

Let $\sum_{i=0}^{d} y_{i}^2<1$. Open unit ball in $d+1$ dimensional Euclidean
space $(y_{0}, .., y_{d})$,  written $B_{d+1}. $Then? 

$$ 
ds^2 = \frac{4}{(1 - |y|^2)^2} \sum_{i=0}^{d} d y_{i}^2
$$
is the metric of Euclidean AdS. Here $|y|^2 = y_{0}^2 + y_{1}^2 + \cdot \cdot +
y_{d}^2$. So the metric blows up where ball ends. But hey. He says $B_{d+1}$ is
$AdS_{d+1}$ itself! So metric isn't singular. I think I have seen this form
elsewhere. It's the Poincare patch I think. 

Compactification. 

* Boundary of $B_{d+1}$ is $\sum_i y_{i}^2 = 1$, which is $\mathbb{S}^{d}$. This
  can be included in space, but the metric will break down. To do this right,
  pick $f$ defined on $\overline{B}_{d+1}$, which vanishes (with first order zero) on $\mathbb{S}^{d}$,
  like $f = 1 - |y|^2$,  then set 
$$ 
d \widetilde{s}^2 = f^2 ds ^2 
$$
That modifies metric inside, but that's okay for now.. for some reason. 
Let $f \to fe^{w}$ for some real function $w$ on $\overline{B}_{d+1}$. This would ensure $d \widetilde{s}^2$ is line element for whole $AdS$.  Then, 

$$ 
d \widetilde{s}^2 = f^2 e^{2 w} ds ^2 
$$
which on the sphere would kill $f^2$, and the boundary metric would be left
conformally invariant because of $e^{2w}$ factor.  


He gives 2 other representations. One is akin to global coordinates and another
to Poincare patch again. This is kind of weird business. The global coordinates
define $r = \tanh (y/2)$.  Is this really AdS space? I should look at this.

  1. At the end of the buffer, try doing this. First mk ---> $|$ then $atd$ --> $a^{|}$ ---> $a^{d |}$. Here | is the cursor. Hitting tab twice will reveal the error. It happens 90% of the times

Actual vs expected behaviour

1 tab should give $a^{d}|$ which it does. 2 tabs should give $a^{d}$|, which it does not 90% of times.

Try deleting all text from buffer and try it again; then it works 100% times.

Additional context (optional)

I think some time variable can be adjusted to prevent this behaviour?

And thank you for the plugin!

Edit: I forgot to add that

  1. On removing buffer source from minimal.vim problem vanishes.
  2. it happens for other kinds of snippets too, after a lot of text has been added. Is it possible that buffer source only tries to complete 'words'? After all I don't want buffer to complete anything with {,}, (, etc..

Seems like #167 describes the solution? I tried adding default_pattern=[[\w*]], which seems to fix the issue. That restricts the completion options from buffer to only alpha-numerics. Is this the optimal way?

Hm.... Sorry. this issue is a bit difficult with my English skills...

I can't think nvim-compe breaks ultisnips tab expansion behavior... it's very weird.
(I can believe if you claims nvim-compe doesn't show ultinsips completion)

It’s okay! No problem! I know some Japanese so let me try that.

Tashkani ultisnips snippets o complete koto ga dekimasu. Mondai sore ja nai. Buffer source o tsukatte toki ultisnips no tab ga chotte dake kowarimasu. Sore dake desu.

Tatoeba snippet ga buffer no words to onaji nattara, snippet no execution jikan ni nvim-compe no pop up ga ikimasu. Sono ato tab wa kikanai.

Sono tame ni buffer ‘default_pattern’ o [[\w\+]] set kuretanda, soshite ‘tab’ wa ima ok desu. #167 to onaji desu.

chotto shitsumon wa kore deshita: kono pattern wa best desu ka? Anata no default pattern wa osoraku ‘{,},^..}’ o recognise kuretanda. Kore wa ‘[A-Za-z0-9]’ dake o recognise ga dekimasu. Sore ni, buffer no kotoba to betsu nani mono o complete koto no hitsuyo wa arimasu ka?

Nihongo de ayamachi o yurushtekudasai demo kono ato mo romaji de hanasu koto no hitsuyo nara oshiete kudasai.

Arigatou! Hopefully I have conveyed it to you!

@physicophilic I'm very surprised by your Japanese!!! Your Japanese is very well and thank you for your effort.
But someone might see this issue for finding information so I think English is better.

The nvim-compe's default pattern is the following.

[['\%(-\?\d\+\%(\.\d\+\)\?\|\h\w*\%(-\w*\)*\)']]

I think it recognize word, saneke_case, kebab-case, 0.1, -0.1, 1 and -1.

The word's pattern is \h\w*\%(-\w*\)*.

I think [\h\w*\%(-\w*\)* is very similar to \w\+ .... it's weird...

Thank you @hrsh7th !
I learnt most of it from anime. Once took an N5 course at college to watch more anime without subtitles 😄

I think you're right. I have been trying to work but the problem is still there. The reason is something else. I don't know what I should do.

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.