cohama / lexima.vim

Auto close parentheses and repeat by dot dot dot...
995 stars 46 forks source link

Feature request: support context_filetype.vim #109

Closed kg8m closed 3 years ago

kg8m commented 3 years ago

Some filetypes contains multiple filetypes in a file. For example, JavaScript codes are sometimes contained in a HTML file as following:

<html>
  <head>
    ...
  </head>

  <body>
    ...

    <script>
      // some JavaScript codes...
    </script>
  </body>
</html>

I think it is convenient if lexima.vim rules for javascript can be used in the JavaScript codes. For one more example, vue filetype contains html, javascript, and css in itself. I think it is very convenient if rules for html, javascript, or css can be used when editing a Vue file.

I am aware that I can use rules for javascript when editing a HTML file if I add rules like { ..., "filetype": ["html", "javascript"] }. But with this way, the rules will be applied to non-JavaScript codes.

How about supporting Shougo/context_filetype.vim? This plugin provides functions to detect filetype depending on the cursor position context.

I will create a Pull Request if you are positive about supporting context_filetype.vim.

Best regards.

kg8m commented 3 years ago

I'm closing this issue because supporting context_filetype.vim has a side effect. For example, rules like { "at": '```[a-z]\+\%#', "filetype": "markdown", ... } doesn't work because ```foo in a Markdown file is treated as foo filetype by context_filetype.vim.

I'll loosely add rules. For example, rules for JavaScript by { "filetype": ["javascript", "html"], ... }. Rules for HTML, JavaScript, and CSS by { "filetype": [..., "vue"], ... }. They work well in most cases.