Coder Social home page Coder Social logo

vim-closetag's People

Contributors

aaronkor avatar abhishek8923 avatar alvan avatar aryansoxyboiiii avatar dhleong avatar hadesd avatar hbarcelos avatar jtr109 avatar jwworth avatar louisrli avatar wikimatze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-closetag's Issues

Not working in some jsx component-as-prop case

Reproduce
| = cursor

Actual behaviour:

<MyComponent prop1={()=><Testing/>}|
<MyComponent prop1={()=><Testing/>}>|

Expected behavuour:

<MyComponent prop1={()=><Testing/>}|
<MyComponent prop1={()=><Testing/>}>|</MyComponent>

Enable closetag for any file type

Is there a way to enable this plugin for any file type instead of based on a whitelist? Any reason not to? Then perhaps it can be enabled temporarily by a keyboard shortcut?

For example, in Ruby, I may have a heredoc (or any string literal for that matter) containing html or xml, and I would like closetag to work there.

Thanks!

feature requestβ€”ability to add exceptions to b:closetag_emptyTags

This feature is motivated by the increasing use of JSX and Javscript Flow within the React.js world.

In general the auto-closing of tags by this plugin is a godsend for JSX users, but when the pluging interacts with Flow, Facebook's type-checking layer, it becomes too eager.

For example, sometimes I want to declare things like the following:

Promise<any>
React.Element<*>

As it stands, these two bad boys auto-expand (that rhymes lol!)

It does not work with .html.erb files

I'm trying to use this Plugin with .html.erb files (ruby on rails) but it does not work.

it works with anything ending with a ".html"

but it won't work if the file has ".erb" (or haml for example)

Thanks.

Add option to add closing tag on separate line?

Would it be possible to add an option to configure the default closing tag location? Currently, it is unconditionally added immediately after the closing >, but it can be desirable to have it added on the next line for people that prefer opening and closing tags on their own lines.

Autoclose not working in only JSX, TSX

Hi, I love your wonderful work.

Actually, It works like charms with *.html. I tried many times and many ways with *.jsx and *.tsx, but failed.
Below is my configuration. Any clue?

call vundle#begin()

Plugin 'VundleVim/Vundle.vim'
Plugin 'rust-lang/rust.vim'
Plugin 'ervandew/supertab'
Plugin 'pangloss/vim-javascript'
Plugin 'mxw/vim-jsx'
Plugin 'maxmellon/vim-jsx-pretty'
Plugin 'leafgarland/typescript-vim'
Plugin 'w0rp/ale'
Plugin 'alvan/vim-closetag'

call vundle#end()
let g:closetag_filenames = "*.html,*.xhtml,*.phtml,*.erb,*.jsx,*.tsx"
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx,*.tsx,*.erb'
let g:closetag_emptyTags_caseSensitive = 1
let g:closetag_shortcut = '>'
let g:closetag_close_shortcut = '<leader>>'

Autoclose issue in JSX

I have this configuration:

let g:closetag_filenames = "*.html,*.xhtml,*.phtml,*.erb,*.jsx"
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx,*.erb'
let g:closetag_emptyTags_caseSensitive = 1
let g:closetag_shortcut = '>'
let g:closetag_close_shortcut = '<leader>>'

And still it doesn't work for my jsx configuration. It works for all other extensions though. Any help would be appreciated.

vim-closetag-issue

tab alignement after in other languages

I added *.php to the closetag_filenames in vimrc, so the plug in works in php files. My problem is that when I press the angle bracket key the second time to get the multi line option, the closing tag is placed at the beginning of the line, it doesn't line up with the opening tag. This works as expected in html files though.

Plugin does not working in jsx file

When set imdisable option , autoclose is not work in jsx file.

steps to reproduce

$ vim
:set ft=jsx
:CloseTagEnableBuffer
i
<h1>

minimal vimrc

set rtp+=~/plugin/vim-closetag

" filenames like *.xml, *.html, *.xhtml, ...
" These are the file extensions where this plugin is enabled.
"
let g:closetag_filenames = '*.html,*.xhtml,*.phtml'

" filenames like *.xml, *.xhtml, ...
" This will make the list of non-closing tags self-closing in the specified files.
"
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx'

" filetypes like xml, html, xhtml, ...
" These are the file types where this plugin is enabled.
"
let g:closetag_filetypes = 'html,xhtml,phtml'

" filetypes like xml, xhtml, ...
" This will make the list of non-closing tags self-closing in the specified files.
"
let g:closetag_xhtml_filetypes = 'xhtml,jsx'

" integer value [0|1]
" This will make the list of non-closing tags case-sensitive (e.g. `<Link>` will be closed while `<link>` won't.)
"
let g:closetag_emptyTags_caseSensitive = 1

" dict
" Disables auto-close if not in a "valid" region (based on filetype)
"
let g:closetag_regions = {
    \ 'typescript.tsx': 'jsxRegion,tsxRegion',
    \ 'javascript.jsx': 'jsxRegion',
   \ 'typescriptreact': 'jsxRegion,tsxRegion',
    \ 'javascriptreact': 'jsxRegion',
    \ }

" Shortcut for closing tags, default is '>'
"
let g:closetag_shortcut = '>'

" Add > at current position without closing the current tag, default is ''
"
let g:closetag_close_shortcut = '<leader>>'

set imdisable

Use newline CR to put on the next line

The docs say

And now if you press > again, the content will be:
<table>
    |
</table>

How can I get this same behavior by pressing the <enter> key (i.e. <c-r>) after I type the close > in <table>?

Does not work when setting filetype on a unnamed buffer

When I set the filetype trough set filetype=html when on an empty (or one with a different .format) buffer the plugin won't work.

Suggestion on how to fix it while keeping the old functionality:

- call s:Declare('g:closetag_filenames', '*.html,*.xhtml,*.phtml')
- call s:Declare('g:closetag_xhtml_filenames', '*.xhtml')
+ call s:Declare('g:closetag_filenames', 'html,xhtml,phtml')
+ call s:Declare('g:closetag_xhtml_filenames', 'xhtml')

- exec "au BufNewFile,Bufread " . g:closetag_filenames . " inoremap <silent> <buffer> " . g:closetag_shortcut . " ><Esc>:call <SID>CloseTagFun()<Cr>"
+ exec "au FileType " . g:closetag_filenames . " inoremap <silent> <buffer> " . g:closetag_shortcut . " ><Esc>:call <SID>CloseTagFun()<Cr>"

- exec "au BufNewFile,Bufread " . g:closetag_filenames . " inoremap <silent> <buffer> " . g:closetag_close_shortcut . " >"
+ exec "au FileType " . g:closetag_filenames . " inoremap <silent> <buffer> " . g:closetag_close_shortcut . " >"


- exec "au BufNewFile,Bufread " . g:closetag_xhtml_filenames . " call <SID>Declare('b:closetag_use_xhtml', 1)"
+ exec "au FileType " . g:closetag_xhtml_filenames . " call <SID>Declare('b:closetag_use_xhtml', 1)"

Auto close in JSX

I have added this to my VIMRC:
let g:closetag_filenames = "*.html,*.xhtml,*.phtml,*.php, *.jsx"

but auto closing tags does not work.

Give option to choose which filetypes should be treated as XHTML

Today, in order to properly handle empty tags in JSX which closes empty elements like XHTML, I have two autocmds change the global variable g:closetag_use_xhtml depending on the file extension.
This option is not documented in the README, so I'm not sure if I should actually use it.

I currently have the following in my .vimrc

let g:closetag_filenames = '*.html,*.js'
let g:closetag_emptyTags_caseSensitive = 1
autocmd BufNewFile,Bufread *.html let g:closetag_use_xhtml = 0
autocmd BufNewFile,Bufread *.js let g:closetag_use_xhtml = 1

But I think it would be nicer to have something like:

let g:closetag_filenames = '*.html'
let g:closetag_xhtml_filenames = '*.js'
let g:closetag_emptyTags_caseSensitive = 1

What do you think?

feature request: do not close tag if the end tag already exists

For example, say you already have this in your code:

<div className="test">
  Hello world
</div>

Then you want to change it to:

<div>
  Hello world
</div>

One way you might do this is to move the cursor to the end of the first div, then type C to go to the end of the line, then type > to close the first div tag:

<div|
  Hello world
</div>

As soon as you press > you get:

<div></div>
  Hello world
</div>

There are plugins that can detect and highlight the closing tag (e.g. https://github.com/Valloric/MatchTagAlways), so it seems like this should be possible (check if there's a match already once > is entered, and only add the closing tag if it's not already there).

The workaround of course would be not to delete the >, by doing dt> or ct> instead of C, but I think this would be a nice feature.

Config with file .js

Hi,
My project use react written in .js file
I try to config to apply config of vim-closetag to js file but it's not working
Thanks for any helps

Custom-Elements, children indents breaking

It seems that, the indents of children elements are preserved for known html elements, but gets erased for custom elements.

<div>
    <span
</div>

after inserting the > for span...

<div>
    <span></span>
</div>

However for custom elements...

<custom-div>
    <span
</custom-div>

after inserting the `> for span...

<custom-div>
<span></span>
</custom-div>

Ill behaved >> for multiline tag

Tested with only the plugin in .vim and an empty .vimrc :

$ cd ~
$ mv .vim vimbackup
$ mv .vimrc vimbackuprc
$ touch .vimrc
$ git clone [email protected]:alvan/vim-closetag.git .vim
$ cd .vim
$ git rev-parse HEAD  # current commit
8496544ba82a210b66ab2d8283609f65a36d92a6
$ vim --version | head -n2
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Oct  7 2017 13:50:55)
Included patches: 1-1176
$ vim hello.html

| as cursor position

<form method="POST"
      action="stuff"|

enter >>

<form method="POST|
      action="stuff">></form>

(note dissappeared ", cursor having moved UP, one too many >, no new lines for cursor and closing tag)

expected outcome:

<form method="POST"
      action="stuff">
|
</form>

(or similar, with valid form tag and cursor and closing tag on their own lines)

Closes tag when `>` is seen inside of an attribute value

I'm currently building an app with Vue, where the templating will at times have > comparisons inside of an attribute value. When that character is entered, closetag immediately closes the tag, even though it shouldn't.

Typing <div :complete="1 > will immediately result in <div :complete="1></div>. When using the auto-pairs plugin to insert a closing quote as soon as the opening is typed closetag ends up with <div :complete="1 >" being converted to <div :complete="1 ></div>".

Is there any kind of setting/flag I need to set, or is this a bug?

TSX?

Love this plugin by the way. I tried to include .tsx file types in to the variable in my init.vim file. it looks like:

let g:closetag_filenames = '*.html,*.jsx,*.tsx'

It doesn't auto close for TSX files but JSX works just fine. Any thoughts or something I may be doing wrong?

Conflict with delimitMate

Hi, when I type <, delimitMate automatically add > for me, so with vim-closetag, there will be an extra >.

vim-closetag helped me a lot, thank you very much!

Doesn't work using dein lazy load

Doesn't work

call dein#add('alvan/vim-closetag', {'lazy':1, 'on_ft': ['html', 'htmldjango', 'xhtml', 'jinja']})

Works

call dein#add('alvan/vim-closetag', {'lazy':0, 'on_ft': ['html', 'htmldjango', 'xhtml', 'jinja']})

GetCloseTag() runtime error - vim 7.4

Hello, I have the following .vimrc setup:
2016-03-21_23-45-16

typing <sometag> , exiting to the command and Ctrl+_ shows the following error:
2016-03-21_23-48-02

after the error the tag closes correcty:
2016-03-21_23-48-46

this is my vim --version
2016-03-21_23-49-51

Thank you for your time. I love this addon and hoping to try and get it to work.

Visual block mode is interrupted when typing '>'

To reproduce:

  1. Make sure the plugin is active (:imap > should show that > has been mapped)
  2. Enter visual-block mode (CTRL-V), and make a selection
  3. Enter "visual block insert" mode (by pressing I, c, or A).
  4. As soon as you type > in this mode, vim exits visual block mode prematurely.

Better autocomplete of self-closing tags

Right now self-closing tags are not expanded, which is good enough, but the proper way of closing them is />.

Either, when typing > on such tag expand it to />, or let / expand into />, or both. (If / would extend to '/>', if the very next input is >, ignore it and move the cursor to the right. Or forget if the mode has been switched.)

The second option looks a bit more complicated than just letting > expand "backwards" into />

It's true that the ending slash in HTML5 is optional but in XHTML it's required.

wrong close in quotation

Hi, your plugin is awesome! I have use it for a long time.

But I met an issue that it not works well in attribute value. If I want to insert a attribute in class. For example:

<div class="a|"></div>
<!-- "|" is the cursor placed -->

If I hit the >, the vim-closetag will make effect and the line will be like this:

<div class="a></div>"></div>

It is not what it should be. And it makes trouble when using ng-if or v-if in angularjs or vuejs.

Vim/Neovim frozen after editing a tag in the first level

Hi! First of all, thanks for your good plugin. It is really useful.

Under a certain conditions, Vim or Neovim stay frozen after editing a tag. I tried it in HTML and XML. The way to reproduce it:

  1. Must be the first tag level. So a new file editing the first line will be enough for the test. Let's call it xml.xml.
  2. Insert a tag called <test> and the plugin will insert </test> perfectly.
  3. Now press > again to create the indent for the following tag:
<test>
    |
</test>
  1. Still into 'Insert mode', let's remove the indentation. I press 2 times <BS> and 1 time <Del>. What happens if you press 2 times <Del> by mistake? You will have this:
    <test>|/test>
  2. Ok, it was a mistake. Let's enter again the missing <... But nothing is happening. Literally nothing. You can't <Esc>, you can't close Vim. I had to close the tmux pane/window.

Can you reproduce it? Thanks in advance!

Update: I upload an animated GIF. As you can see, I can't close the 'Insert mode' pressing <Esc>. Actually, I had to kill the process with sudo kill -2 {PID} because Vim was consuming 100% of the CPU (even after closing Vim deleting the tmux pane).

closetag

Not Working with .html files

The plugin isn't working , my .vimrc file has :
let g:closetag_filenames = '*.html,*.xhtml,*.phtml'
and I downloaded the plugin with pathogen by following commands:
cd ~/.vim/bundle
git clone https://github.com/alvan/vim-closetag.git

incorrectly runs on generics in tsx

I've set up vim-closetag for use with tsx regions but it still adds closing tags for generics, which is quite annoying. Do I need to create the tsxRegion manually or where is it supposed to come from?

My config:

let g:closetag_filenames = "*.html,*.jsx,*.tsx,*.vue,*.xhml,*.xml"
let g:closetag_regions = {
  \ 'typescript.tsx': 'jsxRegion,tsxRegion',
  \ 'javascript.jsx': 'jsxRegion',
  \ }

Otherwise, I'm really happy with this plugin, great time saver! πŸ˜ƒ

during installation using Vundle, vim asking for github credentials

[2021-05-17 15:37:25]
[2021-05-17 15:37:25] Plugin alvanvim-closetag
[2021-05-17 15:37:25] $ git clone --recursive "https://github.com/vim-scripts/alvanvim-closetag.git" "C:\Users\marct.vim\bundle\alvanvim-closetag"
[2021-05-17 15:37:25] > Cloning into 'C:\Users\marct.vim\bundle\alvanvim-closetag'...
[2021-05-17 15:37:25] > Logon failed, use ctrl+c to cancel basic credential prompt.
[2021-05-17 15:37:25] > bash: /dev/tty: No such device or address
[2021-05-17 15:37:25] > error: failed to execute prompt script (exit code 1)
[2021-05-17 15:37:25] > fatal: could not read Username for 'https://github.com': No such file or directory
[2021-05-17 15:37:25] >
[2021-05-17 15:37:27]
[2021-05-17 15:37:27] Helptags:
[2021-05-17 15:37:27] :helptags C:\Users\marct.vim\bundle\Vundle.vim/doc/
[2021-05-17 15:37:27] :helptags C:\Users\marct.vim\bundle\auto-pairs/doc/
[2021-05-17 15:37:27] Helptags: 2 plugins processed

Too much indentation when `set noexpandtab virtualedit=all`

When I set noexpandtab virtualedit=all I get wrong indentation on the empty line inserted between two tags. For example when I start out like

<html>|</html>

and press > I get this (a tab and 7 spaces):

<html>
β†’       β‹…β‹…β‹…β‹…β‹…β‹…β‹…|
</html>

Setting either set expandtab or set virtualedit= fixes the problem. I can't live without either of these options, so it would be really nice if this can be fixed another way.

I have also set these options, they may be relevant, but don't seem to change the behavior when I change/disable them.

set autoindent
set shiftwidth=8
set smartindent
set smarttab
set softtabstop=8
set tabstop=8

doesn't work for html.erb

in my .vimrc, I have let g:closetag_filenames = "*.html,*.erb" and yet it doesn't seem to work in .erb files. Any idea why?

Problem with indentation in js, jsx, ts, tsx files

Example render method in react class. Symbol | is my cursor.

render() {
  return (
    <div>|</div>
  );
}

Then I press > and this is what happens:

render() {
  return (
    <div>
  |
    </div>
  );
}

And this happens with all files

Disabling closing tag in regular Javascript files when outside JSX regions?

Is it possible to disable the auto-closing of tags when outside of a JSX region in a regular javascript file? I don't really use the jsx extension and would like to be able to do the following:

let g:closetag_regions = {
    \ 'typescript.tsx': 'jsxRegion,tsxRegion',
    \ 'javascript.jsx': 'jsxRegion',
    \ 'javascript': 'jsxRegion',
    \ }

Toggle Buffer?

CloseTagEnableBuffer and CloseTagDisableBuffer are great, but it would be even better if there were a way to toggle the plugin to make keybinds a little bit cleaner.

Weird behavior pasting HTML

I am having some troubles pasting some HTML into a .jsx file with autopairs turned on

<blockquote>This is a blockquote</blockquote><p><br></p><h1>This is a header</h1>

ends up as

<blockquote>This is a blockquote</blockquote><p><br></p><h1>This is a header</h1></h1></p></blockquote>

Temporarily disable at runtime

Is there a way to temporarily disable this plugin at runtime through an ex command? I am using this in Typescript to edit template strings that contain html but it has the side effect of interpreting generic types like List<MyType> as tags and auto closes them as well.

Extra closing tag in html file

I'm pretty sure this problem is on my end only but I can't seem to find a fix. When using close tag I get an extra closing tag in html files as displayed by the picture underneath. Any help would be greatly appreciated, thank you in advance.

screenshot from 2017-06-24 08-16-99

Overrides previous search highlighting

When search highlighting is enabled and a search has been done, closing a tag changes the highlighted search to > instead of the previous search.
I'm not too savvy with vimscript but I fixed this by putting let old_search = @/ at the beginning of fun! s:CloseIt() and then putting let @/ = old_search right before any retu in that function, if this isn't too naive of a fix I can submit a PR

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.