Closed brainclone closed 2 years ago
lexima#add_rule
should put on .vimrc
(e.g. ~/.vim/vimrc
), not on ftplugin
.
This rule will only works with what is listed in the filetype key.
(EDIT2: I did a little vim debugging with function s:find_rules()
(in autoload/insmode.vim
) and find that rules returned is {}
. (It seems to be caused by this line:
let searchlimit = max([0, line('.') - 20]
I am confused by this searchlimit assignment - why line('.') - 20
?
)
(EDIT I deleted the comment within code where it's causing a vim grammar problem. Now when I type'%'
at '{#}'
(# is cursor), it just jumps to '{}#'
.'<'
and'<Space>'
rules work. )
Thank you for your reply. I moved them into .vimrc
: (as this is loaded before the plugins, I made autocmd
for them)
Still no luck.
" lexima rules for '%','<','<Space>'
autocmd filetype html call lexima#add_rule({
\ 'char': '%',
\ 'at': '{\%#}',
\ 'input_after': '<Space><Space>%',
\ 'mode': 'i',
\ 'leave': 1,
\ 'filetype': 'html',
\ })
autocmd filetype html call lexima#add_rule({
\ 'char': '<',
\ 'input_after': '>',
\ 'filetype': ['html', 'jinja', 'htmljinja', 'django', 'htmldjango', 'liquid', 'twig', 'html.twig', 'mako', 'xml'],
\ })
autocmd filetype html call lexima#add_rule({
\ 'char': '<Space>',
\ 'at': '{{\%#',
\ 'input_after': '<Space>',
\ 'filetype': ['html', 'jinja', 'htmljinja', 'django', 'htmldjango', 'liquid', 'twig', 'html.twig', 'mako', 'xml'],
\ })
Hi, on vim 8.1. I am trying to add the following rule in my ~/.vim/after/ftplugin/html/html.vim: {#} + '%' => {% # %} (# is the cursor.)
Here is the code from ~/.vim/after/ftplugin/html/html.vim (I also tried the path:~/.vim/after/ftplugin/html.vim) with line numbers: 8 call lexima#add_rule({ 9 \ 'char': '%', 10 \ 'at\': '{\%#}', 11 \ 'input_after': '%',
12 \ 'mode': 'i',
13 \ 'leave': 1,
14 \ 'filetype': ['html', 'jinja', 'htmljinja', 'django', 'htmldjango', 'liquid', 'twig', 'html.twig', 'mako',
15 \ })
This does not work. As I put this in the .vim/after directory for 'html' filetype, this should work at least for html files. Thanks,
Brain.Clone