jmbuhr / otter.nvim

Just ask an otter! 🦦
MIT License
521 stars 11 forks source link

Configuration for add lsp feature to html! macro in Yew (rust) #62

Closed GustavoJCL closed 1 year ago

GustavoJCL commented 1 year ago

hi, i try to config this plugin for add support for add lsp features to the html macro, i try to follow the config i found in quarto-nvim but it didn't work, this is the config: { "jmbuhr/otter.nvim", opts = function(_, opts) local rsquery = [[ (macro_invocation name: (indentifier) @name (#eq? @name "html") (token_tree (ERROR) @html_macro ) ) ]] local otter = require("otter") otter.activate( { "html" }, { true }, { true }, rsquery ) end },

jmbuhr commented 1 year ago

How does such a file look like?

GustavoJCL commented 1 year ago

this is how look the rust file, i'm trying to add html support for this macro image

jmbuhr commented 1 year ago

You'll need a TS query where either one capture called @_lang captures the name of a language and @content captures the content or where the name of the capture is the name of a language (e.g. @html). You can find examples for both in this query: https://github.com/quarto-dev/quarto-nvim/blob/14a80ffab90567e360eb97b19039c4c16913ad79/lua/quarto/init.lua#L125-L138

    tsquery = [[
      (fenced_code_block
      (info_string
        (language) @_lang
      ) @info
        (#match? @info "{")
      (code_fence_content) @content (#offset! @content)
      )
      ((html_block) @html @combined)

      ((minus_metadata) @yaml (#offset! @yaml 1 0 -1 0))
      ((plus_metadata) @toml (#offset! @toml 1 0 -1 0)
      ]]

Or define a query that creates an injection and it can work without passing an additional query.