Code Monkey home page Code Monkey logo

Comments (6)

andymass avatar andymass commented on May 30, 2024 3

Sorry for the delay. I think currently it makes more sense to handle this locally using the hotfix feature. Then you can personalize the highlight however you like. For example, put this in your vimrc:

function! JsxHotfix()
    setlocal matchpairs=(:),{:},[:],<:>
    let b:match_words = '<\@<=\([^/][^ \t>]*\)\g{hlend}[^>]*\%(/\@<!>\|$\):<\@<=/\1>'
endfunction
let g:matchup_hotfix_javascript = 'JsxHotfix'

If you can, let me know whether this works. It's difficult to interoperate with other plugins that use different conventions.

from vim-matchup.

jlesquembre avatar jlesquembre commented on May 30, 2024 1

Don't worry for the delay, and thanks for the advice, I didn't know about the hotfix feature.

I did some tests and that works perfectly :-)

Thank you for the effort you put on matchup, it's really a great plugin, I think vim should replace matchin with matchup

from vim-matchup.

andymass avatar andymass commented on May 30, 2024

This looks like an html file, not a javascript file.. https://github.com/Polymer/lit-element/blob/master/demo/lit-element.html
The following should work:

let g:matchup_matchpref.html = {'tagnameonly': 1}

If it doesn't work, what is the output of :set filetype?

from vim-matchup.

jlesquembre avatar jlesquembre commented on May 30, 2024

You found the example I used, but I moved the javascript code to a js file. It looks like a html file, but is a javascript file, the html code is inside a template string. It's similar to JSX syntax, if you want to know more about it see https://polymer.github.io/lit-html/guide#lit-html-templates

You can see the same problem on this file: https://github.com/Polymer/lit-html/blob/master/demo/clock.js

screenshot

I have this on my vimrc:

let g:matchup_matchpref = {
    \ 'html': { 'tagnameonly': 1, },
    \ 'javascript':  { 'tagnameonly': 1, },
    \}

It looks like the tagnameonly option works for html but not for javascript.

If it doesn't work, what is the output of :set filetype?

filetype=javascript

from vim-matchup.

andymass avatar andymass commented on May 30, 2024

Actually it seems to work correctly for me (in both html and javascript filetypes). Are you using any external filetype plugin for javascript? What is the output :scriptnames?

from vim-matchup.

jlesquembre avatar jlesquembre commented on May 30, 2024

Yes, I'm using https://github.com/MaxMEllon/vim-jsx-pretty and looks like that is the reason.

I found that if here:
https://github.com/MaxMEllon/vim-jsx-pretty/blob/master/after/ftplugin/javascript.vim,
I replace it with (as you wrote in #35 (comment))

setlocal matchpairs=(:),{:},[:],<:>
let b:match_words = '<\@<=\([^/][^ \t>]*\)\g{hlend}[^>]*\%(/\@<!>\|$\):<\@<=/\1>'

everything works as expected. I'm thinking about sending a PR to the vim-jsx-pretty project, with something like:

if exists("loaded_matchup")
  let b:match_ignorecase = 0
  setlocal matchpairs=(:),{:},[:],<:>
  let b:match_words = '<\@<=\([^/][^ \t>]*\)\g{hlend}[^>]*\%(/\@<!>\|$\):<\@<=/\1>'
elseif exists("loaded_matchit")
  let b:match_ignorecase = 0
  let b:match_words = '(:),\[:\],{:},<:>,' .
        \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>'
endif

Do you think is makes sense or do you have a better solution?

from vim-matchup.

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.