Coder Social home page Coder Social logo

Comments (2)

JoosepAlviste avatar JoosepAlviste commented on August 18, 2024 2

Hey @eduardoarandah, just wanted to let you know that #3 has been implemented and PHP should work a bit better now.

However, I still didn't get the injected CSS and JS working because it doesn't seem like they even get injected.

Anyways, if you manage to inject those languages, then the current solution should work 😄 I just couldn't figure out how to get the injection working.

Other than that, let me know if there are any other problems with PHP.

from nvim-ts-context-commentstring.

JoosepAlviste avatar JoosepAlviste commented on August 18, 2024 1

Hey! The tree that the PHP treesitter parser creates seems to be a bit weird and it doesn't seem to match the output in the treesitter playground.

For example, in this simple case, the playground shows the tags, but in reality, the HTML part is just text (everything up to <?php):

image

(I checked the current node under the cursor with :lua print(require'nvim-treesitter.ts_utils'.get_node_at_cursor(0):type()))

This means that there is no container node that can be used as a check for this plugin. The only nodes are text and program.

However, if I add a PHP end tag (?>), then there is a text_interpolation node:

image

text_interpolation seems like a good check for setting <!-- %s -->.

Everything inside text_interpolation is once again a text node. This means that any style or script tags cannot be detected 😕

Also, if the PHP tag is wrapped in an HTML tag, then the parser will break:

image

This is the best result I managed to get:

Screen.Recording.2021-03-27.at.22.51.38.mov

I used this config:

  php = {
    text_interpolation = '<!-- %s -->',
  },

And setlocal commentstring=//\ %s in after/ftplugin/php.vim


I'm hoping that once #3 is implemented, we could use language tree to improve this.

from nvim-ts-context-commentstring.

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.