Git Product home page Git Product logo

Comments (15)

wookayin avatar wookayin commented on May 21, 2024 4

This plugin (or precisely the imap ) also breaks vim-clap. Is there any general solution that is agnostic of other plugins but preserves the mapping chian?

from pear-tree.

jounathaen avatar jounathaen commented on May 21, 2024 3

I think I have solve my mapping issue for neosnippet and ncm2 with the following mappings:

let g:pear_tree_map_special_keys = 0
imap <BS> <Plug>(PearTreeBackspace)
imap <Esc> <Plug>(PearTreeFinishExpansion)
imap <expr><CR> neosnippet#expandable_or_jumpable() ?
      \ "\<Plug>(neosnippet_expand_or_jump)" : "\<Plug>(PearTreeExpand)"

from pear-tree.

adworacz avatar adworacz commented on May 21, 2024 3

For anyone using this is coc.nvim, here's how I got the autocomplete window to work properly with PearTreeExpand (much thanks to jounathaen above):

    " Disable automapping so we can fix Coc mapping.
    let g:pear_tree_map_special_keys = 0

    " Default mappings:
    imap <BS> <Plug>(PearTreeBackspace)
    imap <Esc> <Plug>(PearTreeFinishExpansion)

    " Get PearTreeExpand working with coc.nvim
    imap <expr> <CR> pumvisible() ? coc#_select_confirm() : "\<Plug>(PearTreeExpand)"

Note: you have to use imap - inoremap didn't work for me likely because of how the <Plug> command works.

from pear-tree.

tmsvg avatar tmsvg commented on May 21, 2024 1

Hello! It appears that putting imap <CR> <Plug>(PearTreeExpand)<Plug>DiscretionaryEnd in my vimrc fixes this. I don't normally use Endwise, so let me know if this misses something.

I don't really like the idea of having plugin-specific compatibility code in Pear Tree, so if putting the above in your vimrc does work, I would consider that the official solution.

from pear-tree.

JoosepAlviste avatar JoosepAlviste commented on May 21, 2024 1

Since Pear Tree isn't really useful in vim-clap's popup I disabled Pear Tree in that filetype:

let g:pear_tree_ft_disabled = ['clap_input']

But that kind of an approach only works for some use cases though.

from pear-tree.

jonsmithers avatar jonsmithers commented on May 21, 2024

It looks like the extra newline is coming from endwise's <cr> mapping.

maparg("<CR>", "i") == '<CR><Plug>DiscretionaryEnd'

You could just omit this by changing maparg("<CR>", "i") to substitute(maparg('<CR>', 'i'), '<CR>', '', '')

[update] .......except that won't work because vim-endwise wants to be invoked after <CR>. One alternative bad idea is to explicitly invoke EndwiseDiscretionary() inside of <Plug>(PearTreeExpand), after <CR>.

So instead of

  return "\<CR>"

we could do

  if exists('*EndwiseDiscretionary')
    return "\<CR>\<C-R>=EndwiseDiscretionary()\<CR>"
  else
    return "\<CR>"
  endif

from pear-tree.

jounathaen avatar jounathaen commented on May 21, 2024

Well, just to add something to the list of stuff that breaks with the <CR> mapping: I use it to select the completion in the ncm2 window or jump between neosnippets fields.

from pear-tree.

jakewvincent avatar jakewvincent commented on May 21, 2024

Hello! It appears that putting imap <CR> <Plug>(PearTreeExpand)<Plug>DiscretionaryEnd in my vimrc fixes this. I don't normally use Endwise, so let me know if this misses something.

I don't really like the idea of having plugin-specific compatibility code in Pear Tree, so if putting the above in your vimrc does work, I would consider that the official solution.

This worked for me. In markdown documents using vimwiki, hitting in a list is expected to continue the list, but pear-tree was interfering with that functionality before using this fix.

from pear-tree.

mellery451 avatar mellery451 commented on May 21, 2024

the <cr> map also conflicts with telescope. I'm sure there is a way to disable pear-tree when telescope activates, but I haven't found it yet.

from pear-tree.

Leo310 avatar Leo310 commented on May 21, 2024

@mellery451 did you fix it? I am facing the same problem now

from pear-tree.

mellery451 avatar mellery451 commented on May 21, 2024

@Leo310 my fix was to remove this plugin - I need Telescope more than I need this so it was not a big loss of productivity.

from pear-tree.

Leo310 avatar Leo310 commented on May 21, 2024

Ah ok I see. I switched to auto-pair plugin

from pear-tree.

skarrok avatar skarrok commented on May 21, 2024

You can disable pear-tree in telescope prompt with

let g:pear_tree_ft_disabled = ['TelescopePrompt']

from pear-tree.

bsaxon20 avatar bsaxon20 commented on May 21, 2024

for lua nvim I used the following: vim.g.pear_tree_ft_disabled = 'TelescopePrompt'

from pear-tree.

EmreDogann avatar EmreDogann commented on May 21, 2024

For anyone using this is coc.nvim, here's how I got the autocomplete window to work properly with PearTreeExpand (much thanks to jounathaen above):

    " Disable automapping so we can fix Coc mapping.
    let g:pear_tree_map_special_keys = 0

    " Default mappings:
    imap <BS> <Plug>(PearTreeBackspace)
    imap <Esc> <Plug>(PearTreeFinishExpansion)

    " Get PearTreeExpand working with coc.nvim
    imap <expr> <CR> pumvisible() ? coc#_select_confirm() : "\<Plug>(PearTreeExpand)"

Note: you have to use imap - inoremap didn't work for me likely because of how the command works.

This code wasn't working for me (would just paste <Plug>(PearTreeExpand) as text) but I managed to hack together a function that kinda does what I want:

function! CustomCR() abort
	" Make <CR> to accept selected completion item or notify coc.nvim to format.
	if coc#pum#visible()
		return coc#_select_confirm()
	else
		" Undo each individual enter action as opposed to undo in blocks.
		" call feedkeys("\<C-g>u")
		call coc#on_enter()
		return "\<Plug>(PearTreeExpand)"
endfunction

" Get PearTreeExpand working with coc.nvim
imap <silent><expr> <CR> CustomCR()

I haven't fully tested it but from the 5 minutes of playing around with it, it seems to work.

from pear-tree.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.