luchermitte / lh-brackets Goto Github PK
View Code? Open in Web Editor NEWLH's bracketing system for vim
License: Other
LH's bracketing system for vim
License: Other
When typing
for(int i; i!=42 ; ++i)
lh-brackets produces
for(int i); i!=42 ; ++i)
The issue also appears when pasting through terminal. See https://vi.stackexchange.com/questions/13746/which-vim-plugin-should-i-use-if-i-want-to-surround-specific-text-with-brackets/13748?noredirect=1#comment23603_13748 and https://vi.stackexchange.com/questions/13754/bracket-is-added-in-unintended-position-when-i-paste-some-code-in-vim
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?
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:
** Context (please complete the following information):**
Installing lh-brackets with dependencies to MacVim ("mvim --version" here: http://pastebin.com/Jp4gnp38) (.vimrc here: http://pastebin.com/SXJxpMWy) leads to unavailability to type double brackets in a file of any type with message:
E116: Invalid arguments for function lh#brackets#opener('"',0,"",function('lh#vim#brackets#dquotes'),""",1,'')
E15: Invalid expression: lh#brackets#opener('"',0,"",function('lh#vim#brackets#dquotes'),""",1,'')
Repeat last insertion (with '.' in normal mode) is broken when lh-brackets intervenes.
If I delete first (
in ()
second removed automatically, but it doesn't work for something like <|>
, when added through Bracket < >
.
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:
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
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.
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:
vim-nox
from debian stable for this.~/.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
~/.vimrc
and press C-<
: it should insert<>«»
~/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
«»
.tex
file, result is:<++>
Expected behavior
Explained above.
Context (please complete the following information):
% vim --version
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled May 04 2023 10:24:44)
Included patches: 1-1378, 1499
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.
Обнаружена ошибка при обработке 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
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.
In Python's list comprehension ([v for v in mylist]
), for
gets exanded to for :
and a newline is added. This is not the expected behavior. The same applies for a = b if b else 0
.
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.
Hi,
thank you for providing this plugin.
I wanted to try it with a C++ file and here is what happens:
void foo
(
, my line gets broken into two lines and I getvoid
foo(|)«»
(|
represent the cursor position).
How can I avoid this behavior and obtain
void foo(|)«»
?
Thanks for your help!
When inserting a ;
before another ;
or between ()
in a C++ file, it throws this error:
Error detected while processing function lh#mapping#_switch[1]..lh#mapping#_switch_int:
line 3:
E117: Unknown function: s:JumpOverAllClose
Press ENTER or type command to continue
Also, a -1
is inserted where the ;
would have been after Enter is pressed.
As i see by default brackets not working inside string literals and comments, how to overcome this for some file types and brackets? Let's say i want { }
for in string literals for rust.
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
to
MarkersJumpFin (: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?
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>`.
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
After installing the plugins using vundle, vim reports several errors.
The errors list as follows:
**Error detected while processing function lh#mapping#plug[34]..lh#mapping#define
line 7:
E109: Missing ':' after '?'
E15: Invalid expression: get(a:md, 'expr', 0) ? "<c-r>=".(a:md.rhs)."<cr>"**
Any help would be appreciated.
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?
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
~/.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#
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:
Expected behavior
Backspace should remove a character.
Context
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
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.
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.
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
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.
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:
let g:cb_disable_default = { '[': 'n', '{': 'nv' }
to .vimrc
(
[, {
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
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.