Giter Site home page Giter Site logo

lh-brackets's Issues

Disable normal mode default bracket mappings

I want to use the default vim key mappings in normal mode.
But I cannot find a way to disable only some specific keymap ((, {).
Only way to disable them is to disable all default mapping (g:cb_no_default_brackets).
Is there a way to disable only some specific default keymap?

lh-brackets won't work in nvim

Describe the bug
A clear and concise description of what the bug is.
After installing these two plugins, an error message popped up which prevented the plugin to work properly.

vim/_editor.lua:0: /Users/at8i/.config/nvim/init.lua..nvim_exec2() called at /Users/at8i/.config/nvim/init.lua:0../Users/at8i/.local/share/nvim/lazy/lh-brackets/plugin/bracketing.base.vim[196]..
function lh#mapping#plug[33]..
<SNR>20_callsite[1]..lh#exception#get_callstack[4]..lh#exception#decode[2]
..lh#exception#callstack[61]..lh#askvim#where_is_function_defined[13]..lh#askvim#execute, line 1: Vim(function):E123: Undefined function: 0

# stacktrace:
  - vim/_editor.lua:0 _in_ **cmd**
  - ~/.config/nvim/init.lua:19

And also when I press ", it prints out the following;

""<Plug>MarkersInsertMark

To Reproduce
Steps to reproduce the behavior:

  1. Go to your init file and install lh-brackets and lh-vim-lib
  2. Installing these two plugins using lazynvim plugin manger and setting lh-vim-lib as a dependency for lh-brackets
  3. Starting nvim with any file will cause the above error to pop out.

** Context (please complete the following information):**

  • nvim v0.9.0

Neovim bug with lh-brackets

Describe the bug
I am switching to neovim.
I don't know it your plugins are supposed to be working with neovim or not. If ther are , then this is a bug. if not you can close the issue. Thanks for the Plugins it made working in vim much easier.
******** This is not a bug in vim but in neovim *************
To Reproduce
Steps to reproduce the behavior:

  1. After installing lh-refactor thus installing lh-brackets
  2. If you open any .cpp or . tex file and write anything and press enter in insert mode (I tried with .cpp and .tex files not sure about the others)
  3. It writes a function from lh-brackets
  4. The function is : lh#mapping#_switch('''
    ''', [{'action': 'lh#brackets#_add_newline_between_brackets()', 'condition': 'getline(".")[col(".")-2:col(".")-1]=="{}"'}])

Expected behavior
I did not want anything to happen. It was supposed to go to next line. If I remove the bracket plugin, the refactor is actually working at least for getters and setters.

Context

  • NeoVim v0.05.0-dev
  • I have lots of plugins installed but they all work just fine in vim 8.1

Additional context
The only Plugin that I use in neovim and I don't have it in vim is coc.vim which might be causing some problems.
If you think that it is a problem from neovim, I will open an issue there as well.

Suggested alternative keybindings cause issues

The suggested alternative keybindings don’t work too well for me. I’m talking about what is suggested in https://github.com/LucHermitte/lh-brackets/blob/master/doc/lh-map-tools.txt#L584:

If you'd rather use other keybindings, then add into your |.vimrc| something
like: >
        imap <C-J>      <Plug>MarkersJumpF
         map <C-J>      <Plug>MarkersJumpF
        imap <C-K>      <Plug>MarkersJumpB
         map <C-K>      <Plug>MarkersJumpB
        imap <C-<>      <Plug>MarkersMark
        nmap <C-<>      <Plug>MarkersMark
        xmap <C-<>      <Plug>MarkersMark
Note: all default mappings can be disabled by setting
|g:marker_define_jump_mappings| to 0.

What happens is that e.g. when editing my ~/.vimrc pressing <C-<> does what I expect and inserts

<>«»

and places the cursor between < and >.

Editing a .tex file has a different result, though: pressing <C-<> inserts a literal <.

Changing the binding to use <C-n> instead makes it work correctly in .tex files as well.

To Reproduce
Steps to reproduce the behavior:

  1. I use the package vim-nox from debian stable for this.
  2. put the following in ~/.vimrc, which sets up vim-addon-manager as recommended in their instructions to install lh-brackets as recommended in its instructions:
" put this line first in ~/.vimrc
set nocompatible | filetype indent plugin on | syn on

fun! SetupVAM()
  let c = get(g:, 'vim_addon_manager', {})
  let g:vim_addon_manager = c
  let c.plugin_root_dir = expand('$HOME', 1) . '/.vim/vim-addons'

  " Force your ~/.vim/after directory to be last in &rtp always:
  " let g:vim_addon_manager.rtp_list_hook = 'vam#ForceUsersAfterDirectoriesToBeLast'

  " most used options you may want to use:
  " let c.log_to_buf = 1
  " let c.auto_install = 0
  let &rtp.=(empty(&rtp)?'':',').c.plugin_root_dir.'/vim-addon-manager'
  if !isdirectory(c.plugin_root_dir.'/vim-addon-manager/autoload')
    execute '!git clone --depth=1'
        \       'https://github.com/MarcWeber/vim-addon-manager'
        \       shellescape(c.plugin_root_dir.'/vim-addon-manager', 1)
  endif

  " This provides the VAMActivate command, you could be passing plugin names, too
  call vam#ActivateAddons([], {})
endfun
call SetupVAM()

" ACTIVATING PLUGINS

" OPTION 1, use VAMActivate
VAMActivate lh-brackets

" " OPTION 2: use call vam#ActivateAddons
" call vam#ActivateAddons([PLUGIN_NAME], {})
" " use <c-x><c-p> to complete plugin names
"
" " OPTION 3: Create a file ~/.vim-scripts putting a PLUGIN_NAME into each line (# for comments)
" " See lazy loading plugins section in README.md for details
" call vam#Scripts('~/.vim-scripts', {'tag_regex': '.*'})

" we disable those because they conflict with C-L from vim-sensible which does
" nohlsearch and diffupdate, etc.
let g:marker_define_jump_mappings = 0
" but I still want those functions on some keys
imap <C-J>      <Plug>MarkersJumpF
 map <C-J>      <Plug>MarkersJumpF
imap <C-K>      <Plug>MarkersJumpB
 map <C-K>      <Plug>MarkersJumpB
imap <C-<>      <Plug>MarkersMark
nmap <C-<>      <Plug>MarkersMark
xmap <C-<>      <Plug>MarkersMark
imap <C-$>      <Plug>MarkersCloseAllAndJumpToLast
nmap <C-$>      <Plug>MarkersCloseAllAndJumpToLast
vmap <C-$>      <Plug>MarkersCloseAllAndJumpToLast
imap <C-)>      <Plug>MarkersJumpOutside
nmap <C-)>      <Plug>MarkersJumpOutside
vmap <C-)>      <Plug>MarkersJumpOutside
  1. open ~/.vimrc and press C-<: it should insert
<>«»
  1. open ~/foo.tex and press C-<: it should insert
<

which is not the expected result. Also, in an existing .tex file, the same happens.
5. Change the mappings for <Plug>MarkersMark in ~/.vimrc:

imap <C-n>      <Plug>MarkersMark
nmap <C-n>      <Plug>MarkersMark
xmap <C-n>      <Plug>MarkersMark
  1. Repeat step 3, result should be the same.
  2. Repeat step 4, result should be:
«»
  1. Open an existing .tex file, result is:
<++>

Expected behavior
Explained above.

Context (please complete the following information):

  • Vim version:
% vim --version
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled May 04 2023 10:24:44)
Included patches: 1-1378, 1499
  • Other plugins installed: only VAM, as mentioned above

Additional context
Curiously, even with the mapping changed to <C-<>, when I press that keycombo in my ~/.vimrc, it still inserts:

<>«»

even though the command :imap <C-<> says No mapping found.
EDIT: I think this is explained by the mapping for a single < having almost the same effect as <Plug>MarkersMark, so please disregard this comment, unless my interpretation is wrong.

Everything in this report seems to apply equally to neovim, which is my usual editor.

The comment about mapping conflict with vim-sensible comes from my neovim config but is irrelevant here because for reproducing the issue in "proper" vim, I did not install that plugin.

I’m happy to provide more information if you let me know what is needed to find the cause for this unexpected behaviour.

Thank you very much.

E705: Variable name conflicts with an existing function: Close

Обнаружена ошибка при обработке function lh#brackets#define[3]..209_DecodeDefineOptions:
строка 37:
E705: Имя переменной конфликтует с существующей функцией: Close


An error was encountered while processing function lh # brackets # define [3] .. 209_DecodeDefineOptions:
line 37:
E705: Variable name conflicts with an existing function: Close


I think conflict with ctrlp.vim plugin, when try open php files, maybe I'm wrong

Please don't define mappings beginning with '!'

This leads to strange behavior when typing '!' in normal usage, and vim is trying to decide whether a mapping applies. These mappings are clearly not intended to be typed by a user, so please use mappings instead.

Using lh-brackets with Go

Is your feature request related to a problem? Please describe.
I am annoyed with how vim works with brackets when programming in Go. I think that lh-bracket might be in help here but it looks like I don't understand how to configure it. Main problem is when I try to create a new struct. When I type opening bracket { and hit I get what I've expected. Unfortunately after typing all member I've left with unwanted mark after closing bracket }.

Describe the solution you'd like
I would like that when I type all the members and then hit <cr>} I have cursor after closing bracket } and no mark after it.

Describe alternatives you've considered
I am able to have expected result If I hit <C-J>, but this is counter intuitive for me.

Additional context
Situation I am describing is when struct looks like below and cursor is in marked position <cursor>

type struct foo {
    member int<cursor>
}

Now hitting <cr> and } (or even shorter only }) I would like to have cursor after closing } bracket and no placeholder mark.

Line inserted above current line with typing '('

Hi,

thank you for providing this plugin.

I wanted to try it with a C++ file and here is what happens:

  • I type void foo
  • when I type (, my line gets broken into two lines and I get
void
foo(|)«»

(| represent the cursor position).

How can I avoid this behavior and obtain

void foo(|)«»

?

Thanks for your help!

How can I change default mapping in lh-brackets?

Hi,
i have a problem because e.g. Ctrl+J mapping is already defined in Latex-Suite
and there is an error:
Cannot define imap toMarkersJumpFin (:source):{(unset )}: a previous global mapping on was defined in /home/przemek/.vim/bundl e/vim-latex-suite/plugin/imaps.vim.

I read the documentation about Brackets-default but I did not find how to change default
mappings e.g. into Ctrl+G.
Can you help me?

Opt-out / Disable Default Mappings

The following mappings conflict with my existing mappings, and produce this warning text every time I start nvim.

I'd like to be able to turn them off with a global variable, similar to the other ones already present (g:cb_no_default_brackets, etc).

I believe they start here:
https://github.com/LucHermitte/lh-brackets/blob/master/plugin/bracketing.base.vim#L200

Warning: While defining nmap `<C-L><Ins>` to `<Plug>MarkersMark`: there already exists another mapping starting as `<C-L><Ins>` to `:tabnext <CR>`.
Warning: While defining vmap `<C-L><Ins>` to `<Plug>MarkersMark`: there already exists another mapping starting as `<C-L><Ins>` to `:tabnext <CR>`.
Warning: Cannot define nmap `<C-J>` to `<Plug>MarkersJumpF`: a previous global mapping on `<C-J>` was defined in /nix/store/kzmvis2xfahj8bdmi7r717drd0xq5n41-vimrc.
Warning: Cannot define vmap `<C-J>` to `<Plug>MarkersJumpF`: a previous global mapping on `<C-J>` was defined in /nix/store/kzmvis2xfahj8bdmi7r717drd0xq5n41-vimrc.
Warning: While defining nmap `<C-L><S-Del>` to `<Plug>MarkersJumpB`: there already exists another mapping starting as `<C-L><S-Del>` to `:tabnext <CR>`.
Warning: While defining vmap `<C-L><S-Del>` to `<Plug>MarkersJumpB`: there already exists another mapping starting as `<C-L><S-Del>` to `:tabnext <CR>`.
Warning: While defining nmap `<C-L>$` to `<Plug>MarkersCloseAllAndJumpToLast`: there already exists another mapping starting as `<C-L>$` to `:tabnext <CR>`.
Warning: While defining vmap `<C-L>$` to `<Plug>MarkersCloseAllAndJumpToLast`: there already exists another mapping starting as `<C-L>$` to `:tabnext <CR>`.
Warning: While defining nmap `<C-L><End>` to `<Plug>MarkersJumpOutside`: there already exists another mapping starting as `<C-L><End>` to `:tabnext <CR>`.
Warning: While defining smap `<C-L><End>` to `<Plug>MarkersJumpOutside`: there already exists another mapping starting as `<C-L><End>` to `:tabnext <CR>`.
Warning: While defining xmap `<C-L><End>` to `<Plug>MarkersJumpOutside`: there already exists another mapping starting as `<C-L><End>` to `:tabnext <CR>`.

Opening bracket on indented line moves cursor to first column

After the change at a45b9e4 and all the way to 7df6e69, typing the following with :setl noet:

int main() {
	if*
}

(where * is the cursor) then typing (, the parentheses appear fine, but the cursor moves to the first column right after.

The problem is only present under setl noet and behaves as expected with setl et.


VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 23 2017 12:10:29)
Included patches: 1-197, 322, 377-378, 550
Modified by [email protected]
Compiled by [email protected]
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl             +cmdline_hist    -ebcdic          +gettext         +listcmds        +mouse_sgr       +persistent_undo +smartindent     +textobjects     +wildmenu
+arabic          +cmdline_info    +emacs_tags      -hangul_input    +localmap        -mouse_sysmouse  +postscript      +startuptime     +timers          +windows
+autocmd         +comments        +eval            +iconv           +lua             +mouse_urxvt     +printer         +statusline      +title           +writebackup
+balloon_eval    +conceal         +ex_extra        +insert_expand   +menu            +mouse_xterm     +profile         -sun_workshop    +toolbar         +X11
+browse          +cryptv          +extra_search    +job             +mksession       +multi_byte      -python          +syntax          +user_commands   -xfontset
++builtin_terms  +cscope          +farsi           +jumplist        +modify_fname    +multi_lang      +python3         +tag_binary      +vertsplit       +xim
+byte_offset     +cursorbind      +file_in_path    +keymap          +mouse           -mzscheme        +quickfix        +tag_old_static  +virtualedit     +xpm
+channel         +cursorshape     +find_in_path    +lambda          +mouseshape      +netbeans_intg   +reltime         -tag_any_white   +visual          +xsmp_interact
+cindent         +dialog_con_gui  +float           +langmap         +mouse_dec       +num64           +rightleft       +tcl             +visualextra     +xterm_clipboard
+clientserver    +diff            +folding         +libcall         +mouse_gpm       +packages        +ruby            +termguicolors   +viminfo         -xterm_save
+clipboard       +digraphs        -footer          +linebreak       -mouse_jsbterm   +path_extra      +scrollbind      +terminfo        +vreplace
+cmdline_compl   +dnd             +fork()          +lispindent      +mouse_netterm   +perl            +signs           +termresponse    +wildignore

It's unclear how to jump to placeholders

The placeholders that get inserted by lh-brackets after typing brackets characters seem to not work in the way they're supposed to.
I can't find any shortcuts to jump to a placeholder, nor do they get deleted when I go from insert mode to normal mode. So for me the placeholder characters don't seem to do anything and only get in the way.
There isn't a lot of documentation that can help me with this.
So my question is: How are you supposed to work with these placeholder characters?

I'm getting an error

after having used visual mode to select some text I press shift + 9 to get a left bracket, however I get the following errors in the vim command line:

Error detected while processing function lh#tags#ctags_flavor[3]..<SNR>147_System:
line    4:
E605: Exception not caught: Cannot execute system call (ctags --version): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ctags: illegal opt
ion -- -^@usage: ctags [-BFadtuwvx] [-f tagsfile] file ...^@
Press ENTER or type command to continue
Error detected while processing /Users/Thermatix/.vim/bundle/lh-dev/autoload/lh/dev.vim:
line  100:
E171: Missing :endif
Press ENTER or type command to continue
Error detected while processing function lh#map#surround:
line   43:
E171: Missing :endif
Press ENTER or type command to continue

if it helps I'm working on an empty unsaved file, here's a link to my vim files, the entry point is vimrc.vim

deprecated methods from lh-vim-lib

~/.vim/plugged/lh-brackets/after/ftplugin/c/c_brackets.vim:98
~/.vim/plugged/lh-brackets/plugin/common_brackets.vim:199

fix plz
change #dev# to #ft#

After setting g:cb_no_default_brackets to 1, backspace goes to start of line

Describe the bug
After setting g:cb_no_default_brackets to 1, backspace in insert mode moves the cursor to start of line.

To Reproduce
Steps to reproduce the behavior:

  1. Put "let g:cb_no_default_brackets = 1" in vimrc, and reload
  2. Open any text file and move cursor to any text
  3. Press "i" to go to insert mode
  4. Press "Backspace"
  5. See error: the cursor goes to start of the line

Expected behavior
Backspace should remove a character.

Context

  • VIM - Vi IMproved 8.1 (2018 May 18, compiled Jan 6 2019 22:28:49), Included patches: 1-700 macOS version, Compiled by Homebrew
  • NVIM v0.3.4

Additional context
vimrc:

if has('nvim')
    set runtimepath^=~/.vim runtimepath+=~/.vim/after
    let &packpath = &runtimepath
endif

set nocompatible
filetype off
syntax on
filetype plugin indent on
set modelines=0
set number
set ruler
set backspace=eol,start,indent

call plug#begin('~/.vim/plugged')
Plug 'LucHermitte/lh-vim-lib' | Plug 'LucHermitte/lh-brackets'
call plug#end()

let g:cb_no_default_brackets = 1

Weird behaviour when there are an unequal amount of opening/closing braces.

Is your feature request related to a problem? Please describe.
Suppose I had a C++ file:

int main()
{
    if (...)
    {
        for (...)
        {
            if (...)
            {
             <cursor here>   
        }
    }
}

(Notice the missing closing bracket). Currently, there is no easy way to insert a closing bracket at <cursor here>, as attempting to type a } will jump to the next bracket, rather than insert a new one. I've been unable to find anything in the documentation to deal with a situation like this.

Describe the solution you'd like
A new bracket is inserted rather than jump to the next bracket when there is a bracket mismatch (or perhaps a manual toggle if this is too computational expensive).

Describe alternatives you've considered
One way I've currently been dealing with this situation is by following the jumps to the end, in which case a new bracket would be inserted, and then moving the bracket up to the place where it should be. However, this is suboptimal, as it can become a hassle when nested very deeply.

Additional context
None.

Move `lh#map#*` and `lh#marker#*` to lh-vim-lib

The idea is to reduce dependency to lh-brackets from mu-template or lh-refactor.

This way those plugins can be used without necessarily using lh-brackets that define/impose mappings on brackets.

TODO: check how to import history from a few files from one project to the other.

Brackets command not available in vimrc

I added the following line in my vimrc as instructed in the home page

:Brackets < > -open=function('lh#cpp#brackets#lt') -visual=1 -nl

but it generated the following error when I opened vim

E492: Not an editor command: :Brackets < > -open=function('lh#cpp#brackets#lt') -visual=1 -nl

Running the same command after opening vim works

The reason why I added it is that I could not type > in my markdown page. It keeps jumping to find the next > character

The command :imap > Enter shows

 i  >           *@lh#brackets#closer(">",function('lh#html#brackets#gt'),"")

Also, could you please advise why I could not get the following mappings work (no bracket around the current word is deleted, or changed for the other commands)

noremap        ,bx         <Plug>DeleteBrackets
noremap        ,b<del>     <Plug>DeleteBrackets
noremap        ,b(         <Plug>ChangeToRoundBrackets
noremap        ,b[         <Plug>ChangeToSquareBrackets
noremap        ,b{         <Plug>ChangeToCurlyBrackets
noremap        ,b<         <Plug>ChangeToAngleBrackets
noremap        ,b\         <Plug>ToggleBackslash

The command :map ,bx Enter shows

,bx         * <Plug>DeleteBrackets

which shows the mapping is correct

Many thanks

Weird behaviour when using Latex-suite

Not sure if it is my fault or a general thing but when I do not edit Latex files the plugin seems to be working normally. When I edit Latex files (with latex-suite) the closing bracket appears correctly with the placeholder but if I type the closing bracket, another placeholder appears with a second closing bracket. When I hit only the character before the cursor gets deleted.
Any help will be appreciated,
Thanks.

cd_disable_default disables additional brackets

Description
cb_disable_default disables additional brackets. After adding the line below, double quote completion and paren completion are disabled even though they are not explicitly disabled.
To Reproduce
Steps to reproduce the behavior:

  1. Add let g:cb_disable_default = { '[': 'n', '{': 'nv' } to .vimrc
  2. Open a new file and hit (
  3. [, { completion are still enabled.

Expected behavior
Hitting ( should close to ( )<++>

I am trying to disable automatically closing single quotes. From reading the docs I would expect let g:cb_disable_default = { '''': 'i'} to disable single quotes but leave everything else the same as the default behavior, am I missing something?

Version
NVIM v0.5.0-718-g090551a80

Multiple errors when usemarks is off

If I :let b:usemarks = 0 or :let g:usemarks = 0, the following occurs when I type a bracket:

Error detected while processing function lh#brackets#opener[71]..lh#map#insert_seq[15]..lh#map#smart_insert_seq2:
line    6:
E871: (NFA regexp) Can't have a multi follow a multi !
Press ENTER or type command to continue
Error detected while processing function lh#brackets#opener[71]..lh#map#insert_seq[15]..lh#map#smart_insert_seq2:
line    6:
E62: Nested +
Press ENTER or type command to continue
Error detected while processing function lh#brackets#opener:
line   71:
E171: Missing :endif
Press ENTER or type command to continue

The error disappears if I :unlet b:usemarks

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.